Lines Matching full:udc

3  * Handles the Intel 27x USB Device Controller (UDC)
36 * This driver handles the USB Device Controller (UDC) in Intel's PXA 27x
45 * This UDC hardware wants to implement a bit too much USB protocol. The
64 * made of UDC's double buffering either. USB "On-The-Go" is not implemented.
91 struct pxa_udc *udc = s->private; in state_dbg_show() local
94 if (!udc->driver) in state_dbg_show()
102 udc->driver ? udc->driver->driver.name : "(none)"); in state_dbg_show()
104 tmp = udc_readl(udc, UDCCR); in state_dbg_show()
123 udc_readl(udc, UDCICR0), udc_readl(udc, UDCICR1)); in state_dbg_show()
125 udc_readl(udc, UDCISR0), udc_readl(udc, UDCISR1)); in state_dbg_show()
126 seq_printf(s, "udcfnr=%d\n", udc_readl(udc, UDCFNR)); in state_dbg_show()
128 udc->stats.irqs_reset, udc->stats.irqs_suspend, in state_dbg_show()
129 udc->stats.irqs_resume, udc->stats.irqs_reconfig); in state_dbg_show()
137 struct pxa_udc *udc = s->private; in queues_dbg_show() local
142 if (!udc->driver) in queues_dbg_show()
147 ep = &udc->pxa_ep[i]; in queues_dbg_show()
170 struct pxa_udc *udc = s->private; in eps_dbg_show() local
175 if (!udc->driver) in eps_dbg_show()
178 ep = &udc->pxa_ep[0]; in eps_dbg_show()
190 ep = &udc->pxa_ep[i]; in eps_dbg_show()
191 tmp = i? udc_ep_readl(ep, UDCCR) : udc_readl(udc, UDCCR); in eps_dbg_show()
205 static void pxa_init_debugfs(struct pxa_udc *udc) in pxa_init_debugfs() argument
209 root = debugfs_create_dir(udc->gadget.name, usb_debug_root); in pxa_init_debugfs()
210 debugfs_create_file("udcstate", 0400, root, udc, &state_dbg_fops); in pxa_init_debugfs()
211 debugfs_create_file("queues", 0400, root, udc, &queues_dbg_fops); in pxa_init_debugfs()
212 debugfs_create_file("epstate", 0400, root, udc, &eps_dbg_fops); in pxa_init_debugfs()
215 static void pxa_cleanup_debugfs(struct pxa_udc *udc) in pxa_cleanup_debugfs() argument
217 debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root); in pxa_cleanup_debugfs()
221 static inline void pxa_init_debugfs(struct pxa_udc *udc) in pxa_init_debugfs() argument
225 static inline void pxa_cleanup_debugfs(struct pxa_udc *udc) in pxa_cleanup_debugfs() argument
257 * @udc: pxa udc
280 static struct pxa_ep *find_pxa_ep(struct pxa_udc *udc, in find_pxa_ep() argument
285 int cfg = udc->config; in find_pxa_ep()
286 int iface = udc->last_interface; in find_pxa_ep()
287 int alt = udc->last_alternate; in find_pxa_ep()
289 if (udc_usb_ep == &udc->udc_usb_ep[0]) in find_pxa_ep()
290 return &udc->pxa_ep[0]; in find_pxa_ep()
293 ep = &udc->pxa_ep[i]; in find_pxa_ep()
302 * @udc: pxa udc
310 static void update_pxa_ep_matches(struct pxa_udc *udc) in update_pxa_ep_matches() argument
316 udc_usb_ep = &udc->udc_usb_ep[i]; in update_pxa_ep_matches()
318 udc_usb_ep->pxa_ep = find_pxa_ep(udc, udc_usb_ep); in update_pxa_ep_matches()
324 * @ep: udc endpoint
328 struct pxa_udc *udc = ep->dev; in pio_irq_enable() local
330 u32 udcicr0 = udc_readl(udc, UDCICR0); in pio_irq_enable()
331 u32 udcicr1 = udc_readl(udc, UDCICR1); in pio_irq_enable()
334 udc_writel(udc, UDCICR0, udcicr0 | (3 << (index * 2))); in pio_irq_enable()
336 udc_writel(udc, UDCICR1, udcicr1 | (3 << ((index - 16) * 2))); in pio_irq_enable()
341 * @ep: udc endpoint
345 struct pxa_udc *udc = ep->dev; in pio_irq_disable() local
347 u32 udcicr0 = udc_readl(udc, UDCICR0); in pio_irq_disable()
348 u32 udcicr1 = udc_readl(udc, UDCICR1); in pio_irq_disable()
351 udc_writel(udc, UDCICR0, udcicr0 & ~(3 << (index * 2))); in pio_irq_disable()
353 udc_writel(udc, UDCICR1, udcicr1 & ~(3 << ((index - 16) * 2))); in pio_irq_disable()
358 * @udc: udc device
363 static inline void udc_set_mask_UDCCR(struct pxa_udc *udc, int mask) in udc_set_mask_UDCCR() argument
365 u32 udccr = udc_readl(udc, UDCCR); in udc_set_mask_UDCCR()
366 udc_writel(udc, UDCCR, in udc_set_mask_UDCCR()
372 * @udc: udc device
377 static inline void udc_clear_mask_UDCCR(struct pxa_udc *udc, int mask) in udc_clear_mask_UDCCR() argument
379 u32 udccr = udc_readl(udc, UDCCR); in udc_clear_mask_UDCCR()
380 udc_writel(udc, UDCCR, in udc_clear_mask_UDCCR()
386 * @ep: udc endpoint
402 * ep_count_bytes_remain - get how many bytes in udc endpoint
403 * @ep: udc endpoint
416 * @ep: udc endpoint
439 * @ep: udc endpoint
472 * @udc: udc device
475 static void set_ep0state(struct pxa_udc *udc, int state) in set_ep0state() argument
477 struct pxa_ep *ep = &udc->pxa_ep[0]; in set_ep0state()
478 char *old_stname = EP0_STNAME(udc); in set_ep0state()
480 udc->ep0state = state; in set_ep0state()
482 EP0_STNAME(udc), udc_ep_readl(ep, UDCCSR), in set_ep0state()
488 * @dev: udc device
547 * @dev: udc device
1215 * done from software on the PXA UDC, and the hardware in pxa_ep_set_halt()
1310 * before udc is enabled. After udc enable, no physical endpoint configuration
1319 struct pxa_udc *udc; in pxa_ep_enable() local
1352 udc = ep->dev; in pxa_ep_enable()
1354 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in pxa_ep_enable()
1416 * @udc: udc device
1423 static void dplus_pullup(struct pxa_udc *udc, int on) in dplus_pullup() argument
1425 if (udc->gpiod) { in dplus_pullup()
1426 gpiod_set_value(udc->gpiod, on); in dplus_pullup()
1427 } else if (udc->udc_command) { in dplus_pullup()
1429 udc->udc_command(PXA2XX_UDC_CMD_CONNECT); in dplus_pullup()
1431 udc->udc_command(PXA2XX_UDC_CMD_DISCONNECT); in dplus_pullup()
1433 udc->pullup_on = on; in dplus_pullup()
1442 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_get_frame() local
1444 return (udc_readl(udc, UDCFNR) & 0x7ff); in pxa_udc_get_frame()
1448 * pxa_udc_wakeup - Force udc device out of suspend
1455 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_wakeup() local
1458 if ((udc_readl(udc, UDCCR) & UDCCR_DWRE) == 0) in pxa_udc_wakeup()
1460 udc_set_mask_UDCCR(udc, UDCCR_UDR); in pxa_udc_wakeup()
1464 static void udc_enable(struct pxa_udc *udc);
1465 static void udc_disable(struct pxa_udc *udc);
1468 * should_enable_udc - Tells if UDC should be enabled
1469 * @udc: udc device
1472 * The UDC should be enabled if :
1477 * Returns 1 if UDC should be enabled, 0 otherwise
1479 static int should_enable_udc(struct pxa_udc *udc) in should_enable_udc() argument
1483 put_on = ((udc->pullup_on) && (udc->driver)); in should_enable_udc()
1484 put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver))); in should_enable_udc()
1489 * should_disable_udc - Tells if UDC should be disabled
1490 * @udc: udc device
1493 * The UDC should be disabled if :
1498 * Returns 1 if UDC should be disabled
1500 static int should_disable_udc(struct pxa_udc *udc) in should_disable_udc() argument
1504 put_off = ((!udc->pullup_on) || (!udc->driver)); in should_disable_udc()
1505 put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver))); in should_disable_udc()
1516 * Returns 0 if OK, -EOPNOTSUPP if udc driver doesn't handle D+ pullup
1520 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_pullup() local
1522 if (!udc->gpiod && !udc->udc_command) in pxa_udc_pullup()
1525 dplus_pullup(udc, is_active); in pxa_udc_pullup()
1527 if (should_enable_udc(udc)) in pxa_udc_pullup()
1528 udc_enable(udc); in pxa_udc_pullup()
1529 if (should_disable_udc(udc)) in pxa_udc_pullup()
1530 udc_disable(udc); in pxa_udc_pullup()
1535 * pxa_udc_vbus_session - Called by external transceiver to enable/disable udc
1537 * @is_active: 0 if should disable the udc, 1 if should enable
1539 * Enables the udc, and optionnaly activates D+ pullup resistor. Or disables the
1540 * udc, and deactivates D+ pullup resistor.
1546 struct pxa_udc *udc = to_gadget_udc(_gadget); in pxa_udc_vbus_session() local
1548 udc->vbus_sensed = is_active; in pxa_udc_vbus_session()
1549 if (should_enable_udc(udc)) in pxa_udc_vbus_session()
1550 udc_enable(udc); in pxa_udc_vbus_session()
1551 if (should_disable_udc(udc)) in pxa_udc_vbus_session()
1552 udc_disable(udc); in pxa_udc_vbus_session()
1567 * Returns 0 or -EOPNOTSUPP if no transceiver is handling the udc
1571 struct pxa_udc *udc; in pxa_udc_vbus_draw() local
1573 udc = to_gadget_udc(_gadget); in pxa_udc_vbus_draw()
1574 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_vbus_draw()
1575 return usb_phy_set_power(udc->transceiver, mA); in pxa_udc_vbus_draw()
1625 * udc_disable - disable udc device controller
1626 * @udc: udc device
1629 * Disables the udc device : disables clocks, udc interrupts, control endpoint
1632 static void udc_disable(struct pxa_udc *udc) in udc_disable() argument
1634 if (!udc->enabled) in udc_disable()
1637 udc_writel(udc, UDCICR0, 0); in udc_disable()
1638 udc_writel(udc, UDCICR1, 0); in udc_disable()
1640 udc_clear_mask_UDCCR(udc, UDCCR_UDE); in udc_disable()
1642 ep0_idle(udc); in udc_disable()
1643 udc->gadget.speed = USB_SPEED_UNKNOWN; in udc_disable()
1644 clk_disable(udc->clk); in udc_disable()
1646 udc->enabled = 0; in udc_disable()
1650 * udc_init_data - Initialize udc device data structures
1651 * @dev: udc device
1687 * udc_enable - Enables the udc device
1688 * @udc: udc device
1690 * Enables the udc device : enables clocks, udc interrupts, control endpoint
1691 * interrupts, sets usb as UDC client and setups endpoints.
1693 static void udc_enable(struct pxa_udc *udc) in udc_enable() argument
1695 if (udc->enabled) in udc_enable()
1698 clk_enable(udc->clk); in udc_enable()
1699 udc_writel(udc, UDCICR0, 0); in udc_enable()
1700 udc_writel(udc, UDCICR1, 0); in udc_enable()
1701 udc_clear_mask_UDCCR(udc, UDCCR_UDE); in udc_enable()
1703 ep0_idle(udc); in udc_enable()
1704 udc->gadget.speed = USB_SPEED_FULL; in udc_enable()
1705 memset(&udc->stats, 0, sizeof(udc->stats)); in udc_enable()
1707 pxa_eps_setup(udc); in udc_enable()
1708 udc_set_mask_UDCCR(udc, UDCCR_UDE); in udc_enable()
1709 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_ACM); in udc_enable()
1711 if (udc_readl(udc, UDCCR) & UDCCR_EMCE) in udc_enable()
1712 dev_err(udc->dev, "Configuration errors, udc disabled\n"); in udc_enable()
1720 udc_writel(udc, UDCICR1, in udc_enable()
1725 pio_irq_enable(&udc->pxa_ep[0]); in udc_enable()
1727 udc->enabled = 1; in udc_enable()
1740 * Note that the udc is not automatically enabled. Check function
1748 struct pxa_udc *udc = to_pxa(g); in pxa27x_udc_start() local
1752 udc->driver = driver; in pxa27x_udc_start()
1754 if (!IS_ERR_OR_NULL(udc->transceiver)) { in pxa27x_udc_start()
1755 retval = otg_set_peripheral(udc->transceiver->otg, in pxa27x_udc_start()
1756 &udc->gadget); in pxa27x_udc_start()
1758 dev_err(udc->dev, "can't bind to transceiver\n"); in pxa27x_udc_start()
1763 if (should_enable_udc(udc)) in pxa27x_udc_start()
1764 udc_enable(udc); in pxa27x_udc_start()
1768 udc->driver = NULL; in pxa27x_udc_start()
1773 * stop_activity - Stops udc endpoints
1774 * @udc: udc device
1776 * Disables all udc endpoints (even control endpoint), report disconnect to
1779 static void stop_activity(struct pxa_udc *udc) in stop_activity() argument
1783 udc->gadget.speed = USB_SPEED_UNKNOWN; in stop_activity()
1786 pxa_ep_disable(&udc->udc_usb_ep[i].usb_ep); in stop_activity()
1797 struct pxa_udc *udc = to_pxa(g); in pxa27x_udc_stop() local
1799 stop_activity(udc); in pxa27x_udc_stop()
1800 udc_disable(udc); in pxa27x_udc_stop()
1802 udc->driver = NULL; in pxa27x_udc_stop()
1804 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa27x_udc_stop()
1805 return otg_set_peripheral(udc->transceiver->otg, NULL); in pxa27x_udc_stop()
1811 * @udc: udc device
1814 static void handle_ep0_ctrl_req(struct pxa_udc *udc, in handle_ep0_ctrl_req() argument
1817 struct pxa_ep *ep = &udc->pxa_ep[0]; in handle_ep0_ctrl_req()
1859 set_ep0state(udc, IN_DATA_STAGE); in handle_ep0_ctrl_req()
1861 set_ep0state(udc, OUT_DATA_STAGE); in handle_ep0_ctrl_req()
1863 /* Tell UDC to enter Data Stage */ in handle_ep0_ctrl_req()
1867 i = udc->driver->setup(&udc->gadget, &u.r); in handle_ep0_ctrl_req()
1878 set_ep0state(udc, STALL); in handle_ep0_ctrl_req()
1884 * @udc: udc device
1930 static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq) in handle_ep0() argument
1933 struct pxa_ep *ep = &udc->pxa_ep[0]; in handle_ep0()
1942 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), in handle_ep0()
1949 ep0_idle(udc); in handle_ep0()
1954 set_ep0state(udc, SETUP_STAGE); in handle_ep0()
1957 switch (udc->ep0state) { in handle_ep0()
1969 handle_ep0_ctrl_req(udc, req); in handle_ep0()
1995 ep0_idle(udc); in handle_ep0()
2001 ep0_idle(udc); in handle_ep0()
2071 * @udc: udc device
2077 static void pxa27x_change_configuration(struct pxa_udc *udc, int config) in pxa27x_change_configuration() argument
2081 dev_dbg(udc->dev, "config=%d\n", config); in pxa27x_change_configuration()
2083 udc->config = config; in pxa27x_change_configuration()
2084 udc->last_interface = 0; in pxa27x_change_configuration()
2085 udc->last_alternate = 0; in pxa27x_change_configuration()
2093 set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); in pxa27x_change_configuration()
2094 udc->driver->setup(&udc->gadget, &req); in pxa27x_change_configuration()
2095 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN); in pxa27x_change_configuration()
2100 * @udc: udc device
2107 static void pxa27x_change_interface(struct pxa_udc *udc, int iface, int alt) in pxa27x_change_interface() argument
2111 dev_dbg(udc->dev, "interface=%d, alternate setting=%d\n", iface, alt); in pxa27x_change_interface()
2113 udc->last_interface = iface; in pxa27x_change_interface()
2114 udc->last_alternate = alt; in pxa27x_change_interface()
2122 set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); in pxa27x_change_interface()
2123 udc->driver->setup(&udc->gadget, &req); in pxa27x_change_interface()
2124 ep_write_UDCCSR(&udc->pxa_ep[0], UDCCSR0_AREN); in pxa27x_change_interface()
2130 * @udc: dev pxa_udc device structure
2134 static void irq_handle_data(int irq, struct pxa_udc *udc) in irq_handle_data() argument
2138 u32 udcisr0 = udc_readl(udc, UDCISR0) & UDCCISR0_EP_MASK; in irq_handle_data()
2139 u32 udcisr1 = udc_readl(udc, UDCISR1) & UDCCISR1_EP_MASK; in irq_handle_data()
2142 udc->pxa_ep[0].stats.irqs++; in irq_handle_data()
2143 udc_writel(udc, UDCISR0, UDCISR_INT(0, UDCISR_INT_MASK)); in irq_handle_data()
2144 handle_ep0(udc, !!(udcisr0 & UDCICR_FIFOERR), in irq_handle_data()
2153 udc_writel(udc, UDCISR0, UDCISR_INT(i, UDCISR_INT_MASK)); in irq_handle_data()
2155 WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); in irq_handle_data()
2156 if (i < ARRAY_SIZE(udc->pxa_ep)) { in irq_handle_data()
2157 ep = &udc->pxa_ep[i]; in irq_handle_data()
2164 udc_writel(udc, UDCISR1, UDCISR_INT(i - 16, UDCISR_INT_MASK)); in irq_handle_data()
2168 WARN_ON(i >= ARRAY_SIZE(udc->pxa_ep)); in irq_handle_data()
2169 if (i < ARRAY_SIZE(udc->pxa_ep)) { in irq_handle_data()
2170 ep = &udc->pxa_ep[i]; in irq_handle_data()
2179 * irq_udc_suspend - Handle IRQ "UDC Suspend"
2180 * @udc: udc device
2182 static void irq_udc_suspend(struct pxa_udc *udc) in irq_udc_suspend() argument
2184 udc_writel(udc, UDCISR1, UDCISR1_IRSU); in irq_udc_suspend()
2185 udc->stats.irqs_suspend++; in irq_udc_suspend()
2187 if (udc->gadget.speed != USB_SPEED_UNKNOWN in irq_udc_suspend()
2188 && udc->driver && udc->driver->suspend) in irq_udc_suspend()
2189 udc->driver->suspend(&udc->gadget); in irq_udc_suspend()
2190 ep0_idle(udc); in irq_udc_suspend()
2194 * irq_udc_resume - Handle IRQ "UDC Resume"
2195 * @udc: udc device
2197 static void irq_udc_resume(struct pxa_udc *udc) in irq_udc_resume() argument
2199 udc_writel(udc, UDCISR1, UDCISR1_IRRU); in irq_udc_resume()
2200 udc->stats.irqs_resume++; in irq_udc_resume()
2202 if (udc->gadget.speed != USB_SPEED_UNKNOWN in irq_udc_resume()
2203 && udc->driver && udc->driver->resume) in irq_udc_resume()
2204 udc->driver->resume(&udc->gadget); in irq_udc_resume()
2208 * irq_udc_reconfig - Handle IRQ "UDC Change Configuration"
2209 * @udc: udc device
2211 static void irq_udc_reconfig(struct pxa_udc *udc) in irq_udc_reconfig() argument
2214 u32 udccr = udc_readl(udc, UDCCR); in irq_udc_reconfig()
2216 udc_writel(udc, UDCISR1, UDCISR1_IRCC); in irq_udc_reconfig()
2217 udc->stats.irqs_reconfig++; in irq_udc_reconfig()
2220 config_change = (config != udc->config); in irq_udc_reconfig()
2221 pxa27x_change_configuration(udc, config); in irq_udc_reconfig()
2225 pxa27x_change_interface(udc, interface, alternate); in irq_udc_reconfig()
2228 update_pxa_ep_matches(udc); in irq_udc_reconfig()
2229 udc_set_mask_UDCCR(udc, UDCCR_SMAC); in irq_udc_reconfig()
2233 * irq_udc_reset - Handle IRQ "UDC Reset"
2234 * @udc: udc device
2236 static void irq_udc_reset(struct pxa_udc *udc) in irq_udc_reset() argument
2238 u32 udccr = udc_readl(udc, UDCCR); in irq_udc_reset()
2239 struct pxa_ep *ep = &udc->pxa_ep[0]; in irq_udc_reset()
2241 dev_info(udc->dev, "USB reset\n"); in irq_udc_reset()
2242 udc_writel(udc, UDCISR1, UDCISR1_IRRS); in irq_udc_reset()
2243 udc->stats.irqs_reset++; in irq_udc_reset()
2246 dev_dbg(udc->dev, "USB reset start\n"); in irq_udc_reset()
2247 stop_activity(udc); in irq_udc_reset()
2249 udc->gadget.speed = USB_SPEED_FULL; in irq_udc_reset()
2250 memset(&udc->stats, 0, sizeof udc->stats); in irq_udc_reset()
2254 ep0_idle(udc); in irq_udc_reset()
2260 * @_dev: udc device
2262 * Handles all udc interrupts
2266 struct pxa_udc *udc = _dev; in pxa_udc_irq() local
2267 u32 udcisr0 = udc_readl(udc, UDCISR0); in pxa_udc_irq()
2268 u32 udcisr1 = udc_readl(udc, UDCISR1); in pxa_udc_irq()
2269 u32 udccr = udc_readl(udc, UDCCR); in pxa_udc_irq()
2272 dev_vdbg(udc->dev, "Interrupt, UDCISR0:0x%08x, UDCISR1:0x%08x, " in pxa_udc_irq()
2277 irq_udc_suspend(udc); in pxa_udc_irq()
2279 irq_udc_resume(udc); in pxa_udc_irq()
2281 irq_udc_reconfig(udc); in pxa_udc_irq()
2283 irq_udc_reset(udc); in pxa_udc_irq()
2286 irq_handle_data(irq, udc); in pxa_udc_irq()
2340 { .compatible = "marvell,pxa270-udc" },
2347 * pxa_udc_probe - probes the udc device
2350 * Perform basic init : allocates udc clock, creates sysfs files, requests
2355 struct pxa_udc *udc = &memory; in pxa_udc_probe() local
2369 udc->gpiod = gpio_to_desc(mach->gpio_pullup); in pxa_udc_probe()
2371 udc->udc_command = mach->udc_command; in pxa_udc_probe()
2373 udc->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS); in pxa_udc_probe()
2376 udc->regs = devm_platform_ioremap_resource(pdev, 0); in pxa_udc_probe()
2377 if (IS_ERR(udc->regs)) in pxa_udc_probe()
2378 return PTR_ERR(udc->regs); in pxa_udc_probe()
2379 udc->irq = platform_get_irq(pdev, 0); in pxa_udc_probe()
2380 if (udc->irq < 0) in pxa_udc_probe()
2381 return udc->irq; in pxa_udc_probe()
2383 udc->dev = &pdev->dev; in pxa_udc_probe()
2385 udc->transceiver = in pxa_udc_probe()
2386 devm_usb_get_phy_by_phandle(udc->dev, "phys", 0); in pxa_udc_probe()
2387 if (IS_ERR(udc->transceiver)) in pxa_udc_probe()
2388 return PTR_ERR(udc->transceiver); in pxa_udc_probe()
2390 udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); in pxa_udc_probe()
2393 if (IS_ERR(udc->gpiod)) { in pxa_udc_probe()
2395 PTR_ERR(udc->gpiod)); in pxa_udc_probe()
2396 return PTR_ERR(udc->gpiod); in pxa_udc_probe()
2398 if (udc->gpiod) in pxa_udc_probe()
2399 gpiod_direction_output(udc->gpiod, 0); in pxa_udc_probe()
2401 udc->clk = devm_clk_get(&pdev->dev, NULL); in pxa_udc_probe()
2402 if (IS_ERR(udc->clk)) in pxa_udc_probe()
2403 return PTR_ERR(udc->clk); in pxa_udc_probe()
2405 retval = clk_prepare(udc->clk); in pxa_udc_probe()
2409 udc->vbus_sensed = 0; in pxa_udc_probe()
2411 the_controller = udc; in pxa_udc_probe()
2412 platform_set_drvdata(pdev, udc); in pxa_udc_probe()
2413 udc_init_data(udc); in pxa_udc_probe()
2416 retval = devm_request_irq(&pdev->dev, udc->irq, pxa_udc_irq, in pxa_udc_probe()
2417 IRQF_SHARED, driver_name, udc); in pxa_udc_probe()
2419 dev_err(udc->dev, "%s: can't get irq %i, err %d\n", in pxa_udc_probe()
2420 driver_name, udc->irq, retval); in pxa_udc_probe()
2424 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_probe()
2425 usb_register_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_probe()
2426 retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget); in pxa_udc_probe()
2430 pxa_init_debugfs(udc); in pxa_udc_probe()
2431 if (should_enable_udc(udc)) in pxa_udc_probe()
2432 udc_enable(udc); in pxa_udc_probe()
2436 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa_udc_probe()
2437 usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_probe()
2439 clk_unprepare(udc->clk); in pxa_udc_probe()
2444 * pxa_udc_remove - removes the udc device driver
2449 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_remove() local
2451 usb_del_gadget_udc(&udc->gadget); in pxa_udc_remove()
2452 pxa_cleanup_debugfs(udc); in pxa_udc_remove()
2454 if (!IS_ERR_OR_NULL(udc->transceiver)) { in pxa_udc_remove()
2455 usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy); in pxa_udc_remove()
2456 usb_put_phy(udc->transceiver); in pxa_udc_remove()
2459 udc->transceiver = NULL; in pxa_udc_remove()
2461 clk_unprepare(udc->clk); in pxa_udc_remove()
2466 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_shutdown() local
2468 if (udc_readl(udc, UDCCR) & UDCCR_UDE) in pxa_udc_shutdown()
2469 udc_disable(udc); in pxa_udc_shutdown()
2474 * pxa_udc_suspend - Suspend udc device
2478 * Suspends udc : saves configuration registers (UDCCR*), then disables the udc
2483 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_suspend() local
2486 ep = &udc->pxa_ep[0]; in pxa_udc_suspend()
2487 udc->udccsr0 = udc_ep_readl(ep, UDCCSR); in pxa_udc_suspend()
2489 udc_disable(udc); in pxa_udc_suspend()
2490 udc->pullup_resume = udc->pullup_on; in pxa_udc_suspend()
2491 dplus_pullup(udc, 0); in pxa_udc_suspend()
2493 if (udc->driver) in pxa_udc_suspend()
2494 udc->driver->disconnect(&udc->gadget); in pxa_udc_suspend()
2500 * pxa_udc_resume - Resume udc device
2503 * Resumes udc : restores configuration registers (UDCCR*), then enables the udc
2508 struct pxa_udc *udc = platform_get_drvdata(_dev); in pxa_udc_resume() local
2511 ep = &udc->pxa_ep[0]; in pxa_udc_resume()
2512 udc_ep_writel(ep, UDCCSR, udc->udccsr0 & (UDCCSR0_FST | UDCCSR0_DME)); in pxa_udc_resume()
2514 dplus_pullup(udc, udc->pullup_resume); in pxa_udc_resume()
2515 if (should_enable_udc(udc)) in pxa_udc_resume()
2516 udc_enable(udc); in pxa_udc_resume()
2523 * Software must configure the USB OTG pad, UDC, and UHC in pxa_udc_resume()
2533 MODULE_ALIAS("platform:pxa27x-udc");
2537 .name = "pxa27x-udc",