Lines Matching full:ep0
75 /* EP0 registers offsets from Base + USBF_BASE_EP0 (EP0 regs area) */
313 /* for EP0 control messages */
344 /* ep0: buf @0x0000 64 bytes, fixed 32 words */
345 [0] = USBF_EP_INFO("ep0-ctrl",
547 static void usbf_ep0_send_null(struct usbf_ep *ep0, bool is_data1) in usbf_ep0_send_null() argument
555 usbf_ep_reg_bitset(ep0, USBF_REG_EP0_CONTROL, set); in usbf_ep0_send_null()
558 static int usbf_ep0_pio_in(struct usbf_ep *ep0, struct usbf_req *req) in usbf_ep0_pio_in() argument
571 dev_dbg(ep0->udc->dev, "ep0 send null\n"); in usbf_ep0_pio_in()
572 usbf_ep0_send_null(ep0, false); in usbf_ep0_pio_in()
576 if ((req->req.actual % ep0->ep.maxpacket) == 0) { in usbf_ep0_pio_in()
578 dev_dbg(ep0->udc->dev, "ep0 send null\n"); in usbf_ep0_pio_in()
579 usbf_ep0_send_null(ep0, false); in usbf_ep0_pio_in()
588 if (left > ep0->ep.maxpacket) in usbf_ep0_pio_in()
589 left = ep0->ep.maxpacket; in usbf_ep0_pio_in()
596 usbf_ep_reg_write_rep(ep0, USBF_REG_EP0_WRITE, buf, nb); in usbf_ep0_pio_in()
601 ctrl = usbf_ep_reg_readl(ep0, USBF_REG_EP0_CONTROL); in usbf_ep0_pio_in()
605 usbf_ep_reg_writel(ep0, USBF_REG_EP0_WRITE, last); in usbf_ep0_pio_in()
609 usbf_ep_reg_writel(ep0, USBF_REG_EP0_CONTROL, ctrl | USBF_EP0_DEND); in usbf_ep0_pio_in()
611 dev_dbg(ep0->udc->dev, "ep0 send %u/%u\n", in usbf_ep0_pio_in()
617 static int usbf_ep0_pio_out(struct usbf_ep *ep0, struct usbf_req *req) in usbf_ep0_pio_out() argument
627 if (ep0->status & USBF_EP0_OUT_INT) { in usbf_ep0_pio_out()
628 recv = usbf_ep_reg_readl(ep0, USBF_REG_EP0_LENGTH) & USBF_EP0_LDATA; in usbf_ep0_pio_out()
636 dev_dbg(ep0->udc->dev, "ep0 recv %u, left %u\n", count, left); in usbf_ep0_pio_out()
638 if (left > ep0->ep.maxpacket) in usbf_ep0_pio_out()
639 left = ep0->ep.maxpacket; in usbf_ep0_pio_out()
649 usbf_ep_reg_read_rep(ep0, USBF_REG_EP0_READ, in usbf_ep0_pio_out()
656 last = usbf_ep_reg_readl(ep0, USBF_REG_EP0_READ); 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()
670 if (recv < ep0->ep.maxpacket) { in usbf_ep0_pio_out()
671 dev_dbg(ep0->udc->dev, "ep0 short packet\n"); in usbf_ep0_pio_out()
689 if (ep0->status & USBF_EP0_OUT_NULL_INT) { in usbf_ep0_pio_out()
691 dev_dbg(ep0->udc->dev, "ep0 null packet\n"); in usbf_ep0_pio_out()
704 static void usbf_ep0_fifo_flush(struct usbf_ep *ep0) in usbf_ep0_fifo_flush() argument
709 usbf_ep_reg_bitset(ep0, USBF_REG_EP0_CONTROL, USBF_EP0_BCLR); in usbf_ep0_fifo_flush()
711 ret = readl_poll_timeout_atomic(ep0->regs + USBF_REG_EP0_STATUS, sts, in usbf_ep0_fifo_flush()
715 dev_err(ep0->udc->dev, "ep0 flush fifo timed out\n"); in usbf_ep0_fifo_flush()
1785 static void usbf_ep0_enable(struct usbf_ep *ep0) in usbf_ep0_enable() argument
1787 usbf_ep_reg_writel(ep0, USBF_REG_EP0_CONTROL, USBF_EP0_INAK_EN | USBF_EP0_BCLR); in usbf_ep0_enable()
1789 usbf_ep_reg_writel(ep0, USBF_REG_EP0_INT_ENA, in usbf_ep0_enable()
1793 ep0->udc->ep0state = EP0_IDLE; in usbf_ep0_enable()
1794 ep0->disabled = 0; in usbf_ep0_enable()
1796 /* enable interrupts for the ep0 */ in usbf_ep0_enable()
1797 usbf_reg_bitset(ep0->udc, USBF_REG_USB_INT_ENA, USBF_USB_EPN_EN(0)); in usbf_ep0_enable()
1916 static int usbf_ep0_queue(struct usbf_ep *ep0, struct usbf_req *req, in usbf_ep0_queue() argument
1925 list_add_tail(&req->queue, &ep0->queue); in usbf_ep0_queue()
1927 if (ep0->udc->ep0state == EP0_IN_STATUS_START_PHASE) in usbf_ep0_queue()
1930 if (!ep0->is_in) 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()
1936 "request lng %u for ep0 in status phase\n", in usbf_ep0_queue()
1940 ep0->delayed_status = 0; in usbf_ep0_queue()
1942 if (!ep0->is_processing) { in usbf_ep0_queue()
1943 ret = usbf_ep0_pio_in(ep0, req); in usbf_ep0_queue()
1945 dev_err(ep0->udc->dev, in usbf_ep0_queue()
2049 /* We dequeue a request on ep0. On this endpoint, we can have in usbf_ep_dequeue()
2176 static void usbf_ep0_fill_req(struct usbf_ep *ep0, struct usbf_req *req, in usbf_ep0_fill_req() argument
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()
2329 * Returning an error code leads to a STALL on this ep0 in usbf_req_clear_set_feature()
2444 static int usbf_handle_ep0_setup(struct usbf_ep *ep0) in usbf_handle_ep0_setup() argument
2450 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_setup()
2457 dev_dbg(ep0->udc->dev, in usbf_handle_ep0_setup()
2458 "ep0 req%02x.%02x, wValue 0x%04x, wIndex 0x%04x, wLength 0x%04x\n", in usbf_handle_ep0_setup()
2462 /* Set current EP0 state according to the received request */ in usbf_handle_ep0_setup()
2466 usbf_ep_reg_clrset(ep0, USBF_REG_EP0_CONTROL, in usbf_handle_ep0_setup()
2469 ep0->is_in = 1; in usbf_handle_ep0_setup()
2472 usbf_ep_reg_bitclr(ep0, USBF_REG_EP0_CONTROL, in usbf_handle_ep0_setup()
2474 ep0->is_in = 0; in usbf_handle_ep0_setup()
2478 ep0->is_in = 1; in usbf_handle_ep0_setup()
2482 ep0->delayed_status = 0; in usbf_handle_ep0_setup()
2520 static int usbf_handle_ep0_data_status(struct usbf_ep *ep0, in usbf_handle_ep0_data_status() argument
2524 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_data_status()
2527 ret = usbf_ep_process_queue(ep0); in usbf_handle_ep0_data_status()
2531 "no request available for ep0 %s phase\n", in usbf_handle_ep0_data_status()
2544 "process queue failed for ep0 %s phase (%d)\n", in usbf_handle_ep0_data_status()
2551 static int usbf_handle_ep0_out_status_start(struct usbf_ep *ep0) in usbf_handle_ep0_out_status_start() argument
2553 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_out_status_start()
2556 usbf_ep_reg_clrset(ep0, USBF_REG_EP0_CONTROL, in usbf_handle_ep0_out_status_start()
2559 ep0->is_in = 0; in usbf_handle_ep0_out_status_start()
2561 req = list_first_entry_or_null(&ep0->queue, struct usbf_req, queue); in usbf_handle_ep0_out_status_start()
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()
2568 "queued request length %u for ep0 out status phase\n", in usbf_handle_ep0_out_status_start()
2576 static int usbf_handle_ep0_in_status_start(struct usbf_ep *ep0) in usbf_handle_ep0_in_status_start() argument
2578 struct usbf_udc *udc = ep0->udc; in usbf_handle_ep0_in_status_start()
2582 usbf_ep_reg_clrset(ep0, USBF_REG_EP0_CONTROL, in usbf_handle_ep0_in_status_start()
2585 ep0->is_in = 1; in usbf_handle_ep0_in_status_start()
2588 req = list_first_entry_or_null(&ep0->queue, struct usbf_req, queue); in usbf_handle_ep0_in_status_start()
2590 if (ep0->delayed_status) { in usbf_handle_ep0_in_status_start()
2591 dev_dbg(ep0->udc->dev, in usbf_handle_ep0_in_status_start()
2592 "EP0_IN_STATUS_START_PHASE ep0->delayed_status set\n"); 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()
2602 req = list_first_entry_or_null(&ep0->queue, struct usbf_req, queue); in usbf_handle_ep0_in_status_start()
2606 "queued request length %u for ep0 in status phase\n", in usbf_handle_ep0_in_status_start()
2611 ret = usbf_ep0_pio_in(ep0, req); in usbf_handle_ep0_in_status_start()
2613 usbf_ep_req_done(ep0, req, ret); in usbf_handle_ep0_in_status_start()
2622 static void usbf_ep0_interrupt(struct usbf_ep *ep0) in usbf_ep0_interrupt() argument
2624 struct usbf_udc *udc = ep0->udc; in usbf_ep0_interrupt()
2629 ep0->status = usbf_ep_reg_readl(ep0, USBF_REG_EP0_STATUS); in usbf_ep0_interrupt()
2630 usbf_ep_reg_writel(ep0, USBF_REG_EP0_STATUS, ~ep0->status); in usbf_ep0_interrupt()
2632 dev_dbg(ep0->udc->dev, "ep0 status=0x%08x, enable=%08x\n, ctrl=0x%08x\n", in usbf_ep0_interrupt()
2633 ep0->status, in usbf_ep0_interrupt()
2634 usbf_ep_reg_readl(ep0, USBF_REG_EP0_INT_ENA), in usbf_ep0_interrupt()
2635 usbf_ep_reg_readl(ep0, USBF_REG_EP0_CONTROL)); in usbf_ep0_interrupt()
2637 sts = ep0->status & (USBF_EP0_SETUP_INT | USBF_EP0_IN_INT | USBF_EP0_OUT_INT | in usbf_ep0_interrupt()
2643 dev_dbg(ep0->udc->dev, "udc->ep0state=%d\n", udc->ep0state); in usbf_ep0_interrupt()
2653 dev_dbg(ep0->udc->dev, "ep0 handle setup\n"); in usbf_ep0_interrupt()
2654 ret = usbf_handle_ep0_setup(ep0); in usbf_ep0_interrupt()
2662 dev_dbg(ep0->udc->dev, "ep0 handle in data phase\n"); in usbf_ep0_interrupt()
2663 ret = usbf_handle_ep0_data_status(ep0, in usbf_ep0_interrupt()
2672 dev_dbg(ep0->udc->dev, "ep0 handle out status start phase\n"); in usbf_ep0_interrupt()
2673 ret = usbf_handle_ep0_out_status_start(ep0); in usbf_ep0_interrupt()
2681 dev_dbg(ep0->udc->dev, "ep0 handle out status phase\n"); in usbf_ep0_interrupt()
2682 ret = usbf_handle_ep0_data_status(ep0, in usbf_ep0_interrupt()
2692 dev_dbg(ep0->udc->dev, "ep0 handle out status end phase\n"); in usbf_ep0_interrupt()
2701 dev_dbg(ep0->udc->dev, "ep0 handle out data phase\n"); in usbf_ep0_interrupt()
2702 ret = usbf_handle_ep0_data_status(ep0, in usbf_ep0_interrupt()
2711 dev_dbg(ep0->udc->dev, "ep0 handle in status start phase\n"); in usbf_ep0_interrupt()
2712 ret = usbf_handle_ep0_in_status_start(ep0); in usbf_ep0_interrupt()
2720 dev_dbg(ep0->udc->dev, "ep0 handle in status phase\n"); in usbf_ep0_interrupt()
2721 ret = usbf_handle_ep0_data_status(ep0, in usbf_ep0_interrupt()
2730 dev_dbg(ep0->udc->dev, "ep0 handle in status end\n"); in usbf_ep0_interrupt()
2740 dev_dbg(ep0->udc->dev, "ep0 failed (%d)\n", ret); in usbf_ep0_interrupt()
2745 usbf_ep_stall(ep0, true); in usbf_ep0_interrupt()
2748 usbf_ep_nuke(ep0, -EPROTO); 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()
2758 usbf_ep_reg_readl(ep0, USBF_REG_EP0_STATUS)); in usbf_ep0_interrupt()
3285 udc->gadget.ep0 = &udc->ep[0].ep; in usbf_probe()