more debug output
[linux-2.4.git] / drivers / sbus / dvma.c
1 /* dvma.c:  Routines that are used to access DMA on the Sparc SBus.
2  *
3  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
4  */
5
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>
12
13 #include <asm/oplib.h>
14 #include <asm/io.h>
15 #include <asm/dma.h>
16 #include <asm/sbus.h>
17
18 struct sbus_dma *dma_chain;
19
20 /* Print out the current values in the DMA control registers */
21 static inline void dump_dma_regs(unsigned long dregs)
22 {
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));
26 }
27
28 void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
29 {
30         printk("dma%d: ", num_dma);
31         
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;
65         }
66         printk("\n");
67 #if 0 /* Clutters up the screen */
68         dump_dma_regs(dma->regs);
69 #endif
70 }
71
72 /* Probe this SBus DMA module(s) */
73 void __init dvma_init(struct sbus_bus *sbus)
74 {
75         struct sbus_dev *this_dev;
76         struct sbus_dma *dma;
77         struct sbus_dma *dchain;
78         static int num_dma = 0;
79
80         for_each_sbusdev(this_dev, sbus) {
81                 char *name = this_dev->prom_name;
82                 int hme = 0;
83
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;
90
91                 /* Found one... */
92                 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
93
94                 dma->sdev = this_dev;
95
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;
105                 }
106
107                 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
108                                          dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
109                                          "dma");
110
111                 dma->node = dma->sdev->prom_node;
112                 
113                 init_one_dvma(dma, num_dma++);
114         }
115 }
116
117 #ifdef CONFIG_SUN4
118
119 #include <asm/sun4paddr.h>
120
121 void __init sun4_dvma_init(void)
122 {
123         struct sbus_dma *dma;
124         struct sbus_dma *dchain;
125         struct resource r;
126
127         if(sun4_dma_physaddr) {
128                 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
129
130                 /* No SBUS */
131                 dma->sdev = NULL;
132
133                 /* Only one DMA device */
134                 dma_chain = dma;
135
136                 memset(&r, 0, sizeof(r));
137                 r.start = sun4_dma_physaddr;
138                 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
139
140                 /* No prom node */
141                 dma->node = 0x0;
142
143                 init_one_dvma(dma, 0);
144         } else {
145                 dma_chain = NULL;
146         }
147 }
148
149 #endif