1 /* dvma.c: Routines that are used to access DMA on the Sparc SBus.
3 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 #include <linux/config.h>
7 #include <linux/string.h>
8 #include <linux/kernel.h>
9 #include <linux/slab.h>
10 #include <linux/init.h>
11 #include <linux/delay.h>
13 #include <asm/oplib.h>
18 struct sbus_dma *dma_chain;
20 /* Print out the current values in the DMA control registers */
21 extern __inline__ void dump_dma_regs(unsigned long dregs)
23 printk("DMA CONTROL<%08x> ADDR<%08x> CNT<%08x> TEST<%08x>\n",
24 sbus_readl(dregs + DMA_CSR), sbus_readl(dregs + DMA_ADDR),
25 sbus_readl(dregs + DMA_COUNT), sbus_readl(dregs + DMA_TEST));
28 void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
30 printk("dma%d: ", num_dma);
33 dma->running = 0; /* No transfers going on as of yet */
34 dma->allocated = 0; /* No one has allocated us yet */
35 switch(sbus_readl(dma->regs + DMA_CSR)&DMA_DEVICE_ID) {
37 dma->revision = dvmarev0;
38 printk("Revision 0 ");
41 dma->revision = dvmaesc1;
42 printk("ESC Revision 1 ");
45 dma->revision = dvmarev1;
46 printk("Revision 1 ");
49 dma->revision = dvmarev2;
50 printk("Revision 2 ");
53 dma->revision = dvmahme;
54 printk("HME DVMA gate array ");
57 dma->revision = dvmarevplus;
58 printk("Revision 1 PLUS ");
61 printk("unknown dma version %08x",
62 sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
67 #if 0 /* Clutters up the screen */
68 dump_dma_regs(dma->regs);
72 /* Probe this SBus DMA module(s) */
73 void __init dvma_init(struct sbus_bus *sbus)
75 struct sbus_dev *this_dev;
77 struct sbus_dma *dchain;
78 static int num_dma = 0;
80 for_each_sbusdev(this_dev, sbus) {
81 char *name = this_dev->prom_name;
84 if(!strcmp(name, "SUNW,fas"))
86 else if(strcmp(name, "dma") &&
87 strcmp(name, "ledma") &&
88 strcmp(name, "espdma"))
92 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
96 /* Put at end of dma chain */
100 dchain = dchain->next;
103 /* We're the first in line */
107 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
108 dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
111 dma->node = dma->sdev->prom_node;
113 init_one_dvma(dma, num_dma++);
119 #include <asm/sun4paddr.h>
121 void __init sun4_dvma_init(void)
123 struct sbus_dma *dma;
126 if(sun4_dma_physaddr) {
127 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
132 /* Only one DMA device */
135 memset(&r, 0, sizeof(r));
136 r.start = sun4_dma_physaddr;
137 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
142 init_one_dvma(dma, 0);