Lines Matching refs:epn
5 * epn.c - Generic endpoints management
63 if (ep->epn.is_in) {
67 writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
69 if (ep->epn.is_in)
71 writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
77 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
79 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
90 stat = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
96 stat, ep->epn.is_in, req, req ? req->active : 0);
122 if (!req->req.dma && !ep->epn.is_in && len) {
164 return (ep->epn.d_last + AST_VHUB_DESCS_COUNT - ep->epn.d_next - 1) &
184 act, len, ep->epn.chunk_max, ast_vhub_count_free_descs(ep));
191 d_num = ep->epn.d_next;
192 desc = &ep->epn.descs[d_num];
193 ep->epn.d_next = (d_num + 1) & (AST_VHUB_DESCS_COUNT - 1);
197 if (chunk <= ep->epn.chunk_max) {
209 chunk = ep->epn.chunk_max;
241 writel(VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next),
242 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
245 ep->epn.d_next, readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS));
256 stat = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
257 stat1 = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
267 stat, ep->epn.is_in, ep->epn.d_last, d_last);
270 while (ep->epn.d_last != d_last) {
276 d_num = ep->epn.d_last;
277 desc = &ep->epn.descs[d_num];
278 ep->epn.d_last = (d_num + 1) & (AST_VHUB_DESCS_COUNT - 1);
309 CHECK(ep, d_last == ep->epn.d_last,
311 d_last, ep->epn.d_last);
329 if (ep->epn.desc_mode)
356 if (!ep->epn.enabled || !u_ep->desc || !ep->dev || !ep->d_idx ||
378 if (ep->epn.desc_mode ||
380 (ep->epn.is_in || !(u_req->length & (u_ep->maxpacket - 1))))) {
382 ep->epn.is_in);
395 ep->epn.is_in);
409 if (ep->epn.desc_mode)
425 if (ep->epn.desc_mode)
426 writel(VHUB_EP_DMA_CTRL_RESET, ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
428 writel(0, ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
432 state = readl(ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
447 if (ep->epn.desc_mode) {
458 reg = VHUB_EP_DMA_SET_RPTR(ep->epn.d_next) |
459 VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next);
460 writel(reg, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
463 writel(ep->epn.dma_conf,
464 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
467 writel(ep->epn.dma_conf,
468 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
509 reg = readl(ep->epn.regs + AST_VHUB_EP_CONFIG);
510 if (ep->epn.stalled || ep->epn.wedged)
514 writel(reg, ep->epn.regs + AST_VHUB_EP_CONFIG);
516 if (!ep->epn.stalled && !ep->epn.wedged)
517 writel(VHUB_EP_TOGGLE_SET_EPNUM(ep->epn.g_idx),
534 if (ep->epn.is_iso)
540 if (halt && ep->epn.is_in && !list_empty(&ep->queue)) {
544 ep->epn.stalled = halt;
545 ep->epn.wedged = wedge;
574 ep->epn.enabled = false;
580 writel(0, ep->epn.regs + AST_VHUB_EP_CONFIG);
583 imask = VHUB_EP_IRQ(ep->epn.g_idx);
628 if (ep->epn.enabled) {
643 ep->epn.is_in = usb_endpoint_dir_in(desc);
646 ep->epn.d_next = ep->epn.d_last = 0;
647 ep->epn.is_iso = false;
648 ep->epn.stalled = false;
649 ep->epn.wedged = false;
652 ep->epn.is_in ? "in" : "out", usb_ep_type_string(type),
656 ep->epn.desc_mode = ep->epn.descs && ep->epn.is_in;
657 if (ep->epn.desc_mode)
658 memset(ep->epn.descs, 0, 8 * AST_VHUB_DESCS_COUNT);
664 ep->epn.chunk_max = ep->ep.maxpacket;
665 if (ep->epn.is_in) {
666 ep->epn.chunk_max <<= 3;
667 while (ep->epn.chunk_max > 4095)
668 ep->epn.chunk_max -= ep->ep.maxpacket;
683 ep->epn.is_iso = true;
692 if (!ep->epn.is_in)
702 writel(0, ep->epn.regs + AST_VHUB_EP_CONFIG);
704 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
707 writel(ep_conf, ep->epn.regs + AST_VHUB_EP_CONFIG);
709 if (ep->epn.desc_mode) {
711 writel(0, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
714 writel(ep->epn.descs_dma,
715 ep->epn.regs + AST_VHUB_EP_DESC_BASE);
718 ep->epn.dma_conf = VHUB_EP_DMA_DESC_MODE;
719 if (ep->epn.is_in)
720 ep->epn.dma_conf |= VHUB_EP_DMA_IN_LONG_MODE;
723 writel(ep->epn.dma_conf | VHUB_EP_DMA_CTRL_RESET,
724 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
727 writel(ep->epn.dma_conf,
728 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
731 ep->epn.dma_conf = VHUB_EP_DMA_SINGLE_STAGE;
734 writel(ep->epn.dma_conf | VHUB_EP_DMA_CTRL_RESET,
735 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
736 writel(ep->epn.dma_conf,
737 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
738 writel(0, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
742 writel(VHUB_EP_TOGGLE_SET_EPNUM(ep->epn.g_idx),
746 imask = VHUB_EP_IRQ(ep->epn.g_idx);
753 ep->epn.enabled = true;
783 ep->epn.descs = NULL;
830 ep->epn.g_idx = i;
831 ep->epn.regs = vhub->regs + 0x200 + (i * 0x10);
842 ep->epn.descs = ep->buf + AST_VHUB_EPn_MAX_PACKET;
843 ep->epn.descs_dma = ep->buf_dma + AST_VHUB_EPn_MAX_PACKET;