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 void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
22 printk("dma%d: ", num_dma);
25 dma->running = 0; /* No transfers going on as of yet */
26 dma->allocated = 0; /* No one has allocated us yet */
27 switch(sbus_readl(dma->regs + DMA_CSR)&DMA_DEVICE_ID) {
29 dma->revision = dvmarev0;
30 printk("Revision 0 ");
33 dma->revision = dvmaesc1;
34 printk("ESC Revision 1 ");
37 dma->revision = dvmarev1;
38 printk("Revision 1 ");
41 dma->revision = dvmarev2;
42 printk("Revision 2 ");
45 dma->revision = dvmahme;
46 printk("HME DVMA gate array ");
49 dma->revision = dvmarevplus;
50 printk("Revision 1 PLUS ");
53 printk("unknown dma version %08x",
54 sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
61 /* Probe this SBus DMA module(s) */
62 void __init dvma_init(struct sbus_bus *sbus)
64 struct sbus_dev *this_dev;
66 struct sbus_dma *dchain;
67 static int num_dma = 0;
69 for_each_sbusdev(this_dev, sbus) {
70 char *name = this_dev->prom_name;
73 if(!strcmp(name, "SUNW,fas"))
75 else if(strcmp(name, "dma") &&
76 strcmp(name, "ledma") &&
77 strcmp(name, "espdma"))
81 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
85 /* Put at end of dma chain */
89 dchain = dchain->next;
92 /* We're the first in line */
96 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
97 dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
100 dma->node = dma->sdev->prom_node;
102 init_one_dvma(dma, num_dma++);
108 #include <asm/sun4paddr.h>
110 void __init sun4_dvma_init(void)
112 struct sbus_dma *dma;
115 if(sun4_dma_physaddr) {
116 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
121 /* Only one DMA device */
124 memset(&r, 0, sizeof(r));
125 r.start = sun4_dma_physaddr;
126 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
131 init_one_dvma(dma, 0);