[PATCH] usbcore: Improve endpoint sysfs file handling
[linux/fpc-iii.git] / drivers / sbus / dvma.c
blob378a1d68024da32556eeda812f5dfea7a0203b86
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 void __init init_one_dvma(struct sbus_dma *dma, int num_dma)
22 printk("dma%d: ", num_dma);
24 dma->next = NULL;
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) {
28 case DMA_VERS0:
29 dma->revision = dvmarev0;
30 printk("Revision 0 ");
31 break;
32 case DMA_ESCV1:
33 dma->revision = dvmaesc1;
34 printk("ESC Revision 1 ");
35 break;
36 case DMA_VERS1:
37 dma->revision = dvmarev1;
38 printk("Revision 1 ");
39 break;
40 case DMA_VERS2:
41 dma->revision = dvmarev2;
42 printk("Revision 2 ");
43 break;
44 case DMA_VERHME:
45 dma->revision = dvmahme;
46 printk("HME DVMA gate array ");
47 break;
48 case DMA_VERSPLUS:
49 dma->revision = dvmarevplus;
50 printk("Revision 1 PLUS ");
51 break;
52 default:
53 printk("unknown dma version %08x",
54 sbus_readl(dma->regs + DMA_CSR) & DMA_DEVICE_ID);
55 dma->allocated = 1;
56 break;
58 printk("\n");
61 /* Probe this SBus DMA module(s) */
62 void __init dvma_init(struct sbus_bus *sbus)
64 struct sbus_dev *this_dev;
65 struct sbus_dma *dma;
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;
71 int hme = 0;
73 if(!strcmp(name, "SUNW,fas"))
74 hme = 1;
75 else if(strcmp(name, "dma") &&
76 strcmp(name, "ledma") &&
77 strcmp(name, "espdma"))
78 continue;
80 /* Found one... */
81 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
83 dma->sdev = this_dev;
85 /* Put at end of dma chain */
86 dchain = dma_chain;
87 if(dchain) {
88 while(dchain->next)
89 dchain = dchain->next;
90 dchain->next = dma;
91 } else {
92 /* We're the first in line */
93 dma_chain = dma;
96 dma->regs = sbus_ioremap(&dma->sdev->resource[0], 0,
97 dma->sdev->resource[0].end - dma->sdev->resource[0].start + 1,
98 "dma");
100 dma->node = dma->sdev->prom_node;
102 init_one_dvma(dma, num_dma++);
106 #ifdef CONFIG_SUN4
108 #include <asm/sun4paddr.h>
110 void __init sun4_dvma_init(void)
112 struct sbus_dma *dma;
113 struct resource r;
115 if(sun4_dma_physaddr) {
116 dma = kmalloc(sizeof(struct sbus_dma), GFP_ATOMIC);
118 /* No SBUS */
119 dma->sdev = NULL;
121 /* Only one DMA device */
122 dma_chain = dma;
124 memset(&r, 0, sizeof(r));
125 r.start = sun4_dma_physaddr;
126 dma->regs = sbus_ioremap(&r, 0, PAGE_SIZE, "dma");
128 /* No prom node */
129 dma->node = 0x0;
131 init_one_dvma(dma, 0);
132 } else {
133 dma_chain = NULL;
137 #endif