15 #include <linux/kernel.h>
16 #include <linux/module.h>
19 #include <linux/device.h>
20 #include <linux/errno.h>
21 #include <linux/slab.h>
29 #include <mach/irqs.h>
31 #include <mach/regs-sys.h>
50 static unsigned char debug_show_buffs = 0;
54 pr_debug(
"DMA%d: %08x->%08x L %08x C %08x,%08x S %08x\n",
66 pr_debug(
"LLI[%p] %08x->%08x, NL %08x C %08x,%08x\n",
76 pr_debug(
"DMA%d: buffs next %p, curr %p, end %p\n",
82 if (debug_show_buffs) {
83 for (; ptr !=
NULL; ptr = ptr->
next) {
103 for (offs = 0; offs < 8; offs++) {
147 u32 control0, control1;
187 pr_debug(
"%s: LLI %p => regs\n", __func__, lli);
205 pr_debug(
"%s: clearing interrupts\n", __func__);
211 pr_debug(
"%s: starting channel\n", __func__);
217 pr_debug(
"%s: writing config %08x\n", __func__, config);
228 pr_debug(
"%s: stopping channel\n", __func__);
239 pr_debug(
"%s: %d - config %08x\n", __func__, timeout, config);
244 }
while (--timeout > 0);
279 pr_debug(
"%s: flushing channel\n", __func__);
287 for (buff = chan->
curr; buff !=
NULL; buff = next) {
289 pr_debug(
"%s: buff %p (next %p)\n", __func__, buff, buff->
next);
292 s3c64xx_dma_freebuff(buff);
310 return s3c64xx_dma_start(chan);
313 return s3c64xx_dma_stop(chan);
316 return s3c64xx_dma_flush(chan);
361 pr_debug(
"%s: buff %p, dp %08x lli (%p, %08x) %d\n",
362 __func__, buff, data, lli, (
u32)buff->
lli_dma, size);
367 s3c64xx_dma_fill_lli(chan, lli, data, size);
385 if (next == chan->
curr) {
393 pr_debug(
"enquing onto empty channel\n");
399 s3c64xx_lli_to_regs(chan, lli);
420 unsigned long devaddr)
426 pr_debug(
"%s: channel %d, source %d, dev %08lx, chan %p\n",
427 __func__, channel, source, devaddr, chan);
437 pr_debug(
"%s: peripheral %d\n", __func__, peripheral);
457 pr_debug(
"%s: config %08x\n", __func__, config);
497 pr_debug(
"dma%d: s3c2410_request_dma: client=%s, dev=%p\n",
498 channel, client->
name, dev);
502 chan = s3c64xx_dma_map_channel(channel);
518 pr_debug(
"%s: channel initialised, %p\n", __func__, chan);
546 if (chan->
client != client) {
547 printk(
KERN_WARNING "dma%d: possible free from different client (channel %p, passed %p)\n",
548 channel, chan->
client, client);
579 for (offs = 0, bit = 1; offs < 8; offs++, bit <<= 1) {
582 if (!(errstat & bit) && !(tcstat & bit))
602 while (buff && buff != chan->
next
609 if (buff == chan->
next)
612 s3c64xx_dma_bufffdone(chan, buff, res);
617 s3c64xx_dma_freebuff(buff);
634 static struct bus_type dma_subsys = {
635 .name =
"s3c64xx-dma",
636 .dev_name =
"s3c64xx-dma",
639 static int s3c64xx_dma_init1(
int chno,
enum dma_ch chbase,
640 int irq,
unsigned int base)
655 dmac->
dev.id = chno / 8;
656 dmac->
dev.bus = &dma_subsys;
671 snprintf(clkname,
sizeof(clkname),
"dma%d", dmac->
dev.id);
674 if (IS_ERR(dmac->
clk)) {
675 printk(
KERN_ERR "%s: failed to get clock %s\n", __func__, clkname);
676 err = PTR_ERR(dmac->
clk);
686 err =
request_irq(irq, s3c64xx_dma_irq, 0,
"DMA", dmac);
694 for (ch = 0; ch < 8; ch++, chptr++) {
695 pr_debug(
"%s: registering DMA %d (%p)\n",
696 __func__, chno + ch, regptr);
698 chptr->
bit = 1 << ch;
699 chptr->
number = chno + ch;
709 irq, regs, chno, chno+8);
725 static int __init s3c64xx_dma_init(
void)