Lines Matching full:udc
3 * Handles the Intel 27x USB Device Controller (UDC)
37 * This driver handles the USB Device Controller (UDC) in Intel's PXA 27x
46 * This UDC hardware wants to implement a bit too much USB protocol. The
65 * made of UDC's double buffering either. USB "On-The-Go" is not implemented.
92 struct pxa_udc *udc = s->private; in state_dbg_show() local
95 if (!udc->driver) in state_dbg_show()
103 udc->driver ? udc->driver->driver.name : "(none)"); in state_dbg_show()
105 tmp = udc_readl(udc, UDCCR); in state_dbg_show()
124 udc_readl(udc, UDCICR0), udc_readl(udc, UDCICR1)); in state_dbg_show()
126 udc_readl(udc, UDCISR0), udc_readl(udc, UDCISR1)); in state_dbg_show()
127 seq_printf(s, "udcfnr=%d\n", udc_readl(udc, UDCFNR)); in state_dbg_show()
129 udc->stats.irqs_reset, udc->stats.irqs_suspend, in state_dbg_show()
130 udc->stats.irqs_resume, udc->stats.irqs_reconfig); in state_dbg_show()
138 struct pxa_udc *udc = s->private; in queues_dbg_show() local
143 if (!udc->driver) in queues_dbg_show()
148 ep = &udc->pxa_ep[i]; in queues_dbg_show()
171 struct pxa_udc *udc = s->private; in eps_dbg_show() local
176 if (!udc->driver) in eps_dbg_show()
179 ep = &udc->pxa_ep[0]; in eps_dbg_show()
191 ep = &udc->pxa_ep[i]; in eps_dbg_show()
192 tmp = i? udc_ep_readl(ep, UDCCR) : udc_readl(udc, UDCCR); in eps_dbg_show()
206 static void pxa_init_debugfs(struct pxa_udc *udc) in pxa_init_debugfs() argument
210 root = debugfs_create_dir(udc->gadget.name, usb_debug_root); in pxa_init_debugfs()
211 debugfs_create_file("udcstate", 0400, root, udc, &state_dbg_fops); in pxa_init_debugfs()
212 debugfs_create_file("queues", 0400, root, udc, &queues_dbg_fops); in pxa_init_debugfs()
213 debugfs_create_file("epstate", 0400, root, udc, &eps_dbg_fops); in pxa_init_debugfs()
216 static void pxa_cleanup_debugfs(struct pxa_udc *udc) in pxa_cleanup_debugfs() argument
218 debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root); in pxa_cleanup_debugfs()
222 static inline void pxa_init_debugfs(struct pxa_udc *udc) in pxa_init_debugfs() argument
226 static inline void pxa_cleanup_debugfs(struct pxa_udc *udc) in pxa_cleanup_debugfs() argument
258 * @udc: pxa udc
281 static struct pxa_ep *find_pxa_ep(struct pxa_udc *udc, in find_pxa_ep() argument
286 int cfg = udc->config; in find_pxa_ep()
287 int iface = udc->last_interface; in find_pxa_ep()
288 int alt = udc->last_alternate; in find_pxa_ep()
290 if (udc_usb_ep == &udc->udc_usb_ep[0]) in find_pxa_ep()
291 return &udc->pxa_ep[0]; in find_pxa_ep()
294 ep = &udc->pxa_ep[i]; in find_pxa_ep()
303 * @udc: pxa udc
311 static void update_pxa_ep_matches(struct pxa_udc *udc) in update_pxa_ep_matches() argument
317 udc_usb_ep = &udc->udc_usb_ep[i]; in update_pxa_ep_matches()
319 udc_usb_ep->pxa_ep = find_pxa_ep(udc, udc_usb_ep); in update_pxa_ep_matches()
325 * @ep: udc endpoint
329 struct pxa_udc *udc = ep->dev; in pio_irq_enable() local
331 u32 udcicr0 = udc_readl(udc, UDCICR0); in pio_irq_enable()
332 u32 udcicr1 = udc_readl(udc, UDCICR1); in pio_irq_enable()
335 udc_writel(udc, UDCICR0, udcicr0 | (3 << (index * 2))); in pio_irq_enable()
337 udc_writel(udc, UDCICR1, udcicr1 | (3 << ((index - 16) * 2))); in pio_irq_enable()
342 * @ep: udc endpoint
346 struct pxa_udc *udc = ep->dev; in pio_irq_disable() local
348 u32 udcicr0 = udc_readl(udc, UDCICR0); in pio_irq_disable()
349 u32 udcicr1 = udc_readl(udc, UDCICR1); in pio_irq_disable()
352 udc_writel(udc, UDCICR0, udcicr0 & ~(3 << (index * 2))); in pio_irq_disable()
354 udc_writel(udc, UDCICR1, udcicr1 & ~(3 << ((index - 16) * 2))); in pio_irq_disable()
359 * @udc: udc device
364 static inline void udc_set_mask_UDCCR(struct pxa_udc *udc, int mask) in udc_set_mask_UDCCR() argument
366 u32 udccr = udc_readl(udc, UDCCR); in udc_set_mask_UDCCR()
367 udc_writel(udc, UDCCR, in udc_set_mask_UDCCR()
373 * @udc: udc device
378 static inline void udc_clear_mask_UDCCR(struct pxa_udc *udc, int mask) in udc_clear_mask_UDCCR() argument
380 u32 udccr = udc_readl(udc, UDCCR); in udc_clear_mask_UDCCR()
381 udc_writel(udc, UDCCR, in udc_clear_mask_UDCCR()
387 * @ep: udc endpoint
403 * ep_count_bytes_remain - get how many bytes in udc endpoint
404 * @ep: udc endpoint
417 * @ep: udc endpoint
440 * @ep: udc endpoint
473 * @udc: udc device
476 static void set_ep0state(struct pxa_udc *udc, int state) in set_ep0state() argument
478 struct pxa_ep *ep = &udc->pxa_ep[0]; in set_ep0state()
479 char *old_stname = EP0_STNAME(udc); in set_ep0state()
481 udc->ep0state = state; in set_ep0state()
483 EP0_STNAME(udc), udc_ep_readl(ep, UDCCSR), in set_ep0state()
489 * @dev: udc device
548 * @dev: udc device
1216 * done from software on the PXA UDC, and the hardware in pxa_ep_set_halt()
1311 * before udc is enabled. After udc enable, no physical endpoint configuration
1320 struct pxa_udc *udc; in pxa_ep_enable() local
1353 udc = ep->dev; in pxa_ep_enable()
1355 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in pxa_ep_enable()
1417 * @udc: udc device
1424 static void dplus_pullup(struct pxa_udc *udc, int on) in dplus_pullup() argument
1426 if (udc->gpiod) { in dplus_pullup()
1427 gpiod_set_value(udc->gpiod, on); in dplus_pullup()
1428 } else if (udc->udc_command) { in dplus_pullup()
1430 udc->udc_command(PXA2XX_UDC_CMD_CONNECT); in dplus_pullup()
1432 udc->udc_command(PXA2XX_UDC_CMD_DISCONNECT); in dplus_pullup()
1434 udc->pullup_on = on; in dplus_pullup()
1443 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_get_frame() local
1445 return (udc_readl(udc, UDCFNR) & 0x7ff); in pxa_udc_get_frame()
1449 * pxa_udc_wakeup - Force udc device out of suspend
1456 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_wakeup() local
1459 if ((udc_readl(udc, UDCCR) & UDCCR_DWRE) == 0) in pxa_udc_wakeup()
1461 udc_set_mask_UDCCR(udc, UDCCR_UDR); in pxa_udc_wakeup()
1465 static void udc_enable(struct pxa_udc *udc);
1466 static void udc_disable(struct pxa_udc *udc);
1469 * should_enable_udc - Tells if UDC should be enabled
1470 * @udc: udc device
1473 * The UDC should be enabled if :
1478 * Returns 1 if UDC should be enabled, 0 otherwise
1480 static int should_enable_udc(struct pxa_udc *udc) in should_enable_udc() argument
1484 put_on = ((udc->pullup_on) && (udc->driver)); in should_enable_udc()
1485 put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver))); in should_enable_udc()
1490 * should_disable_udc - Tells if UDC should be disabled
1491 * @udc: udc device
1494 * The UDC should be disabled if :
1499 * Returns 1 if UDC should be disabled
1501 static int should_disable_udc(struct pxa_udc *udc) in should_disable_udc() argument
1505 put_off = ((!udc->pullup_on) || (!udc->driver)); in should_disable_udc()
1506 put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver))); in should_disable_udc()
1517 * Returns 0 if OK, -EOPNOTSUPP if udc driver doesn't handle D+ pullup
1521 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_pullup() local
1523 if (!udc->gpiod && !udc->udc_command) in pxa_udc_pullup()
1526 dplus_pullup(udc, is_active); in pxa_udc_pullup()
1528 if (should_enable_udc(udc)) in pxa_udc_pullup()
1529 udc_enable(udc); in pxa_udc_pullup()
1530 if (should_disable_udc(udc)) in pxa_udc_pullup()
1531 udc_disable(udc); in pxa_udc_pullup()
1536 * pxa_udc_vbus_session - Called by external transceiver to enable/disable udc
1538 * @is_active: 0 if should disable the udc, 1 if should enable
1540 * Enables the udc, and optionnaly activates D+ pullup resistor. Or disables the
1541 * udc, and deactivates D+ pullup resistor.
1547 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_vbus_session() local
1549 udc->vbus_sensed = is_active; in pxa_udc_vbus_session()
1550 if (should_enable_udc(udc)) in pxa_udc_vbus_session()
1551 udc_enable(udc); in pxa_udc_vbus_session()
1552 if (should_disable_udc(udc)) in pxa_udc_vbus_session()
1553 udc_disable(udc); in pxa_udc_vbus_session()
1568 * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc
1572 struct pxa_udc *udc; in pxa_udc_vbus_draw() local
1574 udc = to_gadget_udc(_gadget); in pxa_udc_vbus_draw()
1575 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_vbus_draw()
1576 return usb_phy_set_power(udc->transceiver, mA); in pxa_udc_vbus_draw()
1626 * udc_disable - disable udc device controller
1627 * @udc: udc device
1630 * Disables the udc device : disables clocks, udc interrupts, control endpoint
1633 static void udc_disable(struct pxa_udc *udc) in udc_disable() argument
1635 if (!udc->enabled) in udc_disable()
1638 udc_writel(udc, UDCICR0, 0); in udc_disable()
1639 udc_writel(udc, UDCICR1, 0); in udc_disable()
1641 udc_clear_mask_UDCCR(udc, UDCCR_UDE); in udc_disable()
1643 ep0_idle(udc); in udc_disable()
1644 udc->gadget.speed = USB_SPEED_UNKNOWN; in udc_disable()
1645 clk_disable(udc->clk); in udc_disable()
1647 udc->enabled = 0; in udc_disable()
1651 * udc_init_data - Initialize udc device data structures
1652 * @dev: udc device
1688 * udc_enable - Enables the udc device
1689 * @udc: udc device
1691 * Enables the udc device : enables clocks, udc interrupts, control endpoint
1692 * interrupts, sets usb as UDC client and setups endpoints.
1694 static void udc_enable(struct pxa_udc *udc) in udc_enable() argument
1696 if (udc->enabled) in udc_enable()
1699 clk_enable(udc->clk); in udc_enable()
1700 udc_writel(udc, UDCICR0, 0); in udc_enable()
1701 udc_writel(udc, UDCICR1, 0); in udc_enable()
1702 udc_clear_mask_UDCCR(udc, UDCCR_UDE); in udc_enable()
1704 ep0_idle(udc); in udc_enable()
1705 udc->gadget.speed = USB_SPEED_FULL; in udc_enable()
1706 memset(&udc->stats, 0, sizeof(udc->stats)); in udc_enable()
1708 pxa_eps_setup(udc); in udc_enable()
1709 udc_set_mask_UDCCR(udc, UDCCR_UDE); in udc_enable()
1710 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_ACM); in udc_enable()
1712 if (udc_readl(udc, UDCCR) & UDCCR_EMCE) in udc_enable()
1713 dev_err(udc->dev, "Configuration errors, udc disabled\n"); in udc_enable()
1721 udc_writel(udc, UDCICR1, in udc_enable()
1726 pio_irq_enable(&udc->pxa_ep[0]); in udc_enable()
1728 udc->enabled = 1; in udc_enable()
1741 * Note that the udc is not automatically enabled. Check function
1749 struct pxa_udc *udc = to_pxa(g); in pxa27x_udc_start() local
1753 udc->driver = driver; in pxa27x_udc_start()
1755 if (!IS_ERR_OR_NULL(udc->transceiver)) { in pxa27x_udc_start()
1756 retval = otg_set_peripheral(udc->transceiver->otg, in pxa27x_udc_start()
1757 &udc->gadget); in pxa27x_udc_start()
1759 dev_err(udc->dev, "can't bind to transceiver\n"); in pxa27x_udc_start()
1764 if (should_enable_udc(udc)) in pxa27x_udc_start()
1765 udc_enable(udc); in pxa27x_udc_start()
1769 udc->driver = NULL; in pxa27x_udc_start()
1774 * stop_activity - Stops udc endpoints
1775 * @udc: udc device
1777 * Disables all udc endpoints (even control endpoint), report disconnect to
1780 static void stop_activity(struct pxa_udc *udc) in stop_activity() argument
1784 udc->gadget.speed = USB_SPEED_UNKNOWN; in stop_activity()
1787 pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep); in stop_activity()
1798 struct pxa_udc *udc = to_pxa(g); in pxa27x_udc_stop() local
1800 stop_activity(udc); in pxa27x_udc_stop()
1801 udc_disable(udc); in pxa27x_udc_stop()
1803 udc->driver = NULL; in pxa27x_udc_stop()
1805 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa27x_udc_stop()
1806 return otg_set_peripheral(udc->transceiver->otg, NULL); in pxa27x_udc_stop()
1812 * @udc: udc device
1815 static void handle_ep0_ctrl_req(struct pxa_udc *udc, in handle_ep0_ctrl_req() argument
1818 struct pxa_ep *ep = &udc->pxa_ep[0]; in handle_ep0_ctrl_req()
1860 set_ep0state(udc, IN_DATA_STAGE); in handle_ep0_ctrl_req()
1862 set_ep0state(udc, OUT_DATA_STAGE); in handle_ep0_ctrl_req()
1864 /* Tell UDC to enter Data Stage */ in handle_ep0_ctrl_req()
1868 i = udc->driver->setup(&udc->gadget, &u.r); in handle_ep0_ctrl_req()
1879 set_ep0state(udc, STALL); in handle_ep0_ctrl_req()
1885 * @udc: udc device
1931 static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) in handle_ep0() argument
1934 struct pxa_ep *ep = &udc->pxa_ep[0]; in handle_ep0()
1943 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), in handle_ep0()
1950 ep0_idle(udc); in handle_ep0()
1955 set_ep0state(udc, SETUP_STAGE); in handle_ep0()
1958 switch (udc->ep0state) { in handle_ep0()
1970 handle_ep0_ctrl_req(udc, req); in handle_ep0()
1996 ep0_idle(udc); in handle_ep0()
2002 ep0_idle(udc); in handle_ep0()
2072 * @udc: udc device
2078 static void pxa27x_change_configuration(struct pxa_udc *udc, int config) in pxa27x_change_configuration() argument
2082 dev_dbg(udc->dev, "config=%d\n", config); in pxa27x_change_configuration()
2084 udc->config = config; in pxa27x_change_configuration()
2085 udc->last_interface = 0; in pxa27x_change_configuration()
2086 udc->last_alternate = 0; in pxa27x_change_configuration()
2094 set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); in pxa27x_change_configuration()
2095 udc->driver->setup(&udc->gadget, &req); in pxa27x_change_configuration()
2096 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN); in pxa27x_change_configuration()
2101 * @udc: udc device
2108 static void pxa27x_change_interface(struct pxa_udc *udc, int iface, int alt) in pxa27x_change_interface() argument
2112 dev_dbg(udc->dev, "interface=%d, alternate setting=%d\n", iface, alt); in pxa27x_change_interface()
2114 udc->last_interface = iface; in pxa27x_change_interface()
2115 udc->last_alternate = alt; in pxa27x_change_interface()
2123 set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); in pxa27x_change_interface()
2124 udc->driver->setup(&udc->gadget, &req); in pxa27x_change_interface()
2125 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN); in pxa27x_change_interface()
2131 * @udc: dev pxa_udc device structure
2135 static void irq_handle_data(int irq, struct pxa_udc *udc) in irq_handle_data() argument
2139 u32 udcisr0 = udc_readl(udc, UDCISR0) & UDCCISR0_EP_MASK; in irq_handle_data()
2140 u32 udcisr1 = udc_readl(udc, UDCISR1) & UDCCISR1_EP_MASK; in irq_handle_data()
2143 udc->pxa_ep[0].stats.irqs++; in irq_handle_data()
2144 udc_writel(udc, UDCISR0, UDCISR_INT(0, UDCISR_INT_MASK)); in irq_handle_data()
2145 handle_ep0(udc, !!(udcisr0 & UDCICR_FIFOERR), in irq_handle_data()
2154 udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); in irq_handle_data()
2156 WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); in irq_handle_data()
2157 if (i < ARRAY_SIZE(udc->pxa_ep)) { in irq_handle_data()
2158 ep = &udc->pxa_ep[i]; in irq_handle_data()
2165 udc_writel(udc, UDCISR1, UDCISR_INT(i - 16, UDCISR_INT_MASK)); in irq_handle_data()
2169 WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); in irq_handle_data()
2170 if (i < ARRAY_SIZE(udc->pxa_ep)) { in irq_handle_data()
2171 ep = &udc->pxa_ep[i]; in irq_handle_data()
2180 * irq_udc_suspend - Handle IRQ "UDC Suspend"
2181 * @udc: udc device
2183 static void irq_udc_suspend(struct pxa_udc *udc) in irq_udc_suspend() argument
2185 udc_writel(udc, UDCISR1, UDCISR1_IRSU); in irq_udc_suspend()
2186 udc->stats.irqs_suspend++; in irq_udc_suspend()
2188 if (udc->gadget.speed != USB_SPEED_UNKNOWN in irq_udc_suspend()
2189 && udc->driver && udc->driver->suspend) in irq_udc_suspend()
2190 udc->driver->suspend(&udc->gadget); in irq_udc_suspend()
2191 ep0_idle(udc); in irq_udc_suspend()
2195 * irq_udc_resume - Handle IRQ "UDC Resume"
2196 * @udc: udc device
2198 static void irq_udc_resume(struct pxa_udc *udc) in irq_udc_resume() argument
2200 udc_writel(udc, UDCISR1, UDCISR1_IRRU); in irq_udc_resume()
2201 udc->stats.irqs_resume++; in irq_udc_resume()
2203 if (udc->gadget.speed != USB_SPEED_UNKNOWN in irq_udc_resume()
2204 && udc->driver && udc->driver->resume) in irq_udc_resume()
2205 udc->driver->resume(&udc->gadget); in irq_udc_resume()
2209 * irq_udc_reconfig - Handle IRQ "UDC Change Configuration"
2210 * @udc: udc device
2212 static void irq_udc_reconfig(struct pxa_udc *udc) in irq_udc_reconfig() argument
2215 u32 udccr = udc_readl(udc, UDCCR); in irq_udc_reconfig()
2217 udc_writel(udc, UDCISR1, UDCISR1_IRCC); in irq_udc_reconfig()
2218 udc->stats.irqs_reconfig++; in irq_udc_reconfig()
2221 config_change = (config != udc->config); in irq_udc_reconfig()
2222 pxa27x_change_configuration(udc, config); in irq_udc_reconfig()
2226 pxa27x_change_interface(udc, interface, alternate); in irq_udc_reconfig()
2229 update_pxa_ep_matches(udc); in irq_udc_reconfig()
2230 udc_set_mask_UDCCR(udc, UDCCR_SMAC); in irq_udc_reconfig()
2234 * irq_udc_reset - Handle IRQ "UDC Reset"
2235 * @udc: udc device
2237 static void irq_udc_reset(struct pxa_udc *udc) in irq_udc_reset() argument
2239 u32 udccr = udc_readl(udc, UDCCR); in irq_udc_reset()
2240 struct pxa_ep *ep = &udc->pxa_ep[0]; in irq_udc_reset()
2242 dev_info(udc->dev, "USB reset\n"); in irq_udc_reset()
2243 udc_writel(udc, UDCISR1, UDCISR1_IRRS); in irq_udc_reset()
2244 udc->stats.irqs_reset++; in irq_udc_reset()
2247 dev_dbg(udc->dev, "USB reset start\n"); in irq_udc_reset()
2248 stop_activity(udc); in irq_udc_reset()
2250 udc->gadget.speed = USB_SPEED_FULL; in irq_udc_reset()
2251 memset(&udc->stats, 0, sizeof udc->stats); in irq_udc_reset()
2255 ep0_idle(udc); in irq_udc_reset()
2261 * @_dev: udc device
2263 * Handles all udc interrupts
2267 struct pxa_udc *udc = _dev; in pxa_udc_irq() local
2268 u32 udcisr0 = udc_readl(udc, UDCISR0); in pxa_udc_irq()
2269 u32 udcisr1 = udc_readl(udc, UDCISR1); in pxa_udc_irq()
2270 u32 udccr = udc_readl(udc, UDCCR); in pxa_udc_irq()
2273 dev_vdbg(udc->dev, "Interrupt, UDCISR0:0x%08x, UDCISR1:0x%08x, " in pxa_udc_irq()
2278 irq_udc_suspend(udc); in pxa_udc_irq()
2280 irq_udc_resume(udc); in pxa_udc_irq()
2282 irq_udc_reconfig(udc); in pxa_udc_irq()
2284 irq_udc_reset(udc); in pxa_udc_irq()
2287 irq_handle_data(irq, udc); in pxa_udc_irq()
2341 { .compatible = "marvell,pxa270-udc" },
2348 * pxa_udc_probe - probes the udc device
2351 * Perform basic init : allocates udc clock, creates sysfs files, requests
2356 struct pxa_udc *udc = &memory; in pxa_udc_probe() local
2368 udc->gpiod = gpio_to_desc(mach->gpio_pullup); in pxa_udc_probe()
2370 if (mach->gpio_pullup_inverted ^ gpiod_is_active_low(udc->gpiod)) in pxa_udc_probe()
2371 gpiod_toggle_active_low(udc->gpiod); in pxa_udc_probe()
2373 udc->udc_command = mach->udc_command; in pxa_udc_probe()
2375 udc->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); in pxa_udc_probe()
2378 udc->regs = devm_platform_ioremap_resource(pdev, 0); in pxa_udc_probe()
2379 if (IS_ERR(udc->regs)) in pxa_udc_probe()
2380 return PTR_ERR(udc->regs); in pxa_udc_probe()
2381 udc->irq = platform_get_irq(pdev, 0); in pxa_udc_probe()
2382 if (udc->irq < 0) in pxa_udc_probe()
2383 return udc->irq; in pxa_udc_probe()
2385 udc->dev = &pdev->dev; in pxa_udc_probe()
2387 udc->transceiver = in pxa_udc_probe()
2388 devm_usb_get_phy_by_phandle(udc->dev, "phys", 0); in pxa_udc_probe()
2389 if (IS_ERR(udc->transceiver)) in pxa_udc_probe()
2390 return PTR_ERR(udc->transceiver); in pxa_udc_probe()
2392 udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); in pxa_udc_probe()
2395 if (IS_ERR(udc->gpiod)) { in pxa_udc_probe()
2397 PTR_ERR(udc->gpiod)); in pxa_udc_probe()
2398 return PTR_ERR(udc->gpiod); in pxa_udc_probe()
2400 if (udc->gpiod) in pxa_udc_probe()
2401 gpiod_direction_output(udc->gpiod, 0); in pxa_udc_probe()
2403 udc->clk = devm_clk_get(&pdev->dev, NULL); in pxa_udc_probe()
2404 if (IS_ERR(udc->clk)) in pxa_udc_probe()
2405 return PTR_ERR(udc->clk); in pxa_udc_probe()
2407 retval = clk_prepare(udc->clk); in pxa_udc_probe()
2411 udc->vbus_sensed = 0; in pxa_udc_probe()
2413 the_controller = udc; in pxa_udc_probe()
2414 platform_set_drvdata(pdev, udc); in pxa_udc_probe()
2415 udc_init_data(udc); in pxa_udc_probe()
2418 retval = devm_request_irq(&pdev->dev, udc->irq, pxa_udc_irq, in pxa_udc_probe()
2419 IRQF_SHARED, driver_name, udc); in pxa_udc_probe()
2421 dev_err(udc->dev, "%s: can't get irq %i, err %d\n", in pxa_udc_probe()
2422 driver_name, udc->irq, retval); in pxa_udc_probe()
2426 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_probe()
2427 usb_register_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_probe()
2428 retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget); in pxa_udc_probe()
2432 pxa_init_debugfs(udc); in pxa_udc_probe()
2433 if (should_enable_udc(udc)) in pxa_udc_probe()
2434 udc_enable(udc); in pxa_udc_probe()
2438 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_probe()
2439 usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_probe()
2441 clk_unprepare(udc->clk); in pxa_udc_probe()
2446 * pxa_udc_remove - removes the udc device driver
2451 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_remove() local
2453 usb_del_gadget_udc(&udc->gadget); in pxa_udc_remove()
2454 pxa_cleanup_debugfs(udc); in pxa_udc_remove()
2456 if (!IS_ERR_OR_NULL(udc->transceiver)) { in pxa_udc_remove()
2457 usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_remove()
2458 usb_put_phy(udc->transceiver); in pxa_udc_remove()
2461 udc->transceiver = NULL; in pxa_udc_remove()
2463 clk_unprepare(udc->clk); in pxa_udc_remove()
2468 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_shutdown() local
2470 if (udc_readl(udc, UDCCR) & UDCCR_UDE) in pxa_udc_shutdown()
2471 udc_disable(udc); in pxa_udc_shutdown()
2476 * pxa_udc_suspend - Suspend udc device
2480 * Suspends udc : saves configuration registers (UDCCR*), then disables the udc
2485 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_suspend() local
2488 ep = &udc->pxa_ep[0]; in pxa_udc_suspend()
2489 udc->udccsr0 = udc_ep_readl(ep, UDCCSR); in pxa_udc_suspend()
2491 udc_disable(udc); in pxa_udc_suspend()
2492 udc->pullup_resume = udc->pullup_on; in pxa_udc_suspend()
2493 dplus_pullup(udc, 0); in pxa_udc_suspend()
2495 if (udc->driver) in pxa_udc_suspend()
2496 udc->driver->disconnect(&udc->gadget); in pxa_udc_suspend()
2502 * pxa_udc_resume - Resume udc device
2505 * Resumes udc : restores configuration registers (UDCCR*), then enables the udc
2510 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_resume() local
2513 ep = &udc->pxa_ep[0]; in pxa_udc_resume()
2514 udc_ep_writel(ep, UDCCSR, udc->udccsr0 & (UDCCSR0_FST | UDCCSR0_DME)); in pxa_udc_resume()
2516 dplus_pullup(udc, udc->pullup_resume); in pxa_udc_resume()
2517 if (should_enable_udc(udc)) in pxa_udc_resume()
2518 udc_enable(udc); in pxa_udc_resume()
2525 * Software must configure the USB OTG pad, UDC, and UHC in pxa_udc_resume()
2535 MODULE_ALIAS("platform:pxa27x-udc");
2539 .name = "pxa27x-udc",