aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/of_device_32.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/of_device_32.c')
-rw-r--r--arch/sparc/kernel/of_device_32.c63
1 files changed, 24 insertions, 39 deletions
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 47e63f1e719c..2d055a1e9cc2 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -241,10 +241,10 @@ static int __init use_1to1_mapping(struct device_node *pp)
241 241
242static int of_resource_verbose; 242static int of_resource_verbose;
243 243
244static void __init build_device_resources(struct of_device *op, 244static void __init build_device_resources(struct platform_device *op,
245 struct device *parent) 245 struct device *parent)
246{ 246{
247 struct of_device *p_op; 247 struct platform_device *p_op;
248 struct of_bus *bus; 248 struct of_bus *bus;
249 int na, ns; 249 int na, ns;
250 int index, num_reg; 250 int index, num_reg;
@@ -253,7 +253,7 @@ static void __init build_device_resources(struct of_device *op,
253 if (!parent) 253 if (!parent)
254 return; 254 return;
255 255
256 p_op = to_of_device(parent); 256 p_op = to_platform_device(parent);
257 bus = of_match_bus(p_op->dev.of_node); 257 bus = of_match_bus(p_op->dev.of_node);
258 bus->count_cells(op->dev.of_node, &na, &ns); 258 bus->count_cells(op->dev.of_node, &na, &ns);
259 259
@@ -267,6 +267,8 @@ static void __init build_device_resources(struct of_device *op,
267 /* Conver to num-entries. */ 267 /* Conver to num-entries. */
268 num_reg /= na + ns; 268 num_reg /= na + ns;
269 269
270 op->resource = op->archdata.resource;
271 op->num_resources = num_reg;
270 for (index = 0; index < num_reg; index++) { 272 for (index = 0; index < num_reg; index++) {
271 struct resource *r = &op->resource[index]; 273 struct resource *r = &op->resource[index];
272 u32 addr[OF_MAX_ADDR_CELLS]; 274 u32 addr[OF_MAX_ADDR_CELLS];
@@ -333,10 +335,10 @@ static void __init build_device_resources(struct of_device *op,
333 } 335 }
334} 336}
335 337
336static struct of_device * __init scan_one_device(struct device_node *dp, 338static struct platform_device * __init scan_one_device(struct device_node *dp,
337 struct device *parent) 339 struct device *parent)
338{ 340{
339 struct of_device *op = kzalloc(sizeof(*op), GFP_KERNEL); 341 struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL);
340 const struct linux_prom_irqs *intr; 342 const struct linux_prom_irqs *intr;
341 struct dev_archdata *sd; 343 struct dev_archdata *sd;
342 int len, i; 344 int len, i;
@@ -349,27 +351,21 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
349 351
350 op->dev.of_node = dp; 352 op->dev.of_node = dp;
351 353
352 op->clock_freq = of_getintprop_default(dp, "clock-frequency",
353 (25*1000*1000));
354 op->portid = of_getintprop_default(dp, "upa-portid", -1);
355 if (op->portid == -1)
356 op->portid = of_getintprop_default(dp, "portid", -1);
357
358 intr = of_get_property(dp, "intr", &len); 354 intr = of_get_property(dp, "intr", &len);
359 if (intr) { 355 if (intr) {
360 op->num_irqs = len / sizeof(struct linux_prom_irqs); 356 op->archdata.num_irqs = len / sizeof(struct linux_prom_irqs);
361 for (i = 0; i < op->num_irqs; i++) 357 for (i = 0; i < op->archdata.num_irqs; i++)
362 op->irqs[i] = intr[i].pri; 358 op->archdata.irqs[i] = intr[i].pri;
363 } else { 359 } else {
364 const unsigned int *irq = 360 const unsigned int *irq =
365 of_get_property(dp, "interrupts", &len); 361 of_get_property(dp, "interrupts", &len);
366 362
367 if (irq) { 363 if (irq) {
368 op->num_irqs = len / sizeof(unsigned int); 364 op->archdata.num_irqs = len / sizeof(unsigned int);
369 for (i = 0; i < op->num_irqs; i++) 365 for (i = 0; i < op->archdata.num_irqs; i++)
370 op->irqs[i] = irq[i]; 366 op->archdata.irqs[i] = irq[i];
371 } else { 367 } else {
372 op->num_irqs = 0; 368 op->archdata.num_irqs = 0;
373 } 369 }
374 } 370 }
375 if (sparc_cpu_model == sun4d) { 371 if (sparc_cpu_model == sun4d) {
@@ -411,8 +407,8 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
411 goto build_resources; 407 goto build_resources;
412 } 408 }
413 409
414 for (i = 0; i < op->num_irqs; i++) { 410 for (i = 0; i < op->archdata.num_irqs; i++) {
415 int this_irq = op->irqs[i]; 411 int this_irq = op->archdata.irqs[i];
416 int sbusl = pil_to_sbus[this_irq]; 412 int sbusl = pil_to_sbus[this_irq];
417 413
418 if (sbusl) 414 if (sbusl)
@@ -420,7 +416,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
420 (sbusl << 2) + 416 (sbusl << 2) +
421 slot); 417 slot);
422 418
423 op->irqs[i] = this_irq; 419 op->archdata.irqs[i] = this_irq;
424 } 420 }
425 } 421 }
426 422
@@ -428,7 +424,7 @@ build_resources:
428 build_device_resources(op, parent); 424 build_device_resources(op, parent);
429 425
430 op->dev.parent = parent; 426 op->dev.parent = parent;
431 op->dev.bus = &of_platform_bus_type; 427 op->dev.bus = &platform_bus_type;
432 if (!parent) 428 if (!parent)
433 dev_set_name(&op->dev, "root"); 429 dev_set_name(&op->dev, "root");
434 else 430 else
@@ -447,7 +443,7 @@ build_resources:
447static void __init scan_tree(struct device_node *dp, struct device *parent) 443static void __init scan_tree(struct device_node *dp, struct device *parent)
448{ 444{
449 while (dp) { 445 while (dp) {
450 struct of_device *op = scan_one_device(dp, parent); 446 struct platform_device *op = scan_one_device(dp, parent);
451 447
452 if (op) 448 if (op)
453 scan_tree(dp->child, &op->dev); 449 scan_tree(dp->child, &op->dev);
@@ -456,30 +452,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent)
456 } 452 }
457} 453}
458 454
459static void __init scan_of_devices(void) 455static int __init scan_of_devices(void)
460{ 456{
461 struct device_node *root = of_find_node_by_path("/"); 457 struct device_node *root = of_find_node_by_path("/");
462 struct of_device *parent; 458 struct platform_device *parent;
463 459
464 parent = scan_one_device(root, NULL); 460 parent = scan_one_device(root, NULL);
465 if (!parent) 461 if (!parent)
466 return; 462 return 0;
467 463
468 scan_tree(root->child, &parent->dev); 464 scan_tree(root->child, &parent->dev);
465 return 0;
469} 466}
470 467postcore_initcall(scan_of_devices);
471static int __init of_bus_driver_init(void)
472{
473 int err;
474
475 err = of_bus_type_init(&of_platform_bus_type, "of");
476 if (!err)
477 scan_of_devices();
478
479 return err;
480}
481
482postcore_initcall(of_bus_driver_init);
483 468
484static int __init of_debug(char *str) 469static int __init of_debug(char *str)
485{ 470{