aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/ebus.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/ebus.c')
-rw-r--r--arch/sparc/kernel/ebus.c164
1 files changed, 84 insertions, 80 deletions
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
index 5c3529ceb5d6..9d461da76399 100644
--- a/arch/sparc/kernel/ebus.c
+++ b/arch/sparc/kernel/ebus.c
@@ -20,6 +20,7 @@
20#include <asm/ebus.h> 20#include <asm/ebus.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/oplib.h> 22#include <asm/oplib.h>
23#include <asm/prom.h>
23#include <asm/bpp.h> 24#include <asm/bpp.h>
24 25
25struct linux_ebus *ebus_chain = NULL; 26struct linux_ebus *ebus_chain = NULL;
@@ -83,79 +84,81 @@ int __init ebus_blacklist_irq(char *name)
83 return 0; 84 return 0;
84} 85}
85 86
86void __init fill_ebus_child(int node, struct linux_prom_registers *preg, 87void __init fill_ebus_child(struct device_node *dp,
87 struct linux_ebus_child *dev) 88 struct linux_ebus_child *dev)
88{ 89{
89 int regs[PROMREG_MAX]; 90 int *regs;
90 int irqs[PROMREG_MAX]; 91 int *irqs;
91 char lbuf[128];
92 int i, len; 92 int i, len;
93 93
94 dev->prom_node = node; 94 dev->prom_node = dp;
95 prom_getstring(node, "name", lbuf, sizeof(lbuf)); 95 regs = of_get_property(dp, "reg", &len);
96 strcpy(dev->prom_name, lbuf); 96 if (!regs)
97 97 len = 0;
98 len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
99 if (len == -1) len = 0;
100 dev->num_addrs = len / sizeof(regs[0]); 98 dev->num_addrs = len / sizeof(regs[0]);
101 99
102 for (i = 0; i < dev->num_addrs; i++) { 100 for (i = 0; i < dev->num_addrs; i++) {
103 if (regs[i] >= dev->parent->num_addrs) { 101 if (regs[i] >= dev->parent->num_addrs) {
104 prom_printf("UGH: property for %s was %d, need < %d\n", 102 prom_printf("UGH: property for %s was %d, need < %d\n",
105 dev->prom_name, len, dev->parent->num_addrs); 103 dev->prom_node->name, len,
104 dev->parent->num_addrs);
106 panic(__FUNCTION__); 105 panic(__FUNCTION__);
107 } 106 }
108 dev->resource[i].start = dev->parent->resource[regs[i]].start; /* XXX resource */ 107
108 /* XXX resource */
109 dev->resource[i].start =
110 dev->parent->resource[regs[i]].start;
109 } 111 }
110 112
111 for (i = 0; i < PROMINTR_MAX; i++) 113 for (i = 0; i < PROMINTR_MAX; i++)
112 dev->irqs[i] = PCI_IRQ_NONE; 114 dev->irqs[i] = PCI_IRQ_NONE;
113 115
114 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) { 116 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
115 dev->num_irqs = 1; 117 dev->num_irqs = 1;
116 } else if ((len = prom_getproperty(node, "interrupts",
117 (char *)&irqs, sizeof(irqs))) == -1 || len == 0) {
118 dev->num_irqs = 0;
119 dev->irqs[0] = 0;
120 if (dev->parent->num_irqs != 0) {
121 dev->num_irqs = 1;
122 dev->irqs[0] = dev->parent->irqs[0];
123/* P3 */ /* printk("EBUS: dev %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
124 }
125 } else { 118 } else {
126 dev->num_irqs = len / sizeof(irqs[0]); 119 irqs = of_get_property(dp, "interrupts", &len);
127 if (irqs[0] == 0 || irqs[0] >= 8) { 120 if (!irqs) {
128 /*
129 * XXX Zero is a valid pin number...
130 * This works as long as Ebus is not wired to INTA#.
131 */
132 printk("EBUS: %s got bad irq %d from PROM\n",
133 dev->prom_name, irqs[0]);
134 dev->num_irqs = 0; 121 dev->num_irqs = 0;
135 dev->irqs[0] = 0; 122 dev->irqs[0] = 0;
123 if (dev->parent->num_irqs != 0) {
124 dev->num_irqs = 1;
125 dev->irqs[0] = dev->parent->irqs[0];
126 }
136 } else { 127 } else {
137 dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name); 128 dev->num_irqs = len / sizeof(irqs[0]);
129 if (irqs[0] == 0 || irqs[0] >= 8) {
130 /*
131 * XXX Zero is a valid pin number...
132 * This works as long as Ebus is not wired
133 * to INTA#.
134 */
135 printk("EBUS: %s got bad irq %d from PROM\n",
136 dev->prom_node->name, irqs[0]);
137 dev->num_irqs = 0;
138 dev->irqs[0] = 0;
139 } else {
140 dev->irqs[0] =
141 pcic_pin_to_irq(irqs[0],
142 dev->prom_node->name);
143 }
138 } 144 }
139 } 145 }
140} 146}
141 147
142void __init fill_ebus_device(int node, struct linux_ebus_device *dev) 148void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
143{ 149{
144 struct linux_prom_registers regs[PROMREG_MAX]; 150 struct linux_prom_registers *regs;
145 struct linux_ebus_child *child; 151 struct linux_ebus_child *child;
146 int irqs[PROMINTR_MAX]; 152 int *irqs;
147 char lbuf[128];
148 int i, n, len; 153 int i, n, len;
149 unsigned long baseaddr; 154 unsigned long baseaddr;
150 155
151 dev->prom_node = node; 156 dev->prom_node = dp;
152 prom_getstring(node, "name", lbuf, sizeof(lbuf));
153 strcpy(dev->prom_name, lbuf);
154 157
155 len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs)); 158 regs = of_get_property(dp, "reg", &len);
156 if (len % sizeof(struct linux_prom_registers)) { 159 if (len % sizeof(struct linux_prom_registers)) {
157 prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", 160 prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
158 dev->prom_name, len, 161 dev->prom_node->name, len,
159 (int)sizeof(struct linux_prom_registers)); 162 (int)sizeof(struct linux_prom_registers));
160 panic(__FUNCTION__); 163 panic(__FUNCTION__);
161 } 164 }
@@ -197,7 +200,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
197 if ((baseaddr = (unsigned long) ioremap(baseaddr, 200 if ((baseaddr = (unsigned long) ioremap(baseaddr,
198 regs[i].reg_size)) == 0) { 201 regs[i].reg_size)) == 0) {
199 panic("ebus: unable to remap dev %s", 202 panic("ebus: unable to remap dev %s",
200 dev->prom_name); 203 dev->prom_node->name);
201 } 204 }
202 } 205 }
203 dev->resource[i].start = baseaddr; /* XXX Unaligned */ 206 dev->resource[i].start = baseaddr; /* XXX Unaligned */
@@ -206,29 +209,33 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
206 for (i = 0; i < PROMINTR_MAX; i++) 209 for (i = 0; i < PROMINTR_MAX; i++)
207 dev->irqs[i] = PCI_IRQ_NONE; 210 dev->irqs[i] = PCI_IRQ_NONE;
208 211
209 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) { 212 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
210 dev->num_irqs = 1; 213 dev->num_irqs = 1;
211 } else if ((len = prom_getproperty(node, "interrupts",
212 (char *)&irqs, sizeof(irqs))) == -1 || len == 0) {
213 dev->num_irqs = 0;
214 if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
215 dev->num_irqs = 1;
216/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
217 }
218 } else { 214 } else {
219 dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */ 215 irqs = of_get_property(dp, "interrupts", &len);
220 if (irqs[0] == 0 || irqs[0] >= 8) { 216 if (!irqs) {
221 /* See above for the parent. XXX */
222 printk("EBUS: %s got bad irq %d from PROM\n",
223 dev->prom_name, irqs[0]);
224 dev->num_irqs = 0; 217 dev->num_irqs = 0;
225 dev->irqs[0] = 0; 218 if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
219 dev->num_irqs = 1;
220/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
221 }
226 } else { 222 } else {
227 dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name); 223 dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */
224 if (irqs[0] == 0 || irqs[0] >= 8) {
225 /* See above for the parent. XXX */
226 printk("EBUS: %s got bad irq %d from PROM\n",
227 dev->prom_node->name, irqs[0]);
228 dev->num_irqs = 0;
229 dev->irqs[0] = 0;
230 } else {
231 dev->irqs[0] =
232 pcic_pin_to_irq(irqs[0],
233 dev->prom_node->name);
234 }
228 } 235 }
229 } 236 }
230 237
231 if ((node = prom_getchild(node))) { 238 if ((dp = dp->child) != NULL) {
232 dev->children = (struct linux_ebus_child *) 239 dev->children = (struct linux_ebus_child *)
233 ebus_alloc(sizeof(struct linux_ebus_child)); 240 ebus_alloc(sizeof(struct linux_ebus_child));
234 241
@@ -236,9 +243,9 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
236 child->next = NULL; 243 child->next = NULL;
237 child->parent = dev; 244 child->parent = dev;
238 child->bus = dev->bus; 245 child->bus = dev->bus;
239 fill_ebus_child(node, &regs[0], child); 246 fill_ebus_child(dp, child);
240 247
241 while ((node = prom_getsibling(node)) != 0) { 248 while ((dp = dp->sibling) != NULL) {
242 child->next = (struct linux_ebus_child *) 249 child->next = (struct linux_ebus_child *)
243 ebus_alloc(sizeof(struct linux_ebus_child)); 250 ebus_alloc(sizeof(struct linux_ebus_child));
244 251
@@ -246,51 +253,49 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
246 child->next = NULL; 253 child->next = NULL;
247 child->parent = dev; 254 child->parent = dev;
248 child->bus = dev->bus; 255 child->bus = dev->bus;
249 fill_ebus_child(node, &regs[0], child); 256 fill_ebus_child(dp, child);
250 } 257 }
251 } 258 }
252} 259}
253 260
254void __init ebus_init(void) 261void __init ebus_init(void)
255{ 262{
256 struct linux_prom_pci_registers regs[PROMREG_MAX]; 263 struct linux_prom_pci_registers *regs;
257 struct linux_pbm_info *pbm; 264 struct linux_pbm_info *pbm;
258 struct linux_ebus_device *dev; 265 struct linux_ebus_device *dev;
259 struct linux_ebus *ebus; 266 struct linux_ebus *ebus;
260 struct ebus_system_entry *sp; 267 struct ebus_system_entry *sp;
261 struct pci_dev *pdev; 268 struct pci_dev *pdev;
262 struct pcidev_cookie *cookie; 269 struct pcidev_cookie *cookie;
263 char lbuf[128]; 270 struct device_node *dp;
264 unsigned long addr, *base; 271 unsigned long addr, *base;
265 unsigned short pci_command; 272 unsigned short pci_command;
266 int nd, len, ebusnd; 273 int len, reg, nreg;
267 int reg, nreg;
268 int num_ebus = 0; 274 int num_ebus = 0;
269 275
270 prom_getstring(prom_root_node, "name", lbuf, sizeof(lbuf)); 276 dp = of_find_node_by_path("/");
271 for (sp = ebus_blacklist; sp->esname != NULL; sp++) { 277 for (sp = ebus_blacklist; sp->esname != NULL; sp++) {
272 if (strcmp(lbuf, sp->esname) == 0) { 278 if (strcmp(dp->name, sp->esname) == 0) {
273 ebus_blackp = sp->ipt; 279 ebus_blackp = sp->ipt;
274 break; 280 break;
275 } 281 }
276 } 282 }
277 283
278 pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL); 284 pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL);
279 if (!pdev) { 285 if (!pdev)
280 return; 286 return;
281 } 287
282 cookie = pdev->sysdata; 288 cookie = pdev->sysdata;
283 ebusnd = cookie->prom_node; 289 dp = cookie->prom_node;
284 290
285 ebus_chain = ebus = (struct linux_ebus *) 291 ebus_chain = ebus = (struct linux_ebus *)
286 ebus_alloc(sizeof(struct linux_ebus)); 292 ebus_alloc(sizeof(struct linux_ebus));
287 ebus->next = NULL; 293 ebus->next = NULL;
288 294
289 while (ebusnd) { 295 while (dp) {
296 struct device_node *nd;
290 297
291 prom_getstring(ebusnd, "name", lbuf, sizeof(lbuf)); 298 ebus->prom_node = dp;
292 ebus->prom_node = ebusnd;
293 strcpy(ebus->prom_name, lbuf);
294 ebus->self = pdev; 299 ebus->self = pdev;
295 ebus->parent = pbm = cookie->pbm; 300 ebus->parent = pbm = cookie->pbm;
296 301
@@ -299,9 +304,8 @@ void __init ebus_init(void)
299 pci_command |= PCI_COMMAND_MASTER; 304 pci_command |= PCI_COMMAND_MASTER;
300 pci_write_config_word(pdev, PCI_COMMAND, pci_command); 305 pci_write_config_word(pdev, PCI_COMMAND, pci_command);
301 306
302 len = prom_getproperty(ebusnd, "reg", (void *)regs, 307 regs = of_get_property(dp, "reg", &len);
303 sizeof(regs)); 308 if (!regs) {
304 if (len == 0 || len == -1) {
305 prom_printf("%s: can't find reg property\n", 309 prom_printf("%s: can't find reg property\n",
306 __FUNCTION__); 310 __FUNCTION__);
307 prom_halt(); 311 prom_halt();
@@ -317,7 +321,7 @@ void __init ebus_init(void)
317 *base++ = addr; 321 *base++ = addr;
318 } 322 }
319 323
320 nd = prom_getchild(ebusnd); 324 nd = dp->child;
321 if (!nd) 325 if (!nd)
322 goto next_ebus; 326 goto next_ebus;
323 327
@@ -330,7 +334,7 @@ void __init ebus_init(void)
330 dev->bus = ebus; 334 dev->bus = ebus;
331 fill_ebus_device(nd, dev); 335 fill_ebus_device(nd, dev);
332 336
333 while ((nd = prom_getsibling(nd)) != 0) { 337 while ((nd = nd->sibling) != NULL) {
334 dev->next = (struct linux_ebus_device *) 338 dev->next = (struct linux_ebus_device *)
335 ebus_alloc(sizeof(struct linux_ebus_device)); 339 ebus_alloc(sizeof(struct linux_ebus_device));
336 340
@@ -348,7 +352,7 @@ void __init ebus_init(void)
348 break; 352 break;
349 353
350 cookie = pdev->sysdata; 354 cookie = pdev->sysdata;
351 ebusnd = cookie->prom_node; 355 dp = cookie->prom_node;
352 356
353 ebus->next = (struct linux_ebus *) 357 ebus->next = (struct linux_ebus *)
354 ebus_alloc(sizeof(struct linux_ebus)); 358 ebus_alloc(sizeof(struct linux_ebus));