be877198596b17035cd90cfe72e198a7296bcb82
[linux-flexiantxendom0-3.2.10.git] / arch / sparc64 / kernel / devices.c
1 /* devices.c: Initial scan of the prom device tree for important
2  *            Sparc device nodes which we need to find.
3  *
4  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5  */
6
7 #include <linux/kernel.h>
8 #include <linux/threads.h>
9 #include <linux/init.h>
10 #include <linux/ioport.h>
11
12 #include <asm/page.h>
13 #include <asm/oplib.h>
14 #include <asm/system.h>
15 #include <asm/smp.h>
16
17 struct prom_cpuinfo linux_cpus[64] __initdata = { { 0 } };
18 unsigned prom_cpu_nodes[64];
19 int linux_num_cpus = 0;
20
21 extern void cpu_probe(void);
22 extern void central_probe(void);
23
24 void __init device_scan(void)
25 {
26         char node_str[128];
27         int nd, prom_node_cpu, thismid;
28         int cpu_nds[64];  /* One node for each cpu */
29         int cpu_ctr = 0;
30
31         /* FIX ME FAST... -DaveM */
32         ioport_resource.end = 0xffffffffffffffffUL;
33         iomem_resource.end = 0xffffffffffffffffUL;
34
35         prom_getstring(prom_root_node, "device_type", node_str, sizeof(node_str));
36
37         prom_printf("Booting Linux...\n");
38         if(strcmp(node_str, "cpu") == 0) {
39                 cpu_nds[0] = prom_root_node;
40                 linux_cpus[0].prom_node = prom_root_node;
41                 linux_cpus[0].mid = 0;
42                 cpu_ctr++;
43         } else {
44                 int scan;
45                 scan = prom_getchild(prom_root_node);
46                 /* prom_printf("root child is %08x\n", (unsigned) scan); */
47                 nd = 0;
48                 while((scan = prom_getsibling(scan)) != 0) {
49                         prom_getstring(scan, "device_type", node_str, sizeof(node_str));
50                         if(strcmp(node_str, "cpu") == 0) {
51                                 cpu_nds[cpu_ctr] = scan;
52                                 linux_cpus[cpu_ctr].prom_node = scan;
53                                 prom_getproperty(scan, "upa-portid",
54                                                  (char *) &thismid, sizeof(thismid));
55                                 linux_cpus[cpu_ctr].mid = thismid;
56                                 printk("Found CPU %d (node=%08x,mid=%d)\n",
57                                        cpu_ctr, (unsigned) scan, thismid);
58                                 cpu_ctr++;
59                         }
60                 };
61                 if(cpu_ctr == 0) {
62                         prom_printf("No CPU nodes found, cannot continue.\n");
63                         prom_halt();
64                 }
65                 printk("Found %d CPU prom device tree node(s).\n", cpu_ctr);
66         }
67         prom_node_cpu = cpu_nds[0];
68
69         linux_num_cpus = cpu_ctr;
70         
71         prom_cpu_nodes[0] = prom_node_cpu;
72
73         central_probe();
74
75         cpu_probe();
76 }