Lines Matching refs:epn
5 * epn.c - Generic endpoints management
69 if (ep->epn.is_in) {
73 writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
75 if (ep->epn.is_in)
77 writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
83 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
85 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
95 stat = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
101 stat, ep->epn.is_in, req, req ? req->active : 0);
127 if (!req->req.dma && !ep->epn.is_in && len)
162 return (ep->epn.d_last + AST_VHUB_DESCS_COUNT - ep->epn.d_next - 1) &
182 act, len, ep->epn.chunk_max, ast_vhub_count_free_descs(ep));
189 d_num = ep->epn.d_next;
190 desc = &ep->epn.descs[d_num];
191 ep->epn.d_next = (d_num + 1) & (AST_VHUB_DESCS_COUNT - 1);
195 if (chunk <= ep->epn.chunk_max) {
207 chunk = ep->epn.chunk_max;
239 writel(VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next),
240 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
243 ep->epn.d_next, readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS));
254 stat = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
255 stat1 = readl(ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
265 stat, ep->epn.is_in, ep->epn.d_last, d_last);
268 while (ep->epn.d_last != d_last) {
274 d_num = ep->epn.d_last;
275 desc = &ep->epn.descs[d_num];
276 ep->epn.d_last = (d_num + 1) & (AST_VHUB_DESCS_COUNT - 1);
307 CHECK(ep, d_last == ep->epn.d_last,
309 d_last, ep->epn.d_last);
327 if (ep->epn.desc_mode)
354 if (!ep->epn.enabled || !u_ep->desc || !ep->dev || !ep->d_idx ||
376 if (ep->epn.desc_mode ||
378 (ep->epn.is_in || !(u_req->length & (u_ep->maxpacket - 1))))) {
380 ep->epn.is_in);
393 ep->epn.is_in);
407 if (ep->epn.desc_mode)
423 if (ep->epn.desc_mode)
424 writel(VHUB_EP_DMA_CTRL_RESET, ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
426 writel(0, ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
430 state = readl(ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
445 if (ep->epn.desc_mode) {
456 reg = VHUB_EP_DMA_SET_RPTR(ep->epn.d_next) |
457 VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next);
458 writel(reg, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
461 writel(ep->epn.dma_conf,
462 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
465 writel(ep->epn.dma_conf,
466 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
505 reg = readl(ep->epn.regs + AST_VHUB_EP_CONFIG);
506 if (ep->epn.stalled || ep->epn.wedged)
510 writel(reg, ep->epn.regs + AST_VHUB_EP_CONFIG);
512 if (!ep->epn.stalled && !ep->epn.wedged)
513 writel(VHUB_EP_TOGGLE_SET_EPNUM(ep->epn.g_idx),
530 if (ep->epn.is_iso)
536 if (halt && ep->epn.is_in && !list_empty(&ep->queue)) {
540 ep->epn.stalled = halt;
541 ep->epn.wedged = wedge;
570 ep->epn.enabled = false;
576 writel(0, ep->epn.regs + AST_VHUB_EP_CONFIG);
579 imask = VHUB_EP_IRQ(ep->epn.g_idx);
624 if (ep->epn.enabled) {
639 ep->epn.is_in = usb_endpoint_dir_in(desc);
642 ep->epn.d_next = ep->epn.d_last = 0;
643 ep->epn.is_iso = false;
644 ep->epn.stalled = false;
645 ep->epn.wedged = false;
648 ep->epn.is_in ? "in" : "out", usb_ep_type_string(type),
652 ep->epn.desc_mode = ep->epn.descs && ep->epn.is_in;
653 if (ep->epn.desc_mode)
654 memset(ep->epn.descs, 0, 8 * AST_VHUB_DESCS_COUNT);
660 ep->epn.chunk_max = ep->ep.maxpacket;
661 if (ep->epn.is_in) {
662 ep->epn.chunk_max <<= 3;
663 while (ep->epn.chunk_max > 4095)
664 ep->epn.chunk_max -= ep->ep.maxpacket;
679 ep->epn.is_iso = true;
688 if (!ep->epn.is_in)
698 writel(0, ep->epn.regs + AST_VHUB_EP_CONFIG);
700 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
703 writel(ep_conf, ep->epn.regs + AST_VHUB_EP_CONFIG);
705 if (ep->epn.desc_mode) {
707 writel(0, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
710 writel(ep->epn.descs_dma,
711 ep->epn.regs + AST_VHUB_EP_DESC_BASE);
714 ep->epn.dma_conf = VHUB_EP_DMA_DESC_MODE;
715 if (ep->epn.is_in)
716 ep->epn.dma_conf |= VHUB_EP_DMA_IN_LONG_MODE;
719 writel(ep->epn.dma_conf | VHUB_EP_DMA_CTRL_RESET,
720 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
723 writel(ep->epn.dma_conf,
724 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
727 ep->epn.dma_conf = VHUB_EP_DMA_SINGLE_STAGE;
730 writel(ep->epn.dma_conf | VHUB_EP_DMA_CTRL_RESET,
731 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
732 writel(ep->epn.dma_conf,
733 ep->epn.regs + AST_VHUB_EP_DMA_CTLSTAT);
734 writel(0, ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
738 writel(VHUB_EP_TOGGLE_SET_EPNUM(ep->epn.g_idx),
742 imask = VHUB_EP_IRQ(ep->epn.g_idx);
749 ep->epn.enabled = true;
779 ep->epn.descs = NULL;
826 ep->epn.g_idx = i;
827 ep->epn.regs = vhub->regs + 0x200 + (i * 0x10);
838 ep->epn.descs = ep->buf + AST_VHUB_EPn_MAX_PACKET;
839 ep->epn.descs_dma = ep->buf_dma + AST_VHUB_EPn_MAX_PACKET;