[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Apr 18 08:07:50 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/d59f197f345f
changeset: 456:d59f197f345f
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Wed Apr 18 11:08:04 2012 +0300
description:
USB support for RT5350F

diffstat:

 head/sys/mips/rt305x/rt5350_ehci.c |  236 +++++++++++++++++++++
 head/sys/mips/rt305x/rt5350_usb.c  |  410 +++++++++++++++++++++++++++++++++++++
 2 files changed, 646 insertions(+), 0 deletions(-)

diffs (654 lines):

diff -r 0ab33e4fbea2 -r d59f197f345f head/sys/mips/rt305x/rt5350_ehci.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/mips/rt305x/rt5350_ehci.c	Wed Apr 18 11:08:04 2012 +0300
@@ -0,0 +1,236 @@
+/*-
+ * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
+ * All rights reserved.
+ *
+ * Developed by Semihalf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MARVELL nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Ralink RT5350F attachment driver for the USB Enhanced Host Controller.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_bus.h"
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/rman.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/linker_set.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
+#include <dev/usb/usb_core.h>
+#include <dev/usb/usb_busdma.h>
+#include <dev/usb/usb_process.h>
+#include <dev/usb/usb_util.h>
+
+#include <dev/usb/usb_controller.h>
+#include <dev/usb/usb_bus.h>
+#include <dev/usb/controller/ehci.h>
+#include <dev/usb/controller/ehcireg.h>
+
+#define	EHCI_HC_DEVSTR		"Ralink RT5350F EHCI"
+
+static device_attach_t ehci_siba_attach;
+static device_detach_t ehci_siba_detach;
+
+//#define	USB_BRIDGE_INTR_CAUSE  0x210
+//#define	USB_BRIDGE_INTR_MASK   0x214
+
+static int
+ehci_siba_probe(device_t self)
+{
+
+	device_set_desc(self, EHCI_HC_DEVSTR);
+
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ehci_siba_attach(device_t self)
+{
+	ehci_softc_t *sc = device_get_softc(self);
+	int err;
+	int rid;
+
+	/* initialise some bus fields */
+	sc->sc_bus.parent = self;
+	sc->sc_bus.devices = sc->sc_devices;
+	sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
+	sc->sc_bus.usbrev = USB_REV_2_0;
+
+	/* get all DMA memory */
+	if (usb_bus_mem_alloc_all(&sc->sc_bus,
+	    USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
+		return (ENOMEM);
+	}
+
+	rid = 0;
+	sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, 
+	    RF_ACTIVE);
+	if (!sc->sc_io_res) {
+		device_printf(self, "Could not map memory\n");
+		goto error;
+	}
+	sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
+	sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
+	sc->sc_io_size = rman_get_size(sc->sc_io_res);
+
+	rid = 0;
+	sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
+	    RF_SHAREABLE | RF_ACTIVE);
+	if (sc->sc_irq_res == NULL) {
+		device_printf(self, "Could not allocate error irq\n");
+		ehci_siba_detach(self);
+		return (ENXIO);
+	}
+
+	sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
+	if (!sc->sc_bus.bdev) {
+		device_printf(self, "Could not add USB device\n");
+		goto error;
+	}
+	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
+	device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR);
+
+ 	sprintf(sc->sc_vendor, "Ralink");
+
+	err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
+	    NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
+	if (err) {
+		device_printf(self, "Could not setup irq, %d\n", err);
+		sc->sc_intr_hdl = NULL;
+		goto error;
+	}
+
+//	sc->sc_flags |= EHCI_SCFLG_SETMODE | EHCI_SCFLG_LOSTINTRBUG;
+
+	err = ehci_init(sc);
+	if (!err) {
+		err = device_probe_and_attach(sc->sc_bus.bdev);
+	}
+	if (err) {
+		device_printf(self, "USB init failed err=%d\n", err);
+		goto error;
+	}
+	return (0);
+
+error:
+	ehci_siba_detach(self);
+	return (ENXIO);
+}
+
+static int
+ehci_siba_detach(device_t self)
+{
+	ehci_softc_t *sc = device_get_softc(self);
+	device_t bdev;
+	int err;
+
+ 	if (sc->sc_bus.bdev) {
+		bdev = sc->sc_bus.bdev;
+		device_detach(bdev);
+		device_delete_child(self, bdev);
+	}
+	/* during module unload there are lots of children leftover */
+	device_delete_children(self);
+
+	/*
+	 * disable interrupts that might have been switched on in ehci_init
+	 */
+ 	if (sc->sc_irq_res && sc->sc_intr_hdl) {
+		/*
+		 * only call ehci_detach() after ehci_init()
+		 */
+		ehci_detach(sc);
+
+		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
+
+		if (err)
+			/* XXX or should we panic? */
+			device_printf(self, "Could not tear down irq, %d\n",
+			    err);
+		sc->sc_intr_hdl = NULL;
+	}
+ 	if (sc->sc_irq_res) {
+		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
+		sc->sc_irq_res = NULL;
+	}
+	if (sc->sc_io_res) {
+		bus_release_resource(self, SYS_RES_MEMORY, 0,
+		    sc->sc_io_res);
+		sc->sc_io_res = NULL;
+	}
+	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
+
+	return (0);
+}
+
+static device_method_t ehci_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe, ehci_siba_probe),
+	DEVMETHOD(device_attach, ehci_siba_attach),
+	DEVMETHOD(device_detach, ehci_siba_detach),
+	DEVMETHOD(device_suspend, bus_generic_suspend),
+	DEVMETHOD(device_resume, bus_generic_resume),
+	DEVMETHOD(device_shutdown, bus_generic_shutdown),
+
+	/* Bus interface */
+	DEVMETHOD(bus_print_child, bus_generic_print_child),
+
+	{0, 0}
+};
+
+static driver_t ehci_driver = {
+	"ehci",
+	ehci_methods,
+	sizeof(ehci_softc_t),
+};
+
+static devclass_t ehci_devclass;
+
+DRIVER_MODULE(ehci, rt5350_usb, ehci_driver, ehci_devclass, 0, 0);
+MODULE_DEPEND(ehci, usb, 1, 1, 1);
diff -r 0ab33e4fbea2 -r d59f197f345f head/sys/mips/rt305x/rt5350_usb.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/mips/rt305x/rt5350_usb.c	Wed Apr 18 11:08:04 2012 +0300
@@ -0,0 +1,410 @@
+/*-
+ * Copyright (c) 2012, Aleksandr Rybalko <ray at ddteam.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * RT5350F USB 2.0 core driver.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <sys/malloc.h>
+#include <sys/interrupt.h>
+
+#include <machine/bus.h>
+#include <machine/intr_machdep.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/pmap.h>
+#include <machine/resource.h>
+#include <machine/vmparam.h>
+
+#include <mips/rt305x/rt305xreg.h>
+#include <mips/rt305x/rt305x_sysctlvar.h>
+
+struct rt5350_usb_softc {
+	bus_space_tag_t		 sc_bt;
+	bus_space_handle_t	 sc_bh;
+	bus_addr_t		 sc_maddr;
+	bus_size_t		 sc_msize;
+	bus_addr_t		 sc_irqn;
+	struct intr_event	*sc_events; /* IRQ events structs */
+
+	struct resource *sc_mem;
+	struct resource *sc_irq;
+	struct rman 		 mem_rman;
+	struct rman 		 irq_rman;
+	int 			devid;
+
+};
+
+struct rt5350_usb_devinfo {
+	struct resource_list	sdi_rl;
+	uint8_t			sdi_unit;	/* core index on bus */
+	uint8_t			sdi_irq;
+	char 			sdi_name[8];
+	bus_addr_t 		sdi_maddr;
+	bus_size_t 		sdi_msize;
+};
+
+static int	rt5350_usb_attach(device_t);
+static int	rt5350_usb_probe(device_t);
+static device_t	rt5350_usb_add_child(device_t dev, u_int order,
+    const char *name, int unit);
+
+static int
+rt5350_usb_probe(device_t dev)
+{
+	device_set_desc(dev, "USB core");
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+rt5350_usb_attach(device_t dev)
+{
+	struct rt5350_usb_softc *sc = device_get_softc(dev);
+	int rid;
+
+	/* Run clock for OTG/EHCI/OHCI core */
+	rt305x_sysctl_set(SYSCTL_CLKCFG1, rt305x_sysctl_get(SYSCTL_CLKCFG1) |
+	    SYSCTL_CLKCFG1_OTG_CLK_EN|SYSCTL_CLKCFG1_EHCI_CLK_EN);
+	/* Remove RESET flags from OTG/EHCI/OHCI cores */
+	rt305x_sysctl_set(SYSCTL_RSTCTRL, rt305x_sysctl_get(SYSCTL_RSTCTRL) &
+	    ~(SYSCTL_RSTCTRL_OTG|SYSCTL_RSTCTRL_EHCI));
+	DELAY(10000);
+
+#define SYSCFG1			0x14
+#define USB0_HOST_MODE		(1UL<<10)
+	/* Enable HOST mode */
+	rt305x_sysctl_set(SYSCFG1, rt305x_sysctl_get(SYSCFG1) |
+	    USB0_HOST_MODE);
+
+	/*
+	 * Allocate the resources which the parent bus has already
+	 * determined for us.
+	 */
+	rid = 0;
+	sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+	if (sc->sc_mem == NULL) {
+		device_printf(dev, "unable to allocate memory\n");
+		return (ENXIO);
+	}
+
+	sc->sc_bt = rman_get_bustag(sc->sc_mem);
+	sc->sc_bh = rman_get_bushandle(sc->sc_mem);
+	sc->sc_maddr = rman_get_start(sc->sc_mem);
+	sc->sc_msize = rman_get_size(sc->sc_mem);
+
+
+	rid = 0;
+	sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 
+		RF_SHAREABLE | RF_ACTIVE);
+	if (sc->sc_irq == NULL) {
+		device_printf(dev, "unable to allocate irq\n");
+		return (ENXIO);
+	}
+	sc->sc_irqn = rman_get_start(sc->sc_irq);
+
+	sc->mem_rman.rm_start = sc->sc_maddr;
+	sc->mem_rman.rm_end = sc->sc_maddr + sc->sc_msize - 1;
+	sc->mem_rman.rm_type = RMAN_ARRAY;
+	sc->mem_rman.rm_descr = "rt5350 USB core I/O memory addresses";
+	if (rman_init(&sc->mem_rman) != 0 ||
+	    rman_manage_region(&sc->mem_rman, sc->mem_rman.rm_start, sc->mem_rman.rm_end) != 0) {
+		panic("%s: sc->mem_rman", __func__);
+	}
+
+	sc->irq_rman.rm_start = sc->sc_irqn;
+	sc->irq_rman.rm_end = sc->sc_irqn;
+	sc->irq_rman.rm_type = RMAN_ARRAY;
+	sc->irq_rman.rm_descr = "rt5350 USB core IRQ";
+	/* 
+	 * rt5350 USB share one IRQ between OHCI and EHCI
+	 */
+	if (rman_init(&sc->irq_rman) != 0 ||
+	    rman_manage_region(&sc->irq_rman, sc->irq_rman.rm_start, sc->irq_rman.rm_end) != 0)
+		panic("%s: failed to set up IRQ rman", __func__);
+
+	bus_generic_probe(dev);
+
+	rt5350_usb_add_child(dev, 0, "ehci", -1);
+	rt5350_usb_add_child(dev, 1, "ohci", -1);
+
+	bus_generic_attach(dev);
+
+	return (0);
+}
+
+
+
+
+static struct resource *
+rt5350_usb_alloc_resource(device_t bus, device_t child, int type, int *rid,
+    u_long start, u_long end, u_long count, u_int flags)
+{
+	struct resource			*rv;
+	struct resource_list		*rl;
+	struct resource_list_entry	*rle;
+	int				 isdefault, needactivate;
+	struct rt5350_usb_softc		*sc = device_get_softc(bus);
+
+	isdefault = (start == 0UL && end == ~0UL);
+	needactivate = flags & RF_ACTIVE;
+	rl = BUS_GET_RESOURCE_LIST(bus, child);
+	rle = NULL;
+
+	if (isdefault) {
+		rle = resource_list_find(rl, type, *rid);
+		if (rle == NULL)
+			return (NULL);
+		if (rle->res != NULL)
+			panic("%s: resource entry is busy", __func__);
+		start = rle->start;
+		end = rle->end;
+		count = rle->count;
+	}
+
+	/*
+	 * If the request is for a resource which we manage,
+	 * attempt to satisfy the allocation ourselves.
+	 */
+	if (type == SYS_RES_MEMORY) {
+
+		rv = rman_reserve_resource(&sc->mem_rman, start, end, count,
+		    flags, child);
+		if (rv == 0) {
+			printf("%s: could not reserve resource\n", __func__);
+			return (0);
+		}
+
+		rman_set_rid(rv, *rid);
+
+		if (needactivate) {
+			if (bus_activate_resource(child, type, *rid, rv)) {
+				printf("%s: could not activate resource\n",
+				    __func__);
+				rman_release_resource(rv);
+				return (0);
+			}
+		}
+
+		return (rv);
+	}
+
+	if (type == SYS_RES_IRQ) {
+
+		rv = rman_reserve_resource(&sc->irq_rman, start, end, count,
+		    flags, child);
+		if (rv == 0) {
+			printf("%s: could not reserve resource\n", __func__);
+			return (0);
+		}
+
+		rman_set_rid(rv, *rid);
+
+		if (needactivate) {
+			if (bus_activate_resource(child, type, *rid, rv)) {
+				printf("%s: could not activate resource\n",
+				    __func__);
+				rman_release_resource(rv);
+				return (0);
+			}
+		}
+
+		return (rv);
+	}
+
+	/*
+	 * Pass the request to the parent.
+	 */
+	return (resource_list_alloc(rl, bus, child, type, rid,
+	    start, end, count, flags));
+}
+
+/*
+ * The parent bus is responsible for resource activation; in the
+ * case of MIPS, this boils down to setting the virtual address and
+ * bus handle by mapping the physical address into KSEG1.
+ */
+static int
+rt5350_usb_activate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+	return (BUS_ACTIVATE_RESOURCE(device_get_parent(bus), child, type,
+	    rid, r));
+}
+
+static int
+rt5350_usb_deactivate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+	return (BUS_DEACTIVATE_RESOURCE(device_get_parent(bus), child, type,
+	    rid, r));
+}
+
+
+
+
+static struct resource_list *
+rt5350_usb_get_reslist(device_t dev, device_t child)
+{
+	struct rt5350_usb_devinfo *sdi = device_get_ivars(child);
+
+	return (&sdi->sdi_rl);
+}
+
+
+static int
+rt5350_usb_release_resource(device_t dev, device_t child, int type,
+    int rid, struct resource *r)
+{
+	struct resource_list *rl;
+	struct resource_list_entry *rle;
+
+	rl = rt5350_usb_get_reslist(dev, child);
+	if (rl == NULL)
+		return (EINVAL);
+	rle = resource_list_find(rl, type, rid);
+	if (rle == NULL)
+		return (EINVAL);
+	rman_release_resource(r);
+	rle->res = NULL;
+
+	return (0);
+}
+
+static int
+rt5350_usb_print_all_resources(device_t dev)
+{
+	struct rt5350_usb_devinfo *sdi = device_get_ivars(dev);
+	struct resource_list *rl = &sdi->sdi_rl;
+	int retval = 0;
+
+	if (STAILQ_FIRST(rl))
+		retval += printf(" at");
+
+	retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
+	retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
+
+	return (retval);
+}
+
+static int
+rt5350_usb_print_child(device_t bus, device_t child)
+{
+	int retval = 0;
+
+	retval += bus_print_child_header(bus, child);
+	retval += rt5350_usb_print_all_resources(child);
+	if (device_get_flags(child))
+		retval += printf(" flags %#x", device_get_flags(child));
+	retval += printf(" on %s\n", device_get_nameunit(bus));
+
+	return (retval);
+}
+
+static device_t
+rt5350_usb_add_child(device_t dev, u_int order, const char *name, int unit)
+{
+	struct rt5350_usb_softc	*sc = device_get_softc(dev);
+	device_t 		child;
+	struct rt5350_usb_devinfo 	*sdi;
+
+	child = device_add_child_ordered(dev, order, name, unit);
+	if (child == NULL)
+		return (NULL);
+
+	sdi = malloc(sizeof(struct rt5350_usb_devinfo), M_DEVBUF, M_NOWAIT|M_ZERO);
+	if (sdi == NULL)
+		return (NULL);
+
+	if (strncmp(name, "ohci", 4) == 0) {
+		sdi->sdi_maddr = sc->sc_maddr + 0x1000;
+		sdi->sdi_msize = 0x1000;
+		sdi->sdi_irq   = sc->sc_irqn;
+	} else if (strncmp(name, "ehci", 4) == 0) {
+		sdi->sdi_maddr = sc->sc_maddr + 0x0000;
+		sdi->sdi_msize = 0x1000;
+		sdi->sdi_irq   = sc->sc_irqn;
+	} else {
+		/* Unknown subdevice */
+		sdi->sdi_maddr = 1;
+		sdi->sdi_msize = 1;
+		sdi->sdi_irq   = 1;
+	}
+
+	resource_list_init(&sdi->sdi_rl);
+
+	/*
+	 * Determine memory window on bus and irq if one is needed.
+	 */
+	resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, 0,
+	    sdi->sdi_maddr, sdi->sdi_maddr + sdi->sdi_msize - 1, sdi->sdi_msize);
+
+	resource_list_add(&sdi->sdi_rl, SYS_RES_IRQ, 0,
+	    sdi->sdi_irq, sdi->sdi_irq, 1);
+
+	device_set_ivars(child, sdi);
+	return (child);
+
+}
+
+static device_method_t rt5350_usb_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_attach,	rt5350_usb_attach),
+	DEVMETHOD(device_probe,		rt5350_usb_probe),
+
+	/* Bus interface */
+	DEVMETHOD(bus_activate_resource,	rt5350_usb_activate_resource),
+	DEVMETHOD(bus_deactivate_resource,	rt5350_usb_deactivate_resource),
+	DEVMETHOD(bus_alloc_resource,		rt5350_usb_alloc_resource),
+	DEVMETHOD(bus_release_resource,		rt5350_usb_release_resource),
+	DEVMETHOD(bus_get_resource_list,	rt5350_usb_get_reslist),
+	DEVMETHOD(bus_add_child,		rt5350_usb_add_child),
+	DEVMETHOD(bus_print_child,		rt5350_usb_print_child),
+	DEVMETHOD(bus_setup_intr,		bus_generic_setup_intr),
+	DEVMETHOD(bus_teardown_intr,		bus_generic_teardown_intr),
+
+	DEVMETHOD_END
+};
+
+static driver_t rt5350_usb_driver = {
+	"rt5350_usb",
+	rt5350_usb_methods,
+	sizeof(struct rt5350_usb_softc),
+};
+static devclass_t rt5350_usb_devclass;
+
+DRIVER_MODULE(rt5350_usb, obio, rt5350_usb_driver, rt5350_usb_devclass, 0, 0);


More information about the Zrouter-src-freebsd mailing list