Lines Matching full:udc

3  * omap_udc.c -- for OMAP full speed udc; most chips support OTG.
65 * The OMAP UDC needs _very_ early endpoint setup: before enabling the
69 * optional new "UDC not yet running" state to the gadget driver model,
147 struct omap_udc *udc; in omap_ep_enable() local
191 udc = ep->udc; in omap_ep_enable()
192 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in omap_ep_enable()
197 spin_lock_irqsave(&udc->lock, flags); in omap_ep_enable()
209 omap_writew(udc->clr_halt, UDC_CTRL); in omap_ep_enable()
214 list_add(&ep->iso, &udc->iso); in omap_ep_enable()
229 spin_unlock_irqrestore(&udc->lock, flags); in omap_ep_enable()
247 spin_lock_irqsave(&ep->udc->lock, flags); in omap_ep_disable()
256 spin_unlock_irqrestore(&ep->udc->lock, flags); in omap_ep_disable()
291 struct omap_udc *udc = ep->udc; in done() local
302 usb_gadget_unmap_request(&udc->gadget, &req->req, in done()
314 spin_unlock(&ep->udc->lock); in done()
316 spin_lock(&ep->udc->lock); in done()
510 * When DMA completion isn't request completion, the UDC continues with
634 static void dma_irq(struct omap_udc *udc, u16 irq_src) in dma_irq() argument
642 ep = &udc->ep[16 + UDC_DMA_TX_SRC(dman_stat)]; in dma_irq()
661 ep = &udc->ep[UDC_DMA_RX_SRC(dman_stat)]; in dma_irq()
679 ep = &udc->ep[UDC_DMA_RX_SRC(dman_stat)]; in dma_irq()
868 struct omap_udc *udc; in omap_ep_queue() local
900 udc = ep->udc; in omap_ep_queue()
901 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) in omap_ep_queue()
905 usb_gadget_map_request(&udc->gadget, &req->req, in omap_ep_queue()
911 spin_lock_irqsave(&udc->lock, flags); in omap_ep_queue()
927 if (!udc->ep0_pending || !list_empty(&ep->queue)) { in omap_ep_queue()
928 spin_unlock_irqrestore(&udc->lock, flags); in omap_ep_queue()
933 is_in = udc->ep0_in; in omap_ep_queue()
940 if (udc->ep0_set_config) { in omap_ep_queue()
944 if (!udc->ep0_reset_config) in omap_ep_queue()
961 udc->ep0_pending = 0; in omap_ep_queue()
970 if (udc->ep0_setup) in omap_ep_queue()
999 spin_unlock_irqrestore(&udc->lock, flags); in omap_ep_queue()
1013 spin_lock_irqsave(&ep->udc->lock, flags); in omap_ep_dequeue()
1023 spin_unlock_irqrestore(&ep->udc->lock, flags); in omap_ep_dequeue()
1037 spin_unlock_irqrestore(&ep->udc->lock, flags); in omap_ep_dequeue()
1049 spin_lock_irqsave(&ep->udc->lock, flags); in omap_ep_set_halt()
1053 if (!ep->udc->ep0_pending) in omap_ep_set_halt()
1056 if (ep->udc->ep0_set_config) { in omap_ep_set_halt()
1061 ep->udc->ep0_pending = 0; in omap_ep_set_halt()
1098 omap_writew(ep->udc->clr_halt, UDC_CTRL); in omap_ep_set_halt()
1110 spin_unlock_irqrestore(&ep->udc->lock, flags); in omap_ep_set_halt()
1139 struct omap_udc *udc; in omap_wakeup() local
1143 udc = container_of(gadget, struct omap_udc, gadget); in omap_wakeup()
1145 spin_lock_irqsave(&udc->lock, flags); in omap_wakeup()
1146 if (udc->devstat & UDC_SUS) { in omap_wakeup()
1150 if (udc->devstat & (UDC_B_HNP_ENABLE|UDC_R_WK_OK)) { in omap_wakeup()
1157 } else if (!(udc->devstat & UDC_ATT)) { in omap_wakeup()
1158 if (!IS_ERR_OR_NULL(udc->transceiver)) in omap_wakeup()
1159 retval = otg_start_srp(udc->transceiver->otg); in omap_wakeup()
1161 spin_unlock_irqrestore(&udc->lock, flags); in omap_wakeup()
1169 struct omap_udc *udc; in omap_set_selfpowered() local
1174 udc = container_of(gadget, struct omap_udc, gadget); in omap_set_selfpowered()
1175 spin_lock_irqsave(&udc->lock, flags); in omap_set_selfpowered()
1182 spin_unlock_irqrestore(&udc->lock, flags); in omap_set_selfpowered()
1187 static int can_pullup(struct omap_udc *udc) in can_pullup() argument
1189 return udc->driver && udc->softconnect && udc->vbus_active; in can_pullup()
1192 static void pullup_enable(struct omap_udc *udc) in pullup_enable() argument
1199 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) { in pullup_enable()
1209 static void pullup_disable(struct omap_udc *udc) in pullup_disable() argument
1213 if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx()) { in pullup_disable()
1226 static struct omap_udc *udc; variable
1230 if (udc == NULL || udc->dc_clk == NULL || udc->hhc_clk == NULL) in omap_udc_enable_clock()
1234 clk_enable(udc->dc_clk); in omap_udc_enable_clock()
1235 clk_enable(udc->hhc_clk); in omap_udc_enable_clock()
1238 clk_disable(udc->hhc_clk); in omap_udc_enable_clock()
1239 clk_disable(udc->dc_clk); in omap_udc_enable_clock()
1249 struct omap_udc *udc; in omap_vbus_session() local
1253 udc = container_of(gadget, struct omap_udc, gadget); in omap_vbus_session()
1254 spin_lock_irqsave(&udc->lock, flags); in omap_vbus_session()
1256 udc->vbus_active = (is_active != 0); in omap_vbus_session()
1266 if (udc->dc_clk != NULL && is_active) { in omap_vbus_session()
1267 if (!udc->clk_requested) { in omap_vbus_session()
1269 udc->clk_requested = 1; in omap_vbus_session()
1272 if (can_pullup(udc)) in omap_vbus_session()
1273 pullup_enable(udc); in omap_vbus_session()
1275 pullup_disable(udc); in omap_vbus_session()
1276 if (udc->dc_clk != NULL && !is_active) { in omap_vbus_session()
1277 if (udc->clk_requested) { in omap_vbus_session()
1279 udc->clk_requested = 0; in omap_vbus_session()
1282 spin_unlock_irqrestore(&udc->lock, flags); in omap_vbus_session()
1288 struct omap_udc *udc; in omap_vbus_draw() local
1290 udc = container_of(gadget, struct omap_udc, gadget); in omap_vbus_draw()
1291 if (!IS_ERR_OR_NULL(udc->transceiver)) in omap_vbus_draw()
1292 return usb_phy_set_power(udc->transceiver, mA); in omap_vbus_draw()
1298 struct omap_udc *udc; in omap_pullup() local
1301 udc = container_of(gadget, struct omap_udc, gadget); in omap_pullup()
1302 spin_lock_irqsave(&udc->lock, flags); in omap_pullup()
1303 udc->softconnect = (is_on != 0); in omap_pullup()
1304 if (can_pullup(udc)) in omap_pullup()
1305 pullup_enable(udc); in omap_pullup()
1307 pullup_disable(udc); in omap_pullup()
1308 spin_unlock_irqrestore(&udc->lock, flags); in omap_pullup()
1329 /* dequeue ALL requests; caller holds udc->lock */
1350 /* caller holds udc->lock */
1351 static void udc_quiesce(struct omap_udc *udc) in udc_quiesce() argument
1355 udc->gadget.speed = USB_SPEED_UNKNOWN; in udc_quiesce()
1356 nuke(&udc->ep[0], -ESHUTDOWN); in udc_quiesce()
1357 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) in udc_quiesce()
1363 static void update_otg(struct omap_udc *udc) in update_otg() argument
1367 if (!gadget_is_otg(&udc->gadget)) in update_otg()
1375 udc->gadget.b_hnp_enable = !!(devstat & UDC_B_HNP_ENABLE); in update_otg()
1376 udc->gadget.a_hnp_support = !!(devstat & UDC_A_HNP_SUPPORT); in update_otg()
1377 udc->gadget.a_alt_hnp_support = !!(devstat & UDC_A_ALT_HNP_SUPPORT); in update_otg()
1382 if (udc->gadget.b_hnp_enable) { in update_otg()
1392 static void ep0_irq(struct omap_udc *udc, u16 irq_src) in ep0_irq() argument
1394 struct omap_ep *ep0 = &udc->ep[0]; in ep0_irq()
1431 if (udc->ep0_in) { in ep0_irq()
1438 if (!req && udc->ep0_pending) { in ep0_irq()
1443 udc->ep0_pending = 0; in ep0_irq()
1468 if (!udc->ep0_in) { in ep0_irq()
1476 udc->ep0_pending = 0; in ep0_irq()
1491 udc->ep0_pending = 0; in ep0_irq()
1535 udc->ep0_in = (u.r.bRequestType & USB_DIR_IN) != 0; in ep0_irq()
1536 udc->ep0_set_config = 0; in ep0_irq()
1537 udc->ep0_pending = 1; in ep0_irq()
1542 /* udc needs to know when ep != 0 is valid */ in ep0_irq()
1547 udc->ep0_set_config = 1; in ep0_irq()
1548 udc->ep0_reset_config = (w_value == 0); in ep0_irq()
1551 /* update udc NOW since gadget driver may start in ep0_irq()
1555 if (udc->ep0_reset_config) in ep0_irq()
1559 update_otg(udc); in ep0_irq()
1568 ep = &udc->ep[w_index & 0xf]; in ep0_irq()
1576 omap_writew(udc->clr_halt, UDC_CTRL); in ep0_irq()
1597 ep = &udc->ep[w_index & 0xf]; in ep0_irq()
1621 udc->ep0_pending = 0; in ep0_irq()
1633 ep = &udc->ep[w_index & 0xf]; in ep0_irq()
1668 if (!udc->ep0_in && w_length) { in ep0_irq()
1696 udc->ep0_setup = 1; in ep0_irq()
1697 spin_unlock(&udc->lock); in ep0_irq()
1698 status = udc->driver->setup(&udc->gadget, &u.r); in ep0_irq()
1699 spin_lock(&udc->lock); in ep0_irq()
1700 udc->ep0_setup = 0; in ep0_irq()
1707 if (udc->ep0_set_config) { in ep0_irq()
1708 if (udc->ep0_reset_config) in ep0_irq()
1714 udc->ep0_pending = 0; in ep0_irq()
1723 static void devstate_irq(struct omap_udc *udc, u16 irq_src) in devstate_irq() argument
1728 change = devstat ^ udc->devstat; in devstate_irq()
1729 udc->devstat = devstat; in devstate_irq()
1732 udc_quiesce(udc); in devstate_irq()
1739 udc->gadget.speed = USB_SPEED_FULL; in devstate_irq()
1741 if (IS_ERR_OR_NULL(udc->transceiver)) in devstate_irq()
1742 pullup_enable(udc); in devstate_irq()
1744 } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { in devstate_irq()
1745 udc->gadget.speed = USB_SPEED_UNKNOWN; in devstate_irq()
1746 if (IS_ERR_OR_NULL(udc->transceiver)) in devstate_irq()
1747 pullup_disable(udc); in devstate_irq()
1749 udc->driver->driver.name); in devstate_irq()
1750 if (udc->driver->disconnect) { in devstate_irq()
1751 spin_unlock(&udc->lock); in devstate_irq()
1752 udc->driver->disconnect(&udc->gadget); in devstate_irq()
1753 spin_lock(&udc->lock); in devstate_irq()
1763 udc->gadget.speed = USB_SPEED_FULL; in devstate_irq()
1765 udc->driver->driver.name); in devstate_irq()
1774 if (udc->gadget.speed != USB_SPEED_UNKNOWN) { in devstate_irq()
1778 update_otg(udc); in devstate_irq()
1780 if (udc->gadget.speed == USB_SPEED_FULL in devstate_irq()
1781 && udc->driver->suspend) { in devstate_irq()
1782 spin_unlock(&udc->lock); in devstate_irq()
1783 udc->driver->suspend(&udc->gadget); in devstate_irq()
1784 spin_lock(&udc->lock); in devstate_irq()
1786 if (!IS_ERR_OR_NULL(udc->transceiver)) in devstate_irq()
1788 udc->transceiver, 1); in devstate_irq()
1791 if (!IS_ERR_OR_NULL(udc->transceiver)) in devstate_irq()
1793 udc->transceiver, 0); in devstate_irq()
1794 if (udc->gadget.speed == USB_SPEED_FULL in devstate_irq()
1795 && udc->driver->resume) { in devstate_irq()
1796 spin_unlock(&udc->lock); in devstate_irq()
1797 udc->driver->resume(&udc->gadget); in devstate_irq()
1798 spin_lock(&udc->lock); in devstate_irq()
1805 update_otg(udc); in devstate_irq()
1819 struct omap_udc *udc = _udc; in omap_udc_irq() local
1824 spin_lock_irqsave(&udc->lock, flags); in omap_udc_irq()
1851 spin_unlock_irqrestore(&udc->lock, flags); in omap_udc_irq()
1866 spin_lock_irqsave(&ep->udc->lock, flags); in pio_out_timer()
1886 spin_unlock_irqrestore(&ep->udc->lock, flags); in pio_out_timer()
1895 struct omap_udc *udc = _dev; in omap_udc_pio_irq() local
1899 spin_lock_irqsave(&udc->lock, flags); in omap_udc_pio_irq()
1908 ep = &udc->ep[epnum]; in omap_udc_pio_irq()
1944 ep = &udc->ep[16 + epnum]; in omap_udc_pio_irq()
1963 spin_unlock_irqrestore(&udc->lock, flags); in omap_udc_pio_irq()
1970 struct omap_udc *udc = _dev; in omap_udc_iso_irq() local
1975 spin_lock_irqsave(&udc->lock, flags); in omap_udc_iso_irq()
1978 list_for_each_entry(ep, &udc->iso, iso) { in omap_udc_iso_irq()
2028 spin_unlock_irqrestore(&udc->lock, flags); in omap_udc_iso_irq()
2049 spin_lock_irqsave(&udc->lock, flags); in omap_udc_start()
2051 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in omap_udc_start()
2058 udc->ep0_pending = 0; in omap_udc_start()
2059 udc->ep[0].irqs = 0; in omap_udc_start()
2060 udc->softconnect = 1; in omap_udc_start()
2063 udc->driver = driver; in omap_udc_start()
2064 spin_unlock_irqrestore(&udc->lock, flags); in omap_udc_start()
2066 if (udc->dc_clk != NULL) in omap_udc_start()
2072 if (!IS_ERR_OR_NULL(udc->transceiver)) { in omap_udc_start()
2073 status = otg_set_peripheral(udc->transceiver->otg, in omap_udc_start()
2074 &udc->gadget); in omap_udc_start()
2077 udc->driver = NULL; in omap_udc_start()
2082 if (can_pullup(udc)) in omap_udc_start()
2083 pullup_enable(udc); in omap_udc_start()
2085 pullup_disable(udc); in omap_udc_start()
2092 omap_vbus_session(&udc->gadget, 1); in omap_udc_start()
2095 if (udc->dc_clk != NULL) in omap_udc_start()
2105 if (udc->dc_clk != NULL) in omap_udc_stop()
2109 omap_vbus_session(&udc->gadget, 0); in omap_udc_stop()
2111 if (!IS_ERR_OR_NULL(udc->transceiver)) in omap_udc_stop()
2112 (void) otg_set_peripheral(udc->transceiver->otg, NULL); in omap_udc_stop()
2114 pullup_disable(udc); in omap_udc_stop()
2116 spin_lock_irqsave(&udc->lock, flags); in omap_udc_stop()
2117 udc_quiesce(udc); in omap_udc_stop()
2118 spin_unlock_irqrestore(&udc->lock, flags); in omap_udc_stop()
2120 udc->driver = NULL; in omap_udc_stop()
2122 if (udc->dc_clk != NULL) in omap_udc_stop()
2134 static const char proc_filename[] = "driver/udc";
2298 spin_lock_irqsave(&udc->lock, flags); in proc_udc_show()
2300 seq_printf(s, "OMAP UDC driver, version: " DRIVER_VERSION in proc_udc_show()
2308 "UDC rev %d.%d, fifo mode %d, gadget %s\n" in proc_udc_show()
2312 udc->driver ? udc->driver->driver.name : "(none)", in proc_udc_show()
2314 udc->transceiver in proc_udc_show()
2315 ? udc->transceiver->label in proc_udc_show()
2339 /* UDC controller registers */ in proc_udc_show()
2342 spin_unlock_irqrestore(&udc->lock, flags); in proc_udc_show()
2419 proc_ep_show(s, &udc->ep[0]); in proc_udc_show()
2421 list_for_each_entry(ep, &udc->gadget.ep_list, in proc_udc_show()
2428 spin_unlock_irqrestore(&udc->lock, flags); in proc_udc_show()
2467 ep = &udc->ep[addr & 0xf]; in omap_ep_setup()
2558 ep->udc = udc; in omap_ep_setup()
2586 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in omap_ep_setup()
2593 pullup_disable(udc); in omap_udc_release()
2594 if (!IS_ERR_OR_NULL(udc->transceiver)) { in omap_udc_release()
2595 usb_put_phy(udc->transceiver); in omap_udc_release()
2596 udc->transceiver = NULL; in omap_udc_release()
2600 if (udc->dc_clk) { in omap_udc_release()
2601 if (udc->clk_requested) in omap_udc_release()
2603 clk_unprepare(udc->hhc_clk); in omap_udc_release()
2604 clk_unprepare(udc->dc_clk); in omap_udc_release()
2605 clk_put(udc->hhc_clk); in omap_udc_release()
2606 clk_put(udc->dc_clk); in omap_udc_release()
2608 if (udc->done) in omap_udc_release()
2609 complete(udc->done); in omap_udc_release()
2610 kfree(udc); in omap_udc_release()
2629 udc = kzalloc(sizeof(*udc), GFP_KERNEL); in omap_udc_setup()
2630 if (!udc) in omap_udc_setup()
2633 spin_lock_init(&udc->lock); in omap_udc_setup()
2635 udc->gadget.ops = &omap_gadget_ops; in omap_udc_setup()
2636 udc->gadget.ep0 = &udc->ep[0].ep; in omap_udc_setup()
2637 INIT_LIST_HEAD(&udc->gadget.ep_list); in omap_udc_setup()
2638 INIT_LIST_HEAD(&udc->iso); in omap_udc_setup()
2639 udc->gadget.speed = USB_SPEED_UNKNOWN; in omap_udc_setup()
2640 udc->gadget.max_speed = USB_SPEED_FULL; in omap_udc_setup()
2641 udc->gadget.name = driver_name; in omap_udc_setup()
2642 udc->gadget.quirk_ep_out_aligned_size = 1; in omap_udc_setup()
2643 udc->transceiver = xceiv; in omap_udc_setup()
2648 list_del_init(&udc->ep[0].ep.ep_list); in omap_udc_setup()
2771 INFO("OMAP UDC rev %d.%d%s\n", in omap_udc_probe()
2844 ERR("unrecognized UDC HMC mode %d\n", hmc); in omap_udc_probe()
2857 /* "udc" is now valid */ in omap_udc_probe()
2858 pullup_disable(udc); in omap_udc_probe()
2860 udc->gadget.is_otg = (config->otg != 0); in omap_udc_probe()
2865 udc->clr_halt = UDC_RESET_EP | UDC_CLRDATA_TOGGLE; in omap_udc_probe()
2867 udc->clr_halt = UDC_RESET_EP; in omap_udc_probe()
2871 omap_udc_irq, 0, driver_name, udc); in omap_udc_probe()
2880 omap_udc_pio_irq, 0, "omap_udc pio", udc); in omap_udc_probe()
2888 omap_udc_iso_irq, 0, "omap_udc iso", udc); in omap_udc_probe()
2896 udc->dc_clk = dc_clk; in omap_udc_probe()
2897 udc->hhc_clk = hhc_clk; in omap_udc_probe()
2903 return usb_add_gadget_udc_release(&pdev->dev, &udc->gadget, in omap_udc_probe()
2907 kfree(udc); in omap_udc_probe()
2908 udc = NULL; in omap_udc_probe()
2931 udc->done = &done; in omap_udc_remove()
2933 usb_del_gadget_udc(&udc->gadget); in omap_udc_remove()
2963 omap_pullup(&udc->gadget, 0); in omap_udc_suspend()
2972 omap_pullup(&udc->gadget, 1); in omap_udc_resume()
2976 return omap_wakeup(&udc->gadget); in omap_udc_resume()
2993 MODULE_DESCRIPTION("OMAP UDC driver");