1 /* devices.c: Initial scan of the prom device tree for important
2 * Sparc device nodes which we need to find.
4 * This is based on the sparc64 version, but sun4m doesn't always use
5 * the hardware MIDs, so be careful.
10 #include <linux/kernel.h>
11 #include <linux/threads.h>
12 #include <linux/string.h>
13 #include <linux/init.h>
14 #include <linux/errno.h>
17 #include <asm/oplib.h>
20 #include <asm/system.h>
21 #include <asm/cpudata.h>
23 extern void clock_stop_probe(void); /* tadpole.c */
24 extern void sun4c_probe_memerr_reg(void);
26 static char *cpu_mid_prop(void)
28 if (sparc_cpu_model == sun4d)
33 static int check_cpu_node(phandle nd, int *cur_inst,
34 int (*compare)(phandle, int, void *), void *compare_arg,
35 phandle *prom_node, int *mid)
37 if (!compare(nd, *cur_inst, compare_arg)) {
41 *mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
42 if (sparc_cpu_model == sun4m)
53 static int __cpu_find_by(int (*compare)(phandle, int, void *),
54 void *compare_arg, phandle *prom_node, int *mid)
56 struct device_node *dp;
60 for_each_node_by_type(dp, "cpu") {
61 int err = check_cpu_node(dp->phandle, &cur_inst,
73 static int cpu_instance_compare(phandle nd, int instance, void *_arg)
75 int desired_instance = (int) _arg;
77 if (instance == desired_instance)
82 int cpu_find_by_instance(int instance, phandle *prom_node, int *mid)
84 return __cpu_find_by(cpu_instance_compare, (void *)instance,
88 static int cpu_mid_compare(phandle nd, int instance, void *_arg)
90 int desired_mid = (int) _arg;
93 this_mid = prom_getintdefault(nd, cpu_mid_prop(), 0);
94 if (this_mid == desired_mid
95 || (sparc_cpu_model == sun4m && (this_mid & 3) == desired_mid))
100 int cpu_find_by_mid(int mid, phandle *prom_node)
102 return __cpu_find_by(cpu_mid_compare, (void *)mid,
106 /* sun4m uses truncated mids since we base the cpuid on the ttable/irqset
107 * address (0-3). This gives us the true hardware mid, which might have
108 * some other bits set. On 4d hardware and software mids are the same.
110 int cpu_get_hwmid(phandle prom_node)
112 return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV);
115 void __init device_scan(void)
117 printk(KERN_NOTICE "Booting Linux...\n");
123 err = cpu_find_by_instance(0, &cpu_node, NULL);
125 /* Probably a sun4e, Sun is trying to trick us ;-) */
126 prom_printf("No cpu nodes, cannot continue\n");
129 cpu_data(0).clock_tick = prom_getintdefault(cpu_node,
133 #endif /* !CONFIG_SMP */
136 extern void auxio_probe(void);
137 extern void auxio_power_probe(void);
144 sun4c_probe_memerr_reg();