[PATCH] sparse (compat_ioctl): CDROM_SEND_PACKET handling
[linux-2.6/history.git] / drivers / sbus / dvma.c
blobf15a3016e427bf9be58801bc478fcab4588e01d0
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)
4 */
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>
14 #include <asm/io.h>
15 #include <asm/dma.h>
16 #include <asm/sbus.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);
32 dma->next = 0;
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) {
36 case DMA_VERS0:
37 dma->revision = dvmarev0;
38 printk("Revision 0 ");
39 break;
40 case DMA_ESCV1:
41 dma->revision = dvmaesc1;
42 printk("ESC Revision 1 ");
43 break;
44 case DMA_VERS1:
45 dma->revision = dvmarev1;
46 printk("Revision 1 ");
47 break;
48 case DMA_VERS2:
49 dma->revision = dvmarev2;
50 printk("Revision 2 ");
51 break;
52 case DMA_VERHME:
53 dma->revision = dvmahme;
54 printk("HME DVMA gate array ");
55 break;
56 case DMA_VERSPLUS:
57 dma->revision = dvmarevplus;
58 printk("Revision 1 PLUS ");
59 break;
60 default:
61 printk("unknown dma version %08x",
62 sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
63 dma->allocated = 1;
64 break;
66 printk("\n");
67 #if 0 /* Clutters up the screen */
68 dump_dma_regs(dma->regs);
69 #endif
72 /* Probe this SBus DMA module(s) */
73 void __init dvma_init(struct sbus_bus *sbus)
75 struct sbus_dev *this_dev;
76 struct sbus_dma *dma;
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;
82 int hme = 0;
84 if(!strcmp(name, "SUNW,fas"))
85 hme = 1;
86 else if(strcmp(name, "dma") &&
87 strcmp(name, "ledma") &&
88 strcmp(name, "espdma"))
89 continue;
91 /* Found one... */
92 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
94 dma->sdev = this_dev;
96 /* Put at end of dma chain */
97 dchain = dma_chain;
98 if(dchain) {
99 while(dchain->next)
100 dchain = dchain->next;
101 dchain->next = dma;
102 } else {
103 /* We're the first in line */
104 dma_chain = dma;
107 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
108 dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
109 "dma");
111 dma->node = dma->sdev->prom_node;
113 init_one_dvma(dma, num_dma++);
117 #ifdef CONFIG_SUN4
119 #include <asm/sun4paddr.h>
121 void __init sun4_dvma_init(void)
123 struct sbus_dma *dma;
124 struct sbus_dma *dchain;
125 struct resource r;
127 if(sun4_dma_physaddr) {
128 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
130 /* No SBUS */
131 dma->sdev = NULL;
133 /* Only one DMA device */
134 dma_chain = dma;
136 memset(&r, 0, sizeof(r));
137 r.start = sun4_dma_physaddr;
138 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
140 /* No prom node */
141 dma->node = 0x0;
143 init_one_dvma(dma, 0);
144 } else {
145 dma_chain = NULL;
149 #endif