aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-30 03:36:11 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-30 03:36:11 -0400
commit356d164757310cd822d71da2027d50ec39798b7f (patch)
tree9a4f53bf8a27b66cf654a2fc751e0d23520ca330 /arch
parent75081322c9d0d56f8880178f9fcc93778bcf0220 (diff)
sparc: Kill EBUS driver layer.
All that remains is the EBUS DMA programming library for sparc64. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/include/asm/ebus.h8
-rw-r--r--arch/sparc/include/asm/ebus_32.h99
-rw-r--r--arch/sparc/include/asm/ebus_64.h64
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/ebus.c392
-rw-r--r--arch/sparc/kernel/pcic.c8
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c4
-rw-r--r--arch/sparc64/kernel/Makefile4
-rw-r--r--arch/sparc64/kernel/ebus.c295
-rw-r--r--arch/sparc64/kernel/pci.c4
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c4
11 files changed, 6 insertions, 877 deletions
diff --git a/arch/sparc/include/asm/ebus.h b/arch/sparc/include/asm/ebus.h
deleted file mode 100644
index 83a6d16c22e6..000000000000
--- a/arch/sparc/include/asm/ebus.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_EBUS_H
2#define ___ASM_SPARC_EBUS_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm/ebus_64.h>
5#else
6#include <asm/ebus_32.h>
7#endif
8#endif
diff --git a/arch/sparc/include/asm/ebus_32.h b/arch/sparc/include/asm/ebus_32.h
deleted file mode 100644
index f91f0b267ce1..000000000000
--- a/arch/sparc/include/asm/ebus_32.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * ebus.h: PCI to Ebus pseudo driver software state.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 *
6 * Adopted for sparc by V. Roganov and G. Raiko.
7 */
8
9#ifndef __SPARC_EBUS_H
10#define __SPARC_EBUS_H
11
12#ifndef _LINUX_IOPORT_H
13#include <linux/ioport.h>
14#endif
15#include <linux/of_device.h>
16#include <asm/oplib.h>
17#include <asm/prom.h>
18
19struct linux_ebus_child {
20 struct linux_ebus_child *next;
21 struct linux_ebus_device *parent;
22 struct linux_ebus *bus;
23 struct device_node *prom_node;
24 struct resource resource[PROMREG_MAX];
25 int num_addrs;
26 unsigned int irqs[PROMINTR_MAX];
27 int num_irqs;
28};
29
30struct linux_ebus_device {
31 struct of_device ofdev;
32 struct linux_ebus_device *next;
33 struct linux_ebus_child *children;
34 struct linux_ebus *bus;
35 struct device_node *prom_node;
36 struct resource resource[PROMREG_MAX];
37 int num_addrs;
38 unsigned int irqs[PROMINTR_MAX];
39 int num_irqs;
40};
41#define to_ebus_device(d) container_of(d, struct linux_ebus_device, ofdev.dev)
42
43struct linux_ebus {
44 struct of_device ofdev;
45 struct linux_ebus *next;
46 struct linux_ebus_device *devices;
47 struct linux_pbm_info *parent;
48 struct pci_dev *self;
49 struct device_node *prom_node;
50};
51#define to_ebus(d) container_of(d, struct linux_ebus, ofdev.dev)
52
53struct linux_ebus_dma {
54 unsigned int dcsr;
55 unsigned int dacr;
56 unsigned int dbcr;
57};
58
59#define EBUS_DCSR_INT_PEND 0x00000001
60#define EBUS_DCSR_ERR_PEND 0x00000002
61#define EBUS_DCSR_DRAIN 0x00000004
62#define EBUS_DCSR_INT_EN 0x00000010
63#define EBUS_DCSR_RESET 0x00000080
64#define EBUS_DCSR_WRITE 0x00000100
65#define EBUS_DCSR_EN_DMA 0x00000200
66#define EBUS_DCSR_CYC_PEND 0x00000400
67#define EBUS_DCSR_DIAG_RD_DONE 0x00000800
68#define EBUS_DCSR_DIAG_WR_DONE 0x00001000
69#define EBUS_DCSR_EN_CNT 0x00002000
70#define EBUS_DCSR_TC 0x00004000
71#define EBUS_DCSR_DIS_CSR_DRN 0x00010000
72#define EBUS_DCSR_BURST_SZ_MASK 0x000c0000
73#define EBUS_DCSR_BURST_SZ_1 0x00080000
74#define EBUS_DCSR_BURST_SZ_4 0x00000000
75#define EBUS_DCSR_BURST_SZ_8 0x00040000
76#define EBUS_DCSR_BURST_SZ_16 0x000c0000
77#define EBUS_DCSR_DIAG_EN 0x00100000
78#define EBUS_DCSR_DIS_ERR_PEND 0x00400000
79#define EBUS_DCSR_TCI_DIS 0x00800000
80#define EBUS_DCSR_EN_NEXT 0x01000000
81#define EBUS_DCSR_DMA_ON 0x02000000
82#define EBUS_DCSR_A_LOADED 0x04000000
83#define EBUS_DCSR_NA_LOADED 0x08000000
84#define EBUS_DCSR_DEV_ID_MASK 0xf0000000
85
86extern struct linux_ebus *ebus_chain;
87
88extern void ebus_init(void);
89
90#define for_each_ebus(bus) \
91 for((bus) = ebus_chain; (bus); (bus) = (bus)->next)
92
93#define for_each_ebusdev(dev, bus) \
94 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
95
96#define for_each_edevchild(dev, child) \
97 for((child) = (dev)->children; (child); (child) = (child)->next)
98
99#endif /* !(__SPARC_EBUS_H) */
diff --git a/arch/sparc/include/asm/ebus_64.h b/arch/sparc/include/asm/ebus_64.h
deleted file mode 100644
index cd102b8e28d3..000000000000
--- a/arch/sparc/include/asm/ebus_64.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * ebus.h: PCI to Ebus pseudo driver software state.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef __SPARC64_EBUS_H
9#define __SPARC64_EBUS_H
10
11#include <linux/of_device.h>
12
13#include <asm/oplib.h>
14#include <asm/prom.h>
15
16struct linux_ebus_child {
17 struct linux_ebus_child *next;
18 struct linux_ebus_device *parent;
19 struct linux_ebus *bus;
20 struct device_node *prom_node;
21 struct resource resource[PROMREG_MAX];
22 int num_addrs;
23 unsigned int irqs[PROMINTR_MAX];
24 int num_irqs;
25};
26
27struct linux_ebus_device {
28 struct of_device ofdev;
29 struct linux_ebus_device *next;
30 struct linux_ebus_child *children;
31 struct linux_ebus *bus;
32 struct device_node *prom_node;
33 struct resource resource[PROMREG_MAX];
34 int num_addrs;
35 unsigned int irqs[PROMINTR_MAX];
36 int num_irqs;
37};
38#define to_ebus_device(d) container_of(d, struct linux_ebus_device, ofdev.dev)
39
40struct linux_ebus {
41 struct of_device ofdev;
42 struct linux_ebus *next;
43 struct linux_ebus_device *devices;
44 struct pci_dev *self;
45 int index;
46 int is_rio;
47 struct device_node *prom_node;
48};
49#define to_ebus(d) container_of(d, struct linux_ebus, ofdev.dev)
50
51extern struct linux_ebus *ebus_chain;
52
53extern void ebus_init(void);
54
55#define for_each_ebus(bus) \
56 for((bus) = ebus_chain; (bus); (bus) = (bus)->next)
57
58#define for_each_ebusdev(dev, bus) \
59 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
60
61#define for_each_edevchild(dev, child) \
62 for((child) = (dev)->children; (child); (child) = (child)->next)
63
64#endif /* !(__SPARC64_EBUS_H) */
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index eaf7cf4296ab..a430231647e6 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_PCI) += pcic.o
21obj-$(CONFIG_SUN4) += sun4setup.o 21obj-$(CONFIG_SUN4) += sun4setup.o
22obj-$(CONFIG_SMP) += trampoline.o smp.o sun4m_smp.o sun4d_smp.o 22obj-$(CONFIG_SMP) += trampoline.o smp.o sun4m_smp.o sun4d_smp.o
23obj-$(CONFIG_SUN_AUXIO) += auxio.o 23obj-$(CONFIG_SUN_AUXIO) += auxio.o
24obj-$(CONFIG_PCI) += ebus.o
25obj-$(CONFIG_SUN_PM) += apc.o pmc.o 24obj-$(CONFIG_SUN_PM) += apc.o pmc.o
26obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o 25obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
27obj-$(CONFIG_SPARC_LED) += led.o 26obj-$(CONFIG_SPARC_LED) += led.o
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
deleted file mode 100644
index 7e9397fc6081..000000000000
--- a/arch/sparc/kernel/ebus.c
+++ /dev/null
@@ -1,392 +0,0 @@
1/*
2 * ebus.c: PCI to EBus bridge device.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 *
6 * Adopted for sparc by V. Roganov and G. Raiko.
7 * Fixes for different platforms by Pete Zaitcev.
8 */
9
10#include <linux/kernel.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/slab.h>
14#include <linux/string.h>
15
16#include <asm/system.h>
17#include <asm/page.h>
18#include <asm/pbm.h>
19#include <asm/ebus.h>
20#include <asm/io.h>
21#include <asm/oplib.h>
22#include <asm/prom.h>
23
24struct linux_ebus *ebus_chain = NULL;
25
26/* We are together with pcic.c under CONFIG_PCI. */
27extern unsigned int pcic_pin_to_irq(unsigned int, const char *name);
28
29/*
30 * IRQ Blacklist
31 * Here we list PROMs and systems that are known to supply crap as IRQ numbers.
32 */
33struct ebus_device_irq {
34 char *name;
35 unsigned int pin;
36};
37
38struct ebus_system_entry {
39 char *esname;
40 struct ebus_device_irq *ipt;
41};
42
43static struct ebus_device_irq je1_1[] = {
44 { "8042", 3 },
45 { "SUNW,CS4231", 0 },
46 { "parallel", 0 },
47 { "se", 2 },
48 { NULL, 0 }
49};
50
51/*
52 * Gleb's JE1 supplied reasonable pin numbers, but mine did not (OBP 2.32).
53 * Blacklist the sucker... Note that Gleb's system will work.
54 */
55static struct ebus_system_entry ebus_blacklist[] = {
56 { "SUNW,JavaEngine1", je1_1 },
57 { NULL, NULL }
58};
59
60static struct ebus_device_irq *ebus_blackp = NULL;
61
62/*
63 */
64static inline unsigned long ebus_alloc(size_t size)
65{
66 return (unsigned long)kmalloc(size, GFP_ATOMIC);
67}
68
69/*
70 */
71static int __init ebus_blacklist_irq(const char *name)
72{
73 struct ebus_device_irq *dp;
74
75 if ((dp = ebus_blackp) != NULL) {
76 for (; dp->name != NULL; dp++) {
77 if (strcmp(name, dp->name) == 0) {
78 return pcic_pin_to_irq(dp->pin, name);
79 }
80 }
81 }
82 return 0;
83}
84
85static void __init fill_ebus_child(struct device_node *dp,
86 struct linux_ebus_child *dev)
87{
88 const int *regs;
89 const int *irqs;
90 int i, len;
91
92 dev->prom_node = dp;
93 regs = of_get_property(dp, "reg", &len);
94 if (!regs)
95 len = 0;
96 dev->num_addrs = len / sizeof(regs[0]);
97
98 for (i = 0; i < dev->num_addrs; i++) {
99 if (regs[i] >= dev->parent->num_addrs) {
100 prom_printf("UGH: property for %s was %d, need < %d\n",
101 dev->prom_node->name, len,
102 dev->parent->num_addrs);
103 panic(__func__);
104 }
105
106 /* XXX resource */
107 dev->resource[i].start =
108 dev->parent->resource[regs[i]].start;
109 }
110
111 for (i = 0; i < PROMINTR_MAX; i++)
112 dev->irqs[i] = PCI_IRQ_NONE;
113
114 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
115 dev->num_irqs = 1;
116 } else {
117 irqs = of_get_property(dp, "interrupts", &len);
118 if (!irqs) {
119 dev->num_irqs = 0;
120 dev->irqs[0] = 0;
121 if (dev->parent->num_irqs != 0) {
122 dev->num_irqs = 1;
123 dev->irqs[0] = dev->parent->irqs[0];
124 }
125 } else {
126 dev->num_irqs = len / sizeof(irqs[0]);
127 if (irqs[0] == 0 || irqs[0] >= 8) {
128 /*
129 * XXX Zero is a valid pin number...
130 * This works as long as Ebus is not wired
131 * to INTA#.
132 */
133 printk("EBUS: %s got bad irq %d from PROM\n",
134 dev->prom_node->name, irqs[0]);
135 dev->num_irqs = 0;
136 dev->irqs[0] = 0;
137 } else {
138 dev->irqs[0] =
139 pcic_pin_to_irq(irqs[0],
140 dev->prom_node->name);
141 }
142 }
143 }
144}
145
146static void __init fill_ebus_device(struct device_node *dp,
147 struct linux_ebus_device *dev)
148{
149 const struct linux_prom_registers *regs;
150 struct linux_ebus_child *child;
151 struct dev_archdata *sd;
152 const int *irqs;
153 int i, n, len;
154 unsigned long baseaddr;
155
156 dev->prom_node = dp;
157
158 regs = of_get_property(dp, "reg", &len);
159 if (!regs)
160 len = 0;
161 if (len % sizeof(struct linux_prom_registers)) {
162 prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
163 dev->prom_node->name, len,
164 (int)sizeof(struct linux_prom_registers));
165 panic(__func__);
166 }
167 dev->num_addrs = len / sizeof(struct linux_prom_registers);
168
169 for (i = 0; i < dev->num_addrs; i++) {
170 /*
171 * XXX Collect JE-1 PROM
172 *
173 * Example - JS-E with 3.11:
174 * /ebus
175 * regs
176 * 0x00000000, 0x0, 0x00000000, 0x0, 0x00000000,
177 * 0x82000010, 0x0, 0xf0000000, 0x0, 0x01000000,
178 * 0x82000014, 0x0, 0x38800000, 0x0, 0x00800000,
179 * ranges
180 * 0x00, 0x00000000, 0x02000010, 0x0, 0x0, 0x01000000,
181 * 0x01, 0x01000000, 0x02000014, 0x0, 0x0, 0x00800000,
182 * /ebus/8042
183 * regs
184 * 0x00000001, 0x00300060, 0x00000008,
185 * 0x00000001, 0x00300060, 0x00000008,
186 */
187 n = regs[i].which_io;
188 if (n >= 4) {
189 /* XXX This is copied from old JE-1 by Gleb. */
190 n = (regs[i].which_io - 0x10) >> 2;
191 } else {
192 ;
193 }
194
195/*
196 * XXX Now as we have regions, why don't we make an on-demand allocation...
197 */
198 dev->resource[i].start = 0;
199 if ((baseaddr = dev->bus->self->resource[n].start +
200 regs[i].phys_addr) != 0) {
201 /* dev->resource[i].name = dev->prom_name; */
202 if ((baseaddr = (unsigned long) ioremap(baseaddr,
203 regs[i].reg_size)) == 0) {
204 panic("ebus: unable to remap dev %s",
205 dev->prom_node->name);
206 }
207 }
208 dev->resource[i].start = baseaddr; /* XXX Unaligned */
209 }
210
211 for (i = 0; i < PROMINTR_MAX; i++)
212 dev->irqs[i] = PCI_IRQ_NONE;
213
214 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
215 dev->num_irqs = 1;
216 } else {
217 irqs = of_get_property(dp, "interrupts", &len);
218 if (!irqs) {
219 dev->num_irqs = 0;
220 if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
221 dev->num_irqs = 1;
222/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
223 }
224 } else {
225 dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */
226 if (irqs[0] == 0 || irqs[0] >= 8) {
227 /* See above for the parent. XXX */
228 printk("EBUS: %s got bad irq %d from PROM\n",
229 dev->prom_node->name, irqs[0]);
230 dev->num_irqs = 0;
231 dev->irqs[0] = 0;
232 } else {
233 dev->irqs[0] =
234 pcic_pin_to_irq(irqs[0],
235 dev->prom_node->name);
236 }
237 }
238 }
239
240 sd = &dev->ofdev.dev.archdata;
241 sd->prom_node = dp;
242 sd->op = &dev->ofdev;
243 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
244
245 dev->ofdev.node = dp;
246 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
247 dev->ofdev.dev.bus = &ebus_bus_type;
248 sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
249
250 /* Register with core */
251 if (of_device_register(&dev->ofdev) != 0)
252 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
253 dp->path_component_name);
254
255 if ((dp = dp->child) != NULL) {
256 dev->children = (struct linux_ebus_child *)
257 ebus_alloc(sizeof(struct linux_ebus_child));
258
259 child = dev->children;
260 child->next = NULL;
261 child->parent = dev;
262 child->bus = dev->bus;
263 fill_ebus_child(dp, child);
264
265 while ((dp = dp->sibling) != NULL) {
266 child->next = (struct linux_ebus_child *)
267 ebus_alloc(sizeof(struct linux_ebus_child));
268
269 child = child->next;
270 child->next = NULL;
271 child->parent = dev;
272 child->bus = dev->bus;
273 fill_ebus_child(dp, child);
274 }
275 }
276}
277
278void __init ebus_init(void)
279{
280 const struct linux_prom_pci_registers *regs;
281 struct linux_pbm_info *pbm;
282 struct linux_ebus_device *dev;
283 struct linux_ebus *ebus;
284 struct ebus_system_entry *sp;
285 struct pci_dev *pdev;
286 struct pcidev_cookie *cookie;
287 struct device_node *dp;
288 struct resource *p;
289 unsigned short pci_command;
290 int len, reg, nreg;
291 int num_ebus = 0;
292
293 dp = of_find_node_by_path("/");
294 for (sp = ebus_blacklist; sp->esname != NULL; sp++) {
295 if (strcmp(dp->name, sp->esname) == 0) {
296 ebus_blackp = sp->ipt;
297 break;
298 }
299 }
300
301 pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL);
302 if (!pdev)
303 return;
304
305 cookie = pdev->sysdata;
306 dp = cookie->prom_node;
307
308 ebus_chain = ebus = (struct linux_ebus *)
309 ebus_alloc(sizeof(struct linux_ebus));
310 ebus->next = NULL;
311
312 while (dp) {
313 struct device_node *nd;
314
315 ebus->prom_node = dp;
316 ebus->self = pdev;
317 ebus->parent = pbm = cookie->pbm;
318
319 /* Enable BUS Master. */
320 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
321 pci_command |= PCI_COMMAND_MASTER;
322 pci_write_config_word(pdev, PCI_COMMAND, pci_command);
323
324 regs = of_get_property(dp, "reg", &len);
325 if (!regs) {
326 prom_printf("%s: can't find reg property\n",
327 __func__);
328 prom_halt();
329 }
330 nreg = len / sizeof(struct linux_prom_pci_registers);
331
332 p = &ebus->self->resource[0];
333 for (reg = 0; reg < nreg; reg++) {
334 if (!(regs[reg].which_io & 0x03000000))
335 continue;
336
337 (p++)->start = regs[reg].phys_lo;
338 }
339
340 ebus->ofdev.node = dp;
341 ebus->ofdev.dev.parent = &pdev->dev;
342 ebus->ofdev.dev.bus = &ebus_bus_type;
343 sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
344
345 /* Register with core */
346 if (of_device_register(&ebus->ofdev) != 0)
347 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
348 dp->path_component_name);
349
350
351 nd = dp->child;
352 if (!nd)
353 goto next_ebus;
354
355 ebus->devices = (struct linux_ebus_device *)
356 ebus_alloc(sizeof(struct linux_ebus_device));
357
358 dev = ebus->devices;
359 dev->next = NULL;
360 dev->children = NULL;
361 dev->bus = ebus;
362 fill_ebus_device(nd, dev);
363
364 while ((nd = nd->sibling) != NULL) {
365 dev->next = (struct linux_ebus_device *)
366 ebus_alloc(sizeof(struct linux_ebus_device));
367
368 dev = dev->next;
369 dev->next = NULL;
370 dev->children = NULL;
371 dev->bus = ebus;
372 fill_ebus_device(nd, dev);
373 }
374
375 next_ebus:
376 pdev = pci_get_device(PCI_VENDOR_ID_SUN,
377 PCI_DEVICE_ID_SUN_EBUS, pdev);
378 if (!pdev)
379 break;
380
381 cookie = pdev->sysdata;
382 dp = cookie->prom_node;
383
384 ebus->next = (struct linux_ebus *)
385 ebus_alloc(sizeof(struct linux_ebus));
386 ebus = ebus->next;
387 ebus->next = NULL;
388 ++num_ebus;
389 }
390 if (pdev)
391 pci_dev_put(pdev);
392}
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 9a0aa4ec5793..e5950b03df13 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -17,7 +17,6 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/jiffies.h> 18#include <linux/jiffies.h>
19 19
20#include <asm/ebus.h>
21#include <asm/swift.h> /* for cache flushing. */ 20#include <asm/swift.h> /* for cache flushing. */
22#include <asm/io.h> 21#include <asm/io.h>
23 22
@@ -429,7 +428,6 @@ static int __init pcic_init(void)
429 428
430 pcic_pbm_scan_bus(pcic); 429 pcic_pbm_scan_bus(pcic);
431 430
432 ebus_init();
433 return 0; 431 return 0;
434} 432}
435 433
@@ -492,10 +490,6 @@ static void pcic_map_pci_device(struct linux_pcic *pcic,
492 * do ioremap() before accessing PC-style I/O, 490 * do ioremap() before accessing PC-style I/O,
493 * we supply virtual, ready to access address. 491 * we supply virtual, ready to access address.
494 * 492 *
495 * Ebus devices do not come here even if
496 * CheerIO makes a similar conversion.
497 * See ebus.c for details.
498 *
499 * Note that request_region() 493 * Note that request_region()
500 * works for these devices. 494 * works for these devices.
501 * 495 *
@@ -676,7 +670,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
676} 670}
677 671
678/* 672/*
679 * pcic_pin_to_irq() is exported to ebus.c. 673 * pcic_pin_to_irq() is exported to bus probing code
680 */ 674 */
681unsigned int 675unsigned int
682pcic_pin_to_irq(unsigned int pin, const char *name) 676pcic_pin_to_irq(unsigned int pin, const char *name)
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 50ec48ddef65..6007ac5a7360 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -45,9 +45,6 @@
45#ifdef CONFIG_SBUS 45#ifdef CONFIG_SBUS
46#include <asm/dma.h> 46#include <asm/dma.h>
47#endif 47#endif
48#ifdef CONFIG_PCI
49#include <asm/ebus.h>
50#endif
51#include <asm/io-unit.h> 48#include <asm/io-unit.h>
52#include <asm/bug.h> 49#include <asm/bug.h>
53 50
@@ -152,7 +149,6 @@ EXPORT_SYMBOL(BTFIXUP_CALL(pgprot_noncached));
152EXPORT_SYMBOL(sbus_set_sbus64); 149EXPORT_SYMBOL(sbus_set_sbus64);
153#endif 150#endif
154#ifdef CONFIG_PCI 151#ifdef CONFIG_PCI
155EXPORT_SYMBOL(ebus_chain);
156EXPORT_SYMBOL(insb); 152EXPORT_SYMBOL(insb);
157EXPORT_SYMBOL(outsb); 153EXPORT_SYMBOL(outsb);
158EXPORT_SYMBOL(insw); 154EXPORT_SYMBOL(insw);
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index 360a348e5bbb..928aa7c8058e 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -11,12 +11,12 @@ obj-y := process.o setup.o cpu.o idprom.o \
11 traps.o auxio.o una_asm.o sysfs.o iommu.o \ 11 traps.o auxio.o una_asm.o sysfs.o iommu.o \
12 irq.o ptrace.o time.o sys_sparc.o signal.o \ 12 irq.o ptrace.o time.o sys_sparc.o signal.o \
13 unaligned.o central.o starfire.o \ 13 unaligned.o central.o starfire.o \
14 power.o sbus.o sparc64_ksyms.o \ 14 power.o sbus.o sparc64_ksyms.o ebus.o \
15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o 15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o
16 16
17obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 17obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
18obj-$(CONFIG_STACKTRACE) += stacktrace.o 18obj-$(CONFIG_STACKTRACE) += stacktrace.o
19obj-$(CONFIG_PCI) += ebus.o pci.o pci_common.o \ 19obj-$(CONFIG_PCI) += pci.o pci_common.o \
20 pci_psycho.o pci_sabre.o pci_schizo.o \ 20 pci_psycho.o pci_sabre.o pci_schizo.o \
21 pci_sun4v.o pci_sun4v_asm.o pci_fire.o 21 pci_sun4v.o pci_sun4v_asm.o pci_fire.o
22obj-$(CONFIG_PCI_MSI) += pci_msi.o 22obj-$(CONFIG_PCI_MSI) += pci_msi.o
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 88408741c320..77dbf6d45faf 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -1,5 +1,4 @@
1/* 1/* ebus.c: EBUS DMA library code.
2 * ebus.c: PCI to EBus bridge device.
3 * 2 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 3 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com) 4 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -9,24 +8,12 @@
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/init.h> 10#include <linux/init.h>
12#include <linux/slab.h>
13#include <linux/string.h>
14#include <linux/interrupt.h> 11#include <linux/interrupt.h>
15#include <linux/delay.h> 12#include <linux/delay.h>
16#include <linux/pci.h>
17#include <linux/of_device.h>
18 13
19#include <asm/system.h>
20#include <asm/page.h>
21#include <asm/ebus.h>
22#include <asm/ebus_dma.h> 14#include <asm/ebus_dma.h>
23#include <asm/oplib.h>
24#include <asm/prom.h>
25#include <asm/irq.h>
26#include <asm/io.h> 15#include <asm/io.h>
27 16
28/* EBUS dma library. */
29
30#define EBDMA_CSR 0x00UL /* Control/Status */ 17#define EBDMA_CSR 0x00UL /* Control/Status */
31#define EBDMA_ADDR 0x04UL /* DMA Address */ 18#define EBDMA_ADDR 0x04UL /* DMA Address */
32#define EBDMA_COUNT 0x08UL /* DMA Count */ 19#define EBDMA_COUNT 0x08UL /* DMA Count */
@@ -268,283 +255,3 @@ void ebus_dma_enable(struct ebus_dma_info *p, int on)
268 spin_unlock_irqrestore(&p->lock, flags); 255 spin_unlock_irqrestore(&p->lock, flags);
269} 256}
270EXPORT_SYMBOL(ebus_dma_enable); 257EXPORT_SYMBOL(ebus_dma_enable);
271
272struct linux_ebus *ebus_chain = NULL;
273
274static inline void *ebus_alloc(size_t size)
275{
276 void *mem;
277
278 mem = kzalloc(size, GFP_ATOMIC);
279 if (!mem)
280 panic("ebus_alloc: out of memory");
281 return mem;
282}
283
284static void __init fill_ebus_child(struct device_node *dp,
285 struct linux_ebus_child *dev,
286 int non_standard_regs)
287{
288 struct of_device *op;
289 const int *regs;
290 int i, len;
291
292 dev->prom_node = dp;
293 printk(" (%s)", dp->name);
294
295 regs = of_get_property(dp, "reg", &len);
296 if (!regs)
297 dev->num_addrs = 0;
298 else
299 dev->num_addrs = len / sizeof(regs[0]);
300
301 if (non_standard_regs) {
302 /* This is to handle reg properties which are not
303 * in the parent relative format. One example are
304 * children of the i2c device on CompactPCI systems.
305 *
306 * So, for such devices we just record the property
307 * raw in the child resources.
308 */
309 for (i = 0; i < dev->num_addrs; i++)
310 dev->resource[i].start = regs[i];
311 } else {
312 for (i = 0; i < dev->num_addrs; i++) {
313 int rnum = regs[i];
314 if (rnum >= dev->parent->num_addrs) {
315 prom_printf("UGH: property for %s was %d, need < %d\n",
316 dp->name, len, dev->parent->num_addrs);
317 prom_halt();
318 }
319 dev->resource[i].start = dev->parent->resource[i].start;
320 dev->resource[i].end = dev->parent->resource[i].end;
321 dev->resource[i].flags = IORESOURCE_MEM;
322 dev->resource[i].name = dp->name;
323 }
324 }
325
326 op = of_find_device_by_node(dp);
327 if (!op) {
328 dev->num_irqs = 0;
329 } else {
330 dev->num_irqs = op->num_irqs;
331 for (i = 0; i < dev->num_irqs; i++)
332 dev->irqs[i] = op->irqs[i];
333 }
334
335 if (!dev->num_irqs) {
336 /*
337 * Oh, well, some PROMs don't export interrupts
338 * property to children of EBus devices...
339 *
340 * Be smart about PS/2 keyboard and mouse.
341 */
342 if (!strcmp(dev->parent->prom_node->name, "8042")) {
343 if (!strcmp(dev->prom_node->name, "kb_ps2")) {
344 dev->num_irqs = 1;
345 dev->irqs[0] = dev->parent->irqs[0];
346 } else {
347 dev->num_irqs = 1;
348 dev->irqs[0] = dev->parent->irqs[1];
349 }
350 }
351 }
352}
353
354static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
355{
356 if (!strcmp(dev->prom_node->name, "i2c") ||
357 !strcmp(dev->prom_node->name, "SUNW,lombus"))
358 return 1;
359 return 0;
360}
361
362static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
363{
364 struct linux_ebus_child *child;
365 struct dev_archdata *sd;
366 struct of_device *op;
367 int i, len;
368
369 dev->prom_node = dp;
370
371 printk(" [%s", dp->name);
372
373 op = of_find_device_by_node(dp);
374 if (!op) {
375 dev->num_addrs = 0;
376 dev->num_irqs = 0;
377 } else {
378 const int *regs = of_get_property(dp, "reg", &len);
379
380 if (!regs)
381 len = 0;
382 dev->num_addrs = len / sizeof(struct linux_prom_registers);
383
384 for (i = 0; i < dev->num_addrs; i++)
385 memcpy(&dev->resource[i],
386 &op->resource[i],
387 sizeof(struct resource));
388
389 dev->num_irqs = op->num_irqs;
390 for (i = 0; i < dev->num_irqs; i++)
391 dev->irqs[i] = op->irqs[i];
392 }
393
394 sd = &dev->ofdev.dev.archdata;
395 sd->prom_node = dp;
396 sd->op = &dev->ofdev;
397 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
398 sd->stc = dev->bus->ofdev.dev.parent->archdata.stc;
399 sd->numa_node = dev->bus->ofdev.dev.parent->archdata.numa_node;
400
401 dev->ofdev.node = dp;
402 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
403 dev->ofdev.dev.bus = &ebus_bus_type;
404 dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node);
405
406 /* Register with core */
407 if (of_device_register(&dev->ofdev) != 0)
408 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
409 dp->path_component_name);
410
411 dp = dp->child;
412 if (dp) {
413 printk(" ->");
414 dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
415
416 child = dev->children;
417 child->next = NULL;
418 child->parent = dev;
419 child->bus = dev->bus;
420 fill_ebus_child(dp, child,
421 child_regs_nonstandard(dev));
422
423 while ((dp = dp->sibling) != NULL) {
424 child->next = ebus_alloc(sizeof(struct linux_ebus_child));
425
426 child = child->next;
427 child->next = NULL;
428 child->parent = dev;
429 child->bus = dev->bus;
430 fill_ebus_child(dp, child,
431 child_regs_nonstandard(dev));
432 }
433 }
434 printk("]");
435}
436
437static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
438{
439 struct pci_dev *pdev = start;
440
441 while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
442 if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
443 pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
444 break;
445
446 *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
447
448 return pdev;
449}
450
451void __init ebus_init(void)
452{
453 struct linux_ebus_device *dev;
454 struct linux_ebus *ebus;
455 struct pci_dev *pdev;
456 struct device_node *dp;
457 int is_rio;
458 int num_ebus = 0;
459
460 pdev = find_next_ebus(NULL, &is_rio);
461 if (!pdev) {
462 printk("ebus: No EBus's found.\n");
463 return;
464 }
465
466 dp = pci_device_to_OF_node(pdev);
467
468 ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
469 ebus->next = NULL;
470 ebus->is_rio = is_rio;
471
472 while (dp) {
473 struct device_node *child;
474
475 /* SUNW,pci-qfe uses four empty ebuses on it.
476 I think we should not consider them here,
477 as they have half of the properties this
478 code expects and once we do PCI hot-plug,
479 we'd have to tweak with the ebus_chain
480 in the runtime after initialization. -jj */
481 if (!dp->child) {
482 pdev = find_next_ebus(pdev, &is_rio);
483 if (!pdev) {
484 if (ebus == ebus_chain) {
485 ebus_chain = NULL;
486 printk("ebus: No EBus's found.\n");
487 return;
488 }
489 break;
490 }
491 ebus->is_rio = is_rio;
492 dp = pci_device_to_OF_node(pdev);
493 continue;
494 }
495 printk("ebus%d:", num_ebus);
496
497 ebus->index = num_ebus;
498 ebus->prom_node = dp;
499 ebus->self = pdev;
500
501 ebus->ofdev.node = dp;
502 ebus->ofdev.dev.parent = &pdev->dev;
503 ebus->ofdev.dev.bus = &ebus_bus_type;
504 dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus);
505
506 /* Register with core */
507 if (of_device_register(&ebus->ofdev) != 0)
508 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
509 dp->path_component_name);
510
511
512 child = dp->child;
513 if (!child)
514 goto next_ebus;
515
516 ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
517
518 dev = ebus->devices;
519 dev->next = NULL;
520 dev->children = NULL;
521 dev->bus = ebus;
522 fill_ebus_device(child, dev);
523
524 while ((child = child->sibling) != NULL) {
525 dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
526
527 dev = dev->next;
528 dev->next = NULL;
529 dev->children = NULL;
530 dev->bus = ebus;
531 fill_ebus_device(child, dev);
532 }
533
534 next_ebus:
535 printk("\n");
536
537 pdev = find_next_ebus(pdev, &is_rio);
538 if (!pdev)
539 break;
540
541 dp = pci_device_to_OF_node(pdev);
542
543 ebus->next = ebus_alloc(sizeof(struct linux_ebus));
544 ebus = ebus->next;
545 ebus->next = NULL;
546 ebus->is_rio = is_rio;
547 ++num_ebus;
548 }
549 pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
550}
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 71d423a1c17a..218778617ee4 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -18,11 +18,12 @@
18#include <linux/msi.h> 18#include <linux/msi.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21 23
22#include <asm/uaccess.h> 24#include <asm/uaccess.h>
23#include <asm/pgtable.h> 25#include <asm/pgtable.h>
24#include <asm/irq.h> 26#include <asm/irq.h>
25#include <asm/ebus.h>
26#include <asm/prom.h> 27#include <asm/prom.h>
27#include <asm/apb.h> 28#include <asm/apb.h>
28 29
@@ -808,7 +809,6 @@ static int __init pcibios_init(void)
808 809
809 pci_scan_each_controller_bus(); 810 pci_scan_each_controller_bus();
810 811
811 ebus_init();
812 power_init(); 812 power_init();
813 813
814 return 0; 814 return 0;
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 4c3a6a87c8a4..30bba8b0a3b0 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -45,9 +45,6 @@
45#ifdef CONFIG_SBUS 45#ifdef CONFIG_SBUS
46#include <asm/dma.h> 46#include <asm/dma.h>
47#endif 47#endif
48#ifdef CONFIG_PCI
49#include <asm/ebus.h>
50#endif
51#include <asm/ns87303.h> 48#include <asm/ns87303.h>
52#include <asm/timer.h> 49#include <asm/timer.h>
53#include <asm/cpudata.h> 50#include <asm/cpudata.h>
@@ -165,7 +162,6 @@ EXPORT_SYMBOL(insb);
165EXPORT_SYMBOL(insw); 162EXPORT_SYMBOL(insw);
166EXPORT_SYMBOL(insl); 163EXPORT_SYMBOL(insl);
167#ifdef CONFIG_PCI 164#ifdef CONFIG_PCI
168EXPORT_SYMBOL(ebus_chain);
169EXPORT_SYMBOL(pci_alloc_consistent); 165EXPORT_SYMBOL(pci_alloc_consistent);
170EXPORT_SYMBOL(pci_free_consistent); 166EXPORT_SYMBOL(pci_free_consistent);
171EXPORT_SYMBOL(pci_map_single); 167EXPORT_SYMBOL(pci_map_single);