Lines Matching +full:ixp4xx +full:- +full:timer
1 // SPDX-License-Identifier: GPL-2.0+
3 * Intel PXA25x and IXP4xx on-chip full speed USB device controllers
24 #include <linux/timer.h>
30 #include <linux/dma-mapping.h>
40 #include <asm/mach-types.h>
52 #define UDC_RES1 0x0004 /* UDC Undocumented - Reserved1 */
53 #define UDC_RES2 0x0008 /* UDC Undocumented - Reserved2 */
54 #define UDC_RES3 0x000C /* UDC Undocumented - Reserved3 */
215 * not used here. IN-DMA (to host) is simple enough, when the data is
217 * other software can. OUT-DMA is buggy in most chip versions, as well
219 * bother using DMA. (Mostly-working IN-DMA support was available in
223 #define DRIVER_VERSION "30-June-2007"
234 /* cpu-specific register addresses are compiled in to this code */
256 /* ---------------------------------------------------------------------------
258 * used by gadget driver; and the inner talker-to-hardware core.
259 * ---------------------------------------------------------------------------
268 struct pxa2xx_udc_mach_info *mach = the_controller->mach; in pullup_off()
269 int off_level = mach->gpio_pullup_inverted; in pullup_off()
271 if (gpio_is_valid(mach->gpio_pullup)) in pullup_off()
272 gpio_set_value(mach->gpio_pullup, off_level); in pullup_off()
273 else if (mach->udc_command) in pullup_off()
274 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); in pullup_off()
279 struct pxa2xx_udc_mach_info *mach = the_controller->mach; in pullup_on()
280 int on_level = !mach->gpio_pullup_inverted; in pullup_on()
282 if (gpio_is_valid(mach->gpio_pullup)) in pullup_on()
283 gpio_set_value(mach->gpio_pullup, on_level); in pullup_on()
284 else if (mach->udc_command) in pullup_on()
285 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); in pullup_on()
290 * IXP4xx has its buses wired up in a way that relies on never doing any
291 * byte swaps, independent of whether it runs in big-endian or little-endian
294 * We only support pxa25x in little-endian mode, but it is very likely
299 iowrite32be(val, dev->regs + reg); in udc_set_reg()
304 return ioread32be(dev->regs + reg); in udc_get_reg()
309 writel(val, dev->regs + reg); in udc_set_reg()
314 return readl(dev->regs + reg); in udc_get_reg()
320 u32 bEndpointAddress = ep->bEndpointAddress & 0xf; in pio_irq_enable()
323 udc_set_reg(ep->dev, UICR0, udc_get_reg(ep->dev, UICR0) & in pio_irq_enable()
326 bEndpointAddress -= 8; in pio_irq_enable()
327 udc_set_reg(ep->dev, UICR1, udc_get_reg(ep->dev, UICR1) & in pio_irq_enable()
334 u32 bEndpointAddress = ep->bEndpointAddress & 0xf; in pio_irq_disable()
337 udc_set_reg(ep->dev, UICR0, udc_get_reg(ep->dev, UICR0) | in pio_irq_disable()
340 bEndpointAddress -= 8; in pio_irq_disable()
341 udc_set_reg(ep->dev, UICR1, udc_get_reg(ep->dev, UICR1) | in pio_irq_disable()
375 return udc_get_reg(ep->dev, ep->regoff_udccs); in udc_ep_get_UDCCS()
380 udc_set_reg(ep->dev, data, ep->regoff_udccs); in udc_ep_set_UDCCS()
395 return udc_get_reg(ep->dev, ep->regoff_uddr); in udc_ep_get_UDDR()
400 udc_set_reg(ep->dev, data, ep->regoff_uddr); in udc_ep_set_UDDR()
405 return udc_get_reg(ep->dev, ep->regoff_ubcr); in udc_ep_get_UBCR()
420 * iso endpoints must be in non-default altsettings.
429 if (!_ep || !desc || _ep->name == ep0name in pxa25x_ep_enable()
430 || desc->bDescriptorType != USB_DT_ENDPOINT in pxa25x_ep_enable()
431 || ep->bEndpointAddress != desc->bEndpointAddress in pxa25x_ep_enable()
432 || ep->fifo_size < usb_endpoint_maxp (desc)) { in pxa25x_ep_enable()
434 return -EINVAL; in pxa25x_ep_enable()
438 if (ep->bmAttributes != desc->bmAttributes in pxa25x_ep_enable()
439 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK in pxa25x_ep_enable()
440 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) { in pxa25x_ep_enable()
441 DMSG("%s, %s type mismatch\n", __func__, _ep->name); in pxa25x_ep_enable()
442 return -EINVAL; in pxa25x_ep_enable()
446 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK in pxa25x_ep_enable()
449 || !desc->wMaxPacketSize) { in pxa25x_ep_enable()
450 DMSG("%s, bad %s maxpacket\n", __func__, _ep->name); in pxa25x_ep_enable()
451 return -ERANGE; in pxa25x_ep_enable()
454 dev = ep->dev; in pxa25x_ep_enable()
455 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { in pxa25x_ep_enable()
457 return -ESHUTDOWN; in pxa25x_ep_enable()
460 ep->ep.desc = desc; in pxa25x_ep_enable()
461 ep->stopped = 0; in pxa25x_ep_enable()
462 ep->pio_irqs = 0; in pxa25x_ep_enable()
463 ep->ep.maxpacket = usb_endpoint_maxp (desc); in pxa25x_ep_enable()
470 DBG(DBG_VERBOSE, "enabled %s\n", _ep->name); in pxa25x_ep_enable()
480 if (!_ep || !ep->ep.desc) { in pxa25x_ep_disable()
482 _ep ? ep->ep.name : NULL); in pxa25x_ep_disable()
483 return -EINVAL; in pxa25x_ep_disable()
487 nuke (ep, -ESHUTDOWN); in pxa25x_ep_disable()
492 ep->ep.desc = NULL; in pxa25x_ep_disable()
493 ep->stopped = 1; in pxa25x_ep_disable()
496 DBG(DBG_VERBOSE, "%s disabled\n", _ep->name); in pxa25x_ep_disable()
500 /*-------------------------------------------------------------------------*/
508 * pxa25x_ep_alloc_request - allocate a request data structure
519 INIT_LIST_HEAD (&req->queue); in pxa25x_ep_alloc_request()
520 return &req->req; in pxa25x_ep_alloc_request()
525 * pxa25x_ep_free_request - deallocate a request data structure
533 WARN_ON(!list_empty (&req->queue)); in pxa25x_ep_free_request()
537 /*-------------------------------------------------------------------------*/
540 * done - retire a request; caller blocked irqs
544 unsigned stopped = ep->stopped; in done()
546 list_del_init(&req->queue); in done()
548 if (likely (req->req.status == -EINPROGRESS)) in done()
549 req->req.status = status; in done()
551 status = req->req.status; in done()
553 if (status && status != -ESHUTDOWN) in done()
555 ep->ep.name, &req->req, status, in done()
556 req->req.actual, req->req.length); in done()
559 ep->stopped = 1; in done()
560 usb_gadget_giveback_request(&ep->ep, &req->req); in done()
561 ep->stopped = stopped; in done()
567 dev->ep0state = EP0_IDLE; in ep0_idle()
576 buf = req->req.buf + req->req.actual; in write_packet()
580 length = min(req->req.length - req->req.actual, max); in write_packet()
581 req->req.actual += length; in write_packet()
584 while (likely(count--)) in write_packet()
600 max = usb_endpoint_maxp(ep->ep.desc); in write_fifo()
611 if (likely(req->req.length != req->req.actual) in write_fifo()
612 || req->req.zero) in write_fifo()
617 is_short = unlikely (max < ep->fifo_size); in write_fifo()
621 ep->ep.name, count, in write_fifo()
623 req->req.length - req->req.actual, req); in write_fifo()
636 if (list_empty(&ep->queue)) in write_fifo()
649 /* caller asserts req->pending (ep0 irq status nyet cleared); starts
657 dev->req_pending = 0; in ep0start()
665 struct pxa25x_udc *dev = ep->dev; in write_ep0_fifo()
669 count = write_packet(&dev->ep[0], req, EP0_FIFO_SIZE); in write_ep0_fifo()
670 ep->dev->stats.write.bytes += count; in write_ep0_fifo()
676 req->req.length - req->req.actual, req); in write_ep0_fifo()
679 if (ep->dev->req_pending) in write_ep0_fifo()
680 ep0start(ep->dev, UDCCS0_IPR, "short IN"); in write_ep0_fifo()
684 count = req->req.length; in write_ep0_fifo()
686 ep0_idle(ep->dev); in write_ep0_fifo()
703 count--; in write_ep0_fifo()
709 } else if (ep->dev->req_pending) in write_ep0_fifo()
710 ep0start(ep->dev, 0, "IN"); in write_ep0_fifo()
716 * read_fifo - unload packet(s) from the fifo we use for usb OUT
721 * request buffer having filled (and maybe overran till end-of-packet).
738 buf = req->req.buf + req->req.actual; in read_fifo()
740 bufferspace = req->req.length - req->req.actual; in read_fifo()
745 req->req.actual += min (count, bufferspace); in read_fifo()
748 is_short = (count < ep->ep.maxpacket); in read_fifo()
750 ep->ep.name, udccs, count, in read_fifo()
752 req, req->req.actual, req->req.length); in read_fifo()
753 while (likely (count-- != 0)) { in read_fifo()
761 if (req->req.status != -EOVERFLOW) in read_fifo()
763 ep->ep.name, count); in read_fifo()
764 req->req.status = -EOVERFLOW; in read_fifo()
767 bufferspace--; in read_fifo()
774 if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { in read_fifo()
776 req->req.status = -EHOSTUNREACH; in read_fifo()
782 if (is_short || req->req.actual == req->req.length) { in read_fifo()
784 if (list_empty(&ep->queue)) in read_fifo()
796 * handshaking is magic. most device protocols don't need control-OUT.
806 buf = req->req.buf + req->req.actual; in read_ep0_fifo()
807 bufferspace = req->req.length - req->req.actual; in read_ep0_fifo()
817 if (req->req.status != -EOVERFLOW) in read_ep0_fifo()
818 DMSG("%s overflow\n", ep->ep.name); in read_ep0_fifo()
819 req->req.status = -EOVERFLOW; in read_ep0_fifo()
822 req->req.actual++; in read_ep0_fifo()
823 bufferspace--; in read_ep0_fifo()
830 if (req->req.actual >= req->req.length) in read_ep0_fifo()
837 /*-------------------------------------------------------------------------*/
848 if (unlikely (!_req || !_req->complete || !_req->buf in pxa25x_ep_queue()
849 || !list_empty(&req->queue))) { in pxa25x_ep_queue()
851 return -EINVAL; in pxa25x_ep_queue()
855 if (unlikely(!_ep || (!ep->ep.desc && ep->ep.name != ep0name))) { in pxa25x_ep_queue()
857 return -EINVAL; in pxa25x_ep_queue()
860 dev = ep->dev; in pxa25x_ep_queue()
861 if (unlikely (!dev->driver in pxa25x_ep_queue()
862 || dev->gadget.speed == USB_SPEED_UNKNOWN)) { in pxa25x_ep_queue()
864 return -ESHUTDOWN; in pxa25x_ep_queue()
868 * we can report per-packet status. that also helps with dma. in pxa25x_ep_queue()
870 if (unlikely (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC in pxa25x_ep_queue()
871 && req->req.length > usb_endpoint_maxp(ep->ep.desc))) in pxa25x_ep_queue()
872 return -EMSGSIZE; in pxa25x_ep_queue()
875 _ep->name, _req, _req->length, _req->buf); in pxa25x_ep_queue()
879 _req->status = -EINPROGRESS; in pxa25x_ep_queue()
880 _req->actual = 0; in pxa25x_ep_queue()
883 if (list_empty(&ep->queue) && !ep->stopped) { in pxa25x_ep_queue()
884 if (ep->ep.desc == NULL/* ep0 */) { in pxa25x_ep_queue()
885 unsigned length = _req->length; in pxa25x_ep_queue()
887 switch (dev->ep0state) { in pxa25x_ep_queue()
889 dev->stats.write.ops++; in pxa25x_ep_queue()
895 dev->stats.read.ops++; in pxa25x_ep_queue()
897 if (dev->req_config) { in pxa25x_ep_queue()
899 dev->has_cfr ? "" : " raced"); in pxa25x_ep_queue()
900 if (dev->has_cfr) in pxa25x_ep_queue()
904 dev->ep0state = EP0_END_XFER; in pxa25x_ep_queue()
908 if (dev->req_pending) in pxa25x_ep_queue()
919 DMSG("ep0 i/o, odd state %d\n", dev->ep0state); in pxa25x_ep_queue()
921 return -EL2HLT; in pxa25x_ep_queue()
924 } else if ((ep->bEndpointAddress & USB_DIR_IN) != 0) { in pxa25x_ep_queue()
933 if (likely(req && ep->ep.desc)) in pxa25x_ep_queue()
939 list_add_tail(&req->queue, &ep->queue); in pxa25x_ep_queue()
947 * nuke - dequeue ALL requests
954 while (!list_empty(&ep->queue)) { in nuke()
955 req = list_entry(ep->queue.next, in nuke()
960 if (ep->ep.desc) in nuke()
973 if (!_ep || ep->ep.name == ep0name) in pxa25x_ep_dequeue()
974 return -EINVAL; in pxa25x_ep_dequeue()
979 list_for_each_entry (req, &ep->queue, queue) { in pxa25x_ep_dequeue()
980 if (&req->req == _req) in pxa25x_ep_dequeue()
983 if (&req->req != _req) { in pxa25x_ep_dequeue()
985 return -EINVAL; in pxa25x_ep_dequeue()
988 done(ep, req, -ECONNRESET); in pxa25x_ep_dequeue()
994 /*-------------------------------------------------------------------------*/
1003 || (!ep->ep.desc && ep->ep.name != ep0name)) in pxa25x_ep_set_halt()
1004 || ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) { in pxa25x_ep_set_halt()
1006 return -EINVAL; in pxa25x_ep_set_halt()
1014 DMSG("only host can clear %s halt\n", _ep->name); in pxa25x_ep_set_halt()
1015 return -EROFS; in pxa25x_ep_set_halt()
1020 if ((ep->bEndpointAddress & USB_DIR_IN) != 0 in pxa25x_ep_set_halt()
1022 || !list_empty(&ep->queue))) { in pxa25x_ep_set_halt()
1024 return -EAGAIN; in pxa25x_ep_set_halt()
1031 if (!ep->ep.desc) { in pxa25x_ep_set_halt()
1032 start_watchdog(ep->dev); in pxa25x_ep_set_halt()
1033 ep->dev->req_pending = 0; in pxa25x_ep_set_halt()
1034 ep->dev->ep0state = EP0_STALL; in pxa25x_ep_set_halt()
1047 DBG(DBG_VERBOSE, "%s halt\n", _ep->name); in pxa25x_ep_set_halt()
1058 return -ENODEV; in pxa25x_ep_fifo_status()
1061 if ((ep->bEndpointAddress & USB_DIR_IN) != 0) in pxa25x_ep_fifo_status()
1062 return -EOPNOTSUPP; in pxa25x_ep_fifo_status()
1063 if (ep->dev->gadget.speed == USB_SPEED_UNKNOWN in pxa25x_ep_fifo_status()
1075 if (!_ep || ep->ep.name == ep0name || !list_empty(&ep->queue)) { in pxa25x_ep_fifo_flush()
1083 if ((ep->bEndpointAddress & USB_DIR_IN) == 0) { in pxa25x_ep_fifo_flush()
1091 | (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC in pxa25x_ep_fifo_flush()
1112 /* ---------------------------------------------------------------------------
1113 * device-scoped parts of the api to the usb controller hardware
1114 * ---------------------------------------------------------------------------
1134 return -EHOSTUNREACH; in pxa25x_udc_wakeup()
1143 /* We disable the UDC -- and its 48 MHz clock -- whenever it's not
1148 int is_active = udc->vbus && udc->pullup && !udc->suspended; in pullup()
1151 if (!udc->active) { in pullup()
1152 udc->active = 1; in pullup()
1154 clk_enable(udc->clk); in pullup()
1158 if (udc->active) { in pullup()
1159 if (udc->gadget.speed != USB_SPEED_UNKNOWN) { in pullup()
1160 DMSG("disconnect %s\n", udc->driver in pullup()
1161 ? udc->driver->driver.name in pullup()
1163 stop_activity(udc, udc->driver); in pullup()
1167 clk_disable(udc->clk); in pullup()
1168 udc->active = 0; in pullup()
1181 udc->vbus = is_active; in pxa25x_udc_vbus_session()
1195 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command) in pxa25x_udc_pullup()
1196 return -EOPNOTSUPP; in pxa25x_udc_pullup()
1198 udc->pullup = (is_active != 0); in pxa25x_udc_pullup()
1203 /* boards may consume current from VBUS, up to 100-500mA based on config.
1204 * the 500uA suspend ceiling means that exclusively vbus-powered PXA designs
1213 if (!IS_ERR_OR_NULL(udc->transceiver)) in pxa25x_udc_vbus_draw()
1214 return usb_phy_set_power(udc->transceiver, mA); in pxa25x_udc_vbus_draw()
1215 return -EOPNOTSUPP; in pxa25x_udc_vbus_draw()
1232 /*-------------------------------------------------------------------------*/
1238 struct pxa25x_udc *dev = m->private; in udc_debug_show()
1249 dev->driver ? dev->driver->driver.name : "(none)", in udc_debug_show()
1250 dev->gadget.speed == USB_SPEED_FULL ? "full speed" : "disconnected"); in udc_debug_show()
1283 if (dev->has_cfr) { in udc_debug_show()
1291 if (dev->gadget.speed != USB_SPEED_FULL || !dev->driver) in udc_debug_show()
1295 dev->stats.write.bytes, dev->stats.write.ops, in udc_debug_show()
1296 dev->stats.read.bytes, dev->stats.read.ops, in udc_debug_show()
1297 dev->stats.irqs); in udc_debug_show()
1301 struct pxa25x_ep *ep = &dev->ep [i]; in udc_debug_show()
1307 desc = ep->ep.desc; in udc_debug_show()
1310 tmp = udc_ep_get_UDCCS(&dev->ep[i]); in udc_debug_show()
1313 ep->ep.name, usb_endpoint_maxp(desc), in udc_debug_show()
1314 "pio", tmp, ep->pio_irqs); in udc_debug_show()
1319 ep->pio_irqs); in udc_debug_show()
1321 if (list_empty(&ep->queue)) { in udc_debug_show()
1325 list_for_each_entry(req, &ep->queue, queue) { in udc_debug_show()
1328 &req->req, req->req.actual, in udc_debug_show()
1329 req->req.length, req->req.buf); in udc_debug_show()
1341 dev->debugfs_udc = debugfs_create_file(dev->gadget.name, \
1344 #define remove_debug_files(dev) debugfs_remove(dev->debugfs_udc)
1353 /*-------------------------------------------------------------------------*/
1356 * udc_disable - disable USB device controller
1372 dev->gadget.speed = USB_SPEED_UNKNOWN; in udc_disable()
1377 * udc_reinit - initialize software state
1384 INIT_LIST_HEAD (&dev->gadget.ep_list); in udc_reinit()
1385 INIT_LIST_HEAD (&dev->gadget.ep0->ep_list); in udc_reinit()
1386 dev->ep0state = EP0_IDLE; in udc_reinit()
1387 dev->gadget.quirk_altset_not_supp = 1; in udc_reinit()
1391 struct pxa25x_ep *ep = &dev->ep[i]; in udc_reinit()
1394 list_add_tail (&ep->ep.ep_list, &dev->gadget.ep_list); in udc_reinit()
1396 ep->ep.desc = NULL; in udc_reinit()
1397 ep->stopped = 0; in udc_reinit()
1398 INIT_LIST_HEAD (&ep->queue); in udc_reinit()
1399 ep->pio_irqs = 0; in udc_reinit()
1400 usb_ep_set_maxpacket_limit(&ep->ep, ep->ep.maxpacket); in udc_reinit()
1403 /* the rest was statically initialized, and is read-only */ in udc_reinit()
1417 dev->gadget.speed = USB_SPEED_UNKNOWN; in udc_enable()
1418 dev->stats.irqs = 0; in udc_enable()
1422 * - enable UDC in udc_enable()
1423 * - if RESET is already in progress, ack interrupt in udc_enable()
1424 * - unmask reset interrupt in udc_enable()
1430 if (dev->has_cfr /* UDC_RES2 is defined */) { in udc_enable()
1436 /* "USB test mode" for pxa250 errata 40-42 (stepping a0, a1) in udc_enable()
1459 * non-control requests. then usb traffic follows until a
1470 dev->driver = driver; in pxa25x_udc_start()
1471 dev->pullup = 1; in pxa25x_udc_start()
1477 if (!IS_ERR_OR_NULL(dev->transceiver)) { in pxa25x_udc_start()
1478 retval = otg_set_peripheral(dev->transceiver->otg, in pxa25x_udc_start()
1479 &dev->gadget); in pxa25x_udc_start()
1496 if (dev->gadget.speed == USB_SPEED_UNKNOWN) in reset_gadget()
1498 dev->gadget.speed = USB_SPEED_UNKNOWN; in reset_gadget()
1502 struct pxa25x_ep *ep = &dev->ep[i]; in reset_gadget()
1504 ep->stopped = 1; in reset_gadget()
1505 nuke(ep, -ESHUTDOWN); in reset_gadget()
1507 del_timer_sync(&dev->timer); in reset_gadget()
1511 usb_gadget_udc_reset(&dev->gadget, driver); in reset_gadget()
1513 /* re-init driver-visible data structures */ in reset_gadget()
1523 if (dev->gadget.speed == USB_SPEED_UNKNOWN) in stop_activity()
1525 dev->gadget.speed = USB_SPEED_UNKNOWN; in stop_activity()
1529 struct pxa25x_ep *ep = &dev->ep[i]; in stop_activity()
1531 ep->stopped = 1; in stop_activity()
1532 nuke(ep, -ESHUTDOWN); in stop_activity()
1534 del_timer_sync(&dev->timer); in stop_activity()
1538 driver->disconnect(&dev->gadget); in stop_activity()
1540 /* re-init driver-visible data structures */ in stop_activity()
1549 dev->pullup = 0; in pxa25x_udc_stop()
1553 if (!IS_ERR_OR_NULL(dev->transceiver)) in pxa25x_udc_stop()
1554 (void) otg_set_peripheral(dev->transceiver->otg, NULL); in pxa25x_udc_stop()
1556 dev->driver = NULL; in pxa25x_udc_stop()
1563 /*-------------------------------------------------------------------------*/
1577 dev->stats.irqs++; in lubbock_vbus_irq()
1593 pxa25x_udc_vbus_session(&dev->gadget, vbus); in lubbock_vbus_irq()
1600 /*-------------------------------------------------------------------------*/
1610 nuke(&dev->ep[i], -ECONNABORTED); in clear_ep_state()
1615 struct pxa25x_udc *dev = from_timer(dev, t, timer); in udc_watchdog()
1618 if (dev->ep0state == EP0_STALL in udc_watchdog()
1622 DBG(DBG_VERBOSE, "ep0 re-stall\n"); in udc_watchdog()
1631 struct pxa25x_ep *ep = &dev->ep [0]; in handle_ep0()
1639 if (list_empty(&ep->queue)) in handle_ep0()
1642 req = list_entry(ep->queue.next, struct pxa25x_request, queue); in handle_ep0()
1646 nuke(ep, -EPIPE); in handle_ep0()
1648 del_timer(&dev->timer); in handle_ep0()
1652 /* previous request unfinished? non-error iff back-to-back ... */ in handle_ep0()
1653 if ((udccs0 & UDCCS0_SA) != 0 && dev->ep0state != EP0_IDLE) { in handle_ep0()
1655 del_timer(&dev->timer); in handle_ep0()
1659 switch (dev->ep0state) { in handle_ep0()
1661 /* late-breaking status? */ in handle_ep0()
1669 nuke (ep, -EPROTO); in handle_ep0()
1691 dev->req_std = (u.r.bRequestType & USB_TYPE_MASK) in handle_ep0()
1693 dev->req_config = 0; in handle_ep0()
1694 dev->req_pending = 1; in handle_ep0()
1703 dev->req_config = 1; in handle_ep0()
1715 * - altsetting may only be zero; in handle_ep0()
1716 * - hw resets all interfaces' eps; in handle_ep0()
1717 * - ep reset doesn't include halt(?). in handle_ep0()
1735 dev->ep0state = EP0_IN_DATA_PHASE; in handle_ep0()
1737 dev->ep0state = EP0_OUT_DATA_PHASE; in handle_ep0()
1739 i = dev->driver->setup(&dev->gadget, &u.r); in handle_ep0()
1742 if (dev->req_config) { in handle_ep0()
1758 /* the watchdog timer helps deal with cases in handle_ep0()
1764 dev->ep0state = EP0_STALL; in handle_ep0()
1767 } else if (dev->req_pending) { in handle_ep0()
1768 if (likely(dev->ep0state == EP0_IN_DATA_PHASE in handle_ep0()
1769 || dev->req_std || u.r.wLength)) in handle_ep0()
1786 nuke(ep, -EPROTO); in handle_ep0()
1799 * - we acked FST in handle_ep0()
1800 * - IPR cleared in handle_ep0()
1801 * - OPR got set, without SA (likely status stage) in handle_ep0()
1838 /* ack control-IN status (maybe in-zlp was skipped) in handle_ep0()
1855 int is_in = ep->bEndpointAddress & USB_DIR_IN; in handle_ep()
1861 if (likely (!list_empty(&ep->queue))) in handle_ep()
1862 req = list_entry(ep->queue.next, in handle_ep()
1872 if (likely(ep->bmAttributes == USB_ENDPOINT_XFER_BULK)) in handle_ep()
1881 if (likely(ep->bmAttributes == USB_ENDPOINT_XFER_BULK)) in handle_ep()
1895 ep->pio_irqs++; in handle_ep()
1900 * pxa25x_udc_irq - interrupt handler
1912 dev->stats.irqs++; in pxa25x_udc_irq()
1924 if (dev->gadget.speed != USB_SPEED_UNKNOWN in pxa25x_udc_irq()
1925 && dev->driver in pxa25x_udc_irq()
1926 && dev->driver->suspend) in pxa25x_udc_irq()
1927 dev->driver->suspend(&dev->gadget); in pxa25x_udc_irq()
1937 if (dev->gadget.speed != USB_SPEED_UNKNOWN in pxa25x_udc_irq()
1938 && dev->driver in pxa25x_udc_irq()
1939 && dev->driver->resume) in pxa25x_udc_irq()
1940 dev->driver->resume(&dev->gadget); in pxa25x_udc_irq()
1943 /* ReSeT Interrupt Request - USB reset */ in pxa25x_udc_irq()
1954 reset_gadget(dev, dev->driver); in pxa25x_udc_irq()
1958 dev->gadget.speed = USB_SPEED_FULL; in pxa25x_udc_irq()
1959 memset(&dev->stats, 0, sizeof dev->stats); in pxa25x_udc_irq()
1977 dev->ep[0].pio_irqs++; in pxa25x_udc_irq()
1987 handle_ep(&dev->ep[i]); in pxa25x_udc_irq()
1994 handle_ep(&dev->ep[i+8]); in pxa25x_udc_irq()
2009 /*-------------------------------------------------------------------------*/
2016 /* this uses load-time allocation and initialization (instead of
2017 * doing it at run-time) to save code, eliminate fault paths, and
2048 .name = "ep1in-bulk",
2063 .name = "ep2out-bulk",
2080 .name = "ep3in-iso",
2095 .name = "ep4out-iso",
2111 .name = "ep5in-int",
2127 .name = "ep6in-bulk",
2142 .name = "ep7out-bulk",
2158 .name = "ep8in-iso",
2173 .name = "ep9out-iso",
2189 .name = "ep10in-int",
2205 .name = "ep11in-bulk",
2220 .name = "ep12out-bulk",
2236 .name = "ep13in-iso",
2251 .name = "ep14out-iso",
2267 .name = "ep15in-int",
2288 #define CP15R0_XSCALE_VALUE 0x69054000 /* intel/arm/ixp4xx */
2317 * probe - binds to the platform device
2331 return -ENODEV; in pxa25x_udc_probe()
2334 /* trigger chiprev-specific logic */ in pxa25x_udc_probe()
2338 dev->has_cfr = 1; in pxa25x_udc_probe()
2347 /* OUT-DMA is broken ... */ in pxa25x_udc_probe()
2355 dev->has_cfr = 1; in pxa25x_udc_probe()
2361 /* iop3xx, ixp4xx, ... */ in pxa25x_udc_probe()
2362 return -ENODEV; in pxa25x_udc_probe()
2367 return -ENODEV; in pxa25x_udc_probe()
2369 dev->regs = devm_platform_ioremap_resource(pdev, 0); in pxa25x_udc_probe()
2370 if (IS_ERR(dev->regs)) in pxa25x_udc_probe()
2371 return PTR_ERR(dev->regs); in pxa25x_udc_probe()
2373 dev->clk = devm_clk_get(&pdev->dev, NULL); in pxa25x_udc_probe()
2374 if (IS_ERR(dev->clk)) in pxa25x_udc_probe()
2375 return PTR_ERR(dev->clk); in pxa25x_udc_probe()
2378 dev->has_cfr ? "" : " (!cfr)", in pxa25x_udc_probe()
2382 /* other non-static parts of init */ in pxa25x_udc_probe()
2383 dev->dev = &pdev->dev; in pxa25x_udc_probe()
2384 dev->mach = dev_get_platdata(&pdev->dev); in pxa25x_udc_probe()
2386 dev->transceiver = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); in pxa25x_udc_probe()
2388 if (gpio_is_valid(dev->mach->gpio_pullup)) { in pxa25x_udc_probe()
2389 retval = devm_gpio_request(&pdev->dev, dev->mach->gpio_pullup, in pxa25x_udc_probe()
2392 dev_dbg(&pdev->dev, in pxa25x_udc_probe()
2394 dev->mach->gpio_pullup, retval); in pxa25x_udc_probe()
2397 gpio_direction_output(dev->mach->gpio_pullup, 0); in pxa25x_udc_probe()
2400 timer_setup(&dev->timer, udc_watchdog, 0); in pxa25x_udc_probe()
2408 dev->vbus = 0; in pxa25x_udc_probe()
2411 retval = devm_request_irq(&pdev->dev, irq, pxa25x_udc_irq, 0, in pxa25x_udc_probe()
2418 dev->got_irq = 1; in pxa25x_udc_probe()
2422 retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_DISC_IRQ, in pxa25x_udc_probe()
2430 retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_IRQ, in pxa25x_udc_probe()
2442 retval = usb_add_gadget_udc(&pdev->dev, &dev->gadget); in pxa25x_udc_probe()
2448 if (!IS_ERR_OR_NULL(dev->transceiver)) in pxa25x_udc_probe()
2449 dev->transceiver = NULL; in pxa25x_udc_probe()
2462 if (dev->driver) in pxa25x_udc_remove()
2463 return -EBUSY; in pxa25x_udc_remove()
2465 usb_del_gadget_udc(&dev->gadget); in pxa25x_udc_remove()
2466 dev->pullup = 0; in pxa25x_udc_remove()
2471 if (!IS_ERR_OR_NULL(dev->transceiver)) in pxa25x_udc_remove()
2472 dev->transceiver = NULL; in pxa25x_udc_remove()
2478 /*-------------------------------------------------------------------------*/
2499 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command) in pxa25x_udc_suspend()
2501 udc->suspended = 1; in pxa25x_udc_suspend()
2515 udc->suspended = 0; in pxa25x_udc_resume()
2528 /*-------------------------------------------------------------------------*/
2537 .name = "pxa25x-udc",
2546 MODULE_ALIAS("platform:pxa25x-udc");