34 #include <linux/kernel.h>
35 #include <linux/slab.h>
38 #include <linux/module.h>
57 #define ALIGN_ADDR(x, a) ((((u32)(x)) + (a-1)) & ~(a-1))
61 static int dbdma_initialized;
111 static dbdev_tab_t au1200_dbdev_tab[] __initdata = {
151 static dbdev_tab_t au1300_dbdev_tab[] __initdata = {
196 #define DBDEV_TAB_SIZE 64
222 static u16 new_id = 0x1000;
224 p = find_dbdev_id(~0);
253 void (*
callback)(
int,
void *),
void *callparam)
268 if (!dbdma_initialized)
271 stp = find_dbdev_id(srcid);
274 dtp = find_dbdev_id(destid);
297 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags);
307 if (chan_tab_ptr[i] ==
NULL) {
313 chan_tab_ptr[
i] = ctp;
316 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags);
322 dcp += (0x0100 * chan);
350 return (
u32)(&chan_tab_ptr[chan]);
393 u32 desc_base, srcid, destid;
394 u32 cmd0, cmd1, src1, dest1;
419 if (desc_base & 0x1f) {
424 kfree((
const void *)desc_base);
445 cmd0 = cmd1 = src1 = dest1 = 0;
559 "source1:%x dest0:%x dest1:%x\n",
563 for (i = 0; i <
entries; i++) {
683 printk(
KERN_DEBUG "cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n",
757 int halt_timeout = 0;
767 if (halt_timeout > 100) {
872 chan_index =
__ffs(intstat);
874 ctp = chan_tab_ptr[chan_index];
903 (
u32)ctp, (
u32)stp, stp - dbdev_tab, (
u32)dtp,
906 (
u32)(ctp->chan_desc_base), (
u32)(ctp->get_ptr),
907 (
u32)(ctp->put_ptr), (
u32)(ctp->cur_ptr));
911 cp->ddma_cfg, cp->ddma_desptr, cp->ddma_statptr);
913 cp->ddma_dbell, cp->ddma_irq, cp->ddma_stat,
917 dp = ctp->chan_desc_base;
923 dp->dscr_source0, dp->dscr_source1,
924 dp->dscr_dest0, dp->dscr_dest1);
926 dp->dscr_stat, dp->dscr_nxtptr);
928 }
while (dp != ctp->chan_desc_base);
982 static int alchemy_dbdma_suspend(
void)
988 alchemy_dbdma_pm_data[0][0] =
__raw_readl(addr + 0x00);
989 alchemy_dbdma_pm_data[0][1] =
__raw_readl(addr + 0x04);
990 alchemy_dbdma_pm_data[0][2] =
__raw_readl(addr + 0x08);
991 alchemy_dbdma_pm_data[0][3] =
__raw_readl(addr + 0x0c);
1000 alchemy_dbdma_pm_data[
i][4] =
__raw_readl(addr + 0x10);
1001 alchemy_dbdma_pm_data[
i][5] =
__raw_readl(addr + 0x14);
1004 __raw_writel(alchemy_dbdma_pm_data[i][0] & ~1, addr + 0x00);
1019 static void alchemy_dbdma_resume(
void)
1025 __raw_writel(alchemy_dbdma_pm_data[0][0], addr + 0x00);
1026 __raw_writel(alchemy_dbdma_pm_data[0][1], addr + 0x04);
1027 __raw_writel(alchemy_dbdma_pm_data[0][2], addr + 0x08);
1028 __raw_writel(alchemy_dbdma_pm_data[0][3], addr + 0x0c);
1033 __raw_writel(alchemy_dbdma_pm_data[i][0], addr + 0x00);
1034 __raw_writel(alchemy_dbdma_pm_data[i][1], addr + 0x04);
1035 __raw_writel(alchemy_dbdma_pm_data[i][2], addr + 0x08);
1036 __raw_writel(alchemy_dbdma_pm_data[i][3], addr + 0x0c);
1037 __raw_writel(alchemy_dbdma_pm_data[i][4], addr + 0x10);
1038 __raw_writel(alchemy_dbdma_pm_data[i][5], addr + 0x14);
1044 static struct syscore_ops alchemy_dbdma_syscore_ops = {
1045 .suspend = alchemy_dbdma_suspend,
1046 .resume = alchemy_dbdma_resume,
1059 dbdev_tab[ret].dev_id = ~0;
1066 ret =
request_irq(irq, dbdma_interrupt, 0,
"dbdma", (
void *)dbdma_gptr);
1070 dbdma_initialized = 1;
1077 static int __init alchemy_dbdma_init(
void)
1079 switch (alchemy_get_cputype()) {