Lines Matching refs:udc
89 #define at91_udp_read(udc, reg) \ argument
90 __raw_readl((udc)->udp_baseaddr + (reg))
91 #define at91_udp_write(udc, reg, val) \ argument
92 __raw_writel((val), (udc)->udp_baseaddr + (reg))
114 struct at91_udc *udc = ep->udc; in proc_ep_show() local
116 spin_lock_irqsave(&udc->lock, flags); in proc_ep_show()
160 spin_unlock_irqrestore(&udc->lock, flags); in proc_ep_show()
184 struct at91_udc *udc = s->private; in proc_udc_show() local
191 udc->vbus ? "present" : "off", in proc_udc_show()
192 udc->enabled in proc_udc_show()
193 ? (udc->vbus ? "active" : "enabled") in proc_udc_show()
195 udc->gadget.is_selfpowered ? "self" : "VBUS", in proc_udc_show()
196 udc->suspended ? ", suspended" : "", in proc_udc_show()
197 udc->driver ? udc->driver->driver.name : "(none)"); in proc_udc_show()
200 if (!udc->clocked) { in proc_udc_show()
205 tmp = at91_udp_read(udc, AT91_UDP_FRM_NUM); in proc_udc_show()
211 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); in proc_udc_show()
219 tmp = at91_udp_read(udc, AT91_UDP_FADDR); in proc_udc_show()
224 proc_irq_show(s, "imr ", at91_udp_read(udc, AT91_UDP_IMR)); in proc_udc_show()
225 proc_irq_show(s, "isr ", at91_udp_read(udc, AT91_UDP_ISR)); in proc_udc_show()
227 if (udc->enabled && udc->vbus) { in proc_udc_show()
228 proc_ep_show(s, &udc->ep[0]); in proc_udc_show()
229 list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) { in proc_udc_show()
237 static void create_debug_file(struct at91_udc *udc) in create_debug_file() argument
239 udc->pde = proc_create_single_data(debug_filename, 0, NULL, in create_debug_file()
240 proc_udc_show, udc); in create_debug_file()
243 static void remove_debug_file(struct at91_udc *udc) in remove_debug_file() argument
245 if (udc->pde) in remove_debug_file()
251 static inline void create_debug_file(struct at91_udc *udc) {} in create_debug_file() argument
252 static inline void remove_debug_file(struct at91_udc *udc) {} in remove_debug_file() argument
262 struct at91_udc *udc = ep->udc; in done() local
273 spin_unlock(&udc->lock); in done()
275 spin_lock(&udc->lock); in done()
280 at91_udp_write(udc, AT91_UDP_IDR, ep->int_mask); in done()
475 struct at91_udc *udc; in at91_ep_enable() local
489 udc = ep->udc; in at91_ep_enable()
490 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in at91_ep_enable()
524 spin_lock_irqsave(&udc->lock, flags); in at91_ep_enable()
542 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); in at91_ep_enable()
543 at91_udp_write(udc, AT91_UDP_RST_EP, 0); in at91_ep_enable()
545 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_enable()
552 struct at91_udc *udc = ep->udc; in at91_ep_disable() local
555 if (ep == &ep->udc->ep[0]) in at91_ep_disable()
558 spin_lock_irqsave(&udc->lock, flags); in at91_ep_disable()
567 if (ep->udc->clocked) { in at91_ep_disable()
568 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); in at91_ep_disable()
569 at91_udp_write(udc, AT91_UDP_RST_EP, 0); in at91_ep_disable()
573 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_disable()
609 struct at91_udc *udc; in at91_ep_queue() local
627 udc = ep->udc; in at91_ep_queue()
629 if (!udc || !udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in at91_ep_queue()
637 spin_lock_irqsave(&udc->lock, flags); in at91_ep_queue()
655 if (!udc->req_pending) { in at91_ep_queue()
664 if (udc->wait_for_config_ack) { in at91_ep_queue()
665 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); in at91_ep_queue()
668 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); in at91_ep_queue()
678 udc->req_pending = 0; in at91_ep_queue()
697 at91_udp_write(udc, AT91_UDP_IER, ep->int_mask); in at91_ep_queue()
700 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_queue()
709 struct at91_udc *udc; in at91_ep_dequeue() local
715 udc = ep->udc; in at91_ep_dequeue()
717 spin_lock_irqsave(&udc->lock, flags); in at91_ep_dequeue()
727 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_dequeue()
732 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_dequeue()
739 struct at91_udc *udc = ep->udc; in at91_ep_set_halt() local
745 if (!_ep || ep->is_iso || !ep->udc->clocked) in at91_ep_set_halt()
749 spin_lock_irqsave(&udc->lock, flags); in at91_ep_set_halt()
767 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); in at91_ep_set_halt()
768 at91_udp_write(udc, AT91_UDP_RST_EP, 0); in at91_ep_set_halt()
774 spin_unlock_irqrestore(&udc->lock, flags); in at91_ep_set_halt()
793 struct at91_udc *udc = to_udc(gadget); in at91_get_frame() local
797 return at91_udp_read(udc, AT91_UDP_FRM_NUM) & AT91_UDP_NUM; in at91_get_frame()
802 struct at91_udc *udc = to_udc(gadget); in at91_wakeup() local
807 spin_lock_irqsave(&udc->lock, flags); in at91_wakeup()
809 if (!udc->clocked || !udc->suspended) in at91_wakeup()
814 glbstate = at91_udp_read(udc, AT91_UDP_GLB_STAT); in at91_wakeup()
818 at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate); in at91_wakeup()
821 spin_unlock_irqrestore(&udc->lock, flags); in at91_wakeup()
826 static void udc_reinit(struct at91_udc *udc) in udc_reinit() argument
830 INIT_LIST_HEAD(&udc->gadget.ep_list); in udc_reinit()
831 INIT_LIST_HEAD(&udc->gadget.ep0->ep_list); in udc_reinit()
832 udc->gadget.quirk_stall_not_supp = 1; in udc_reinit()
835 struct at91_ep *ep = &udc->ep[i]; in udc_reinit()
838 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in udc_reinit()
843 ep->creg = (void __iomem *) udc->udp_baseaddr + AT91_UDP_CSR(i); in udc_reinit()
849 static void reset_gadget(struct at91_udc *udc) in reset_gadget() argument
851 struct usb_gadget_driver *driver = udc->driver; in reset_gadget()
854 if (udc->gadget.speed == USB_SPEED_UNKNOWN) in reset_gadget()
856 udc->gadget.speed = USB_SPEED_UNKNOWN; in reset_gadget()
857 udc->suspended = 0; in reset_gadget()
860 struct at91_ep *ep = &udc->ep[i]; in reset_gadget()
866 spin_unlock(&udc->lock); in reset_gadget()
867 usb_gadget_udc_reset(&udc->gadget, driver); in reset_gadget()
868 spin_lock(&udc->lock); in reset_gadget()
871 udc_reinit(udc); in reset_gadget()
874 static void stop_activity(struct at91_udc *udc) in stop_activity() argument
876 struct usb_gadget_driver *driver = udc->driver; in stop_activity()
879 if (udc->gadget.speed == USB_SPEED_UNKNOWN) in stop_activity()
881 udc->gadget.speed = USB_SPEED_UNKNOWN; in stop_activity()
882 udc->suspended = 0; in stop_activity()
885 struct at91_ep *ep = &udc->ep[i]; in stop_activity()
890 spin_unlock(&udc->lock); in stop_activity()
891 driver->disconnect(&udc->gadget); in stop_activity()
892 spin_lock(&udc->lock); in stop_activity()
895 udc_reinit(udc); in stop_activity()
898 static void clk_on(struct at91_udc *udc) in clk_on() argument
900 if (udc->clocked) in clk_on()
902 udc->clocked = 1; in clk_on()
904 clk_enable(udc->iclk); in clk_on()
905 clk_enable(udc->fclk); in clk_on()
908 static void clk_off(struct at91_udc *udc) in clk_off() argument
910 if (!udc->clocked) in clk_off()
912 udc->clocked = 0; in clk_off()
913 udc->gadget.speed = USB_SPEED_UNKNOWN; in clk_off()
914 clk_disable(udc->fclk); in clk_off()
915 clk_disable(udc->iclk); in clk_off()
922 static void pullup(struct at91_udc *udc, int is_on) in pullup() argument
924 if (!udc->enabled || !udc->vbus) in pullup()
929 clk_on(udc); in pullup()
930 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); in pullup()
931 at91_udp_write(udc, AT91_UDP_TXVC, 0); in pullup()
933 stop_activity(udc); in pullup()
934 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); in pullup()
935 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); in pullup()
936 clk_off(udc); in pullup()
939 if (udc->caps && udc->caps->pullup) in pullup()
940 udc->caps->pullup(udc, is_on); in pullup()
946 struct at91_udc *udc = to_udc(gadget); in at91_vbus_session() local
950 spin_lock_irqsave(&udc->lock, flags); in at91_vbus_session()
951 udc->vbus = (is_active != 0); in at91_vbus_session()
952 if (udc->driver) in at91_vbus_session()
953 pullup(udc, is_active); in at91_vbus_session()
955 pullup(udc, 0); in at91_vbus_session()
956 spin_unlock_irqrestore(&udc->lock, flags); in at91_vbus_session()
962 struct at91_udc *udc = to_udc(gadget); in at91_pullup() local
965 spin_lock_irqsave(&udc->lock, flags); in at91_pullup()
966 udc->enabled = is_on = !!is_on; in at91_pullup()
967 pullup(udc, is_on); in at91_pullup()
968 spin_unlock_irqrestore(&udc->lock, flags); in at91_pullup()
974 struct at91_udc *udc = to_udc(gadget); in at91_set_selfpowered() local
977 spin_lock_irqsave(&udc->lock, flags); in at91_set_selfpowered()
979 spin_unlock_irqrestore(&udc->lock, flags); in at91_set_selfpowered()
1047 static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) in handle_setup() argument
1076 udc->wait_for_addr_ack = 0; in handle_setup()
1077 udc->wait_for_config_ack = 0; in handle_setup()
1094 udc->req_pending = 1; in handle_setup()
1103 udc->addr = w_value; in handle_setup()
1104 udc->wait_for_addr_ack = 1; in handle_setup()
1105 udc->req_pending = 0; in handle_setup()
1111 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_CONFG; in handle_setup()
1113 udc->wait_for_config_ack = (tmp == 0); in handle_setup()
1115 udc->wait_for_config_ack = (tmp != 0); in handle_setup()
1116 if (udc->wait_for_config_ack) in handle_setup()
1127 tmp = (udc->gadget.is_selfpowered << USB_DEVICE_SELF_POWERED); in handle_setup()
1128 if (at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_ESR) in handle_setup()
1139 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); in handle_setup()
1141 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); in handle_setup()
1147 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); in handle_setup()
1149 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); in handle_setup()
1176 ep = &udc->ep[tmp]; in handle_setup()
1199 ep = &udc->ep[tmp]; in handle_setup()
1218 ep = &udc->ep[tmp]; in handle_setup()
1231 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); in handle_setup()
1232 at91_udp_write(udc, AT91_UDP_RST_EP, 0); in handle_setup()
1247 if (udc->driver) { in handle_setup()
1248 spin_unlock(&udc->lock); in handle_setup()
1249 status = udc->driver->setup(&udc->gadget, &pkt.r); in handle_setup()
1250 spin_lock(&udc->lock); in handle_setup()
1260 udc->req_pending = 0; in handle_setup()
1270 udc->req_pending = 0; in handle_setup()
1273 static void handle_ep0(struct at91_udc *udc) in handle_ep0() argument
1275 struct at91_ep *ep0 = &udc->ep[0]; in handle_ep0()
1282 udc->req_pending = 0; in handle_ep0()
1291 udc->req_pending = 0; in handle_ep0()
1292 handle_setup(udc, ep0, csr); in handle_ep0()
1309 udc->req_pending = 0; in handle_ep0()
1320 udc->req_pending = 0; in handle_ep0()
1327 if (udc->wait_for_addr_ack) { in handle_ep0()
1330 at91_udp_write(udc, AT91_UDP_FADDR, in handle_ep0()
1331 AT91_UDP_FEN | udc->addr); in handle_ep0()
1332 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); in handle_ep0()
1334 if (udc->addr) in handle_ep0()
1336 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); in handle_ep0()
1338 udc->wait_for_addr_ack = 0; in handle_ep0()
1339 VDBG("address %d\n", udc->addr); in handle_ep0()
1359 udc->req_pending = 0; in handle_ep0()
1361 } else if (udc->req_pending) { in handle_ep0()
1381 udc->req_pending = 0; in handle_ep0()
1398 struct at91_udc *udc = _udc; in at91_udc_irq() local
1403 spin_lock_irqsave(&udc->lock, flags); in at91_udc_irq()
1405 if (!udc->clocked) { in at91_udc_irq()
1406 clk_on(udc); in at91_udc_irq()
1413 status = at91_udp_read(udc, AT91_UDP_ISR) in at91_udc_irq()
1414 & at91_udp_read(udc, AT91_UDP_IMR); in at91_udc_irq()
1420 at91_udp_write(udc, AT91_UDP_IDR, ~MINIMUS_INTERRUPTUS); in at91_udc_irq()
1421 at91_udp_write(udc, AT91_UDP_IER, MINIMUS_INTERRUPTUS); in at91_udc_irq()
1423 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES); in at91_udc_irq()
1424 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES); in at91_udc_irq()
1426 udc->addr = 0; in at91_udc_irq()
1427 reset_gadget(udc); in at91_udc_irq()
1430 at91_udp_write(udc, AT91_UDP_CSR(0), in at91_udc_irq()
1432 udc->gadget.speed = USB_SPEED_FULL; in at91_udc_irq()
1433 udc->suspended = 0; in at91_udc_irq()
1434 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_EP(0)); in at91_udc_irq()
1445 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXSUSP); in at91_udc_irq()
1446 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXRSM); in at91_udc_irq()
1447 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXSUSP); in at91_udc_irq()
1449 if (udc->suspended) in at91_udc_irq()
1451 udc->suspended = 1; in at91_udc_irq()
1459 if (udc->driver && udc->driver->suspend) { in at91_udc_irq()
1460 spin_unlock(&udc->lock); in at91_udc_irq()
1461 udc->driver->suspend(&udc->gadget); in at91_udc_irq()
1462 spin_lock(&udc->lock); in at91_udc_irq()
1467 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); in at91_udc_irq()
1468 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXSUSP); in at91_udc_irq()
1469 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); in at91_udc_irq()
1471 if (!udc->suspended) in at91_udc_irq()
1473 udc->suspended = 0; in at91_udc_irq()
1480 if (udc->driver && udc->driver->resume) { in at91_udc_irq()
1481 spin_unlock(&udc->lock); in at91_udc_irq()
1482 udc->driver->resume(&udc->gadget); in at91_udc_irq()
1483 spin_lock(&udc->lock); in at91_udc_irq()
1490 struct at91_ep *ep = &udc->ep[1]; in at91_udc_irq()
1493 handle_ep0(udc); in at91_udc_irq()
1504 clk_off(udc); in at91_udc_irq()
1506 spin_unlock_irqrestore(&udc->lock, flags); in at91_udc_irq()
1513 static void at91_vbus_update(struct at91_udc *udc, unsigned value) in at91_vbus_update() argument
1515 if (value != udc->vbus) in at91_vbus_update()
1516 at91_vbus_session(&udc->gadget, value); in at91_vbus_update()
1521 struct at91_udc *udc = _udc; in at91_vbus_irq() local
1525 at91_vbus_update(udc, gpiod_get_value(udc->board.vbus_pin)); in at91_vbus_irq()
1532 struct at91_udc *udc = container_of(work, struct at91_udc, in at91_vbus_timer_work() local
1535 at91_vbus_update(udc, gpiod_get_value_cansleep(udc->board.vbus_pin)); in at91_vbus_timer_work()
1537 if (!timer_pending(&udc->vbus_timer)) in at91_vbus_timer_work()
1538 mod_timer(&udc->vbus_timer, jiffies + VBUS_POLL_TIMEOUT); in at91_vbus_timer_work()
1543 struct at91_udc *udc = from_timer(udc, t, vbus_timer); in at91_vbus_timer() local
1550 schedule_work(&udc->vbus_timer_work); in at91_vbus_timer()
1556 struct at91_udc *udc; in at91_start() local
1558 udc = container_of(gadget, struct at91_udc, gadget); in at91_start()
1559 udc->driver = driver; in at91_start()
1560 udc->gadget.dev.of_node = udc->pdev->dev.of_node; in at91_start()
1561 udc->enabled = 1; in at91_start()
1562 udc->gadget.is_selfpowered = 1; in at91_start()
1569 struct at91_udc *udc; in at91_stop() local
1572 udc = container_of(gadget, struct at91_udc, gadget); in at91_stop()
1573 spin_lock_irqsave(&udc->lock, flags); in at91_stop()
1574 udc->enabled = 0; in at91_stop()
1575 at91_udp_write(udc, AT91_UDP_IDR, ~0); in at91_stop()
1576 spin_unlock_irqrestore(&udc->lock, flags); in at91_stop()
1578 udc->driver = NULL; in at91_stop()
1587 struct at91_udc *udc = platform_get_drvdata(dev); in at91udc_shutdown() local
1591 spin_lock_irqsave(&udc->lock, flags); in at91udc_shutdown()
1593 spin_unlock_irqrestore(&udc->lock, flags); in at91udc_shutdown()
1596 static int at91rm9200_udc_init(struct at91_udc *udc) in at91rm9200_udc_init() argument
1602 ep = &udc->ep[i]; in at91rm9200_udc_init()
1618 if (!udc->board.pullup_pin) { in at91rm9200_udc_init()
1623 gpiod_direction_output(udc->board.pullup_pin, in at91rm9200_udc_init()
1624 gpiod_is_active_low(udc->board.pullup_pin)); in at91rm9200_udc_init()
1629 static void at91rm9200_udc_pullup(struct at91_udc *udc, int is_on) in at91rm9200_udc_pullup() argument
1632 gpiod_set_value(udc->board.pullup_pin, 1); in at91rm9200_udc_pullup()
1634 gpiod_set_value(udc->board.pullup_pin, 0); in at91rm9200_udc_pullup()
1642 static int at91sam9260_udc_init(struct at91_udc *udc) in at91sam9260_udc_init() argument
1648 ep = &udc->ep[i]; in at91sam9260_udc_init()
1663 static void at91sam9260_udc_pullup(struct at91_udc *udc, int is_on) in at91sam9260_udc_pullup() argument
1665 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); in at91sam9260_udc_pullup()
1672 at91_udp_write(udc, AT91_UDP_TXVC, txvc); in at91sam9260_udc_pullup()
1680 static int at91sam9261_udc_init(struct at91_udc *udc) in at91sam9261_udc_init() argument
1686 ep = &udc->ep[i]; in at91sam9261_udc_init()
1701 udc->matrix = syscon_regmap_lookup_by_phandle(udc->pdev->dev.of_node, in at91sam9261_udc_init()
1703 return PTR_ERR_OR_ZERO(udc->matrix); in at91sam9261_udc_init()
1706 static void at91sam9261_udc_pullup(struct at91_udc *udc, int is_on) in at91sam9261_udc_pullup() argument
1713 regmap_update_bits(udc->matrix, AT91SAM9261_MATRIX_USBPUCR, in at91sam9261_udc_pullup()
1722 static int at91sam9263_udc_init(struct at91_udc *udc) in at91sam9263_udc_init() argument
1728 ep = &udc->ep[i]; in at91sam9263_udc_init()
1773 static void at91udc_of_init(struct at91_udc *udc, struct device_node *np) in at91udc_of_init() argument
1775 struct at91_udc_data *board = &udc->board; in at91udc_of_init()
1796 udc->caps = match->data; in at91udc_of_init()
1802 struct at91_udc *udc; in at91udc_probe() local
1807 udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL); in at91udc_probe()
1808 if (!udc) in at91udc_probe()
1812 udc->gadget.dev.parent = dev; in at91udc_probe()
1813 at91udc_of_init(udc, pdev->dev.of_node); in at91udc_probe()
1814 udc->pdev = pdev; in at91udc_probe()
1815 udc->enabled = 0; in at91udc_probe()
1816 spin_lock_init(&udc->lock); in at91udc_probe()
1818 udc->gadget.ops = &at91_udc_ops; in at91udc_probe()
1819 udc->gadget.ep0 = &udc->ep[0].ep; in at91udc_probe()
1820 udc->gadget.name = driver_name; in at91udc_probe()
1821 udc->gadget.dev.init_name = "gadget"; in at91udc_probe()
1824 ep = &udc->ep[i]; in at91udc_probe()
1828 ep->udc = udc; in at91udc_probe()
1834 udc->udp_baseaddr = devm_platform_ioremap_resource(pdev, 0); in at91udc_probe()
1835 if (IS_ERR(udc->udp_baseaddr)) in at91udc_probe()
1836 return PTR_ERR(udc->udp_baseaddr); in at91udc_probe()
1838 if (udc->caps && udc->caps->init) { in at91udc_probe()
1839 retval = udc->caps->init(udc); in at91udc_probe()
1844 udc_reinit(udc); in at91udc_probe()
1847 udc->iclk = devm_clk_get(dev, "pclk"); in at91udc_probe()
1848 if (IS_ERR(udc->iclk)) in at91udc_probe()
1849 return PTR_ERR(udc->iclk); in at91udc_probe()
1851 udc->fclk = devm_clk_get(dev, "hclk"); in at91udc_probe()
1852 if (IS_ERR(udc->fclk)) in at91udc_probe()
1853 return PTR_ERR(udc->fclk); in at91udc_probe()
1856 clk_set_rate(udc->fclk, 48000000); in at91udc_probe()
1857 retval = clk_prepare(udc->fclk); in at91udc_probe()
1861 retval = clk_prepare_enable(udc->iclk); in at91udc_probe()
1865 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); in at91udc_probe()
1866 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff); in at91udc_probe()
1868 at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff); in at91udc_probe()
1869 clk_disable(udc->iclk); in at91udc_probe()
1872 udc->udp_irq = retval = platform_get_irq(pdev, 0); in at91udc_probe()
1875 retval = devm_request_irq(dev, udc->udp_irq, at91_udc_irq, 0, in at91udc_probe()
1876 driver_name, udc); in at91udc_probe()
1878 DBG("request irq %d failed\n", udc->udp_irq); in at91udc_probe()
1882 if (udc->board.vbus_pin) { in at91udc_probe()
1883 gpiod_direction_input(udc->board.vbus_pin); in at91udc_probe()
1889 udc->vbus = gpiod_get_value_cansleep(udc->board.vbus_pin); in at91udc_probe()
1891 if (udc->board.vbus_polled) { in at91udc_probe()
1892 INIT_WORK(&udc->vbus_timer_work, at91_vbus_timer_work); in at91udc_probe()
1893 timer_setup(&udc->vbus_timer, at91_vbus_timer, 0); in at91udc_probe()
1894 mod_timer(&udc->vbus_timer, in at91udc_probe()
1898 gpiod_to_irq(udc->board.vbus_pin), in at91udc_probe()
1899 at91_vbus_irq, 0, driver_name, udc); in at91udc_probe()
1902 desc_to_gpio(udc->board.vbus_pin)); in at91udc_probe()
1908 udc->vbus = 1; in at91udc_probe()
1910 retval = usb_add_gadget_udc(dev, &udc->gadget); in at91udc_probe()
1913 dev_set_drvdata(dev, udc); in at91udc_probe()
1915 create_debug_file(udc); in at91udc_probe()
1921 clk_unprepare(udc->iclk); in at91udc_probe()
1923 clk_unprepare(udc->fclk); in at91udc_probe()
1932 struct at91_udc *udc = platform_get_drvdata(pdev); in at91udc_remove() local
1937 usb_del_gadget_udc(&udc->gadget); in at91udc_remove()
1938 if (udc->driver) in at91udc_remove()
1941 spin_lock_irqsave(&udc->lock, flags); in at91udc_remove()
1942 pullup(udc, 0); in at91udc_remove()
1943 spin_unlock_irqrestore(&udc->lock, flags); in at91udc_remove()
1946 remove_debug_file(udc); in at91udc_remove()
1947 clk_unprepare(udc->fclk); in at91udc_remove()
1948 clk_unprepare(udc->iclk); in at91udc_remove()
1956 struct at91_udc *udc = platform_get_drvdata(pdev); in at91udc_suspend() local
1957 int wake = udc->driver && device_may_wakeup(&pdev->dev); in at91udc_suspend()
1965 if ((!udc->suspended && udc->addr) in at91udc_suspend()
1968 spin_lock_irqsave(&udc->lock, flags); in at91udc_suspend()
1969 pullup(udc, 0); in at91udc_suspend()
1971 spin_unlock_irqrestore(&udc->lock, flags); in at91udc_suspend()
1973 enable_irq_wake(udc->udp_irq); in at91udc_suspend()
1975 udc->active_suspend = wake; in at91udc_suspend()
1976 if (udc->board.vbus_pin && !udc->board.vbus_polled && wake) in at91udc_suspend()
1977 enable_irq_wake(gpiod_to_irq(udc->board.vbus_pin)); in at91udc_suspend()
1983 struct at91_udc *udc = platform_get_drvdata(pdev); in at91udc_resume() local
1986 if (udc->board.vbus_pin && !udc->board.vbus_polled && in at91udc_resume()
1987 udc->active_suspend) in at91udc_resume()
1988 disable_irq_wake(gpiod_to_irq(udc->board.vbus_pin)); in at91udc_resume()
1991 if (udc->active_suspend) in at91udc_resume()
1992 disable_irq_wake(udc->udp_irq); in at91udc_resume()
1994 spin_lock_irqsave(&udc->lock, flags); in at91udc_resume()
1995 pullup(udc, 1); in at91udc_resume()
1996 spin_unlock_irqrestore(&udc->lock, flags); in at91udc_resume()