Home | History | Annotate | Line # | Download | only in ti
omap3_prm.c revision 1.1.10.2
      1  1.1.10.2  martin /* $NetBSD: omap3_prm.c,v 1.1.10.2 2020/04/13 08:03:38 martin Exp $ */
      2  1.1.10.2  martin 
      3  1.1.10.2  martin /*-
      4  1.1.10.2  martin  * Copyright (c) 2019 Jared McNeill <jmcneill (at) invisible.ca>
      5  1.1.10.2  martin  * All rights reserved.
      6  1.1.10.2  martin  *
      7  1.1.10.2  martin  * Redistribution and use in source and binary forms, with or without
      8  1.1.10.2  martin  * modification, are permitted provided that the following conditions
      9  1.1.10.2  martin  * are met:
     10  1.1.10.2  martin  * 1. Redistributions of source code must retain the above copyright
     11  1.1.10.2  martin  *    notice, this list of conditions and the following disclaimer.
     12  1.1.10.2  martin  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.10.2  martin  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.10.2  martin  *    documentation and/or other materials provided with the distribution.
     15  1.1.10.2  martin  *
     16  1.1.10.2  martin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1.10.2  martin  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1.10.2  martin  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1.10.2  martin  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1.10.2  martin  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  1.1.10.2  martin  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  1.1.10.2  martin  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  1.1.10.2  martin  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  1.1.10.2  martin  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1.10.2  martin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1.10.2  martin  * SUCH DAMAGE.
     27  1.1.10.2  martin  */
     28  1.1.10.2  martin 
     29  1.1.10.2  martin #include <sys/cdefs.h>
     30  1.1.10.2  martin __KERNEL_RCSID(0, "$NetBSD: omap3_prm.c,v 1.1.10.2 2020/04/13 08:03:38 martin Exp $");
     31  1.1.10.2  martin 
     32  1.1.10.2  martin #include <sys/param.h>
     33  1.1.10.2  martin #include <sys/bus.h>
     34  1.1.10.2  martin #include <sys/device.h>
     35  1.1.10.2  martin #include <sys/intr.h>
     36  1.1.10.2  martin #include <sys/systm.h>
     37  1.1.10.2  martin #include <sys/kernel.h>
     38  1.1.10.2  martin #include <sys/kmem.h>
     39  1.1.10.2  martin 
     40  1.1.10.2  martin #include <dev/fdt/fdtvar.h>
     41  1.1.10.2  martin 
     42  1.1.10.2  martin #include <arm/ti/ti_prcm.h>
     43  1.1.10.2  martin 
     44  1.1.10.2  martin static int	omap3_prm_match(device_t, cfdata_t, void *);
     45  1.1.10.2  martin static void	omap3_prm_attach(device_t, device_t, void *);
     46  1.1.10.2  martin 
     47  1.1.10.2  martin CFATTACH_DECL_NEW(omap3_prm, 0, omap3_prm_match, omap3_prm_attach, NULL, NULL);
     48  1.1.10.2  martin 
     49  1.1.10.2  martin static const char * compatible[] = {
     50  1.1.10.2  martin 	"ti,omap3-prm",
     51  1.1.10.2  martin 	NULL
     52  1.1.10.2  martin };
     53  1.1.10.2  martin 
     54  1.1.10.2  martin static int
     55  1.1.10.2  martin omap3_prm_match(device_t parent, cfdata_t cf, void *aux)
     56  1.1.10.2  martin {
     57  1.1.10.2  martin 	struct fdt_attach_args * const faa = aux;
     58  1.1.10.2  martin 
     59  1.1.10.2  martin 	return of_match_compatible(faa->faa_phandle, compatible);
     60  1.1.10.2  martin }
     61  1.1.10.2  martin 
     62  1.1.10.2  martin static void
     63  1.1.10.2  martin omap3_prm_attach(device_t parent, device_t self, void *aux)
     64  1.1.10.2  martin {
     65  1.1.10.2  martin 	struct fdt_attach_args * const faa = aux;
     66  1.1.10.2  martin 	const int phandle = faa->faa_phandle;
     67  1.1.10.2  martin 	int clocks;
     68  1.1.10.2  martin 
     69  1.1.10.2  martin 	aprint_naive("\n");
     70  1.1.10.2  martin 	aprint_normal("\n");
     71  1.1.10.2  martin 
     72  1.1.10.2  martin 	fdt_add_bus(self, phandle, faa);
     73  1.1.10.2  martin 
     74  1.1.10.2  martin 	clocks = of_find_firstchild_byname(phandle, "clocks");
     75  1.1.10.2  martin 	if (clocks > 0)
     76  1.1.10.2  martin 		fdt_add_bus(self, clocks, faa);
     77  1.1.10.2  martin }
     78