Lines Matching full:udc
281 struct usbf_udc *udc; member
426 static inline u32 usbf_reg_readl(struct usbf_udc *udc, uint offset) in usbf_reg_readl() argument
428 return readl(udc->regs + offset); in usbf_reg_readl()
431 static inline void usbf_reg_writel(struct usbf_udc *udc, uint offset, u32 val) in usbf_reg_writel() argument
433 writel(val, udc->regs + offset); in usbf_reg_writel()
436 static inline void usbf_reg_bitset(struct usbf_udc *udc, uint offset, u32 set) in usbf_reg_bitset() argument
440 tmp = usbf_reg_readl(udc, offset); in usbf_reg_bitset()
442 usbf_reg_writel(udc, offset, tmp); in usbf_reg_bitset()
445 static inline void usbf_reg_bitclr(struct usbf_udc *udc, uint offset, u32 clr) in usbf_reg_bitclr() argument
449 tmp = usbf_reg_readl(udc, offset); in usbf_reg_bitclr()
451 usbf_reg_writel(udc, offset, tmp); in usbf_reg_bitclr()
454 static inline void usbf_reg_clrset(struct usbf_udc *udc, uint offset, in usbf_reg_clrset() argument
459 tmp = usbf_reg_readl(udc, offset); in usbf_reg_clrset()
462 usbf_reg_writel(udc, offset, tmp); in usbf_reg_clrset()
571 dev_dbg(ep0->udc->dev, "ep0 send null\n"); in usbf_ep0_pio_in()
578 dev_dbg(ep0->udc->dev, "ep0 send null\n"); in usbf_ep0_pio_in()
611 dev_dbg(ep0->udc->dev, "ep0 send %u/%u\n", in usbf_ep0_pio_in()
636 dev_dbg(ep0->udc->dev, "ep0 recv %u, left %u\n", count, left); in usbf_ep0_pio_out()
661 dev_dbg(ep0->udc->dev, "ep0 recv %u/%u\n", in usbf_ep0_pio_out()
665 dev_dbg(ep0->udc->dev, "ep0 req.status=%d\n", req_status); in usbf_ep0_pio_out()
671 dev_dbg(ep0->udc->dev, "ep0 short packet\n"); in usbf_ep0_pio_out()
691 dev_dbg(ep0->udc->dev, "ep0 null packet\n"); in usbf_ep0_pio_out()
715 dev_err(ep0->udc->dev, "ep0 flush fifo timed out\n"); in usbf_ep0_fifo_flush()
748 dev_dbg(epn->udc->dev, "ep%u send_null\n", epn->id); in usbf_epn_pio_in()
755 dev_dbg(epn->udc->dev, "ep%u send_null\n", in usbf_epn_pio_in()
789 dev_dbg(epn->udc->dev, "ep%u send %u/%u\n", epn->id, req->req.actual, in usbf_epn_pio_in()
808 dev_dbg(epn->udc->dev, "ep%u buf unaligned -> fallback pio\n", in usbf_epn_dma_in()
819 dev_dbg(epn->udc->dev, "ep%u send null\n", epn->id); in usbf_epn_dma_in()
825 dev_dbg(epn->udc->dev, "ep%u send residue %u\n", epn->id, in usbf_epn_dma_in()
834 ret = usb_gadget_map_request(&epn->udc->gadget, &req->req, 1); in usbf_epn_dma_in()
836 dev_err(epn->udc->dev, "usb_gadget_map_request failed (%d)\n", in usbf_epn_dma_in()
882 dev_dbg(epn->udc->dev, "ep%u dma xfer %zu\n", epn->id, in usbf_epn_dma_in()
890 dev_dbg(epn->udc->dev, "ep%u dma not done\n", epn->id); in usbf_epn_dma_in()
893 dev_dbg(epn->udc->dev, "ep%u dma done\n", epn->id); in usbf_epn_dma_in()
895 usb_gadget_unmap_request(&epn->udc->gadget, &req->req, 1); in usbf_epn_dma_in()
910 dev_dbg(epn->udc->dev, "ep%u send residue %u\n", epn->id, in usbf_epn_dma_in()
923 dev_dbg(epn->udc->dev, "ep%u send short\n", epn->id); in usbf_epn_dma_in()
946 dev_dbg(epn->udc->dev, "ep%u send null\n", epn->id); in usbf_epn_dma_in()
953 dev_dbg(epn->udc->dev, "ep%u end not done\n", epn->id); in usbf_epn_dma_in()
956 dev_dbg(epn->udc->dev, "ep%u send done %u/%u\n", epn->id, in usbf_epn_dma_in()
993 dev_dbg(epn->udc->dev, "ep%u recv %u, left %u, mpkt %u\n", epn->id, in usbf_epn_pio_out()
1018 dev_dbg(epn->udc->dev, "ep%u recv %u/%u\n", epn->id, in usbf_epn_pio_out()
1022 dev_dbg(epn->udc->dev, "ep%u req.status=%d\n", epn->id, in usbf_epn_pio_out()
1029 dev_dbg(epn->udc->dev, "ep%u short packet\n", epn->id); in usbf_epn_pio_out()
1044 dev_dbg(epn->udc->dev, "ep%u null packet\n", epn->id); in usbf_epn_pio_out()
1118 usbf_reg_bitclr(epn->udc, USBF_REG_AHBBINTEN, in usbf_epn_dma_out_send_dma()
1122 usbf_reg_writel(epn->udc, USBF_REG_AHBBINT, in usbf_epn_dma_out_send_dma()
1152 usbf_reg_bitset(epn->udc, USBF_REG_AHBBINTEN, in usbf_epn_dma_out_complete_dma()
1169 dev_err(epn->udc->dev, "ep%u wait bridge timed out\n", in usbf_epn_dma_out_complete_dma()
1196 dev_dbg(epn->udc->dev, "ep%u buf unaligned -> fallback pio\n", in usbf_epn_dma_out()
1205 dev_dbg(epn->udc->dev, "ep%u null packet\n", epn->id); in usbf_epn_dma_out()
1216 dev_dbg(epn->udc->dev, "ep%u OUT_INT not set -> spurious\n", in usbf_epn_dma_out()
1224 dev_dbg(epn->udc->dev, "ep%u recv = 0 -> spurious\n", in usbf_epn_dma_out()
1231 dev_dbg(epn->udc->dev, "ep%u recv %u, left %u, mpkt %u\n", epn->id, in usbf_epn_dma_out()
1235 dev_err(epn->udc->dev, "ep%u overflow (%u/%u)\n", in usbf_epn_dma_out()
1243 dev_dbg(epn->udc->dev, "ep%u short packet\n", epn->id); in usbf_epn_dma_out()
1249 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u\n", in usbf_epn_dma_out()
1256 ret = usb_gadget_map_request(&epn->udc->gadget, &req->req, 0); in usbf_epn_dma_out()
1258 dev_err(epn->udc->dev, "map request failed (%d)\n", in usbf_epn_dma_out()
1269 dev_dbg(epn->udc->dev, "ep%u dma short xfer %zu\n", epn->id, in usbf_epn_dma_out()
1276 ret = usb_gadget_map_request(&epn->udc->gadget, &req->req, 0); in usbf_epn_dma_out()
1278 dev_err(epn->udc->dev, "map request failed (%d)\n", in usbf_epn_dma_out()
1295 dev_dbg(epn->udc->dev, "ep%u dma xfer %zu (%u)\n", epn->id, in usbf_epn_dma_out()
1303 dev_dbg(epn->udc->dev, "ep%u dma short not done\n", epn->id); in usbf_epn_dma_out()
1306 dev_dbg(epn->udc->dev, "ep%u dma short done\n", epn->id); in usbf_epn_dma_out()
1310 usb_gadget_unmap_request(&epn->udc->gadget, &req->req, 0); in usbf_epn_dma_out()
1320 dev_dbg(epn->udc->dev, "ep%u recv residue %u\n", epn->id, in usbf_epn_dma_out()
1327 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u\n", epn->id, in usbf_epn_dma_out()
1335 dev_dbg(epn->udc->dev, "ep%u dma not done\n", epn->id); in usbf_epn_dma_out()
1338 dev_dbg(epn->udc->dev, "ep%u dma done\n", epn->id); in usbf_epn_dma_out()
1345 dev_dbg(epn->udc->dev, "ep%u dma xfer done %u\n", epn->id, in usbf_epn_dma_out()
1352 dev_dbg(epn->udc->dev, "ep%u dma stopped by null pckt\n", in usbf_epn_dma_out()
1354 usb_gadget_unmap_request(&epn->udc->gadget, in usbf_epn_dma_out()
1367 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u\n", in usbf_epn_dma_out()
1377 dev_err(epn->udc->dev, in usbf_epn_dma_out()
1381 usb_gadget_unmap_request(&epn->udc->gadget, in usbf_epn_dma_out()
1395 dev_dbg(epn->udc->dev, "ep%u dma short xfer %zu\n", in usbf_epn_dma_out()
1402 usb_gadget_unmap_request(&epn->udc->gadget, &req->req, 0); in usbf_epn_dma_out()
1407 dev_dbg(epn->udc->dev, "ep%u recv residue %u\n", in usbf_epn_dma_out()
1414 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u\n", epn->id, in usbf_epn_dma_out()
1431 dev_dbg(epn->udc->dev, "ep%u bridge transfers done\n", epn->id); in usbf_epn_dma_out()
1438 usb_gadget_unmap_request(&epn->udc->gadget, &req->req, 0); in usbf_epn_dma_out()
1447 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u\n", epn->id, in usbf_epn_dma_out()
1451 dev_dbg(epn->udc->dev, "ep%u recv done %u/%u, wait more data\n", in usbf_epn_dma_out()
1478 dev_dbg(epn->udc->dev, "ep%u %s dma abort\n", epn->id, in usbf_epn_dma_abort()
1485 usb_gadget_unmap_request(&epn->udc->gadget, &req->req, in usbf_epn_dma_abort()
1505 usbf_reg_writel(epn->udc, USBF_REG_AHBBINT, USBF_SYS_DMA_ENDINT_EPN(epn->id)); in usbf_epn_dma_abort()
1508 usbf_reg_bitset(epn->udc, USBF_REG_AHBBINTEN, in usbf_epn_dma_abort()
1521 dev_dbg(epn->udc->dev, "ep%u %s fifo flush\n", epn->id, in usbf_epn_fifo_flush()
1534 dev_err(epn->udc->dev, "ep%u flush fifo timed out\n", epn->id); in usbf_epn_fifo_flush()
1549 dev_dbg(ep->udc->dev, "ep%u %s req done length %u/%u, status=%d\n", ep->id, in usbf_ep_req_done()
1556 spin_unlock(&ep->udc->lock); in usbf_ep_req_done()
1558 spin_lock(&ep->udc->lock); in usbf_ep_req_done()
1565 dev_dbg(ep->udc->dev, "ep%u %s nuke status %d\n", ep->id, in usbf_ep_nuke()
1612 dev_err(epn->udc->dev, in usbf_epn_start_queue()
1666 dev_err(ep->udc->dev, in usbf_ep_process_queue()
1744 dev_dbg(ep->udc->dev, "ep%u %s %s\n", ep->id, in usbf_ep_stall()
1793 ep0->udc->ep0state = EP0_IDLE; in usbf_ep0_enable()
1797 usbf_reg_bitset(ep0->udc, USBF_REG_USB_INT_ENA, USBF_USB_EPN_EN(0)); in usbf_ep0_enable()
1832 struct usbf_udc *udc = ep->udc; in usbf_ep_enable() local
1842 dev_dbg(ep->udc->dev, "ep%u %s mpkts %d\n", ep->id, in usbf_ep_enable()
1846 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_enable()
1857 usbf_reg_bitset(udc, USBF_REG_USB_INT_ENA, USBF_USB_EPN_EN(ep->id)); in usbf_ep_enable()
1862 usbf_reg_bitset(udc, USBF_REG_AHBBINTEN, in usbf_ep_enable()
1868 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_enable()
1889 struct usbf_udc *udc = ep->udc; in usbf_ep_disable() local
1896 dev_dbg(ep->udc->dev, "ep%u %s mpkts %d\n", ep->id, in usbf_ep_disable()
1899 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_disable()
1903 usbf_reg_bitclr(udc, USBF_REG_AHBBINTEN, in usbf_ep_disable()
1908 usbf_reg_bitclr(udc, USBF_REG_USB_INT_ENA, USBF_USB_EPN_EN(ep->id)); in usbf_ep_disable()
1911 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_disable()
1927 if (ep0->udc->ep0state == EP0_IN_STATUS_START_PHASE) in usbf_ep0_queue()
1933 if (ep0->udc->ep0state == EP0_IN_STATUS_PHASE) { in usbf_ep0_queue()
1935 dev_err(ep0->udc->dev, in usbf_ep0_queue()
1945 dev_err(ep0->udc->dev, in usbf_ep0_queue()
1964 dev_err(ep->udc->dev, "ep%u request queue while disable\n", in usbf_epn_queue()
1989 struct usbf_udc *udc = ep->udc; in usbf_ep_queue() local
1996 if (!udc || !udc->driver) in usbf_ep_queue()
1999 dev_dbg(ep->udc->dev, "ep%u %s req queue length %u, zero %u, short_not_ok %u\n", in usbf_ep_queue()
2003 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_queue()
2008 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_queue()
2021 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_dequeue()
2023 dev_dbg(ep->udc->dev, "ep%u %s req dequeue length %u/%u\n", in usbf_ep_dequeue()
2059 ep->udc->ep0state = EP0_IDLE; in usbf_ep_dequeue()
2072 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_dequeue()
2105 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_free_request()
2107 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_free_request()
2120 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_set_halt()
2133 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_set_halt()
2147 spin_lock_irqsave(&ep->udc->lock, flags); in usbf_ep_set_wedge()
2157 spin_unlock_irqrestore(&ep->udc->lock, flags); in usbf_ep_set_wedge()
2182 memcpy(ep0->udc->ep0_buf, buf, length); in usbf_ep0_fill_req()
2184 req->req.buf = ep0->udc->ep0_buf; in usbf_ep0_fill_req()
2194 static struct usbf_ep *usbf_get_ep_by_addr(struct usbf_udc *udc, u8 address) in usbf_get_ep_by_addr() argument
2200 return &udc->ep[0]; in usbf_get_ep_by_addr()
2202 for (i = 1; i < ARRAY_SIZE(udc->ep); i++) { in usbf_get_ep_by_addr()
2203 ep = &udc->ep[i]; in usbf_get_ep_by_addr()
2215 static int usbf_req_delegate(struct usbf_udc *udc, in usbf_req_delegate() argument
2220 spin_unlock(&udc->lock); in usbf_req_delegate()
2221 ret = udc->driver->setup(&udc->gadget, ctrlrequest); in usbf_req_delegate()
2222 spin_lock(&udc->lock); in usbf_req_delegate()
2224 dev_dbg(udc->dev, "udc driver setup failed %d\n", ret); in usbf_req_delegate()
2228 dev_dbg(udc->dev, "delayed status set\n"); in usbf_req_delegate()
2229 udc->ep[0].delayed_status = 1; in usbf_req_delegate()
2235 static int usbf_req_get_status(struct usbf_udc *udc, in usbf_req_get_status() argument
2254 if (udc->gadget.is_selfpowered) in usbf_req_get_status()
2257 if (udc->is_remote_wakeup) in usbf_req_get_status()
2266 ep = usbf_get_ep_by_addr(udc, wIndex); in usbf_req_get_status()
2285 usbf_ep0_fill_req(&udc->ep[0], &udc->setup_reply, &status_data, in usbf_req_get_status()
2287 usbf_ep0_queue(&udc->ep[0], &udc->setup_reply, GFP_ATOMIC); in usbf_req_get_status()
2292 return usbf_req_delegate(udc, ctrlrequest); in usbf_req_get_status()
2295 static int usbf_req_clear_set_feature(struct usbf_udc *udc, in usbf_req_clear_set_feature() argument
2316 udc->is_remote_wakeup = is_set; in usbf_req_clear_set_feature()
2323 ep = usbf_get_ep_by_addr(udc, wIndex); in usbf_req_clear_set_feature()
2350 return usbf_req_delegate(udc, ctrlrequest); in usbf_req_clear_set_feature()
2361 usb_gadget_set_state(&ep->udc->gadget, USB_STATE_ADDRESS); in usbf_ep0_req_set_address_complete()
2370 static int usbf_req_set_address(struct usbf_udc *udc, in usbf_req_set_address() argument
2393 usbf_reg_writel(udc, USBF_REG_USB_ADDRESS, USBF_USB_SET_USB_ADDR(addr)); in usbf_req_set_address()
2396 usbf_ep0_fill_req(&udc->ep[0], &udc->setup_reply, NULL, 0, in usbf_req_set_address()
2398 usbf_ep0_queue(&udc->ep[0], &udc->setup_reply, GFP_ATOMIC); in usbf_req_set_address()
2403 return usbf_req_delegate(udc, ctrlrequest); in usbf_req_set_address()
2406 static int usbf_req_set_configuration(struct usbf_udc *udc, in usbf_req_set_configuration() argument
2414 ret = usbf_req_delegate(udc, ctrlrequest); in usbf_req_set_configuration()
2432 usbf_reg_bitset(udc, USBF_REG_USB_CONTROL, USBF_USB_CONF); in usbf_req_set_configuration()
2434 usbf_reg_bitclr(udc, USBF_REG_USB_CONTROL, USBF_USB_CONF); in usbf_req_set_configuration()
2436 spin_unlock(&udc->lock); in usbf_req_set_configuration()
2437 usb_gadget_set_state(&udc->gadget, USB_STATE_ADDRESS); in usbf_req_set_configuration()
2438 spin_lock(&udc->lock); in usbf_req_set_configuration()
2450 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_setup() local
2454 crq.raw[0] = usbf_reg_readl(udc, USBF_REG_SETUP_DATA0); in usbf_handle_ep0_setup()
2455 crq.raw[1] = usbf_reg_readl(udc, USBF_REG_SETUP_DATA1); in usbf_handle_ep0_setup()
2457 dev_dbg(ep0->udc->dev, in usbf_handle_ep0_setup()
2465 udc->ep0state = EP0_IN_DATA_PHASE; in usbf_handle_ep0_setup()
2471 udc->ep0state = EP0_OUT_DATA_PHASE; in usbf_handle_ep0_setup()
2477 udc->ep0state = EP0_IN_STATUS_START_PHASE; in usbf_handle_ep0_setup()
2491 ret = usbf_req_get_status(udc, &crq.ctrlreq); in usbf_handle_ep0_setup()
2495 ret = usbf_req_clear_set_feature(udc, &crq.ctrlreq, false); in usbf_handle_ep0_setup()
2499 ret = usbf_req_clear_set_feature(udc, &crq.ctrlreq, true); in usbf_handle_ep0_setup()
2503 ret = usbf_req_set_address(udc, &crq.ctrlreq); in usbf_handle_ep0_setup()
2507 ret = usbf_req_set_configuration(udc, &crq.ctrlreq); in usbf_handle_ep0_setup()
2517 return usbf_req_delegate(udc, &crq.ctrlreq); in usbf_handle_ep0_setup()
2524 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_data_status() local
2530 dev_err(udc->dev, in usbf_handle_ep0_data_status()
2540 udc->ep0state = next_ep0state; in usbf_handle_ep0_data_status()
2543 dev_err(udc->dev, in usbf_handle_ep0_data_status()
2553 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_out_status_start() local
2563 usbf_ep0_fill_req(ep0, &udc->setup_reply, NULL, 0, NULL); in usbf_handle_ep0_out_status_start()
2564 usbf_ep0_queue(ep0, &udc->setup_reply, GFP_ATOMIC); in usbf_handle_ep0_out_status_start()
2567 dev_err(udc->dev, in usbf_handle_ep0_out_status_start()
2572 udc->ep0state = EP0_OUT_STATUS_PHASE; in usbf_handle_ep0_out_status_start()
2578 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_in_status_start() local
2591 dev_dbg(ep0->udc->dev, in usbf_handle_ep0_in_status_start()
2593 udc->ep0state = EP0_IN_STATUS_PHASE; in usbf_handle_ep0_in_status_start()
2597 usbf_ep0_fill_req(ep0, &udc->setup_reply, NULL, in usbf_handle_ep0_in_status_start()
2599 usbf_ep0_queue(ep0, &udc->setup_reply, in usbf_handle_ep0_in_status_start()
2605 dev_err(udc->dev, in usbf_handle_ep0_in_status_start()
2614 udc->ep0state = EP0_IN_STATUS_END_PHASE; in usbf_handle_ep0_in_status_start()
2618 udc->ep0state = EP0_IN_STATUS_PHASE; in usbf_handle_ep0_in_status_start()
2624 struct usbf_udc *udc = ep0->udc; in usbf_ep0_interrupt() local
2632 dev_dbg(ep0->udc->dev, "ep0 status=0x%08x, enable=%08x\n, ctrl=0x%08x\n", in usbf_ep0_interrupt()
2643 dev_dbg(ep0->udc->dev, "udc->ep0state=%d\n", udc->ep0state); in usbf_ep0_interrupt()
2646 prev_ep0state = udc->ep0state; in usbf_ep0_interrupt()
2647 switch (udc->ep0state) { in usbf_ep0_interrupt()
2653 dev_dbg(ep0->udc->dev, "ep0 handle setup\n"); in usbf_ep0_interrupt()
2662 dev_dbg(ep0->udc->dev, "ep0 handle in data phase\n"); in usbf_ep0_interrupt()
2672 dev_dbg(ep0->udc->dev, "ep0 handle out status start phase\n"); in usbf_ep0_interrupt()
2681 dev_dbg(ep0->udc->dev, "ep0 handle out status phase\n"); in usbf_ep0_interrupt()
2692 dev_dbg(ep0->udc->dev, "ep0 handle out status end phase\n"); in usbf_ep0_interrupt()
2693 udc->ep0state = EP0_IDLE; in usbf_ep0_interrupt()
2701 dev_dbg(ep0->udc->dev, "ep0 handle out data phase\n"); in usbf_ep0_interrupt()
2711 dev_dbg(ep0->udc->dev, "ep0 handle in status start phase\n"); in usbf_ep0_interrupt()
2720 dev_dbg(ep0->udc->dev, "ep0 handle in status phase\n"); in usbf_ep0_interrupt()
2730 dev_dbg(ep0->udc->dev, "ep0 handle in status end\n"); in usbf_ep0_interrupt()
2731 udc->ep0state = EP0_IDLE; in usbf_ep0_interrupt()
2735 udc->ep0state = EP0_IDLE; in usbf_ep0_interrupt()
2740 dev_dbg(ep0->udc->dev, "ep0 failed (%d)\n", ret); in usbf_ep0_interrupt()
2750 udc->ep0state = EP0_IDLE; in usbf_ep0_interrupt()
2754 } while ((prev_ep0state != udc->ep0state) || (prev_sts != sts)); in usbf_ep0_interrupt()
2756 dev_dbg(ep0->udc->dev, "ep0 done udc->ep0state=%d, status=0x%08x. next=0x%08x\n", in usbf_ep0_interrupt()
2757 udc->ep0state, sts, in usbf_ep0_interrupt()
2768 dev_warn(epn->udc->dev, "ep%u %s, no request available\n", in usbf_epn_process_queue()
2779 dev_err(epn->udc->dev, "ep%u %s, process queue failed (%d)\n", in usbf_epn_process_queue()
2785 dev_dbg(epn->udc->dev, "ep%u %s failed (%d)\n", epn->id, in usbf_epn_process_queue()
2801 dev_dbg(epn->udc->dev, "ep%u %s status=0x%08x, enable=%08x\n, ctrl=0x%08x\n", in usbf_epn_interrupt()
2806 dev_warn(epn->udc->dev, "ep%u %s, interrupt while disabled\n", in usbf_epn_interrupt()
2815 dev_dbg(epn->udc->dev, "ep%u %s process queue (in interrupts)\n", in usbf_epn_interrupt()
2822 dev_dbg(epn->udc->dev, "ep%u %s process queue (out interrupts)\n", in usbf_epn_interrupt()
2827 dev_dbg(epn->udc->dev, "ep%u %s done status=0x%08x. next=0x%08x\n", in usbf_epn_interrupt()
2839 static void usbf_reset(struct usbf_udc *udc) in usbf_reset() argument
2843 for (i = 0; i < ARRAY_SIZE(udc->ep); i++) { in usbf_reset()
2844 if (udc->ep[i].disabled) in usbf_reset()
2847 usbf_ep_reset(&udc->ep[i]); in usbf_reset()
2850 if (usbf_reg_readl(udc, USBF_REG_USB_STATUS) & USBF_USB_SPEED_MODE) in usbf_reset()
2851 udc->gadget.speed = USB_SPEED_HIGH; in usbf_reset()
2853 udc->gadget.speed = USB_SPEED_FULL; in usbf_reset()
2856 udc->is_remote_wakeup = false; in usbf_reset()
2859 usbf_ep0_enable(&udc->ep[0]); in usbf_reset()
2861 if (udc->driver) { in usbf_reset()
2863 spin_unlock(&udc->lock); in usbf_reset()
2864 usb_gadget_udc_reset(&udc->gadget, udc->driver); in usbf_reset()
2865 spin_lock(&udc->lock); in usbf_reset()
2869 static void usbf_driver_suspend(struct usbf_udc *udc) in usbf_driver_suspend() argument
2871 if (udc->is_usb_suspended) { in usbf_driver_suspend()
2872 dev_dbg(udc->dev, "already suspended\n"); in usbf_driver_suspend()
2876 dev_dbg(udc->dev, "do usb suspend\n"); in usbf_driver_suspend()
2877 udc->is_usb_suspended = true; in usbf_driver_suspend()
2879 if (udc->driver && udc->driver->suspend) { in usbf_driver_suspend()
2880 spin_unlock(&udc->lock); in usbf_driver_suspend()
2881 udc->driver->suspend(&udc->gadget); in usbf_driver_suspend()
2882 spin_lock(&udc->lock); in usbf_driver_suspend()
2894 static void usbf_driver_resume(struct usbf_udc *udc) in usbf_driver_resume() argument
2896 if (!udc->is_usb_suspended) in usbf_driver_resume()
2899 dev_dbg(udc->dev, "do usb resume\n"); in usbf_driver_resume()
2900 udc->is_usb_suspended = false; in usbf_driver_resume()
2902 if (udc->driver && udc->driver->resume) { in usbf_driver_resume()
2903 spin_unlock(&udc->lock); in usbf_driver_resume()
2904 udc->driver->resume(&udc->gadget); in usbf_driver_resume()
2905 spin_lock(&udc->lock); in usbf_driver_resume()
2911 struct usbf_udc *udc = (struct usbf_udc *)_udc; in usbf_epc_irq() local
2918 spin_lock_irqsave(&udc->lock, flags); in usbf_epc_irq()
2920 int_en = usbf_reg_readl(udc, USBF_REG_USB_INT_ENA); in usbf_epc_irq()
2921 int_sts = usbf_reg_readl(udc, USBF_REG_USB_INT_STA) & int_en; in usbf_epc_irq()
2922 usbf_reg_writel(udc, USBF_REG_USB_INT_STA, ~int_sts); in usbf_epc_irq()
2924 dev_dbg(udc->dev, "int_sts=0x%08x\n", int_sts); in usbf_epc_irq()
2927 dev_dbg(udc->dev, "handle resume\n"); in usbf_epc_irq()
2928 usbf_driver_resume(udc); in usbf_epc_irq()
2932 dev_dbg(udc->dev, "handle bus reset\n"); in usbf_epc_irq()
2933 usbf_driver_resume(udc); in usbf_epc_irq()
2934 usbf_reset(udc); in usbf_epc_irq()
2938 if (usbf_reg_readl(udc, USBF_REG_USB_STATUS) & USBF_USB_SPEED_MODE) in usbf_epc_irq()
2939 udc->gadget.speed = USB_SPEED_HIGH; in usbf_epc_irq()
2941 udc->gadget.speed = USB_SPEED_FULL; in usbf_epc_irq()
2942 dev_dbg(udc->dev, "handle speed change (%s)\n", in usbf_epc_irq()
2943 udc->gadget.speed == USB_SPEED_HIGH ? "High" : "Full"); in usbf_epc_irq()
2947 usbf_driver_resume(udc); in usbf_epc_irq()
2948 usbf_ep0_interrupt(&udc->ep[0]); in usbf_epc_irq()
2951 for (i = 1; i < ARRAY_SIZE(udc->ep); i++) { in usbf_epc_irq()
2952 ep = &udc->ep[i]; in usbf_epc_irq()
2955 usbf_driver_resume(udc); in usbf_epc_irq()
2961 dev_dbg(udc->dev, "handle suspend\n"); in usbf_epc_irq()
2962 usbf_driver_suspend(udc); in usbf_epc_irq()
2965 spin_unlock_irqrestore(&udc->lock, flags); in usbf_epc_irq()
2972 struct usbf_udc *udc = (struct usbf_udc *)_udc; in usbf_ahb_epc_irq() local
2979 spin_lock_irqsave(&udc->lock, flags); in usbf_ahb_epc_irq()
2982 sysbint = usbf_reg_readl(udc, USBF_REG_AHBBINT); in usbf_ahb_epc_irq()
2983 usbf_reg_writel(udc, USBF_REG_AHBBINT, sysbint); in usbf_ahb_epc_irq()
2986 if (usbf_reg_readl(udc, USBF_REG_EPCTR) & USBF_SYS_VBUS_LEVEL) { in usbf_ahb_epc_irq()
2987 dev_dbg(udc->dev, "handle vbus (1)\n"); in usbf_ahb_epc_irq()
2988 spin_unlock(&udc->lock); in usbf_ahb_epc_irq()
2989 usb_udc_vbus_handler(&udc->gadget, true); in usbf_ahb_epc_irq()
2990 usb_gadget_set_state(&udc->gadget, USB_STATE_POWERED); in usbf_ahb_epc_irq()
2991 spin_lock(&udc->lock); in usbf_ahb_epc_irq()
2993 dev_dbg(udc->dev, "handle vbus (0)\n"); in usbf_ahb_epc_irq()
2994 udc->is_usb_suspended = false; in usbf_ahb_epc_irq()
2995 spin_unlock(&udc->lock); in usbf_ahb_epc_irq()
2996 usb_udc_vbus_handler(&udc->gadget, false); in usbf_ahb_epc_irq()
2997 usb_gadget_set_state(&udc->gadget, in usbf_ahb_epc_irq()
2999 spin_lock(&udc->lock); in usbf_ahb_epc_irq()
3003 for (i = 1; i < ARRAY_SIZE(udc->ep); i++) { in usbf_ahb_epc_irq()
3005 epn = &udc->ep[i]; in usbf_ahb_epc_irq()
3006 dev_dbg(epn->udc->dev, in usbf_ahb_epc_irq()
3017 spin_unlock_irqrestore(&udc->lock, flags); in usbf_ahb_epc_irq()
3025 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_udc_start() local
3028 dev_info(udc->dev, "start (driver '%s')\n", driver->driver.name); in usbf_udc_start()
3030 spin_lock_irqsave(&udc->lock, flags); in usbf_udc_start()
3033 udc->driver = driver; in usbf_udc_start()
3036 usbf_reg_writel(udc, USBF_REG_AHBBINTEN, USBF_SYS_VBUS_INTEN); in usbf_udc_start()
3038 spin_unlock_irqrestore(&udc->lock, flags); in usbf_udc_start()
3045 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_udc_stop() local
3048 spin_lock_irqsave(&udc->lock, flags); in usbf_udc_stop()
3051 usbf_reg_writel(udc, USBF_REG_AHBBINTEN, 0); in usbf_udc_stop()
3053 udc->driver = NULL; in usbf_udc_stop()
3055 spin_unlock_irqrestore(&udc->lock, flags); in usbf_udc_stop()
3057 dev_info(udc->dev, "stopped\n"); in usbf_udc_stop()
3064 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_get_frame() local
3066 return USBF_USB_GET_FRAME(usbf_reg_readl(udc, USBF_REG_USB_ADDRESS)); in usbf_get_frame()
3069 static void usbf_attach(struct usbf_udc *udc) in usbf_attach() argument
3077 usbf_reg_clrset(udc, USBF_REG_USB_CONTROL, in usbf_attach()
3082 usbf_reg_bitset(udc, USBF_REG_USB_INT_ENA, in usbf_attach()
3086 static void usbf_detach(struct usbf_udc *udc) in usbf_detach() argument
3091 usbf_reg_writel(udc, USBF_REG_USB_INT_ENA, 0); in usbf_detach()
3093 for (i = 0; i < ARRAY_SIZE(udc->ep); i++) { in usbf_detach()
3094 if (udc->ep[i].disabled) in usbf_detach()
3097 usbf_ep_reset(&udc->ep[i]); in usbf_detach()
3105 usbf_reg_clrset(udc, USBF_REG_USB_CONTROL, in usbf_detach()
3112 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_pullup() local
3115 dev_dbg(udc->dev, "pullup %d\n", is_on); in usbf_pullup()
3117 spin_lock_irqsave(&udc->lock, flags); in usbf_pullup()
3119 usbf_attach(udc); in usbf_pullup()
3121 usbf_detach(udc); in usbf_pullup()
3122 spin_unlock_irqrestore(&udc->lock, flags); in usbf_pullup()
3130 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_udc_set_selfpowered() local
3133 spin_lock_irqsave(&udc->lock, flags); in usbf_udc_set_selfpowered()
3135 spin_unlock_irqrestore(&udc->lock, flags); in usbf_udc_set_selfpowered()
3142 struct usbf_udc *udc = container_of(gadget, struct usbf_udc, gadget); in usbf_udc_wakeup() local
3146 spin_lock_irqsave(&udc->lock, flags); in usbf_udc_wakeup()
3148 if (!udc->is_remote_wakeup) { in usbf_udc_wakeup()
3149 dev_dbg(udc->dev, "remote wakeup not allowed\n"); in usbf_udc_wakeup()
3154 dev_dbg(udc->dev, "do wakeup\n"); in usbf_udc_wakeup()
3157 usbf_reg_bitset(udc, USBF_REG_USB_CONTROL, USBF_USB_RSUM_IN); in usbf_udc_wakeup()
3158 usbf_reg_bitclr(udc, USBF_REG_USB_CONTROL, USBF_USB_RSUM_IN); in usbf_udc_wakeup()
3162 spin_unlock_irqrestore(&udc->lock, flags); in usbf_udc_wakeup()
3189 dev_err(epn->udc->dev, in usbf_epn_check()
3198 dev_err(epn->udc->dev, in usbf_epn_check()
3207 dev_err(epn->udc->dev, in usbf_epn_check()
3214 dev_err(epn->udc->dev, "ep%u unknown type\n", epn->id); in usbf_epn_check()
3222 dev_err(epn->udc->dev, in usbf_epn_check()
3230 dev_err(epn->udc->dev, in usbf_epn_check()
3237 dev_dbg(epn->udc->dev, "ep%u (%s) %s, %s buffer %u, checked %s\n", in usbf_epn_check()
3247 struct usbf_udc *udc; in usbf_probe() local
3253 udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL); in usbf_probe()
3254 if (!udc) in usbf_probe()
3256 platform_set_drvdata(pdev, udc); in usbf_probe()
3258 udc->dev = dev; in usbf_probe()
3259 spin_lock_init(&udc->lock); in usbf_probe()
3261 udc->regs = devm_platform_ioremap_resource(pdev, 0); in usbf_probe()
3262 if (IS_ERR(udc->regs)) in usbf_probe()
3263 return PTR_ERR(udc->regs); in usbf_probe()
3271 usbf_reg_readl(udc, USBF_REG_USBSSVER)); in usbf_probe()
3276 usbf_reg_bitclr(udc, USBF_REG_EPCTR, USBF_SYS_EPC_RST); in usbf_probe()
3279 udc->gadget.speed = USB_SPEED_FULL; in usbf_probe()
3280 udc->gadget.max_speed = USB_SPEED_HIGH; in usbf_probe()
3281 udc->gadget.ops = &usbf_gadget_ops; in usbf_probe()
3283 udc->gadget.name = dev->driver->name; in usbf_probe()
3284 udc->gadget.dev.parent = dev; in usbf_probe()
3285 udc->gadget.ep0 = &udc->ep[0].ep; in usbf_probe()
3290 udc->gadget.quirk_avoids_skb_reserve = 1; in usbf_probe()
3292 INIT_LIST_HEAD(&udc->gadget.ep_list); in usbf_probe()
3296 INIT_LIST_HEAD(&udc->setup_reply.queue); in usbf_probe()
3298 for (i = 0; i < ARRAY_SIZE(udc->ep); i++) { in usbf_probe()
3299 ep = &udc->ep[i]; in usbf_probe()
3301 if (!(usbf_reg_readl(udc, USBF_REG_USBSSCONF) & in usbf_probe()
3310 ep->udc = udc; in usbf_probe()
3318 ep->regs = ep->udc->regs + USBF_BASE_EP0; in usbf_probe()
3320 ep->regs = ep->udc->regs + USBF_BASE_EPN(ep->id - 1); in usbf_probe()
3324 if (usbf_reg_readl(udc, USBF_REG_USBSSCONF) & in usbf_probe()
3326 ep->dma_regs = ep->udc->regs + in usbf_probe()
3329 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in usbf_probe()
3336 ret = devm_request_irq(dev, irq, usbf_epc_irq, 0, "usbf-epc", udc); in usbf_probe()
3345 ret = devm_request_irq(dev, irq, usbf_ahb_epc_irq, 0, "usbf-ahb-epc", udc); in usbf_probe()
3351 usbf_reg_bitset(udc, USBF_REG_AHBMCTR, USBF_SYS_WBURST_TYPE); in usbf_probe()
3353 usbf_reg_bitset(udc, USBF_REG_USB_CONTROL, in usbf_probe()
3356 ret = usb_add_gadget_udc(dev, &udc->gadget); in usbf_probe()
3365 struct usbf_udc *udc = platform_get_drvdata(pdev); in usbf_remove() local
3367 usb_del_gadget_udc(&udc->gadget); in usbf_remove()