Lines Matching full:udc
124 * @udc: xilinx usb peripheral driver instance pointer
142 struct xusb_udc *udc; member
201 static const char driver_name[] = "xilinx-udc";
257 * @udc: pointer to the usb device controller structure.
259 static void xudc_wrstatus(struct xusb_udc *udc) in xudc_wrstatus() argument
261 struct xusb_ep *ep0 = &udc->ep[XUSB_EP_NUMBER_ZERO]; in xudc_wrstatus()
264 epcfgreg = udc->read_fn(udc->addr + ep0->offset)| in xudc_wrstatus()
266 udc->write_fn(udc->addr, ep0->offset, epcfgreg); in xudc_wrstatus()
267 udc->write_fn(udc->addr, ep0->offset + XUSB_EP_BUF0COUNT_OFFSET, 0); in xudc_wrstatus()
268 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, 1); in xudc_wrstatus()
274 * @udc: pointer to the usb peripheral controller structure.
279 static void xudc_epconfig(struct xusb_ep *ep, struct xusb_udc *udc) in xudc_epconfig() argument
289 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_epconfig()
292 udc->write_fn(udc->addr, ep->offset + XUSB_EP_BUF0COUNT_OFFSET, in xudc_epconfig()
294 udc->write_fn(udc->addr, ep->offset + XUSB_EP_BUF1COUNT_OFFSET, in xudc_epconfig()
297 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in xudc_epconfig()
300 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in xudc_epconfig()
319 struct xusb_udc *udc = ep->udc; in xudc_start_dma() local
329 udc->write_fn(udc->addr, XUSB_DMA_DSAR_ADDR_OFFSET, src); in xudc_start_dma()
330 udc->write_fn(udc->addr, XUSB_DMA_DDAR_ADDR_OFFSET, dst); in xudc_start_dma()
331 udc->write_fn(udc->addr, XUSB_DMA_LENGTH_OFFSET, length); in xudc_start_dma()
339 reg = udc->read_fn(udc->addr + XUSB_DMA_STATUS_OFFSET); in xudc_start_dma()
349 dev_err(udc->dev, "DMA timeout\n"); in xudc_start_dma()
355 if ((udc->read_fn(udc->addr + XUSB_DMA_STATUS_OFFSET) & in xudc_start_dma()
357 dev_err(udc->dev, "DMA Error\n"); in xudc_start_dma()
382 struct xusb_udc *udc = ep->udc; in xudc_dma_send() local
386 dma_sync_single_for_device(udc->dev, src, in xudc_dma_send()
390 eprambase = (u32 __force *)(udc->addr + ep->rambase); in xudc_dma_send()
392 udc->write_fn(udc->addr, ep->offset + in xudc_dma_send()
394 udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET, in xudc_dma_send()
400 eprambase = (u32 __force *)(udc->addr + ep->rambase + in xudc_dma_send()
403 udc->write_fn(udc->addr, ep->offset + in xudc_dma_send()
405 udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET, in xudc_dma_send()
436 struct xusb_udc *udc = ep->udc; in xudc_dma_receive() local
441 eprambase = (u32 __force *)(udc->addr + ep->rambase); in xudc_dma_receive()
443 udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET, in xudc_dma_receive()
450 eprambase = (u32 __force *)(udc->addr + in xudc_dma_receive()
453 udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET, in xudc_dma_receive()
485 struct xusb_udc *udc = ep->udc; in xudc_eptxrx() local
488 if (udc->dma_enabled) { in xudc_eptxrx()
498 eprambase = (u32 __force *)(udc->addr + ep->rambase); in xudc_eptxrx()
502 udc->write_fn(udc->addr, ep->offset + in xudc_eptxrx()
511 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in xudc_eptxrx()
517 eprambase = (u32 __force *)(udc->addr + ep->rambase + in xudc_eptxrx()
522 udc->write_fn(udc->addr, ep->offset + in xudc_eptxrx()
531 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in xudc_eptxrx()
553 struct xusb_udc *udc = ep->udc; in xudc_done() local
563 dev_dbg(udc->dev, "%s done %p, status %d\n", in xudc_done()
566 if (udc->dma_enabled && ep->epnumber && req->usb_req.length) in xudc_done()
567 usb_gadget_unmap_request(&udc->gadget, &req->usb_req, in xudc_done()
571 spin_unlock(&udc->lock); in xudc_done()
573 spin_lock(&udc->lock); in xudc_done()
594 struct xusb_udc *udc = ep->udc; in xudc_read_fifo() local
597 dev_dbg(udc->dev, "Packet NOT ready!\n"); in xudc_read_fifo()
606 count = udc->read_fn(udc->addr + ep->offset + bufoffset); in xudc_read_fifo()
623 dev_dbg(udc->dev, "%s overflow %d\n", in xudc_read_fifo()
634 dev_dbg(udc->dev, "read %s, %d bytes%s req %p %d/%d\n", in xudc_read_fifo()
640 if (udc->dma_enabled && req->usb_req.length) in xudc_read_fifo()
641 dma_sync_single_for_cpu(udc->dev, in xudc_read_fifo()
654 dev_dbg(udc->dev, "receive busy\n"); in xudc_read_fifo()
682 struct xusb_udc *udc = ep->udc; in xudc_write_fifo() local
705 dev_dbg(udc->dev, "%s: wrote %s %d bytes%s%s %d left %p\n", in xudc_write_fifo()
716 dev_dbg(udc->dev, "Send busy\n"); in xudc_write_fifo()
754 struct xusb_udc *udc; in xudc_ep_set_halt() local
762 udc = ep->udc; in xudc_ep_set_halt()
765 dev_dbg(udc->dev, "requests pending can't halt\n"); in xudc_ep_set_halt()
770 dev_dbg(udc->dev, "HW buffers busy can't halt\n"); in xudc_ep_set_halt()
774 spin_lock_irqsave(&udc->lock, flags); in xudc_ep_set_halt()
778 epcfgreg = udc->read_fn(udc->addr + ep->offset); in xudc_ep_set_halt()
780 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_ep_set_halt()
783 epcfgreg = udc->read_fn(udc->addr + ep->offset); in xudc_ep_set_halt()
785 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_ep_set_halt()
788 epcfgreg = udc->read_fn(ep->udc->addr + ep->offset); in xudc_ep_set_halt()
790 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_ep_set_halt()
794 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_set_halt()
808 struct xusb_udc *udc = ep->udc; in __xudc_ep_enable() local
824 dev_dbg(udc->dev, "only one control endpoint\n"); in __xudc_ep_enable()
832 dev_dbg(udc->dev, "bogus maxpacket %d\n", maxpacket); in __xudc_ep_enable()
841 dev_dbg(udc->dev, "bogus maxpacket %d\n", maxpacket); in __xudc_ep_enable()
855 xudc_epconfig(ep, udc); in __xudc_ep_enable()
857 dev_dbg(udc->dev, "Enable Endpoint %d max pkt is %d\n", in __xudc_ep_enable()
861 epcfg = udc->read_fn(udc->addr + ep->offset); in __xudc_ep_enable()
863 udc->write_fn(udc->addr, ep->offset, epcfg); in __xudc_ep_enable()
868 ier = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in __xudc_ep_enable()
870 udc->write_fn(udc->addr, XUSB_IER_OFFSET, ier); in __xudc_ep_enable()
874 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in __xudc_ep_enable()
877 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, in __xudc_ep_enable()
897 struct xusb_udc *udc; in xudc_ep_enable() local
907 udc = ep->udc; in xudc_ep_enable()
909 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in xudc_ep_enable()
910 dev_dbg(udc->dev, "bogus device state\n"); in xudc_ep_enable()
914 spin_lock_irqsave(&udc->lock, flags); in xudc_ep_enable()
916 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_enable()
932 struct xusb_udc *udc; in xudc_ep_disable() local
940 udc = ep->udc; in xudc_ep_disable()
942 spin_lock_irqsave(&udc->lock, flags); in xudc_ep_disable()
950 dev_dbg(udc->dev, "USB Ep %d disable\n", ep->epnumber); in xudc_ep_disable()
952 epcfg = udc->read_fn(udc->addr + ep->offset); in xudc_ep_disable()
954 udc->write_fn(udc->addr, ep->offset, epcfg); in xudc_ep_disable()
956 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_disable()
1003 struct xusb_udc *udc = ep0->udc; in __xudc_ep0_queue() local
1007 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in __xudc_ep0_queue()
1008 dev_dbg(udc->dev, "%s, bogus device state\n", __func__); in __xudc_ep0_queue()
1012 dev_dbg(udc->dev, "%s:ep0 busy\n", __func__); in __xudc_ep0_queue()
1021 if (udc->setup.bRequestType & USB_DIR_IN) { in __xudc_ep0_queue()
1025 udc->addr); in __xudc_ep0_queue()
1029 udc->write_fn(udc->addr, XUSB_EP_BUF0COUNT_OFFSET, length); in __xudc_ep0_queue()
1030 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, 1); in __xudc_ep0_queue()
1032 if (udc->setup.wLength) { in __xudc_ep0_queue()
1034 udc->write_fn(udc->addr, XUSB_EP_BUF0COUNT_OFFSET, 0); in __xudc_ep0_queue()
1035 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, 1); in __xudc_ep0_queue()
1037 xudc_wrstatus(udc); in __xudc_ep0_queue()
1057 struct xusb_udc *udc = ep0->udc; in xudc_ep0_queue() local
1061 spin_lock_irqsave(&udc->lock, flags); in xudc_ep0_queue()
1063 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep0_queue()
1081 struct xusb_udc *udc = ep->udc; in xudc_ep_queue() local
1086 dev_dbg(udc->dev, "%s: queuing request to disabled %s\n", in xudc_ep_queue()
1091 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { in xudc_ep_queue()
1092 dev_dbg(udc->dev, "%s, bogus device state\n", __func__); in xudc_ep_queue()
1096 spin_lock_irqsave(&udc->lock, flags); in xudc_ep_queue()
1101 if (udc->dma_enabled) { in xudc_ep_queue()
1102 ret = usb_gadget_map_request(&udc->gadget, &req->usb_req, in xudc_ep_queue()
1105 dev_dbg(udc->dev, "gadget_map failed ep%d\n", in xudc_ep_queue()
1107 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_queue()
1114 dev_dbg(udc->dev, "xudc_write_fifo from ep_queue\n"); in xudc_ep_queue()
1118 dev_dbg(udc->dev, "xudc_read_fifo from ep_queue\n"); in xudc_ep_queue()
1127 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_queue()
1143 struct xusb_udc *udc = ep->udc; in xudc_ep_dequeue() local
1146 spin_lock_irqsave(&udc->lock, flags); in xudc_ep_dequeue()
1155 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_dequeue()
1159 spin_unlock_irqrestore(&udc->lock, flags); in xudc_ep_dequeue()
1220 struct xusb_udc *udc; in xudc_get_frame() local
1226 udc = to_udc(gadget); in xudc_get_frame()
1227 frame = udc->read_fn(udc->addr + XUSB_FRAMENUM_OFFSET); in xudc_get_frame()
1239 struct xusb_udc *udc = to_udc(gadget); in xudc_wakeup() local
1244 spin_lock_irqsave(&udc->lock, flags); in xudc_wakeup()
1247 if (!udc->remote_wkp) in xudc_wakeup()
1250 crtlreg = udc->read_fn(udc->addr + XUSB_CONTROL_OFFSET); in xudc_wakeup()
1253 udc->write_fn(udc->addr, XUSB_CONTROL_OFFSET, crtlreg); in xudc_wakeup()
1261 udc->write_fn(udc->addr, XUSB_CONTROL_OFFSET, crtlreg); in xudc_wakeup()
1264 spin_unlock_irqrestore(&udc->lock, flags); in xudc_wakeup()
1279 struct xusb_udc *udc = to_udc(gadget); in xudc_pullup() local
1283 spin_lock_irqsave(&udc->lock, flags); in xudc_pullup()
1285 crtlreg = udc->read_fn(udc->addr + XUSB_CONTROL_OFFSET); in xudc_pullup()
1291 udc->write_fn(udc->addr, XUSB_CONTROL_OFFSET, crtlreg); in xudc_pullup()
1293 spin_unlock_irqrestore(&udc->lock, flags); in xudc_pullup()
1300 * @udc: pointer to the usb device controller structure.
1302 static void xudc_eps_init(struct xusb_udc *udc) in xudc_eps_init() argument
1306 INIT_LIST_HEAD(&udc->gadget.ep_list); in xudc_eps_init()
1309 struct xusb_ep *ep = &udc->ep[ep_number]; in xudc_eps_init()
1313 &udc->gadget.ep_list); in xudc_eps_init()
1334 ep->udc = udc; in xudc_eps_init()
1345 xudc_epconfig(ep, udc); in xudc_eps_init()
1354 * @udc: pointer to the usb device controller structure.
1356 static void xudc_stop_activity(struct xusb_udc *udc) in xudc_stop_activity() argument
1362 ep = &udc->ep[i]; in xudc_stop_activity()
1377 struct xusb_udc *udc = to_udc(gadget); in xudc_start() local
1378 struct xusb_ep *ep0 = &udc->ep[XUSB_EP_NUMBER_ZERO]; in xudc_start()
1383 spin_lock_irqsave(&udc->lock, flags); in xudc_start()
1385 if (udc->driver) { in xudc_start()
1386 dev_err(udc->dev, "%s is already bound to %s\n", in xudc_start()
1387 udc->gadget.name, udc->driver->driver.name); in xudc_start()
1393 udc->driver = driver; in xudc_start()
1394 udc->gadget.speed = driver->max_speed; in xudc_start()
1400 udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET, 0); in xudc_start()
1401 udc->remote_wkp = 0; in xudc_start()
1403 spin_unlock_irqrestore(&udc->lock, flags); in xudc_start()
1415 struct xusb_udc *udc = to_udc(gadget); in xudc_stop() local
1418 spin_lock_irqsave(&udc->lock, flags); in xudc_stop()
1420 udc->gadget.speed = USB_SPEED_UNKNOWN; in xudc_stop()
1421 udc->driver = NULL; in xudc_stop()
1424 udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET, 0); in xudc_stop()
1425 udc->remote_wkp = 0; in xudc_stop()
1427 xudc_stop_activity(udc); in xudc_stop()
1429 spin_unlock_irqrestore(&udc->lock, flags); in xudc_stop()
1444 * @udc: pointer to the udc structure.
1446 static void xudc_clear_stall_all_ep(struct xusb_udc *udc) in xudc_clear_stall_all_ep() argument
1453 ep = &udc->ep[i]; in xudc_clear_stall_all_ep()
1454 epcfgreg = udc->read_fn(udc->addr + ep->offset); in xudc_clear_stall_all_ep()
1456 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_clear_stall_all_ep()
1459 epcfgreg = udc->read_fn(udc->addr + ep->offset); in xudc_clear_stall_all_ep()
1461 udc->write_fn(udc->addr, ep->offset, epcfgreg); in xudc_clear_stall_all_ep()
1468 * @udc: pointer to the udc structure.
1473 static void xudc_startup_handler(struct xusb_udc *udc, u32 intrstatus) in xudc_startup_handler() argument
1479 dev_dbg(udc->dev, "Reset\n"); in xudc_startup_handler()
1482 udc->gadget.speed = USB_SPEED_HIGH; in xudc_startup_handler()
1484 udc->gadget.speed = USB_SPEED_FULL; in xudc_startup_handler()
1486 xudc_stop_activity(udc); in xudc_startup_handler()
1487 xudc_clear_stall_all_ep(udc); in xudc_startup_handler()
1488 udc->write_fn(udc->addr, XUSB_TESTMODE_OFFSET, 0); in xudc_startup_handler()
1491 udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET, 0); in xudc_startup_handler()
1492 udc->remote_wkp = 0; in xudc_startup_handler()
1495 intrreg = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_startup_handler()
1498 udc->write_fn(udc->addr, XUSB_IER_OFFSET, intrreg); in xudc_startup_handler()
1502 dev_dbg(udc->dev, "Suspend\n"); in xudc_startup_handler()
1505 intrreg = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_startup_handler()
1508 udc->write_fn(udc->addr, XUSB_IER_OFFSET, intrreg); in xudc_startup_handler()
1510 udc->usb_state = USB_STATE_SUSPENDED; in xudc_startup_handler()
1512 if (udc->driver->suspend) { in xudc_startup_handler()
1513 spin_unlock(&udc->lock); in xudc_startup_handler()
1514 udc->driver->suspend(&udc->gadget); in xudc_startup_handler()
1515 spin_lock(&udc->lock); in xudc_startup_handler()
1519 bool condition = (udc->usb_state != USB_STATE_SUSPENDED); in xudc_startup_handler()
1521 dev_WARN_ONCE(udc->dev, condition, in xudc_startup_handler()
1524 dev_dbg(udc->dev, "Resume\n"); in xudc_startup_handler()
1527 intrreg = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_startup_handler()
1530 udc->write_fn(udc->addr, XUSB_IER_OFFSET, intrreg); in xudc_startup_handler()
1532 udc->usb_state = 0; in xudc_startup_handler()
1534 if (udc->driver->resume) { in xudc_startup_handler()
1535 spin_unlock(&udc->lock); in xudc_startup_handler()
1536 udc->driver->resume(&udc->gadget); in xudc_startup_handler()
1537 spin_lock(&udc->lock); in xudc_startup_handler()
1542 dev_dbg(udc->dev, "Disconnect\n"); in xudc_startup_handler()
1545 intrreg = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_startup_handler()
1548 udc->write_fn(udc->addr, XUSB_IER_OFFSET, intrreg); in xudc_startup_handler()
1550 if (udc->driver && udc->driver->disconnect) { in xudc_startup_handler()
1551 spin_unlock(&udc->lock); in xudc_startup_handler()
1552 udc->driver->disconnect(&udc->gadget); in xudc_startup_handler()
1553 spin_lock(&udc->lock); in xudc_startup_handler()
1560 * @udc: pointer to the udc structure.
1564 static void xudc_ep0_stall(struct xusb_udc *udc) in xudc_ep0_stall() argument
1567 struct xusb_ep *ep0 = &udc->ep[XUSB_EP_NUMBER_ZERO]; in xudc_ep0_stall()
1569 epcfgreg = udc->read_fn(udc->addr + ep0->offset); in xudc_ep0_stall()
1571 udc->write_fn(udc->addr, ep0->offset, epcfgreg); in xudc_ep0_stall()
1576 * @udc: pointer to the udc structure.
1580 static void xudc_setaddress(struct xusb_udc *udc) in xudc_setaddress() argument
1582 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_setaddress()
1583 struct xusb_req *req = udc->req; in xudc_setaddress()
1591 dev_err(udc->dev, "Can't respond to SET ADDRESS request\n"); in xudc_setaddress()
1592 xudc_ep0_stall(udc); in xudc_setaddress()
1597 * @udc: pointer to the udc structure.
1601 static void xudc_getstatus(struct xusb_udc *udc) in xudc_getstatus() argument
1603 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_getstatus()
1604 struct xusb_req *req = udc->req; in xudc_getstatus()
1612 switch (udc->setup.bRequestType & USB_RECIP_MASK) { in xudc_getstatus()
1616 if (udc->remote_wkp) in xudc_getstatus()
1622 epnum = le16_to_cpu(udc->setup.wIndex) & USB_ENDPOINT_NUMBER_MASK; in xudc_getstatus()
1625 target_ep = &udc->ep[epnum]; in xudc_getstatus()
1626 epcfgreg = udc->read_fn(udc->addr + target_ep->offset); in xudc_getstatus()
1628 if (le16_to_cpu(udc->setup.wIndex) & USB_DIR_IN) { in xudc_getstatus()
1648 dev_err(udc->dev, "Can't respond to getstatus request\n"); in xudc_getstatus()
1649 xudc_ep0_stall(udc); in xudc_getstatus()
1654 * @udc: pointer to the usb device controller structure.
1658 static void xudc_set_clear_feature(struct xusb_udc *udc) in xudc_set_clear_feature() argument
1660 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_set_clear_feature()
1661 struct xusb_req *req = udc->req; in xudc_set_clear_feature()
1666 int flag = (udc->setup.bRequest == USB_REQ_SET_FEATURE ? 1 : 0); in xudc_set_clear_feature()
1669 switch (udc->setup.bRequestType) { in xudc_set_clear_feature()
1671 switch (le16_to_cpu(udc->setup.wValue)) { in xudc_set_clear_feature()
1680 udc->remote_wkp = 1; in xudc_set_clear_feature()
1682 udc->remote_wkp = 0; in xudc_set_clear_feature()
1685 xudc_ep0_stall(udc); in xudc_set_clear_feature()
1690 if (!udc->setup.wValue) { in xudc_set_clear_feature()
1691 endpoint = le16_to_cpu(udc->setup.wIndex) & in xudc_set_clear_feature()
1694 xudc_ep0_stall(udc); in xudc_set_clear_feature()
1697 target_ep = &udc->ep[endpoint]; in xudc_set_clear_feature()
1698 outinbit = le16_to_cpu(udc->setup.wIndex) & in xudc_set_clear_feature()
1704 xudc_ep0_stall(udc); in xudc_set_clear_feature()
1707 epcfgreg = udc->read_fn(udc->addr + target_ep->offset); in xudc_set_clear_feature()
1711 udc->write_fn(udc->addr, in xudc_set_clear_feature()
1716 udc->write_fn(udc->addr, in xudc_set_clear_feature()
1723 udc->write_fn(udc->addr, in xudc_set_clear_feature()
1731 xudc_ep0_stall(udc); in xudc_set_clear_feature()
1740 dev_err(udc->dev, "Can't respond to SET/CLEAR FEATURE\n"); in xudc_set_clear_feature()
1741 xudc_ep0_stall(udc); in xudc_set_clear_feature()
1746 * @udc: pointer to the usb device controller structure.
1750 static void xudc_handle_setup(struct xusb_udc *udc) in xudc_handle_setup() argument
1751 __must_hold(&udc->lock) in xudc_handle_setup()
1753 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_handle_setup()
1758 ep0rambase = (u32 __force *) (udc->addr + XUSB_SETUP_PKT_ADDR_OFFSET); in xudc_handle_setup()
1761 udc->setup = setup; in xudc_handle_setup()
1762 udc->setup.wValue = cpu_to_le16((u16 __force)setup.wValue); in xudc_handle_setup()
1763 udc->setup.wIndex = cpu_to_le16((u16 __force)setup.wIndex); in xudc_handle_setup()
1764 udc->setup.wLength = cpu_to_le16((u16 __force)setup.wLength); in xudc_handle_setup()
1769 if (udc->setup.bRequestType & USB_DIR_IN) { in xudc_handle_setup()
1771 udc->setupseqrx = STATUS_PHASE; in xudc_handle_setup()
1772 udc->setupseqtx = DATA_PHASE; in xudc_handle_setup()
1775 udc->setupseqrx = DATA_PHASE; in xudc_handle_setup()
1776 udc->setupseqtx = STATUS_PHASE; in xudc_handle_setup()
1779 switch (udc->setup.bRequest) { in xudc_handle_setup()
1781 /* Data+Status phase form udc */ in xudc_handle_setup()
1782 if ((udc->setup.bRequestType & in xudc_handle_setup()
1786 xudc_getstatus(udc); in xudc_handle_setup()
1789 /* Status phase from udc */ in xudc_handle_setup()
1790 if (udc->setup.bRequestType != (USB_DIR_OUT | in xudc_handle_setup()
1793 xudc_setaddress(udc); in xudc_handle_setup()
1797 /* Requests with no data phase, status phase from udc */ in xudc_handle_setup()
1798 if ((udc->setup.bRequestType & USB_TYPE_MASK) in xudc_handle_setup()
1801 xudc_set_clear_feature(udc); in xudc_handle_setup()
1807 spin_unlock(&udc->lock); in xudc_handle_setup()
1808 if (udc->driver->setup(&udc->gadget, &setup) < 0) in xudc_handle_setup()
1809 xudc_ep0_stall(udc); in xudc_handle_setup()
1810 spin_lock(&udc->lock); in xudc_handle_setup()
1815 * @udc: pointer to the usb device controller structure.
1817 static void xudc_ep0_out(struct xusb_udc *udc) in xudc_ep0_out() argument
1819 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_ep0_out()
1827 switch (udc->setupseqrx) { in xudc_ep0_out()
1833 udc->setupseqrx = SETUP_PHASE; in xudc_ep0_out()
1834 udc->setupseqtx = SETUP_PHASE; in xudc_ep0_out()
1839 bytes_to_rx = udc->read_fn(udc->addr + in xudc_ep0_out()
1842 ep0rambase = (u8 __force *) (udc->addr + in xudc_ep0_out()
1850 xudc_wrstatus(udc); in xudc_ep0_out()
1853 udc->write_fn(udc->addr, XUSB_EP_BUF0COUNT_OFFSET, 0); in xudc_ep0_out()
1854 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, 1); in xudc_ep0_out()
1864 * @udc: pointer to the usb device controller structure.
1866 static void xudc_ep0_in(struct xusb_udc *udc) in xudc_ep0_in() argument
1868 struct xusb_ep *ep0 = &udc->ep[0]; in xudc_ep0_in()
1876 u8 test_mode = le16_to_cpu(udc->setup.wIndex) >> 8; in xudc_ep0_in()
1881 switch (udc->setupseqtx) { in xudc_ep0_in()
1883 switch (udc->setup.bRequest) { in xudc_ep0_in()
1886 udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET, in xudc_ep0_in()
1887 le16_to_cpu(udc->setup.wValue)); in xudc_ep0_in()
1890 if (udc->setup.bRequestType == in xudc_ep0_in()
1892 if (le16_to_cpu(udc->setup.wValue) == in xudc_ep0_in()
1894 udc->write_fn(udc->addr, in xudc_ep0_in()
1910 epcfgreg = udc->read_fn(udc->addr + ep0->offset); in xudc_ep0_in()
1912 udc->write_fn(udc->addr, ep0->offset, epcfgreg); in xudc_ep0_in()
1913 udc->setupseqtx = STATUS_PHASE; in xudc_ep0_in()
1918 ep0rambase = (u8 __force *) (udc->addr + in xudc_ep0_in()
1924 udc->write_fn(udc->addr, XUSB_EP_BUF0COUNT_OFFSET, count); in xudc_ep0_in()
1925 udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET, 1); in xudc_ep0_in()
1934 * @udc: pointer to the udc structure.
1939 static void xudc_ctrl_ep_handler(struct xusb_udc *udc, u32 intrstatus) in xudc_ctrl_ep_handler() argument
1943 xudc_handle_setup(udc); in xudc_ctrl_ep_handler()
1946 xudc_ep0_out(udc); in xudc_ctrl_ep_handler()
1948 xudc_ep0_in(udc); in xudc_ctrl_ep_handler()
1954 * @udc: pointer to the udc structure.
1961 static void xudc_nonctrl_ep_handler(struct xusb_udc *udc, u8 epnum, in xudc_nonctrl_ep_handler() argument
1968 ep = &udc->ep[epnum]; in xudc_nonctrl_ep_handler()
1995 struct xusb_udc *udc = _udc; in xudc_irq() local
2002 spin_lock_irqsave(&udc->lock, flags); in xudc_irq()
2008 ier = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_irq()
2010 udc->write_fn(udc->addr, XUSB_IER_OFFSET, ier); in xudc_irq()
2013 intrstatus = udc->read_fn(udc->addr + XUSB_STATUS_OFFSET); in xudc_irq()
2024 xudc_startup_handler(udc, intrstatus); in xudc_irq()
2030 ier = udc->read_fn(udc->addr + XUSB_IER_OFFSET); in xudc_irq()
2032 udc->write_fn(udc->addr, XUSB_IER_OFFSET, ier); in xudc_irq()
2035 xudc_ctrl_ep_handler(udc, intrstatus); in xudc_irq()
2044 xudc_nonctrl_ep_handler(udc, index, in xudc_irq()
2050 spin_unlock_irqrestore(&udc->lock, flags); in xudc_irq()
2064 struct xusb_udc *udc; in xudc_probe() local
2070 udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL); in xudc_probe()
2071 if (!udc) in xudc_probe()
2075 udc->req = devm_kzalloc(&pdev->dev, sizeof(struct xusb_req), in xudc_probe()
2077 if (!udc->req) in xudc_probe()
2084 udc->req->usb_req.buf = buff; in xudc_probe()
2087 udc->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in xudc_probe()
2088 if (IS_ERR(udc->addr)) in xudc_probe()
2089 return PTR_ERR(udc->addr); in xudc_probe()
2095 dev_name(&pdev->dev), udc); in xudc_probe()
2101 udc->dma_enabled = of_property_read_bool(np, "xlnx,has-builtin-dma"); in xudc_probe()
2104 udc->gadget.ops = &xusb_udc_ops; in xudc_probe()
2105 udc->gadget.max_speed = USB_SPEED_HIGH; in xudc_probe()
2106 udc->gadget.speed = USB_SPEED_UNKNOWN; in xudc_probe()
2107 udc->gadget.ep0 = &udc->ep[XUSB_EP_NUMBER_ZERO].ep_usb; in xudc_probe()
2108 udc->gadget.name = driver_name; in xudc_probe()
2110 udc->clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); in xudc_probe()
2111 if (IS_ERR(udc->clk)) { in xudc_probe()
2112 if (PTR_ERR(udc->clk) != -ENOENT) { in xudc_probe()
2113 ret = PTR_ERR(udc->clk); in xudc_probe()
2122 udc->clk = NULL; in xudc_probe()
2125 ret = clk_prepare_enable(udc->clk); in xudc_probe()
2131 spin_lock_init(&udc->lock); in xudc_probe()
2134 udc->write_fn = xudc_write32_be; in xudc_probe()
2135 udc->read_fn = xudc_read32_be; in xudc_probe()
2136 udc->write_fn(udc->addr, XUSB_TESTMODE_OFFSET, USB_TEST_J); in xudc_probe()
2137 if ((udc->read_fn(udc->addr + XUSB_TESTMODE_OFFSET)) in xudc_probe()
2139 udc->write_fn = xudc_write32; in xudc_probe()
2140 udc->read_fn = xudc_read32; in xudc_probe()
2142 udc->write_fn(udc->addr, XUSB_TESTMODE_OFFSET, 0); in xudc_probe()
2144 xudc_eps_init(udc); in xudc_probe()
2147 udc->write_fn(udc->addr, XUSB_ADDRESS_OFFSET, 0); in xudc_probe()
2149 ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget); in xudc_probe()
2153 udc->dev = &udc->gadget.dev; in xudc_probe()
2161 udc->write_fn(udc->addr, XUSB_IER_OFFSET, ier); in xudc_probe()
2163 platform_set_drvdata(pdev, udc); in xudc_probe()
2166 driver_name, (u32)res->start, udc->addr, in xudc_probe()
2167 udc->dma_enabled ? "with DMA" : "without DMA"); in xudc_probe()
2172 clk_disable_unprepare(udc->clk); in xudc_probe()
2186 struct xusb_udc *udc = platform_get_drvdata(pdev); in xudc_remove() local
2188 usb_del_gadget_udc(&udc->gadget); in xudc_remove()
2189 clk_disable_unprepare(udc->clk); in xudc_remove()
2195 struct xusb_udc *udc; in xudc_suspend() local
2199 udc = dev_get_drvdata(dev); in xudc_suspend()
2201 spin_lock_irqsave(&udc->lock, flags); in xudc_suspend()
2203 crtlreg = udc->read_fn(udc->addr + XUSB_CONTROL_OFFSET); in xudc_suspend()
2206 udc->write_fn(udc->addr, XUSB_CONTROL_OFFSET, crtlreg); in xudc_suspend()
2208 spin_unlock_irqrestore(&udc->lock, flags); in xudc_suspend()
2209 if (udc->driver && udc->driver->suspend) in xudc_suspend()
2210 udc->driver->suspend(&udc->gadget); in xudc_suspend()
2212 clk_disable(udc->clk); in xudc_suspend()
2219 struct xusb_udc *udc; in xudc_resume() local
2224 udc = dev_get_drvdata(dev); in xudc_resume()
2226 ret = clk_enable(udc->clk); in xudc_resume()
2230 spin_lock_irqsave(&udc->lock, flags); in xudc_resume()
2232 crtlreg = udc->read_fn(udc->addr + XUSB_CONTROL_OFFSET); in xudc_resume()
2235 udc->write_fn(udc->addr, XUSB_CONTROL_OFFSET, crtlreg); in xudc_resume()
2237 spin_unlock_irqrestore(&udc->lock, flags); in xudc_resume()
2266 MODULE_DESCRIPTION("Xilinx udc driver");