/* bi_udc_init - initialize USB Device Controller This function is called for each physical bus interface that is found. Register an interrupt handler and IO region. Return non-zero for error. */ int bi_udc_init() { dbg_init(1,"Loading %s", udc_name()); bi_driver.name = udc_name(); bi_driver.max_endpoints = udc_max_endpoints(); bi_driver.maxpacketsize = udc_ep0_packetsize(); dbg_init(1,"name: %s endpoints: %d ep0: %d", bi_driver.name, bi_driver.max_endpoints, bi_driver.maxpacketsize); // request device IRQ. if (udc_request_udc_irq()) { dbg_init(0,"name: %s request udc irq failed", udc_name()); return -EINVAL; } // request device IO if (udc_request_io()) { udc_release_udc_irq(); dbg_init(0,"name: %s request udc io failed", udc_name()); return -EINVAL; } if (udc_init()) { udc_release_udc_irq(); udc_release_io(); dbg_init(1,"name: %s probe failed", udc_name()); return -EINVAL; } return 0; }
/** * bi_udc_init - initialize USB Device Controller * * Get ready to use the USB Device Controller. * * Register an interrupt handler and IO region. Return non-zero for error. */ int bi_udc_init (void) { dbg_init (1, "Loading %s", udc_name ()); bi_driver.name = udc_name (); bi_driver.max_endpoints = udc_max_endpoints (); bi_driver.maxpacketsize = udc_ep0_packetsize (); dbg_init (1, "name: %s endpoints: %d ep0: %d", bi_driver.name, bi_driver.max_endpoints, bi_driver.maxpacketsize); // request device IRQ if (udc_request_udc_irq ()) { dbg_init (0, "name: %s request udc irq failed", udc_name ()); return -EINVAL; } // request device IO if (udc_request_io ()) { udc_release_udc_irq (); dbg_init (0, "name: %s request udc io failed", udc_name ()); return -EINVAL; } // probe for device if (udc_init ()) { udc_release_udc_irq (); udc_release_io (); dbg_init (1, "name: %s probe failed", udc_name ()); return -EINVAL; } // optional cable IRQ have_cable_irq = !udc_request_cable_irq (); dbg_init (1, "name: %s request cable irq %d", udc_name (), have_cable_irq); return 0; }
/** * bi_udc_exit - Stop using the USB Device Controller * * Stop using the USB Device Controller. * * Shutdown and free dma channels, de-register the interrupt handler. */ void bi_udc_exit(void) { int i; dbg_init(1, "Unloading %s", udc_name()); for (i = 0; i < udc_max_endpoints(); i++) { udc_disable_ep(i); } // free io and irq udc_disconnect(); udc_disable(); udc_release_io(); udc_release_udc_irq(); if (have_cable_irq) { udc_release_cable_irq(); } }