diff options
Diffstat (limited to 'sys/dev/usb/controller/usb_controller.c')
| -rw-r--r-- | sys/dev/usb/controller/usb_controller.c | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 1e91643865e5..3e7c0a7eaa20 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -28,7 +28,7 @@ #include <dev/usb/usb_error.h> #include <dev/usb/usb.h> -#define USB_DEBUG_VAR usb2_ctrl_debug +#define USB_DEBUG_VAR usb_ctrl_debug #include <dev/usb/usb_core.h> #include <dev/usb/usb_debug.h> @@ -43,66 +43,66 @@ /* function prototypes */ -static device_probe_t usb2_probe; -static device_attach_t usb2_attach; -static device_detach_t usb2_detach; +static device_probe_t usb_probe; +static device_attach_t usb_attach; +static device_detach_t usb_detach; -static void usb2_attach_sub(device_t, struct usb_bus *); -static void usb2_post_init(void *); +static void usb_attach_sub(device_t, struct usb_bus *); +static void usb_post_init(void *); /* static variables */ #if USB_DEBUG -static int usb2_ctrl_debug = 0; +static int usb_ctrl_debug = 0; SYSCTL_NODE(_hw_usb, OID_AUTO, ctrl, CTLFLAG_RW, 0, "USB controller"); -SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb2_ctrl_debug, 0, +SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0, "Debug level"); #endif -static uint8_t usb2_post_init_called = 0; +static uint8_t usb_post_init_called = 0; -static devclass_t usb2_devclass; +static devclass_t usb_devclass; -static device_method_t usb2_methods[] = { - DEVMETHOD(device_probe, usb2_probe), - DEVMETHOD(device_attach, usb2_attach), - DEVMETHOD(device_detach, usb2_detach), +static device_method_t usb_methods[] = { + DEVMETHOD(device_probe, usb_probe), + DEVMETHOD(device_attach, usb_attach), + DEVMETHOD(device_detach, usb_detach), DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume, bus_generic_resume), DEVMETHOD(device_shutdown, bus_generic_shutdown), {0, 0} }; -static driver_t usb2_driver = { +static driver_t usb_driver = { .name = "usbus", - .methods = usb2_methods, + .methods = usb_methods, .size = 0, }; -DRIVER_MODULE(usbus, ohci, usb2_driver, usb2_devclass, 0, 0); -DRIVER_MODULE(usbus, uhci, usb2_driver, usb2_devclass, 0, 0); -DRIVER_MODULE(usbus, ehci, usb2_driver, usb2_devclass, 0, 0); -DRIVER_MODULE(usbus, at91_udp, usb2_driver, usb2_devclass, 0, 0); -DRIVER_MODULE(usbus, uss820, usb2_driver, usb2_devclass, 0, 0); +DRIVER_MODULE(usbus, ohci, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, uhci, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, ehci, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, at91_udp, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, uss820, usb_driver, usb_devclass, 0, 0); /*------------------------------------------------------------------------* - * usb2_probe + * usb_probe * * This function is called from "{ehci,ohci,uhci}_pci_attach()". *------------------------------------------------------------------------*/ static int -usb2_probe(device_t dev) +usb_probe(device_t dev) { DPRINTF("\n"); return (0); } /*------------------------------------------------------------------------* - * usb2_attach + * usb_attach *------------------------------------------------------------------------*/ static int -usb2_attach(device_t dev) +usb_attach(device_t dev) { struct usb_bus *bus = device_get_ivars(dev); @@ -116,20 +116,20 @@ usb2_attach(device_t dev) /* delay vfs_mountroot until the bus is explored */ bus->bus_roothold = root_mount_hold(device_get_nameunit(dev)); - if (usb2_post_init_called) { + if (usb_post_init_called) { mtx_lock(&Giant); - usb2_attach_sub(dev, bus); + usb_attach_sub(dev, bus); mtx_unlock(&Giant); - usb2_needs_explore(bus, 1); + usb_needs_explore(bus, 1); } return (0); /* return success */ } /*------------------------------------------------------------------------* - * usb2_detach + * usb_detach *------------------------------------------------------------------------*/ static int -usb2_detach(device_t dev) +usb_detach(device_t dev) { struct usb_bus *bus = device_get_softc(dev); @@ -140,7 +140,7 @@ usb2_detach(device_t dev) return (0); } /* Stop power watchdog */ - usb2_callout_drain(&bus->power_wdog); + usb_callout_drain(&bus->power_wdog); /* Let the USB explore process detach all devices. */ if (bus->bus_roothold != NULL) { @@ -149,40 +149,40 @@ usb2_detach(device_t dev) } USB_BUS_LOCK(bus); - if (usb2_proc_msignal(&bus->explore_proc, + if (usb_proc_msignal(&bus->explore_proc, &bus->detach_msg[0], &bus->detach_msg[1])) { /* ignore */ } /* Wait for detach to complete */ - usb2_proc_mwait(&bus->explore_proc, + usb_proc_mwait(&bus->explore_proc, &bus->detach_msg[0], &bus->detach_msg[1]); USB_BUS_UNLOCK(bus); /* Get rid of USB callback processes */ - usb2_proc_free(&bus->giant_callback_proc); - usb2_proc_free(&bus->non_giant_callback_proc); + usb_proc_free(&bus->giant_callback_proc); + usb_proc_free(&bus->non_giant_callback_proc); /* Get rid of USB explore process */ - usb2_proc_free(&bus->explore_proc); + usb_proc_free(&bus->explore_proc); /* Get rid of control transfer process */ - usb2_proc_free(&bus->control_xfer_proc); + usb_proc_free(&bus->control_xfer_proc); return (0); } /*------------------------------------------------------------------------* - * usb2_bus_explore + * usb_bus_explore * * This function is used to explore the device tree from the root. *------------------------------------------------------------------------*/ static void -usb2_bus_explore(struct usb_proc_msg *pm) +usb_bus_explore(struct usb_proc_msg *pm) { struct usb_bus *bus; struct usb_device *udev; @@ -207,7 +207,7 @@ usb2_bus_explore(struct usb_proc_msg *pm) /* * First update the USB power state! */ - usb2_bus_powerd(bus); + usb_bus_powerd(bus); /* * Explore the Root USB HUB. This call can sleep, * exiting Giant, which is actually Giant. @@ -225,12 +225,12 @@ usb2_bus_explore(struct usb_proc_msg *pm) } /*------------------------------------------------------------------------* - * usb2_bus_detach + * usb_bus_detach * * This function is used to detach the device tree from the root. *------------------------------------------------------------------------*/ static void -usb2_bus_detach(struct usb_proc_msg *pm) +usb_bus_detach(struct usb_proc_msg *pm) { struct usb_bus *bus; struct usb_device *udev; @@ -252,7 +252,7 @@ usb2_bus_detach(struct usb_proc_msg *pm) * Free USB Root device, but not any sub-devices, hence they * are freed by the caller of this function: */ - usb2_free_device(udev, + usb_free_device(udev, USB_UNCFG_FLAG_FREE_EP0); mtx_unlock(&Giant); @@ -262,29 +262,29 @@ usb2_bus_detach(struct usb_proc_msg *pm) } static void -usb2_power_wdog(void *arg) +usb_power_wdog(void *arg) { struct usb_bus *bus = arg; USB_BUS_LOCK_ASSERT(bus, MA_OWNED); - usb2_callout_reset(&bus->power_wdog, - 4 * hz, usb2_power_wdog, arg); + usb_callout_reset(&bus->power_wdog, + 4 * hz, usb_power_wdog, arg); USB_BUS_UNLOCK(bus); - usb2_bus_power_update(bus); + usb_bus_power_update(bus); USB_BUS_LOCK(bus); } /*------------------------------------------------------------------------* - * usb2_bus_attach + * usb_bus_attach * * This function attaches USB in context of the explore thread. *------------------------------------------------------------------------*/ static void -usb2_bus_attach(struct usb_proc_msg *pm) +usb_bus_attach(struct usb_proc_msg *pm) { struct usb_bus *bus; struct usb_device *child; @@ -342,10 +342,10 @@ usb2_bus_attach(struct usb_proc_msg *pm) /* Allocate the Root USB device */ - child = usb2_alloc_device(bus->bdev, bus, NULL, 0, 0, 1, + child = usb_alloc_device(bus->bdev, bus, NULL, 0, 0, 1, speed, USB_MODE_HOST); if (child) { - err = usb2_probe_and_attach(child, + err = usb_probe_and_attach(child, USB_IFACE_INDEX_ANY); if (!err) { if ((bus->devices[USB_ROOT_HUB_ADDR] == NULL) || @@ -362,68 +362,68 @@ usb2_bus_attach(struct usb_proc_msg *pm) if (err) { device_printf(bus->bdev, "Root HUB problem, error=%s\n", - usb2_errstr(err)); + usbd_errstr(err)); } /* set softc - we are ready */ device_set_softc(dev, bus); /* start watchdog */ - usb2_power_wdog(bus); + usb_power_wdog(bus); } /*------------------------------------------------------------------------* - * usb2_attach_sub + * usb_attach_sub * * This function creates a thread which runs the USB attach code. It * is factored out, hence it can be called at two different places in * time. During bootup this function is called from - * "usb2_post_init". During hot-plug it is called directly from the - * "usb2_attach()" method. + * "usb_post_init". During hot-plug it is called directly from the + * "usb_attach()" method. *------------------------------------------------------------------------*/ static void -usb2_attach_sub(device_t dev, struct usb_bus *bus) +usb_attach_sub(device_t dev, struct usb_bus *bus) { const char *pname = device_get_nameunit(dev); /* Initialise USB process messages */ - bus->explore_msg[0].hdr.pm_callback = &usb2_bus_explore; + bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore; bus->explore_msg[0].bus = bus; - bus->explore_msg[1].hdr.pm_callback = &usb2_bus_explore; + bus->explore_msg[1].hdr.pm_callback = &usb_bus_explore; bus->explore_msg[1].bus = bus; - bus->detach_msg[0].hdr.pm_callback = &usb2_bus_detach; + bus->detach_msg[0].hdr.pm_callback = &usb_bus_detach; bus->detach_msg[0].bus = bus; - bus->detach_msg[1].hdr.pm_callback = &usb2_bus_detach; + bus->detach_msg[1].hdr.pm_callback = &usb_bus_detach; bus->detach_msg[1].bus = bus; - bus->attach_msg[0].hdr.pm_callback = &usb2_bus_attach; + bus->attach_msg[0].hdr.pm_callback = &usb_bus_attach; bus->attach_msg[0].bus = bus; - bus->attach_msg[1].hdr.pm_callback = &usb2_bus_attach; + bus->attach_msg[1].hdr.pm_callback = &usb_bus_attach; bus->attach_msg[1].bus = bus; /* Create USB explore and callback processes */ - if (usb2_proc_create(&bus->giant_callback_proc, + if (usb_proc_create(&bus->giant_callback_proc, &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB Giant " "callback process failed.\n"); - } else if (usb2_proc_create(&bus->non_giant_callback_proc, + } else if (usb_proc_create(&bus->non_giant_callback_proc, &bus->bus_mtx, pname, USB_PRI_HIGH)) { printf("WARNING: Creation of USB non-Giant " "callback process failed.\n"); - } else if (usb2_proc_create(&bus->explore_proc, + } else if (usb_proc_create(&bus->explore_proc, &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB explore " "process failed.\n"); - } else if (usb2_proc_create(&bus->control_xfer_proc, + } else if (usb_proc_create(&bus->control_xfer_proc, &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB control transfer " "process failed.\n"); } else { /* Get final attach going */ USB_BUS_LOCK(bus); - if (usb2_proc_msignal(&bus->explore_proc, + if (usb_proc_msignal(&bus->explore_proc, &bus->attach_msg[0], &bus->attach_msg[1])) { /* ignore */ } @@ -432,13 +432,13 @@ usb2_attach_sub(device_t dev, struct usb_bus *bus) } /*------------------------------------------------------------------------* - * usb2_post_init + * usb_post_init * * This function is called to attach all USB busses that were found * during bootup. *------------------------------------------------------------------------*/ static void -usb2_post_init(void *arg) +usb_post_init(void *arg) { struct usb_bus *bus; devclass_t dc; @@ -448,9 +448,9 @@ usb2_post_init(void *arg) mtx_lock(&Giant); - usb2_devclass_ptr = devclass_find("usbus"); + usb_devclass_ptr = devclass_find("usbus"); - dc = usb2_devclass_ptr; + dc = usb_devclass_ptr; if (dc) { max = devclass_get_maxunit(dc) + 1; for (n = 0; n != max; n++) { @@ -459,7 +459,7 @@ usb2_post_init(void *arg) bus = device_get_ivars(dev); if (bus) { mtx_lock(&Giant); - usb2_attach_sub(dev, bus); + usb_attach_sub(dev, bus); mtx_unlock(&Giant); } } @@ -467,69 +467,69 @@ usb2_post_init(void *arg) } else { DPRINTFN(0, "no devclass\n"); } - usb2_post_init_called = 1; + usb_post_init_called = 1; /* explore all USB busses in parallell */ - usb2_needs_explore_all(); + usb_needs_explore_all(); mtx_unlock(&Giant); } -SYSINIT(usb2_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb2_post_init, NULL); -SYSUNINIT(usb2_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb2_bus_unload, NULL); +SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL); +SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL); /*------------------------------------------------------------------------* - * usb2_bus_mem_flush_all_cb + * usb_bus_mem_flush_all_cb *------------------------------------------------------------------------*/ #if USB_HAVE_BUSDMA static void -usb2_bus_mem_flush_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, +usb_bus_mem_flush_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, struct usb_page *pg, usb_size_t size, usb_size_t align) { - usb2_pc_cpu_flush(pc); + usb_pc_cpu_flush(pc); } #endif /*------------------------------------------------------------------------* - * usb2_bus_mem_flush_all - factored out code + * usb_bus_mem_flush_all - factored out code *------------------------------------------------------------------------*/ #if USB_HAVE_BUSDMA void -usb2_bus_mem_flush_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb) +usb_bus_mem_flush_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb) { if (cb) { - cb(bus, &usb2_bus_mem_flush_all_cb); + cb(bus, &usb_bus_mem_flush_all_cb); } } #endif /*------------------------------------------------------------------------* - * usb2_bus_mem_alloc_all_cb + * usb_bus_mem_alloc_all_cb *------------------------------------------------------------------------*/ #if USB_HAVE_BUSDMA static void -usb2_bus_mem_alloc_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, +usb_bus_mem_alloc_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, struct usb_page *pg, usb_size_t size, usb_size_t align) { /* need to initialize the page cache */ pc->tag_parent = bus->dma_parent_tag; - if (usb2_pc_alloc_mem(pc, pg, size, align)) { + if (usb_pc_alloc_mem(pc, pg, size, align)) { bus->alloc_failed = 1; } } #endif /*------------------------------------------------------------------------* - * usb2_bus_mem_alloc_all - factored out code + * usb_bus_mem_alloc_all - factored out code * * Returns: * 0: Success * Else: Failure *------------------------------------------------------------------------*/ uint8_t -usb2_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, +usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb) { bus->alloc_failed = 0; @@ -537,13 +537,13 @@ usb2_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent), NULL, MTX_DEF | MTX_RECURSE); - usb2_callout_init_mtx(&bus->power_wdog, + usb_callout_init_mtx(&bus->power_wdog, &bus->bus_mtx, 0); TAILQ_INIT(&bus->intr_q.head); #if USB_HAVE_BUSDMA - usb2_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags, + usb_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags, dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX); #endif if ((bus->devices_max > USB_MAX_DEVICES) || @@ -555,38 +555,38 @@ usb2_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, } #if USB_HAVE_BUSDMA if (cb) { - cb(bus, &usb2_bus_mem_alloc_all_cb); + cb(bus, &usb_bus_mem_alloc_all_cb); } #endif if (bus->alloc_failed) { - usb2_bus_mem_free_all(bus, cb); + usb_bus_mem_free_all(bus, cb); } return (bus->alloc_failed); } /*------------------------------------------------------------------------* - * usb2_bus_mem_free_all_cb + * usb_bus_mem_free_all_cb *------------------------------------------------------------------------*/ #if USB_HAVE_BUSDMA static void -usb2_bus_mem_free_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, +usb_bus_mem_free_all_cb(struct usb_bus *bus, struct usb_page_cache *pc, struct usb_page *pg, usb_size_t size, usb_size_t align) { - usb2_pc_free_mem(pc); + usb_pc_free_mem(pc); } #endif /*------------------------------------------------------------------------* - * usb2_bus_mem_free_all - factored out code + * usb_bus_mem_free_all - factored out code *------------------------------------------------------------------------*/ void -usb2_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb) +usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb) { #if USB_HAVE_BUSDMA if (cb) { - cb(bus, &usb2_bus_mem_free_all_cb); + cb(bus, &usb_bus_mem_free_all_cb); } - usb2_dma_tag_unsetup(bus->dma_parent_tag); + usb_dma_tag_unsetup(bus->dma_parent_tag); #endif mtx_destroy(&bus->bus_mtx); |
