Lines Matching refs:chdat
61 static inline int tusb_omap_use_shared_dmareq(struct tusb_omap_dma_ch *chdat) in tusb_omap_use_shared_dmareq() argument
63 u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP); in tusb_omap_use_shared_dmareq()
66 dev_dbg(chdat->musb->controller, "ep%i dmareq0 is busy for ep%i\n", in tusb_omap_use_shared_dmareq()
67 chdat->epnum, reg & 0xf); in tusb_omap_use_shared_dmareq()
71 if (chdat->tx) in tusb_omap_use_shared_dmareq()
72 reg = (1 << 4) | chdat->epnum; in tusb_omap_use_shared_dmareq()
74 reg = chdat->epnum; in tusb_omap_use_shared_dmareq()
76 musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, reg); in tusb_omap_use_shared_dmareq()
81 static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat) in tusb_omap_free_shared_dmareq() argument
83 u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP); in tusb_omap_free_shared_dmareq()
85 if ((reg & 0xf) != chdat->epnum) { in tusb_omap_free_shared_dmareq()
87 chdat->epnum, reg & 0xf); in tusb_omap_free_shared_dmareq()
90 musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0); in tusb_omap_free_shared_dmareq()
100 struct tusb_omap_dma_ch *chdat = to_chdat(channel); in tusb_omap_dma_cb() local
101 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma; in tusb_omap_dma_cb()
102 struct musb *musb = chdat->musb; in tusb_omap_dma_cb()
104 struct musb_hw_ep *hw_ep = chdat->hw_ep; in tusb_omap_dma_cb()
112 chdat->epnum, chdat->tx ? "tx" : "rx"); in tusb_omap_dma_cb()
114 if (chdat->tx) in tusb_omap_dma_cb()
122 if (unlikely(remaining > chdat->transfer_len)) { in tusb_omap_dma_cb()
124 chdat->tx ? "tx" : "rx", remaining); in tusb_omap_dma_cb()
128 channel->actual_len = chdat->transfer_len - remaining; in tusb_omap_dma_cb()
129 pio = chdat->len - channel->actual_len; in tusb_omap_dma_cb()
131 dev_dbg(musb->controller, "DMA remaining %lu/%u\n", remaining, chdat->transfer_len); in tusb_omap_dma_cb()
138 buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len; in tusb_omap_dma_cb()
139 if (chdat->tx) { in tusb_omap_dma_cb()
140 dma_unmap_single(dev, chdat->dma_addr, in tusb_omap_dma_cb()
141 chdat->transfer_len, in tusb_omap_dma_cb()
145 dma_unmap_single(dev, chdat->dma_addr, in tusb_omap_dma_cb()
146 chdat->transfer_len, in tusb_omap_dma_cb()
154 tusb_omap_free_shared_dmareq(chdat); in tusb_omap_dma_cb()
158 musb_dma_completion(musb, chdat->epnum, chdat->tx); in tusb_omap_dma_cb()
164 if ((chdat->transfer_len < chdat->packet_sz) in tusb_omap_dma_cb()
165 || (chdat->transfer_len % chdat->packet_sz != 0)) { in tusb_omap_dma_cb()
168 if (chdat->tx) { in tusb_omap_dma_cb()
170 musb_ep_select(mbase, chdat->epnum); in tusb_omap_dma_cb()
184 struct tusb_omap_dma_ch *chdat = to_chdat(channel); in tusb_omap_dma_program() local
185 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma; in tusb_omap_dma_program()
186 struct musb *musb = chdat->musb; in tusb_omap_dma_program()
188 struct musb_hw_ep *hw_ep = chdat->hw_ep; in tusb_omap_dma_program()
219 if (chdat->tx) in tusb_omap_dma_program()
227 chdat->tx ? "tx" : "rx", dma_remaining); in tusb_omap_dma_program()
231 chdat->transfer_len = len & ~0x1f; in tusb_omap_dma_program()
234 chdat->transfer_packet_sz = chdat->transfer_len; in tusb_omap_dma_program()
236 chdat->transfer_packet_sz = packet_sz; in tusb_omap_dma_program()
238 dma_data = chdat->dma_data; in tusb_omap_dma_program()
240 if (tusb_omap_use_shared_dmareq(chdat) != 0) { in tusb_omap_dma_program()
241 dev_dbg(musb->controller, "could not get dma for ep%i\n", chdat->epnum); in tusb_omap_dma_program()
253 chdat->packet_sz = packet_sz; in tusb_omap_dma_program()
254 chdat->len = len; in tusb_omap_dma_program()
256 chdat->dma_addr = dma_addr; in tusb_omap_dma_program()
260 if (chdat->tx) { in tusb_omap_dma_program()
287 chdat->epnum, chdat->tx ? "tx" : "rx", &dma_addr, in tusb_omap_dma_program()
288 chdat->transfer_len, len, chdat->transfer_packet_sz, packet_sz); in tusb_omap_dma_program()
304 chdat->transfer_len, dma_dir, in tusb_omap_dma_program()
317 chdat->epnum, chdat->tx ? "tx" : "rx", in tusb_omap_dma_program()
326 musb_ep_select(mbase, chdat->epnum); in tusb_omap_dma_program()
327 if (chdat->tx) { in tusb_omap_dma_program()
344 if (chdat->tx) { in tusb_omap_dma_program()
348 psize |= chdat->transfer_packet_sz; in tusb_omap_dma_program()
352 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len)); in tusb_omap_dma_program()
357 psize |= (chdat->transfer_packet_sz << 16); in tusb_omap_dma_program()
361 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len)); in tusb_omap_dma_program()
369 struct tusb_omap_dma_ch *chdat = to_chdat(channel); in tusb_omap_dma_abort() local
371 if (chdat->dma_data) in tusb_omap_dma_abort()
372 dmaengine_terminate_all(chdat->dma_data->chan); in tusb_omap_dma_abort()
379 static inline int tusb_omap_dma_allocate_dmareq(struct tusb_omap_dma_ch *chdat) in tusb_omap_dma_allocate_dmareq() argument
381 u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP); in tusb_omap_dma_allocate_dmareq()
395 reg |= (chdat->epnum << (dmareq_nr * 5)); in tusb_omap_dma_allocate_dmareq()
396 if (chdat->tx) in tusb_omap_dma_allocate_dmareq()
398 musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, reg); in tusb_omap_dma_allocate_dmareq()
400 chdat->dma_data = &chdat->tusb_dma->dma_pool[dmareq_nr]; in tusb_omap_dma_allocate_dmareq()
405 static inline void tusb_omap_dma_free_dmareq(struct tusb_omap_dma_ch *chdat) in tusb_omap_dma_free_dmareq() argument
409 if (!chdat || !chdat->dma_data || chdat->dma_data->dmareq < 0) in tusb_omap_dma_free_dmareq()
412 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP); in tusb_omap_dma_free_dmareq()
413 reg &= ~(0x1f << (chdat->dma_data->dmareq * 5)); in tusb_omap_dma_free_dmareq()
414 musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, reg); in tusb_omap_dma_free_dmareq()
416 chdat->dma_data = NULL; in tusb_omap_dma_free_dmareq()
430 struct tusb_omap_dma_ch *chdat = NULL; in tusb_omap_dma_allocate() local
447 chdat = ch->private_data; in tusb_omap_dma_allocate()
455 chdat->musb = tusb_dma->controller.musb; in tusb_omap_dma_allocate()
456 chdat->tbase = tusb_dma->tbase; in tusb_omap_dma_allocate()
457 chdat->hw_ep = hw_ep; in tusb_omap_dma_allocate()
458 chdat->epnum = hw_ep->epnum; in tusb_omap_dma_allocate()
459 chdat->completed_len = 0; in tusb_omap_dma_allocate()
460 chdat->tusb_dma = tusb_dma; in tusb_omap_dma_allocate()
462 chdat->tx = 1; in tusb_omap_dma_allocate()
464 chdat->tx = 0; in tusb_omap_dma_allocate()
470 if (!chdat->dma_data) { in tusb_omap_dma_allocate()
472 ret = tusb_omap_dma_allocate_dmareq(chdat); in tusb_omap_dma_allocate()
476 chdat->dma_data = &tusb_dma->dma_pool[0]; in tusb_omap_dma_allocate()
480 dma_data = chdat->dma_data; in tusb_omap_dma_allocate()
483 chdat->epnum, in tusb_omap_dma_allocate()
484 chdat->tx ? "tx" : "rx", in tusb_omap_dma_allocate()
491 tusb_omap_dma_free_dmareq(chdat); in tusb_omap_dma_allocate()
493 dev_dbg(musb->controller, "ep%i: Could not get a DMA channel\n", chdat->epnum); in tusb_omap_dma_allocate()
501 struct tusb_omap_dma_ch *chdat = to_chdat(channel); in tusb_omap_dma_release() local
502 struct musb *musb = chdat->musb; in tusb_omap_dma_release()
504 dev_dbg(musb->controller, "Release for ep%i\n", chdat->epnum); in tusb_omap_dma_release()
508 dmaengine_terminate_sync(chdat->dma_data->chan); in tusb_omap_dma_release()
509 tusb_omap_dma_free_dmareq(chdat); in tusb_omap_dma_release()
616 struct tusb_omap_dma_ch *chdat; in tusb_dma_controller_create() local
624 chdat = kzalloc(sizeof(struct tusb_omap_dma_ch), GFP_KERNEL); in tusb_dma_controller_create()
625 if (!chdat) in tusb_dma_controller_create()
629 ch->private_data = chdat; in tusb_dma_controller_create()