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/string.h>
7 #include <linux/kernel.h>
8 #include <linux/slab.h>
9 #include <linux/init.h>
10 #include <linux/delay.h>
12 #include <asm/oplib.h>
17 struct sbus_dma *dma_chain;
19 static void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
21 printk("dma%d: ", num_dma);
24 dma->running = 0; /* No transfers going on as of yet */
25 dma->allocated = 0; /* No one has allocated us yet */
26 switch(sbus_readl(dma->regs + DMA_CSR)&DMA_DEVICE_ID) {
28 dma->revision = dvmarev0;
29 printk("Revision 0 ");
32 dma->revision = dvmaesc1;
33 printk("ESC Revision 1 ");
36 dma->revision = dvmarev1;
37 printk("Revision 1 ");
40 dma->revision = dvmarev2;
41 printk("Revision 2 ");
44 dma->revision = dvmahme;
45 printk("HME DVMA gate array ");
48 dma->revision = dvmarevplus;
49 printk("Revision 1 PLUS ");
52 printk("unknown dma version %08x",
53 sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
60 /* Probe this SBus DMA module(s) */
61 void __init dvma_init(struct sbus_bus *sbus)
63 struct sbus_dev *this_dev;
65 struct sbus_dma *dchain;
66 static int num_dma = 0;
68 for_each_sbusdev(this_dev, sbus) {
69 char *name = this_dev->prom_name;
72 if(!strcmp(name, "SUNW,fas"))
74 else if(strcmp(name, "dma") &&
75 strcmp(name, "ledma") &&
76 strcmp(name, "espdma"))
80 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
84 /* Put at end of dma chain */
88 dchain = dchain->next;
91 /* We're the first in line */
95 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
96 dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
99 dma->node = dma->sdev->prom_node;
101 init_one_dvma(dma, num_dma++);
107 #include <asm/sun4paddr.h>
109 void __init sun4_dvma_init(void)
111 struct sbus_dma *dma;
114 if(sun4_dma_physaddr) {
115 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
120 /* Only one DMA device */
123 memset(&r, 0, sizeof(r));
124 r.start = sun4_dma_physaddr;
125 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
130 init_one_dvma(dma, 0);