Lines Matching refs:c
238 static inline struct omap_chan *to_omap_dma_chan(struct dma_chan *c) in to_omap_dma_chan() argument
240 return container_of(c, struct omap_chan, vc.chan); in to_omap_dma_chan()
369 static void omap_dma_chan_write(struct omap_chan *c, unsigned reg, unsigned val) in omap_dma_chan_write() argument
371 const struct omap_dma_reg *r = c->reg_map + reg; in omap_dma_chan_write()
373 omap_dma_write(val, r->type, c->channel_base + r->offset); in omap_dma_chan_write()
376 static unsigned omap_dma_chan_read(struct omap_chan *c, unsigned reg) in omap_dma_chan_read() argument
378 const struct omap_dma_reg *r = c->reg_map + reg; in omap_dma_chan_read()
380 return omap_dma_read(r->type, c->channel_base + r->offset); in omap_dma_chan_read()
383 static void omap_dma_clear_csr(struct omap_chan *c) in omap_dma_clear_csr() argument
386 omap_dma_chan_read(c, CSR); in omap_dma_clear_csr()
388 omap_dma_chan_write(c, CSR, ~0); in omap_dma_clear_csr()
391 static unsigned omap_dma_get_csr(struct omap_chan *c) in omap_dma_get_csr() argument
393 unsigned val = omap_dma_chan_read(c, CSR); in omap_dma_get_csr()
396 omap_dma_chan_write(c, CSR, val); in omap_dma_get_csr()
403 struct omap_chan *c; in omap_dma_clear_lch() local
406 c = od->lch_map[lch]; in omap_dma_clear_lch()
407 if (!c) in omap_dma_clear_lch()
411 omap_dma_chan_write(c, i, 0); in omap_dma_clear_lch()
414 static void omap_dma_assign(struct omap_dmadev *od, struct omap_chan *c, in omap_dma_assign() argument
417 c->channel_base = od->base + od->plat->channel_stride * lch; in omap_dma_assign()
419 od->lch_map[lch] = c; in omap_dma_assign()
422 static void omap_dma_start(struct omap_chan *c, struct omap_desc *d) in omap_dma_start() argument
424 struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); in omap_dma_start()
428 omap_dma_chan_write(c, CPC, 0); in omap_dma_start()
430 omap_dma_chan_write(c, CDAC, 0); in omap_dma_start()
432 omap_dma_clear_csr(c); in omap_dma_start()
441 omap_dma_chan_write(c, CDP, cdp); in omap_dma_start()
443 omap_dma_chan_write(c, CNDP, d->sg[0].t2_desc_paddr); in omap_dma_start()
444 omap_dma_chan_write(c, CCDN, 0); in omap_dma_start()
445 omap_dma_chan_write(c, CCFN, 0xffff); in omap_dma_start()
446 omap_dma_chan_write(c, CCEN, 0xffffff); in omap_dma_start()
450 omap_dma_chan_write(c, CDP, 0); in omap_dma_start()
454 omap_dma_chan_write(c, CICR, cicr); in omap_dma_start()
457 omap_dma_chan_write(c, CCR, d->ccr | CCR_ENABLE); in omap_dma_start()
459 c->running = true; in omap_dma_start()
462 static void omap_dma_drain_chan(struct omap_chan *c) in omap_dma_drain_chan() argument
469 val = omap_dma_chan_read(c, CCR); in omap_dma_drain_chan()
480 dev_err(c->vc.chan.device->dev, in omap_dma_drain_chan()
482 c->dma_ch); in omap_dma_drain_chan()
485 static int omap_dma_stop(struct omap_chan *c) in omap_dma_stop() argument
487 struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); in omap_dma_stop()
491 omap_dma_chan_write(c, CICR, 0); in omap_dma_stop()
493 omap_dma_clear_csr(c); in omap_dma_stop()
495 val = omap_dma_chan_read(c, CCR); in omap_dma_stop()
504 val = omap_dma_chan_read(c, CCR); in omap_dma_stop()
506 omap_dma_chan_write(c, CCR, val); in omap_dma_stop()
508 if (!(c->ccr & CCR_BUFFERING_DISABLE)) in omap_dma_stop()
509 omap_dma_drain_chan(c); in omap_dma_stop()
517 omap_dma_chan_write(c, CCR, val); in omap_dma_stop()
519 if (!(c->ccr & CCR_BUFFERING_DISABLE)) in omap_dma_stop()
520 omap_dma_drain_chan(c); in omap_dma_stop()
525 if (!__dma_omap15xx(od->plat->dma_attr) && c->cyclic) { in omap_dma_stop()
526 val = omap_dma_chan_read(c, CLNK_CTRL); in omap_dma_stop()
533 omap_dma_chan_write(c, CLNK_CTRL, val); in omap_dma_stop()
535 c->running = false; in omap_dma_stop()
539 static void omap_dma_start_sg(struct omap_chan *c, struct omap_desc *d) in omap_dma_start_sg() argument
541 struct omap_sg *sg = d->sg + c->sgidx; in omap_dma_start_sg()
554 omap_dma_chan_write(c, cxsa, sg->addr); in omap_dma_start_sg()
555 omap_dma_chan_write(c, cxei, sg->ei); in omap_dma_start_sg()
556 omap_dma_chan_write(c, cxfi, sg->fi); in omap_dma_start_sg()
557 omap_dma_chan_write(c, CEN, sg->en); in omap_dma_start_sg()
558 omap_dma_chan_write(c, CFN, sg->fn); in omap_dma_start_sg()
560 omap_dma_start(c, d); in omap_dma_start_sg()
561 c->sgidx++; in omap_dma_start_sg()
564 static void omap_dma_start_desc(struct omap_chan *c) in omap_dma_start_desc() argument
566 struct virt_dma_desc *vd = vchan_next_desc(&c->vc); in omap_dma_start_desc()
571 c->desc = NULL; in omap_dma_start_desc()
577 c->desc = d = to_omap_dma_desc(&vd->tx); in omap_dma_start_desc()
578 c->sgidx = 0; in omap_dma_start_desc()
587 omap_dma_chan_write(c, CCR, d->ccr); in omap_dma_start_desc()
589 omap_dma_chan_write(c, CCR2, d->ccr >> 16); in omap_dma_start_desc()
601 omap_dma_chan_write(c, cxsa, d->dev_addr); in omap_dma_start_desc()
602 omap_dma_chan_write(c, cxei, d->ei); in omap_dma_start_desc()
603 omap_dma_chan_write(c, cxfi, d->fi); in omap_dma_start_desc()
604 omap_dma_chan_write(c, CSDP, d->csdp); in omap_dma_start_desc()
605 omap_dma_chan_write(c, CLNK_CTRL, d->clnk_ctrl); in omap_dma_start_desc()
607 omap_dma_start_sg(c, d); in omap_dma_start_desc()
612 struct omap_chan *c = data; in omap_dma_callback() local
616 spin_lock_irqsave(&c->vc.lock, flags); in omap_dma_callback()
617 d = c->desc; in omap_dma_callback()
619 if (c->cyclic) { in omap_dma_callback()
621 } else if (d->using_ll || c->sgidx == d->sglen) { in omap_dma_callback()
622 omap_dma_start_desc(c); in omap_dma_callback()
625 omap_dma_start_sg(c, d); in omap_dma_callback()
628 spin_unlock_irqrestore(&c->vc.lock, flags); in omap_dma_callback()
647 struct omap_chan *c; in omap_dma_irq() local
653 c = od->lch_map[channel]; in omap_dma_irq()
654 if (c == NULL) { in omap_dma_irq()
660 csr = omap_dma_get_csr(c); in omap_dma_irq()
663 omap_dma_callback(channel, csr, c); in omap_dma_irq()
705 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_alloc_chan_resources() local
710 ret = omap_request_dma(c->dma_sig, "DMA engine", in omap_dma_alloc_chan_resources()
711 omap_dma_callback, c, &c->dma_ch); in omap_dma_alloc_chan_resources()
713 ret = omap_dma_get_lch(od, &c->dma_ch); in omap_dma_alloc_chan_resources()
716 dev_dbg(dev, "allocating channel %u for %u\n", c->dma_ch, c->dma_sig); in omap_dma_alloc_chan_resources()
719 omap_dma_assign(od, c, c->dma_ch); in omap_dma_alloc_chan_resources()
725 val = BIT(c->dma_ch); in omap_dma_alloc_chan_resources()
731 val &= ~BIT(c->dma_ch); in omap_dma_alloc_chan_resources()
739 c->ccr = CCR_OMAP31_DISABLE; in omap_dma_alloc_chan_resources()
741 c->ccr |= c->dma_ch + 1; in omap_dma_alloc_chan_resources()
743 c->ccr = c->dma_sig & 0x1f; in omap_dma_alloc_chan_resources()
746 c->ccr = c->dma_sig & 0x1f; in omap_dma_alloc_chan_resources()
747 c->ccr |= (c->dma_sig & ~0x1f) << 14; in omap_dma_alloc_chan_resources()
750 c->ccr |= CCR_BUFFERING_DISABLE; in omap_dma_alloc_chan_resources()
758 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_free_chan_resources() local
762 od->irq_enable_mask &= ~BIT(c->dma_ch); in omap_dma_free_chan_resources()
767 c->channel_base = NULL; in omap_dma_free_chan_resources()
768 od->lch_map[c->dma_ch] = NULL; in omap_dma_free_chan_resources()
769 vchan_free_chan_resources(&c->vc); in omap_dma_free_chan_resources()
772 omap_free_dma(c->dma_ch); in omap_dma_free_chan_resources()
774 omap_dma_put_lch(od, c->dma_ch); in omap_dma_free_chan_resources()
776 dev_dbg(od->ddev.dev, "freeing channel %u used for %u\n", c->dma_ch, in omap_dma_free_chan_resources()
777 c->dma_sig); in omap_dma_free_chan_resources()
778 c->dma_sig = 0; in omap_dma_free_chan_resources()
818 static uint32_t omap_dma_chan_read_3_3(struct omap_chan *c, unsigned reg) in omap_dma_chan_read_3_3() argument
820 struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); in omap_dma_chan_read_3_3()
823 val = omap_dma_chan_read(c, reg); in omap_dma_chan_read_3_3()
825 val = omap_dma_chan_read(c, reg); in omap_dma_chan_read_3_3()
830 static dma_addr_t omap_dma_get_src_pos(struct omap_chan *c) in omap_dma_get_src_pos() argument
832 struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); in omap_dma_get_src_pos()
836 addr = omap_dma_chan_read(c, CPC); in omap_dma_get_src_pos()
838 addr = omap_dma_chan_read_3_3(c, CSAC); in omap_dma_get_src_pos()
839 cdac = omap_dma_chan_read_3_3(c, CDAC); in omap_dma_get_src_pos()
847 addr = omap_dma_chan_read(c, CSSA); in omap_dma_get_src_pos()
851 addr |= omap_dma_chan_read(c, CSSA) & 0xffff0000; in omap_dma_get_src_pos()
856 static dma_addr_t omap_dma_get_dst_pos(struct omap_chan *c) in omap_dma_get_dst_pos() argument
858 struct omap_dmadev *od = to_omap_dma_dev(c->vc.chan.device); in omap_dma_get_dst_pos()
862 addr = omap_dma_chan_read(c, CPC); in omap_dma_get_dst_pos()
864 addr = omap_dma_chan_read_3_3(c, CDAC); in omap_dma_get_dst_pos()
873 addr = omap_dma_chan_read(c, CDSA); in omap_dma_get_dst_pos()
877 addr |= omap_dma_chan_read(c, CDSA) & 0xffff0000; in omap_dma_get_dst_pos()
885 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_tx_status() local
894 spin_lock_irqsave(&c->vc.lock, flags); in omap_dma_tx_status()
895 if (c->desc && c->desc->vd.tx.cookie == cookie) in omap_dma_tx_status()
896 d = c->desc; in omap_dma_tx_status()
905 pos = omap_dma_get_src_pos(c); in omap_dma_tx_status()
907 pos = omap_dma_get_dst_pos(c); in omap_dma_tx_status()
913 struct virt_dma_desc *vd = vchan_find_desc(&c->vc, cookie); in omap_dma_tx_status()
923 if (ret == DMA_IN_PROGRESS && c->paused) { in omap_dma_tx_status()
925 } else if (d && d->polled && c->running) { in omap_dma_tx_status()
926 uint32_t ccr = omap_dma_chan_read(c, CCR); in omap_dma_tx_status()
933 omap_dma_start_desc(c); in omap_dma_tx_status()
938 spin_unlock_irqrestore(&c->vc.lock, flags); in omap_dma_tx_status()
945 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_issue_pending() local
948 spin_lock_irqsave(&c->vc.lock, flags); in omap_dma_issue_pending()
949 if (vchan_issue_pending(&c->vc) && !c->desc) in omap_dma_issue_pending()
950 omap_dma_start_desc(c); in omap_dma_issue_pending()
951 spin_unlock_irqrestore(&c->vc.lock, flags); in omap_dma_issue_pending()
959 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_prep_slave_sg() local
970 dev_addr = c->cfg.src_addr; in omap_dma_prep_slave_sg()
971 dev_width = c->cfg.src_addr_width; in omap_dma_prep_slave_sg()
972 burst = c->cfg.src_maxburst; in omap_dma_prep_slave_sg()
973 port_window = c->cfg.src_port_window_size; in omap_dma_prep_slave_sg()
975 dev_addr = c->cfg.dst_addr; in omap_dma_prep_slave_sg()
976 dev_width = c->cfg.dst_addr_width; in omap_dma_prep_slave_sg()
977 burst = c->cfg.dst_maxburst; in omap_dma_prep_slave_sg()
978 port_window = c->cfg.dst_port_window_size; in omap_dma_prep_slave_sg()
1023 d->ccr = c->ccr | CCR_SYNC_FRAME; in omap_dma_prep_slave_sg()
1079 d->clnk_ctrl = c->dma_ch; in omap_dma_prep_slave_sg()
1133 return vchan_tx_prep(&c->vc, &d->vd, tx_flags); in omap_dma_prep_slave_sg()
1141 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_prep_dma_cyclic() local
1149 dev_addr = c->cfg.src_addr; in omap_dma_prep_dma_cyclic()
1150 dev_width = c->cfg.src_addr_width; in omap_dma_prep_dma_cyclic()
1151 burst = c->cfg.src_maxburst; in omap_dma_prep_dma_cyclic()
1153 dev_addr = c->cfg.dst_addr; in omap_dma_prep_dma_cyclic()
1154 dev_width = c->cfg.dst_addr_width; in omap_dma_prep_dma_cyclic()
1155 burst = c->cfg.dst_maxburst; in omap_dma_prep_dma_cyclic()
1190 d->ccr = c->ccr; in omap_dma_prep_dma_cyclic()
1230 d->clnk_ctrl = c->dma_ch | CLNK_CTRL_ENABLE_LNK; in omap_dma_prep_dma_cyclic()
1232 c->cyclic = true; in omap_dma_prep_dma_cyclic()
1234 return vchan_tx_prep(&c->vc, &d->vd, flags); in omap_dma_prep_dma_cyclic()
1241 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_prep_dma_memcpy() local
1261 d->ccr = c->ccr; in omap_dma_prep_dma_memcpy()
1280 return vchan_tx_prep(&c->vc, &d->vd, tx_flags); in omap_dma_prep_dma_memcpy()
1287 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_prep_dma_interleaved() local
1316 d->ccr = c->ccr; in omap_dma_prep_dma_interleaved()
1363 return vchan_tx_prep(&c->vc, &d->vd, flags); in omap_dma_prep_dma_interleaved()
1368 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_slave_config() local
1378 memcpy(&c->cfg, cfg, sizeof(c->cfg)); in omap_dma_slave_config()
1385 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_terminate_all() local
1389 spin_lock_irqsave(&c->vc.lock, flags); in omap_dma_terminate_all()
1396 if (c->desc) { in omap_dma_terminate_all()
1397 vchan_terminate_vdesc(&c->desc->vd); in omap_dma_terminate_all()
1398 c->desc = NULL; in omap_dma_terminate_all()
1400 if (!c->paused) in omap_dma_terminate_all()
1401 omap_dma_stop(c); in omap_dma_terminate_all()
1404 c->cyclic = false; in omap_dma_terminate_all()
1405 c->paused = false; in omap_dma_terminate_all()
1407 vchan_get_all_descriptors(&c->vc, &head); in omap_dma_terminate_all()
1408 spin_unlock_irqrestore(&c->vc.lock, flags); in omap_dma_terminate_all()
1409 vchan_dma_desc_free_list(&c->vc, &head); in omap_dma_terminate_all()
1416 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_synchronize() local
1418 vchan_synchronize(&c->vc); in omap_dma_synchronize()
1423 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_pause() local
1431 if (!c->desc) in omap_dma_pause()
1434 if (c->cyclic) in omap_dma_pause()
1460 else if (c->desc->dir == DMA_DEV_TO_MEM) in omap_dma_pause()
1463 if (can_pause && !c->paused) { in omap_dma_pause()
1464 ret = omap_dma_stop(c); in omap_dma_pause()
1466 c->paused = true; in omap_dma_pause()
1476 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_resume() local
1483 if (c->paused && c->desc) { in omap_dma_resume()
1487 omap_dma_chan_write(c, CLNK_CTRL, c->desc->clnk_ctrl); in omap_dma_resume()
1489 omap_dma_start(c, c->desc); in omap_dma_resume()
1490 c->paused = false; in omap_dma_resume()
1500 struct omap_chan *c; in omap_dma_chan_init() local
1502 c = kzalloc(sizeof(*c), GFP_KERNEL); in omap_dma_chan_init()
1503 if (!c) in omap_dma_chan_init()
1506 c->reg_map = od->reg_map; in omap_dma_chan_init()
1507 c->vc.desc_free = omap_dma_desc_free; in omap_dma_chan_init()
1508 vchan_init(&c->vc, &od->ddev); in omap_dma_chan_init()
1516 struct omap_chan *c = list_first_entry(&od->ddev.channels, in omap_dma_free() local
1519 list_del(&c->vc.chan.device_node); in omap_dma_free()
1520 tasklet_kill(&c->vc.task); in omap_dma_free()
1521 kfree(c); in omap_dma_free()
1528 struct omap_chan *c; in omap_dma_busy() local
1535 c = od->lch_map[lch]; in omap_dma_busy()
1536 if (!c) in omap_dma_busy()
1538 if (omap_dma_chan_read(c, CCR) & CCR_ENABLE) in omap_dma_busy()
1926 struct omap_chan *c = to_omap_dma_chan(chan); in omap_dma_filter_fn() local
1930 c->dma_sig = req; in omap_dma_filter_fn()