v2.4.2.7 -> v2.4.2.8
[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 #include <asm/spitfire.h>
17
18 struct prom_cpuinfo linux_cpus[64] __initdata = { { 0 } };
19 unsigned prom_cpu_nodes[64];
20 int linux_num_cpus = 0;
21
22 extern void cpu_probe(void);
23 extern void central_probe(void);
24
25 void __init device_scan(void)
26 {
27         char node_str[128];
28         int nd, prom_node_cpu, thismid;
29         int cpu_nds[64];  /* One node for each cpu */
30         int cpu_ctr = 0;
31
32         /* FIX ME FAST... -DaveM */
33         ioport_resource.end = 0xffffffffffffffffUL;
34         iomem_resource.end = 0xffffffffffffffffUL;
35
36         prom_getstring(prom_root_node, "device_type", node_str, sizeof(node_str));
37
38         prom_printf("Booting Linux...\n");
39         if(strcmp(node_str, "cpu") == 0) {
40                 cpu_nds[0] = prom_root_node;
41                 linux_cpus[0].prom_node = prom_root_node;
42                 linux_cpus[0].mid = 0;
43                 cpu_ctr++;
44         } else {
45                 int scan;
46                 scan = prom_getchild(prom_root_node);
47                 /* prom_printf("root child is %08x\n", (unsigned) scan); */
48                 nd = 0;
49                 while((scan = prom_getsibling(scan)) != 0) {
50                         prom_getstring(scan, "device_type", node_str, sizeof(node_str));
51                         if(strcmp(node_str, "cpu") == 0) {
52                                 cpu_nds[cpu_ctr] = scan;
53                                 linux_cpus[cpu_ctr].prom_node = scan;
54                                 thismid = 0;
55                                 if (tlb_type == spitfire) {
56                                         prom_getproperty(scan, "upa-portid",
57                                                          (char *) &thismid, sizeof(thismid));
58                                 } else if (tlb_type == cheetah) {
59                                         prom_getproperty(scan, "portid",
60                                                          (char *) &thismid, sizeof(thismid));
61                                 }
62                                 linux_cpus[cpu_ctr].mid = thismid;
63                                 printk("Found CPU %d (node=%08x,mid=%d)\n",
64                                        cpu_ctr, (unsigned) scan, thismid);
65                                 cpu_ctr++;
66                         }
67                 };
68                 if(cpu_ctr == 0) {
69                         prom_printf("No CPU nodes found, cannot continue.\n");
70                         prom_halt();
71                 }
72                 printk("Found %d CPU prom device tree node(s).\n", cpu_ctr);
73         }
74         prom_node_cpu = cpu_nds[0];
75
76         linux_num_cpus = cpu_ctr;
77         
78         prom_cpu_nodes[0] = prom_node_cpu;
79
80         central_probe();
81
82         cpu_probe();
83 }