xref: /freebsd/sys/powerpc/powermac/uninorth.c (revision 65d08437ef519124f39f113262a3cc71dadb8569)
160727d8bSWarner Losh /*-
298f8e6c0SBenno Rice  * Copyright (C) 2002 Benno Rice.
398f8e6c0SBenno Rice  * All rights reserved.
498f8e6c0SBenno Rice  *
598f8e6c0SBenno Rice  * Redistribution and use in source and binary forms, with or without
698f8e6c0SBenno Rice  * modification, are permitted provided that the following conditions
798f8e6c0SBenno Rice  * are met:
898f8e6c0SBenno Rice  * 1. Redistributions of source code must retain the above copyright
998f8e6c0SBenno Rice  *    notice, this list of conditions and the following disclaimer.
1098f8e6c0SBenno Rice  * 2. Redistributions in binary form must reproduce the above copyright
1198f8e6c0SBenno Rice  *    notice, this list of conditions and the following disclaimer in the
1298f8e6c0SBenno Rice  *    documentation and/or other materials provided with the distribution.
1398f8e6c0SBenno Rice  *
1498f8e6c0SBenno Rice  * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
1598f8e6c0SBenno Rice  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1698f8e6c0SBenno Rice  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1798f8e6c0SBenno Rice  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1898f8e6c0SBenno Rice  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1998f8e6c0SBenno Rice  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2098f8e6c0SBenno Rice  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2198f8e6c0SBenno Rice  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2298f8e6c0SBenno Rice  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2398f8e6c0SBenno Rice  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2498f8e6c0SBenno Rice  *
2598f8e6c0SBenno Rice  * $FreeBSD$
2698f8e6c0SBenno Rice  */
2798f8e6c0SBenno Rice 
2898f8e6c0SBenno Rice #include <sys/param.h>
2998f8e6c0SBenno Rice #include <sys/systm.h>
3040cdee9dSPeter Grehan #include <sys/module.h>
3198f8e6c0SBenno Rice #include <sys/bus.h>
3298f8e6c0SBenno Rice #include <sys/conf.h>
3398f8e6c0SBenno Rice #include <sys/kernel.h>
3498f8e6c0SBenno Rice 
3598f8e6c0SBenno Rice #include <dev/ofw/openfirm.h>
3698f8e6c0SBenno Rice #include <dev/ofw/ofw_pci.h>
3751d163d3SNathan Whitehorn #include <dev/ofw/ofw_bus.h>
3894b4a038SNathan Whitehorn #include <dev/ofw/ofw_bus_subr.h>
3998f8e6c0SBenno Rice 
4098f8e6c0SBenno Rice #include <dev/pci/pcivar.h>
4198f8e6c0SBenno Rice #include <dev/pci/pcireg.h>
4298f8e6c0SBenno Rice 
4398f8e6c0SBenno Rice #include <machine/bus.h>
44ca2c1931SNathan Whitehorn #include <machine/intr_machdep.h>
4598f8e6c0SBenno Rice #include <machine/md_var.h>
46de2fa7b8SMarcel Moolenaar #include <machine/pio.h>
4798f8e6c0SBenno Rice #include <machine/resource.h>
4898f8e6c0SBenno Rice 
4998f8e6c0SBenno Rice #include <sys/rman.h>
5098f8e6c0SBenno Rice 
5198f8e6c0SBenno Rice #include <powerpc/powermac/uninorthvar.h>
5298f8e6c0SBenno Rice 
5398f8e6c0SBenno Rice #include <vm/vm.h>
5498f8e6c0SBenno Rice #include <vm/pmap.h>
5598f8e6c0SBenno Rice 
56ca2c1931SNathan Whitehorn /*
57ca2c1931SNathan Whitehorn  * Driver for the Uninorth chip itself.
58ca2c1931SNathan Whitehorn  */
5998f8e6c0SBenno Rice 
60ca2c1931SNathan Whitehorn static MALLOC_DEFINE(M_UNIN, "unin", "unin device information");
6198f8e6c0SBenno Rice 
6298f8e6c0SBenno Rice /*
6398f8e6c0SBenno Rice  * Device interface.
6498f8e6c0SBenno Rice  */
65ca2c1931SNathan Whitehorn 
66ca2c1931SNathan Whitehorn static int  unin_chip_probe(device_t);
67ca2c1931SNathan Whitehorn static int  unin_chip_attach(device_t);
6898f8e6c0SBenno Rice 
6998f8e6c0SBenno Rice /*
7098f8e6c0SBenno Rice  * Bus interface.
7198f8e6c0SBenno Rice  */
72ca2c1931SNathan Whitehorn static int  unin_chip_print_child(device_t dev, device_t child);
73ca2c1931SNathan Whitehorn static void unin_chip_probe_nomatch(device_t, device_t);
74ca2c1931SNathan Whitehorn static struct resource *unin_chip_alloc_resource(device_t, device_t, int, int *,
75ca2c1931SNathan Whitehorn 						 u_long, u_long, u_long, u_int);
76ca2c1931SNathan Whitehorn static int  unin_chip_activate_resource(device_t, device_t, int, int,
77ca2c1931SNathan Whitehorn 					struct resource *);
78ca2c1931SNathan Whitehorn static int  unin_chip_deactivate_resource(device_t, device_t, int, int,
79ca2c1931SNathan Whitehorn 					  struct resource *);
80ca2c1931SNathan Whitehorn static int  unin_chip_release_resource(device_t, device_t, int, int,
81ca2c1931SNathan Whitehorn 				       struct resource *);
82ca2c1931SNathan Whitehorn static struct resource_list *unin_chip_get_resource_list (device_t, device_t);
8398f8e6c0SBenno Rice 
8498f8e6c0SBenno Rice /*
8551d163d3SNathan Whitehorn  * OFW Bus interface
8651d163d3SNathan Whitehorn  */
8751d163d3SNathan Whitehorn 
88ca2c1931SNathan Whitehorn static ofw_bus_get_devinfo_t unin_chip_get_devinfo;
8951d163d3SNathan Whitehorn 
9051d163d3SNathan Whitehorn /*
91ca2c1931SNathan Whitehorn  * Local routines
9298f8e6c0SBenno Rice  */
93ca2c1931SNathan Whitehorn 
94ca2c1931SNathan Whitehorn static void		unin_enable_gmac(device_t dev);
95ca2c1931SNathan Whitehorn static void		unin_enable_mpic(device_t dev);
9698f8e6c0SBenno Rice 
9798f8e6c0SBenno Rice /*
9898f8e6c0SBenno Rice  * Driver methods.
9998f8e6c0SBenno Rice  */
100ca2c1931SNathan Whitehorn static device_method_t unin_chip_methods[] = {
101ca2c1931SNathan Whitehorn 
10298f8e6c0SBenno Rice 	/* Device interface */
103ca2c1931SNathan Whitehorn 	DEVMETHOD(device_probe,         unin_chip_probe),
104ca2c1931SNathan Whitehorn 	DEVMETHOD(device_attach,        unin_chip_attach),
10598f8e6c0SBenno Rice 
10698f8e6c0SBenno Rice 	/* Bus interface */
107ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_print_child,      unin_chip_print_child),
108ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_probe_nomatch,    unin_chip_probe_nomatch),
10998f8e6c0SBenno Rice 	DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
11098f8e6c0SBenno Rice 	DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
11198f8e6c0SBenno Rice 
112ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_alloc_resource,   unin_chip_alloc_resource),
113ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_release_resource, unin_chip_release_resource),
114ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_activate_resource, unin_chip_activate_resource),
115ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_deactivate_resource, unin_chip_deactivate_resource),
116ca2c1931SNathan Whitehorn 	DEVMETHOD(bus_get_resource_list, unin_chip_get_resource_list),
11798f8e6c0SBenno Rice 
1184fe8025dSNathan Whitehorn 	DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
1194fe8025dSNathan Whitehorn 
12051d163d3SNathan Whitehorn         /* ofw_bus interface */
121ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_devinfo,	unin_chip_get_devinfo),
122ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_compat,	ofw_bus_gen_get_compat),
123ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_model,	ofw_bus_gen_get_model),
124ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_name,	ofw_bus_gen_get_name),
125ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_node,	ofw_bus_gen_get_node),
126ca2c1931SNathan Whitehorn 	DEVMETHOD(ofw_bus_get_type,	ofw_bus_gen_get_type),
12751d163d3SNathan Whitehorn 
12898f8e6c0SBenno Rice 	{ 0, 0 }
12998f8e6c0SBenno Rice };
13098f8e6c0SBenno Rice 
131ca2c1931SNathan Whitehorn static driver_t	unin_chip_driver = {
132ca2c1931SNathan Whitehorn 	"unin",
133ca2c1931SNathan Whitehorn 	unin_chip_methods,
134ca2c1931SNathan Whitehorn 	sizeof(struct unin_chip_softc)
13598f8e6c0SBenno Rice };
13698f8e6c0SBenno Rice 
137ca2c1931SNathan Whitehorn static devclass_t	unin_chip_devclass;
13898f8e6c0SBenno Rice 
1394702d987SJustin Hibbits /*
1404702d987SJustin Hibbits  * Assume there is only one unin chip in a PowerMac, so that pmu.c functions can
1414702d987SJustin Hibbits  * suspend the chip after the whole rest of the device tree is suspended, not
1424702d987SJustin Hibbits  * earlier.
1434702d987SJustin Hibbits  */
1444702d987SJustin Hibbits static device_t		unin_chip;
1454702d987SJustin Hibbits 
146*65d08437SNathan Whitehorn DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0);
14798f8e6c0SBenno Rice 
14851d163d3SNathan Whitehorn /*
149ca2c1931SNathan Whitehorn  * Add an interrupt to the dev's resource list if present
15051d163d3SNathan Whitehorn  */
151ca2c1931SNathan Whitehorn static void
152ca2c1931SNathan Whitehorn unin_chip_add_intr(phandle_t devnode, struct unin_chip_devinfo *dinfo)
153ca2c1931SNathan Whitehorn {
154eaef5f0aSNathan Whitehorn 	phandle_t iparent;
155ca2c1931SNathan Whitehorn 	int	*intr;
156ca2c1931SNathan Whitehorn 	int	i, nintr;
157ca2c1931SNathan Whitehorn 	int 	icells;
15851d163d3SNathan Whitehorn 
159ca2c1931SNathan Whitehorn 	if (dinfo->udi_ninterrupts >= 6) {
160ca2c1931SNathan Whitehorn 		printf("unin: device has more than 6 interrupts\n");
161ca2c1931SNathan Whitehorn 		return;
16251d163d3SNathan Whitehorn 	}
16398f8e6c0SBenno Rice 
164ca2c1931SNathan Whitehorn 	nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr),
165ca2c1931SNathan Whitehorn 		(void **)&intr);
166ca2c1931SNathan Whitehorn 	if (nintr == -1) {
167ca2c1931SNathan Whitehorn 		nintr = OF_getprop_alloc(devnode, "AAPL,interrupts",
168ca2c1931SNathan Whitehorn 			sizeof(*intr), (void **)&intr);
169ca2c1931SNathan Whitehorn 		if (nintr == -1)
170ca2c1931SNathan Whitehorn 			return;
171ca2c1931SNathan Whitehorn 	}
172ca2c1931SNathan Whitehorn 
173ca2c1931SNathan Whitehorn 	if (intr[0] == -1)
174ca2c1931SNathan Whitehorn 		return;
175ca2c1931SNathan Whitehorn 
176ca2c1931SNathan Whitehorn 	if (OF_getprop(devnode, "interrupt-parent", &iparent, sizeof(iparent))
177ca2c1931SNathan Whitehorn 	    <= 0)
178ca2c1931SNathan Whitehorn 		panic("Interrupt but no interrupt parent!\n");
179ca2c1931SNathan Whitehorn 
180ca2c1931SNathan Whitehorn 	if (OF_searchprop(iparent, "#interrupt-cells", &icells, sizeof(icells))
181ca2c1931SNathan Whitehorn 	    <= 0)
182ca2c1931SNathan Whitehorn 		icells = 1;
183ca2c1931SNathan Whitehorn 
184ca2c1931SNathan Whitehorn 	for (i = 0; i < nintr; i+=icells) {
185607ebaafSMarcel Moolenaar 		u_int irq = MAP_IRQ(iparent, intr[i]);
186607ebaafSMarcel Moolenaar 
187ca2c1931SNathan Whitehorn 		resource_list_add(&dinfo->udi_resources, SYS_RES_IRQ,
188607ebaafSMarcel Moolenaar 		    dinfo->udi_ninterrupts, irq, irq, 1);
189ca2c1931SNathan Whitehorn 
190eaef5f0aSNathan Whitehorn 		if (icells > 1) {
191607ebaafSMarcel Moolenaar 			powerpc_config_intr(irq,
192eaef5f0aSNathan Whitehorn 			    (intr[i+1] & 1) ? INTR_TRIGGER_LEVEL :
193a7a32004SNathan Whitehorn 			    INTR_TRIGGER_EDGE, INTR_POLARITY_LOW);
194eaef5f0aSNathan Whitehorn 		}
195eaef5f0aSNathan Whitehorn 
196607ebaafSMarcel Moolenaar 		dinfo->udi_interrupts[dinfo->udi_ninterrupts] = irq;
197ca2c1931SNathan Whitehorn 		dinfo->udi_ninterrupts++;
198ca2c1931SNathan Whitehorn 	}
199ca2c1931SNathan Whitehorn }
200ca2c1931SNathan Whitehorn 
201ca2c1931SNathan Whitehorn static void
202ca2c1931SNathan Whitehorn unin_chip_add_reg(phandle_t devnode, struct unin_chip_devinfo *dinfo)
203ca2c1931SNathan Whitehorn {
204ca2c1931SNathan Whitehorn 	struct	unin_chip_reg *reg;
205ca2c1931SNathan Whitehorn 	int	i, nreg;
206ca2c1931SNathan Whitehorn 
207ca2c1931SNathan Whitehorn 	nreg = OF_getprop_alloc(devnode, "reg", sizeof(*reg), (void **)&reg);
208ca2c1931SNathan Whitehorn 	if (nreg == -1)
209ca2c1931SNathan Whitehorn 		return;
210ca2c1931SNathan Whitehorn 
211ca2c1931SNathan Whitehorn 	for (i = 0; i < nreg; i++) {
212ca2c1931SNathan Whitehorn 		resource_list_add(&dinfo->udi_resources, SYS_RES_MEMORY, i,
213ca2c1931SNathan Whitehorn 				  reg[i].mr_base,
214ca2c1931SNathan Whitehorn 				  reg[i].mr_base + reg[i].mr_size,
215ca2c1931SNathan Whitehorn 				  reg[i].mr_size);
216ca2c1931SNathan Whitehorn 	}
217ca2c1931SNathan Whitehorn }
218ca2c1931SNathan Whitehorn 
219ca2c1931SNathan Whitehorn static void
2204702d987SJustin Hibbits unin_update_reg(device_t dev, uint32_t regoff, uint32_t set, uint32_t clr)
221ca2c1931SNathan Whitehorn {
2224702d987SJustin Hibbits 	volatile u_int *reg;
223ca2c1931SNathan Whitehorn 	struct unin_chip_softc *sc;
224ca2c1931SNathan Whitehorn 	u_int32_t tmpl;
225ca2c1931SNathan Whitehorn 
226ca2c1931SNathan Whitehorn 	sc = device_get_softc(dev);
2274702d987SJustin Hibbits 	reg = (void *)(sc->sc_addr + regoff);
2284702d987SJustin Hibbits 	tmpl = inl(reg);
2294702d987SJustin Hibbits 	tmpl &= ~clr;
2304702d987SJustin Hibbits 	tmpl |= set;
2314702d987SJustin Hibbits 	outl(reg, tmpl);
2324702d987SJustin Hibbits }
2334702d987SJustin Hibbits 
2344702d987SJustin Hibbits static void
2354702d987SJustin Hibbits unin_enable_gmac(device_t dev)
2364702d987SJustin Hibbits {
2374702d987SJustin Hibbits 	unin_update_reg(dev, UNIN_CLOCKCNTL, UNIN_CLOCKCNTL_GMAC, 0);
238ca2c1931SNathan Whitehorn }
239ca2c1931SNathan Whitehorn 
240ca2c1931SNathan Whitehorn static void
241ca2c1931SNathan Whitehorn unin_enable_mpic(device_t dev)
242ca2c1931SNathan Whitehorn {
2434702d987SJustin Hibbits 	unin_update_reg(dev, UNIN_TOGGLE_REG, UNIN_MPIC_RESET | UNIN_MPIC_OUTPUT_ENABLE, 0);
244ca2c1931SNathan Whitehorn }
245ca2c1931SNathan Whitehorn 
246ca2c1931SNathan Whitehorn static int
247ca2c1931SNathan Whitehorn unin_chip_probe(device_t dev)
248ca2c1931SNathan Whitehorn {
249ca2c1931SNathan Whitehorn 	const char	*name;
250ca2c1931SNathan Whitehorn 
251ca2c1931SNathan Whitehorn 	name = ofw_bus_get_name(dev);
252ca2c1931SNathan Whitehorn 
253ca2c1931SNathan Whitehorn 	if (name == NULL)
25498f8e6c0SBenno Rice 		return (ENXIO);
25598f8e6c0SBenno Rice 
256ca2c1931SNathan Whitehorn 	if (strcmp(name, "uni-n") != 0 && strcmp(name, "u3") != 0
257ca2c1931SNathan Whitehorn 	    && strcmp(name, "u4") != 0)
25898f8e6c0SBenno Rice 		return (ENXIO);
259ca2c1931SNathan Whitehorn 
260ca2c1931SNathan Whitehorn 	device_set_desc(dev, "Apple UniNorth System Controller");
261ca2c1931SNathan Whitehorn 	return (0);
26298f8e6c0SBenno Rice }
26398f8e6c0SBenno Rice 
264ca2c1931SNathan Whitehorn static int
265ca2c1931SNathan Whitehorn unin_chip_attach(device_t dev)
266ca2c1931SNathan Whitehorn {
267ca2c1931SNathan Whitehorn 	struct unin_chip_softc *sc;
268ca2c1931SNathan Whitehorn 	struct unin_chip_devinfo *dinfo;
269ca2c1931SNathan Whitehorn 	phandle_t  root;
270ca2c1931SNathan Whitehorn 	phandle_t  child;
27143cbf1a6SAndreas Tobler 	phandle_t  iparent;
272ca2c1931SNathan Whitehorn 	device_t   cdev;
2734ee63553SNathan Whitehorn 	cell_t     acells, scells;
274ca2c1931SNathan Whitehorn 	char compat[32];
27543cbf1a6SAndreas Tobler 	char name[32];
27643cbf1a6SAndreas Tobler 	u_int irq, reg[3];
277ca2c1931SNathan Whitehorn 	int error, i = 0;
278ca2c1931SNathan Whitehorn 
279ca2c1931SNathan Whitehorn 	sc = device_get_softc(dev);
280ca2c1931SNathan Whitehorn 	root = ofw_bus_get_node(dev);
281ca2c1931SNathan Whitehorn 
282ca2c1931SNathan Whitehorn 	if (OF_getprop(root, "reg", reg, sizeof(reg)) < 8)
28398f8e6c0SBenno Rice 		return (ENXIO);
284ca2c1931SNathan Whitehorn 
2854ee63553SNathan Whitehorn 	acells = scells = 1;
2864ee63553SNathan Whitehorn 	OF_getprop(OF_parent(root), "#address-cells", &acells, sizeof(acells));
2874ee63553SNathan Whitehorn 	OF_getprop(OF_parent(root), "#size-cells", &scells, sizeof(scells));
288ca2c1931SNathan Whitehorn 
2894ee63553SNathan Whitehorn 	i = 0;
2904ee63553SNathan Whitehorn 	sc->sc_physaddr = reg[i++];
2914ee63553SNathan Whitehorn 	if (acells == 2) {
2924ee63553SNathan Whitehorn 		sc->sc_physaddr <<= 32;
2934ee63553SNathan Whitehorn 		sc->sc_physaddr |= reg[i++];
2944ee63553SNathan Whitehorn 	}
2954ee63553SNathan Whitehorn 	sc->sc_size = reg[i++];
2964ee63553SNathan Whitehorn 	if (scells == 2) {
2974ee63553SNathan Whitehorn 		sc->sc_size <<= 32;
2984ee63553SNathan Whitehorn 		sc->sc_size |= reg[i++];
2994ee63553SNathan Whitehorn 	}
300ca2c1931SNathan Whitehorn 
30198f8e6c0SBenno Rice 	sc->sc_mem_rman.rm_type = RMAN_ARRAY;
302ca2c1931SNathan Whitehorn 	sc->sc_mem_rman.rm_descr = "UniNorth Device Memory";
303ca2c1931SNathan Whitehorn 
304bda386dbSKevin Lo 	error = rman_init(&sc->sc_mem_rman);
305ca2c1931SNathan Whitehorn 
306bda386dbSKevin Lo 	if (error) {
307bda386dbSKevin Lo 		device_printf(dev, "rman_init() failed. error = %d\n", error);
308bda386dbSKevin Lo 		return (error);
30998f8e6c0SBenno Rice 	}
310ca2c1931SNathan Whitehorn 
311ca2c1931SNathan Whitehorn 	error = rman_manage_region(&sc->sc_mem_rman, sc->sc_physaddr,
312ca2c1931SNathan Whitehorn 				   sc->sc_physaddr + sc->sc_size - 1);
313bda386dbSKevin Lo 	if (error) {
31498f8e6c0SBenno Rice 		device_printf(dev,
315ca2c1931SNathan Whitehorn 			      "rman_manage_region() failed. error = %d\n",
316ca2c1931SNathan Whitehorn 			      error);
317bda386dbSKevin Lo 		return (error);
31898f8e6c0SBenno Rice 	}
31998f8e6c0SBenno Rice 
3204702d987SJustin Hibbits 	if (unin_chip == NULL)
3214702d987SJustin Hibbits 		unin_chip = dev;
3224702d987SJustin Hibbits 
323d48bbef3SPeter Grehan         /*
324ca2c1931SNathan Whitehorn 	 * Iterate through the sub-devices
325d48bbef3SPeter Grehan 	 */
326ca2c1931SNathan Whitehorn 	for (child = OF_child(root); child != 0; child = OF_peer(child)) {
327ca2c1931SNathan Whitehorn 		dinfo = malloc(sizeof(*dinfo), M_UNIN, M_WAITOK | M_ZERO);
328ca2c1931SNathan Whitehorn 		if (ofw_bus_gen_setup_devinfo(&dinfo->udi_obdinfo, child)
329ca2c1931SNathan Whitehorn 		    != 0)
330ca2c1931SNathan Whitehorn 		{
331ca2c1931SNathan Whitehorn 			free(dinfo, M_UNIN);
332ca2c1931SNathan Whitehorn 			continue;
333ca2c1931SNathan Whitehorn 		}
334d48bbef3SPeter Grehan 
335ca2c1931SNathan Whitehorn 		resource_list_init(&dinfo->udi_resources);
336ca2c1931SNathan Whitehorn 		dinfo->udi_ninterrupts = 0;
337ca2c1931SNathan Whitehorn 		unin_chip_add_intr(child, dinfo);
338ca2c1931SNathan Whitehorn 
33943cbf1a6SAndreas Tobler 		/*
34043cbf1a6SAndreas Tobler 		 * Some Apple machines do have a bug in OF, they miss
34143cbf1a6SAndreas Tobler 		 * the interrupt entries on the U3 I2C node. That means they
34243cbf1a6SAndreas Tobler 		 * do not have an entry with number of interrupts nor the
34343cbf1a6SAndreas Tobler 		 * entry of the interrupt parent handle.
34443cbf1a6SAndreas Tobler 		 * We define an interrupt and hardwire it to the /u3/mpic
34543cbf1a6SAndreas Tobler 		 * handle.
34643cbf1a6SAndreas Tobler 		 */
34743cbf1a6SAndreas Tobler 
34843cbf1a6SAndreas Tobler 		if (OF_getprop(child, "name", name, sizeof(name)) <= 0)
34943cbf1a6SAndreas Tobler 			device_printf(dev, "device has no name!\n");
35043cbf1a6SAndreas Tobler 		if (dinfo->udi_ninterrupts == 0 &&
35143cbf1a6SAndreas Tobler 		    (strcmp(name, "i2c-bus") == 0 ||
35243cbf1a6SAndreas Tobler 		     strcmp(name, "i2c")  == 0)) {
35343cbf1a6SAndreas Tobler 			if (OF_getprop(child, "interrupt-parent", &iparent,
35443cbf1a6SAndreas Tobler 				       sizeof(iparent)) <= 0) {
35543cbf1a6SAndreas Tobler 				iparent = OF_finddevice("/u3/mpic");
35643cbf1a6SAndreas Tobler 				device_printf(dev, "Set /u3/mpic as iparent!\n");
35743cbf1a6SAndreas Tobler 			}
35843cbf1a6SAndreas Tobler 			/* Add an interrupt number 0 to the parent. */
35943cbf1a6SAndreas Tobler 			irq = MAP_IRQ(iparent, 0);
36043cbf1a6SAndreas Tobler 			resource_list_add(&dinfo->udi_resources, SYS_RES_IRQ,
36143cbf1a6SAndreas Tobler 					  dinfo->udi_ninterrupts, irq, irq, 1);
36243cbf1a6SAndreas Tobler 			dinfo->udi_interrupts[dinfo->udi_ninterrupts] = irq;
36343cbf1a6SAndreas Tobler 			dinfo->udi_ninterrupts++;
36443cbf1a6SAndreas Tobler 		}
36543cbf1a6SAndreas Tobler 
366ca2c1931SNathan Whitehorn 		unin_chip_add_reg(child, dinfo);
367ca2c1931SNathan Whitehorn 
368ca2c1931SNathan Whitehorn 		cdev = device_add_child(dev, NULL, -1);
369ca2c1931SNathan Whitehorn 		if (cdev == NULL) {
370ca2c1931SNathan Whitehorn 			device_printf(dev, "<%s>: device_add_child failed\n",
371ca2c1931SNathan Whitehorn 				      dinfo->udi_obdinfo.obd_name);
372ca2c1931SNathan Whitehorn 			resource_list_free(&dinfo->udi_resources);
373ca2c1931SNathan Whitehorn 			ofw_bus_gen_destroy_devinfo(&dinfo->udi_obdinfo);
374ca2c1931SNathan Whitehorn 			free(dinfo, M_UNIN);
375ca2c1931SNathan Whitehorn 			continue;
376ca2c1931SNathan Whitehorn 		}
377ca2c1931SNathan Whitehorn 
378ca2c1931SNathan Whitehorn 		device_set_ivars(cdev, dinfo);
379ca2c1931SNathan Whitehorn 	}
380ca2c1931SNathan Whitehorn 
381ca2c1931SNathan Whitehorn 	/*
382ca2c1931SNathan Whitehorn 	 * Only map the first page, since that is where the registers
383ca2c1931SNathan Whitehorn 	 * of interest lie.
384ca2c1931SNathan Whitehorn 	 */
385ca2c1931SNathan Whitehorn 	sc->sc_addr = (vm_offset_t)pmap_mapdev(sc->sc_physaddr, PAGE_SIZE);
386ca2c1931SNathan Whitehorn 
387ca2c1931SNathan Whitehorn 	sc->sc_version = *(u_int *)sc->sc_addr;
388ca2c1931SNathan Whitehorn 	device_printf(dev, "Version %d\n", sc->sc_version);
389ca2c1931SNathan Whitehorn 
390ca2c1931SNathan Whitehorn 	/*
391ca2c1931SNathan Whitehorn 	 * Enable the GMAC Ethernet cell and the integrated OpenPIC
392ca2c1931SNathan Whitehorn 	 * if Open Firmware says they are used.
393ca2c1931SNathan Whitehorn 	 */
394ca2c1931SNathan Whitehorn 	for (child = OF_child(root); child; child = OF_peer(child)) {
395d48bbef3SPeter Grehan 		memset(compat, 0, sizeof(compat));
396d48bbef3SPeter Grehan 		OF_getprop(child, "compatible", compat, sizeof(compat));
397ca2c1931SNathan Whitehorn 		if (strcmp(compat, "gmac") == 0)
398ca2c1931SNathan Whitehorn 			unin_enable_gmac(dev);
399ca2c1931SNathan Whitehorn 		if (strcmp(compat, "chrp,open-pic") == 0)
400ca2c1931SNathan Whitehorn 			unin_enable_mpic(dev);
401d48bbef3SPeter Grehan 	}
402d48bbef3SPeter Grehan 
403ca2c1931SNathan Whitehorn 	/*
404ca2c1931SNathan Whitehorn 	 * GMAC lives under the PCI bus, so just check if enet is gmac.
405ca2c1931SNathan Whitehorn 	 */
406ca2c1931SNathan Whitehorn 	child = OF_finddevice("enet");
407ca2c1931SNathan Whitehorn 	memset(compat, 0, sizeof(compat));
408ca2c1931SNathan Whitehorn 	OF_getprop(child, "compatible", compat, sizeof(compat));
409ca2c1931SNathan Whitehorn 	if (strcmp(compat, "gmac") == 0)
410ca2c1931SNathan Whitehorn 		unin_enable_gmac(dev);
41194b4a038SNathan Whitehorn 
41298f8e6c0SBenno Rice 	return (bus_generic_attach(dev));
41398f8e6c0SBenno Rice }
41498f8e6c0SBenno Rice 
41598f8e6c0SBenno Rice static int
416ca2c1931SNathan Whitehorn unin_chip_print_child(device_t dev, device_t child)
41798f8e6c0SBenno Rice {
418ca2c1931SNathan Whitehorn         struct unin_chip_devinfo *dinfo;
419ca2c1931SNathan Whitehorn         struct resource_list *rl;
420ca2c1931SNathan Whitehorn         int retval = 0;
42198f8e6c0SBenno Rice 
422ca2c1931SNathan Whitehorn         dinfo = device_get_ivars(child);
423ca2c1931SNathan Whitehorn         rl = &dinfo->udi_resources;
42498f8e6c0SBenno Rice 
425ca2c1931SNathan Whitehorn         retval += bus_print_child_header(dev, child);
42698f8e6c0SBenno Rice 
427ca2c1931SNathan Whitehorn         retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
428ca2c1931SNathan Whitehorn         retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
42998f8e6c0SBenno Rice 
430ca2c1931SNathan Whitehorn         retval += bus_print_child_footer(dev, child);
43198f8e6c0SBenno Rice 
432ca2c1931SNathan Whitehorn         return (retval);
43398f8e6c0SBenno Rice }
43498f8e6c0SBenno Rice 
43598f8e6c0SBenno Rice static void
436ca2c1931SNathan Whitehorn unin_chip_probe_nomatch(device_t dev, device_t child)
43798f8e6c0SBenno Rice {
438ca2c1931SNathan Whitehorn         struct unin_chip_devinfo *dinfo;
439ca2c1931SNathan Whitehorn         struct resource_list *rl;
440ca2c1931SNathan Whitehorn 	const char *type;
44198f8e6c0SBenno Rice 
442ca2c1931SNathan Whitehorn 	if (bootverbose) {
443ca2c1931SNathan Whitehorn 		dinfo = device_get_ivars(child);
444ca2c1931SNathan Whitehorn 		rl = &dinfo->udi_resources;
44598f8e6c0SBenno Rice 
446ca2c1931SNathan Whitehorn 		if ((type = ofw_bus_get_type(child)) == NULL)
447ca2c1931SNathan Whitehorn 			type = "(unknown)";
448ca2c1931SNathan Whitehorn 		device_printf(dev, "<%s, %s>", type, ofw_bus_get_name(child));
449ca2c1931SNathan Whitehorn 		resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
450ca2c1931SNathan Whitehorn 		resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
451ca2c1931SNathan Whitehorn 		printf(" (no driver attached)\n");
45298f8e6c0SBenno Rice 	}
45398f8e6c0SBenno Rice }
45498f8e6c0SBenno Rice 
45598f8e6c0SBenno Rice 
45698f8e6c0SBenno Rice static struct resource *
457ca2c1931SNathan Whitehorn unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid,
45898f8e6c0SBenno Rice 			 u_long start, u_long end, u_long count, u_int flags)
45998f8e6c0SBenno Rice {
460ca2c1931SNathan Whitehorn 	struct		unin_chip_softc *sc;
461ca2c1931SNathan Whitehorn 	int		needactivate;
46298f8e6c0SBenno Rice 	struct		resource *rv;
46398f8e6c0SBenno Rice 	struct		rman *rm;
464ca2c1931SNathan Whitehorn 	u_long		adjstart, adjend, adjcount;
465ca2c1931SNathan Whitehorn 	struct		unin_chip_devinfo *dinfo;
466ca2c1931SNathan Whitehorn 	struct		resource_list_entry *rle;
467ca2c1931SNathan Whitehorn 
468ca2c1931SNathan Whitehorn 	sc = device_get_softc(bus);
469ca2c1931SNathan Whitehorn 	dinfo = device_get_ivars(child);
47098f8e6c0SBenno Rice 
47198f8e6c0SBenno Rice 	needactivate = flags & RF_ACTIVE;
47298f8e6c0SBenno Rice 	flags &= ~RF_ACTIVE;
47398f8e6c0SBenno Rice 
47498f8e6c0SBenno Rice 	switch (type) {
47598f8e6c0SBenno Rice 	case SYS_RES_MEMORY:
476ca2c1931SNathan Whitehorn 	case SYS_RES_IOPORT:
477ca2c1931SNathan Whitehorn 		rle = resource_list_find(&dinfo->udi_resources, SYS_RES_MEMORY,
478ca2c1931SNathan Whitehorn 					 *rid);
479ca2c1931SNathan Whitehorn 		if (rle == NULL) {
480ca2c1931SNathan Whitehorn 			device_printf(bus, "no rle for %s memory %d\n",
481ca2c1931SNathan Whitehorn 				      device_get_nameunit(child), *rid);
482ca2c1931SNathan Whitehorn 			return (NULL);
483ca2c1931SNathan Whitehorn 		}
484ca2c1931SNathan Whitehorn 
485ca2c1931SNathan Whitehorn 		rle->end = rle->end - 1; /* Hack? */
486ca2c1931SNathan Whitehorn 
487ca2c1931SNathan Whitehorn 		if (start < rle->start)
488ca2c1931SNathan Whitehorn 			adjstart = rle->start;
489ca2c1931SNathan Whitehorn 		else if (start > rle->end)
490ca2c1931SNathan Whitehorn 			adjstart = rle->end;
491ca2c1931SNathan Whitehorn 		else
492ca2c1931SNathan Whitehorn 			adjstart = start;
493ca2c1931SNathan Whitehorn 
494ca2c1931SNathan Whitehorn 		if (end < rle->start)
495ca2c1931SNathan Whitehorn 			adjend = rle->start;
496ca2c1931SNathan Whitehorn 		else if (end > rle->end)
497ca2c1931SNathan Whitehorn 			adjend = rle->end;
498ca2c1931SNathan Whitehorn 		else
499ca2c1931SNathan Whitehorn 			adjend = end;
500ca2c1931SNathan Whitehorn 
501ca2c1931SNathan Whitehorn 		adjcount = adjend - adjstart;
502ca2c1931SNathan Whitehorn 
50398f8e6c0SBenno Rice 		rm = &sc->sc_mem_rman;
50498f8e6c0SBenno Rice 		break;
505714aa5b9SAndrew Gallatin 
50698f8e6c0SBenno Rice 	case SYS_RES_IRQ:
507ca2c1931SNathan Whitehorn 		/* Check for passthrough from subattachments. */
508ca2c1931SNathan Whitehorn 		if (device_get_parent(child) != bus)
509ca2c1931SNathan Whitehorn 			return BUS_ALLOC_RESOURCE(device_get_parent(bus), child,
510ca2c1931SNathan Whitehorn 						  type, rid, start, end, count,
511ca2c1931SNathan Whitehorn 						  flags);
512de2fa7b8SMarcel Moolenaar 
513ca2c1931SNathan Whitehorn 		rle = resource_list_find(&dinfo->udi_resources, SYS_RES_IRQ,
514ca2c1931SNathan Whitehorn 		    *rid);
515ca2c1931SNathan Whitehorn 		if (rle == NULL) {
516ca2c1931SNathan Whitehorn 			if (dinfo->udi_ninterrupts >= 6) {
517ca2c1931SNathan Whitehorn 				device_printf(bus,
518ca2c1931SNathan Whitehorn 					      "%s has more than 6 interrupts\n",
519ca2c1931SNathan Whitehorn 					      device_get_nameunit(child));
520ca2c1931SNathan Whitehorn 				return (NULL);
521ca2c1931SNathan Whitehorn 			}
522ca2c1931SNathan Whitehorn 			resource_list_add(&dinfo->udi_resources, SYS_RES_IRQ,
523ca2c1931SNathan Whitehorn 					  dinfo->udi_ninterrupts, start, start,
524ca2c1931SNathan Whitehorn 					  1);
525ca2c1931SNathan Whitehorn 
526ca2c1931SNathan Whitehorn 			dinfo->udi_interrupts[dinfo->udi_ninterrupts] = start;
527ca2c1931SNathan Whitehorn 			dinfo->udi_ninterrupts++;
528ca2c1931SNathan Whitehorn 		}
529ca2c1931SNathan Whitehorn 
530ca2c1931SNathan Whitehorn 		return (resource_list_alloc(&dinfo->udi_resources, bus, child,
531ca2c1931SNathan Whitehorn 					    type, rid, start, end, count,
532ca2c1931SNathan Whitehorn 					    flags));
53398f8e6c0SBenno Rice 	default:
53498f8e6c0SBenno Rice 		device_printf(bus, "unknown resource request from %s\n",
53598f8e6c0SBenno Rice 			      device_get_nameunit(child));
53698f8e6c0SBenno Rice 		return (NULL);
53798f8e6c0SBenno Rice 	}
53898f8e6c0SBenno Rice 
539ca2c1931SNathan Whitehorn 	rv = rman_reserve_resource(rm, adjstart, adjend, adjcount, flags,
540ca2c1931SNathan Whitehorn 				   child);
54198f8e6c0SBenno Rice 	if (rv == NULL) {
542ca2c1931SNathan Whitehorn 		device_printf(bus,
543ca2c1931SNathan Whitehorn 			      "failed to reserve resource %#lx - %#lx (%#lx)"
544ca2c1931SNathan Whitehorn 			      " for %s\n", adjstart, adjend, adjcount,
54598f8e6c0SBenno Rice 			      device_get_nameunit(child));
54698f8e6c0SBenno Rice 		return (NULL);
54798f8e6c0SBenno Rice 	}
54898f8e6c0SBenno Rice 
549bdfb66f8SWarner Losh 	rman_set_rid(rv, *rid);
55098f8e6c0SBenno Rice 
55198f8e6c0SBenno Rice 	if (needactivate) {
55298f8e6c0SBenno Rice 		if (bus_activate_resource(child, type, *rid, rv) != 0) {
55398f8e6c0SBenno Rice                         device_printf(bus,
55498f8e6c0SBenno Rice 				      "failed to activate resource for %s\n",
55598f8e6c0SBenno Rice 				      device_get_nameunit(child));
55698f8e6c0SBenno Rice 			rman_release_resource(rv);
55798f8e6c0SBenno Rice 			return (NULL);
55898f8e6c0SBenno Rice                 }
55998f8e6c0SBenno Rice         }
56098f8e6c0SBenno Rice 
56198f8e6c0SBenno Rice 	return (rv);
56298f8e6c0SBenno Rice }
56398f8e6c0SBenno Rice 
56498f8e6c0SBenno Rice static int
565ca2c1931SNathan Whitehorn unin_chip_release_resource(device_t bus, device_t child, int type, int rid,
56698f8e6c0SBenno Rice 			   struct resource *res)
56798f8e6c0SBenno Rice {
568ca2c1931SNathan Whitehorn 	if (rman_get_flags(res) & RF_ACTIVE) {
569ca2c1931SNathan Whitehorn 		int error = bus_deactivate_resource(child, type, rid, res);
570ca2c1931SNathan Whitehorn 		if (error)
571ca2c1931SNathan Whitehorn 			return error;
572ca2c1931SNathan Whitehorn 	}
573ca2c1931SNathan Whitehorn 
574ca2c1931SNathan Whitehorn 	return (rman_release_resource(res));
575ca2c1931SNathan Whitehorn }
576ca2c1931SNathan Whitehorn 
577ca2c1931SNathan Whitehorn static int
578ca2c1931SNathan Whitehorn unin_chip_activate_resource(device_t bus, device_t child, int type, int rid,
579ca2c1931SNathan Whitehorn 			    struct resource *res)
580ca2c1931SNathan Whitehorn {
58198f8e6c0SBenno Rice 	void    *p;
582714aa5b9SAndrew Gallatin 
58398f8e6c0SBenno Rice 	if (type == SYS_RES_IRQ)
58498f8e6c0SBenno Rice                 return (bus_activate_resource(bus, type, rid, res));
58598f8e6c0SBenno Rice 
586ca2c1931SNathan Whitehorn 	if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
587714aa5b9SAndrew Gallatin 		vm_offset_t start;
588714aa5b9SAndrew Gallatin 
589714aa5b9SAndrew Gallatin 		start = (vm_offset_t) rman_get_start(res);
590714aa5b9SAndrew Gallatin 
591714aa5b9SAndrew Gallatin 		if (bootverbose)
592ca2c1931SNathan Whitehorn 			printf("unin mapdev: start %zx, len %ld\n", start,
593714aa5b9SAndrew Gallatin 			       rman_get_size(res));
594714aa5b9SAndrew Gallatin 
595714aa5b9SAndrew Gallatin 		p = pmap_mapdev(start, (vm_size_t) rman_get_size(res));
59698f8e6c0SBenno Rice 		if (p == NULL)
59798f8e6c0SBenno Rice 			return (ENOMEM);
59898f8e6c0SBenno Rice 		rman_set_virtual(res, p);
599ca2c1931SNathan Whitehorn 		rman_set_bustag(res, &bs_be_tag);
60098f8e6c0SBenno Rice 		rman_set_bushandle(res, (u_long)p);
60198f8e6c0SBenno Rice 	}
60298f8e6c0SBenno Rice 
60398f8e6c0SBenno Rice 	return (rman_activate_resource(res));
60498f8e6c0SBenno Rice }
60598f8e6c0SBenno Rice 
606ca2c1931SNathan Whitehorn 
60798f8e6c0SBenno Rice static int
608ca2c1931SNathan Whitehorn unin_chip_deactivate_resource(device_t bus, device_t child, int type, int rid,
609ca2c1931SNathan Whitehorn 			      struct resource *res)
61098f8e6c0SBenno Rice {
61198f8e6c0SBenno Rice         /*
612ca2c1931SNathan Whitehorn          * If this is a memory resource, unmap it.
61398f8e6c0SBenno Rice          */
614ca2c1931SNathan Whitehorn         if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
615ca2c1931SNathan Whitehorn 		u_int32_t psize;
61698f8e6c0SBenno Rice 
617ca2c1931SNathan Whitehorn 		psize = rman_get_size(res);
618ca2c1931SNathan Whitehorn 		pmap_unmapdev((vm_offset_t)rman_get_virtual(res), psize);
61998f8e6c0SBenno Rice 	}
62098f8e6c0SBenno Rice 
621ca2c1931SNathan Whitehorn 	return (rman_deactivate_resource(res));
62298f8e6c0SBenno Rice }
62398f8e6c0SBenno Rice 
624ca2c1931SNathan Whitehorn 
625ca2c1931SNathan Whitehorn static struct resource_list *
626ca2c1931SNathan Whitehorn unin_chip_get_resource_list (device_t dev, device_t child)
62751d163d3SNathan Whitehorn {
628ca2c1931SNathan Whitehorn 	struct unin_chip_devinfo *dinfo;
62951d163d3SNathan Whitehorn 
630ca2c1931SNathan Whitehorn 	dinfo = device_get_ivars(child);
631ca2c1931SNathan Whitehorn 	return (&dinfo->udi_resources);
63251d163d3SNathan Whitehorn }
63351d163d3SNathan Whitehorn 
634ca2c1931SNathan Whitehorn static const struct ofw_bus_devinfo *
635ca2c1931SNathan Whitehorn unin_chip_get_devinfo(device_t dev, device_t child)
63698f8e6c0SBenno Rice {
637ca2c1931SNathan Whitehorn 	struct unin_chip_devinfo *dinfo;
63898f8e6c0SBenno Rice 
639ca2c1931SNathan Whitehorn 	dinfo = device_get_ivars(child);
640ca2c1931SNathan Whitehorn 	return (&dinfo->udi_obdinfo);
64198f8e6c0SBenno Rice }
64298f8e6c0SBenno Rice 
6434702d987SJustin Hibbits int
6444702d987SJustin Hibbits unin_chip_wake(device_t dev)
6454702d987SJustin Hibbits {
6464702d987SJustin Hibbits 
6474702d987SJustin Hibbits 	if (dev == NULL)
6484702d987SJustin Hibbits 		dev = unin_chip;
6494702d987SJustin Hibbits 	unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_NORMAL, UNIN_PWR_MASK);
6504702d987SJustin Hibbits 	DELAY(10);
6514702d987SJustin Hibbits 	unin_update_reg(dev, UNIN_HWINIT_STATE, UNIN_RUNNING, 0);
6524702d987SJustin Hibbits 	DELAY(100);
6534702d987SJustin Hibbits 
6544702d987SJustin Hibbits 	return (0);
6554702d987SJustin Hibbits }
6564702d987SJustin Hibbits 
6574702d987SJustin Hibbits int
6584702d987SJustin Hibbits unin_chip_sleep(device_t dev, int idle)
6594702d987SJustin Hibbits {
6604702d987SJustin Hibbits 	if (dev == NULL)
6614702d987SJustin Hibbits 		dev = unin_chip;
6624702d987SJustin Hibbits 
6634702d987SJustin Hibbits 	unin_update_reg(dev, UNIN_HWINIT_STATE, UNIN_SLEEPING, 0);
6644702d987SJustin Hibbits 	DELAY(10);
6654702d987SJustin Hibbits 	if (idle)
6664702d987SJustin Hibbits 		unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_IDLE2, UNIN_PWR_MASK);
6674702d987SJustin Hibbits 	else
6684702d987SJustin Hibbits 		unin_update_reg(dev, UNIN_PWR_MGMT, UNIN_PWR_SLEEP, UNIN_PWR_MASK);
6694702d987SJustin Hibbits 	DELAY(10);
6704702d987SJustin Hibbits 
6714702d987SJustin Hibbits 	return (0);
6724702d987SJustin Hibbits }
673