Lines Matching full:ch

126 static void bcm_dma_reg_dump(int ch);
131 int ch; member
173 bcm_dma_reset(device_t dev, int ch) in bcm_dma_reset() argument
180 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_reset()
183 cs = bus_read_4(sc->sc_mem, BCM_DMA_CS(ch)); in bcm_dma_reset()
187 bus_write_4(sc->sc_mem, BCM_DMA_CS(ch), 0); in bcm_dma_reset()
191 cs = bus_read_4(sc->sc_mem, BCM_DMA_CS(ch)); in bcm_dma_reset()
196 "Can't abort DMA transfer at channel %d\n", ch); in bcm_dma_reset()
199 bus_write_4(sc->sc_mem, BCM_DMA_CBNEXT(ch), 0); in bcm_dma_reset()
202 bus_write_4(sc->sc_mem, BCM_DMA_CS(ch), in bcm_dma_reset()
207 bus_write_4(sc->sc_mem, BCM_DMA_CBADDR(ch), 0); in bcm_dma_reset()
208 bus_write_4(sc->sc_mem, BCM_DMA_CBNEXT(ch), 0); in bcm_dma_reset()
211 cb = sc->sc_dma_ch[ch].cb; in bcm_dma_reset()
221 struct bcm_dma_ch *ch; in bcm_dma_init() local
268 ch = &sc->sc_dma_ch[i]; in bcm_dma_init()
270 bzero(ch, sizeof(struct bcm_dma_ch)); in bcm_dma_init()
271 ch->ch = i; in bcm_dma_init()
272 ch->flags = BCM_DMA_CH_UNMAP; in bcm_dma_init()
279 &ch->dma_map); in bcm_dma_init()
297 err = bus_dmamap_load(sc->sc_dma_tag, ch->dma_map, cb_virt, in bcm_dma_init()
305 ch->cb = cb_virt; in bcm_dma_init()
306 ch->vc_cb = cb_phys; in bcm_dma_init()
307 ch->flags = BCM_DMA_CH_FREE; in bcm_dma_init()
308 ch->cb->info = INFO_WAIT_RESP; in bcm_dma_init()
325 int ch = BCM_DMA_CH_INVALID; in bcm_dma_allocate() local
334 /* Auto(req_ch < 0) or CH specified */ in bcm_dma_allocate()
340 ch = i; in bcm_dma_allocate()
341 sc->sc_dma_ch[ch].flags &= ~BCM_DMA_CH_FREE; in bcm_dma_allocate()
342 sc->sc_dma_ch[ch].flags |= BCM_DMA_CH_USED; in bcm_dma_allocate()
347 ch = req_ch; in bcm_dma_allocate()
348 sc->sc_dma_ch[ch].flags &= ~BCM_DMA_CH_FREE; in bcm_dma_allocate()
349 sc->sc_dma_ch[ch].flags |= BCM_DMA_CH_USED; in bcm_dma_allocate()
353 return (ch); in bcm_dma_allocate()
360 bcm_dma_free(int ch) in bcm_dma_free() argument
367 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_free()
371 if (sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED) { in bcm_dma_free()
372 sc->sc_dma_ch[ch].flags |= BCM_DMA_CH_FREE; in bcm_dma_free()
373 sc->sc_dma_ch[ch].flags &= ~BCM_DMA_CH_USED; in bcm_dma_free()
374 sc->sc_dma_ch[ch].intr_func = NULL; in bcm_dma_free()
375 sc->sc_dma_ch[ch].intr_arg = NULL; in bcm_dma_free()
378 bcm_dma_reset(sc->sc_dev, ch); in bcm_dma_free()
390 bcm_dma_setup_intr(int ch, void (*func)(int, void *), void *arg) in bcm_dma_setup_intr() argument
398 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_setup_intr()
401 if (!(sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED)) in bcm_dma_setup_intr()
404 sc->sc_dma_ch[ch].intr_func = func; in bcm_dma_setup_intr()
405 sc->sc_dma_ch[ch].intr_arg = arg; in bcm_dma_setup_intr()
406 cb = sc->sc_dma_ch[ch].cb; in bcm_dma_setup_intr()
414 * ch - channel number
427 bcm_dma_setup_src(int ch, int dreq, int inc_addr, int width) in bcm_dma_setup_src() argument
432 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_setup_src()
435 if (!(sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED)) in bcm_dma_setup_src()
438 info = sc->sc_dma_ch[ch].cb->info; in bcm_dma_setup_src()
457 sc->sc_dma_ch[ch].cb->info = info; in bcm_dma_setup_src()
464 * ch - channel number
477 bcm_dma_setup_dst(int ch, int dreq, int inc_addr, int width) in bcm_dma_setup_dst() argument
482 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_setup_dst()
485 if (!(sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED)) in bcm_dma_setup_dst()
488 info = sc->sc_dma_ch[ch].cb->info; in bcm_dma_setup_dst()
507 sc->sc_dma_ch[ch].cb->info = info; in bcm_dma_setup_dst()
531 bcm_dma_reg_dump(int ch) in bcm_dma_reg_dump() argument
540 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_reg_dump()
543 printf("DMA%d: ", ch); in bcm_dma_reg_dump()
545 reg = bus_read_4(sc->sc_mem, BCM_DMA_CH(ch) + i*4); in bcm_dma_reg_dump()
554 * ch - channel number
562 bcm_dma_start(int ch, vm_paddr_t src, vm_paddr_t dst, int len) in bcm_dma_start() argument
570 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_start()
573 if (!(sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED)) in bcm_dma_start()
576 cb = sc->sc_dma_ch[ch].cb; in bcm_dma_start()
583 sc->sc_dma_ch[ch].dma_map, BUS_DMASYNC_PREWRITE); in bcm_dma_start()
585 bus_write_4(sc->sc_mem, BCM_DMA_CBADDR(ch), in bcm_dma_start()
586 sc->sc_dma_ch[ch].vc_cb); in bcm_dma_start()
587 bus_write_4(sc->sc_mem, BCM_DMA_CS(ch), CS_ACTIVE); in bcm_dma_start()
590 bcm_dma_cb_dump(sc->sc_dma_ch[ch].cb); in bcm_dma_start()
591 bcm_dma_reg_dump(ch); in bcm_dma_start()
599 * ch - channel number
604 bcm_dma_length(int ch) in bcm_dma_length() argument
612 if (ch < 0 || ch >= BCM_DMA_CH_MAX) in bcm_dma_length()
615 if (!(sc->sc_dma_ch[ch].flags & BCM_DMA_CH_USED)) in bcm_dma_length()
618 cb = sc->sc_dma_ch[ch].cb; in bcm_dma_length()
627 struct bcm_dma_ch *ch = (struct bcm_dma_ch *)arg; in bcm_dma_intr() local
631 cs = bus_read_4(sc->sc_mem, BCM_DMA_CS(ch->ch)); in bcm_dma_intr()
639 if (!(ch->flags & BCM_DMA_CH_USED)) in bcm_dma_intr()
647 debug = bus_read_4(sc->sc_mem, BCM_DMA_DEBUG(ch->ch)); in bcm_dma_intr()
648 device_printf(sc->sc_dev, "DMA error %d on CH%d\n", in bcm_dma_intr()
649 debug & DEBUG_ERROR_MASK, ch->ch); in bcm_dma_intr()
650 bus_write_4(sc->sc_mem, BCM_DMA_DEBUG(ch->ch), in bcm_dma_intr()
652 bcm_dma_reset(sc->sc_dev, ch->ch); in bcm_dma_intr()
657 bus_write_4(sc->sc_mem, BCM_DMA_CS(ch->ch), in bcm_dma_intr()
661 bus_dmamap_sync(sc->sc_dma_tag, ch->dma_map, in bcm_dma_intr()
665 if (ch->intr_func) in bcm_dma_intr()
666 ch->intr_func(ch->ch, ch->intr_arg); in bcm_dma_intr()