aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/prom_64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/prom_64.c')
-rw-r--r--arch/sparc/kernel/prom_64.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index d397d7fc5c28..6b39125eb927 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -373,6 +373,59 @@ static const char *get_mid_prop(void)
373 return (tlb_type == spitfire ? "upa-portid" : "portid"); 373 return (tlb_type == spitfire ? "upa-portid" : "portid");
374} 374}
375 375
376bool arch_find_n_match_cpu_physical_id(struct device_node *cpun,
377 int cpu, unsigned int *thread)
378{
379 const char *mid_prop = get_mid_prop();
380 int this_cpu_id;
381
382 /* On hypervisor based platforms we interrogate the 'reg'
383 * property. On everything else we look for a 'upa-portis',
384 * 'portid', or 'cpuid' property.
385 */
386
387 if (tlb_type == hypervisor) {
388 struct property *prop = of_find_property(cpun, "reg", NULL);
389 u32 *regs;
390
391 if (!prop) {
392 pr_warn("CPU node missing reg property\n");
393 return false;
394 }
395 regs = prop->value;
396 this_cpu_id = regs[0] & 0x0fffffff;
397 } else {
398 this_cpu_id = of_getintprop_default(cpun, mid_prop, -1);
399
400 if (this_cpu_id < 0) {
401 mid_prop = "cpuid";
402 this_cpu_id = of_getintprop_default(cpun, mid_prop, -1);
403 }
404 if (this_cpu_id < 0) {
405 pr_warn("CPU node missing cpu ID property\n");
406 return false;
407 }
408 }
409 if (this_cpu_id == cpu) {
410 if (thread) {
411 int proc_id = cpu_data(cpu).proc_id;
412
413 /* On sparc64, the cpu thread information is obtained
414 * either from OBP or the machine description. We've
415 * actually probed this information already long before
416 * this interface gets called so instead of interrogating
417 * both the OF node and the MDESC again, just use what
418 * we discovered already.
419 */
420 if (proc_id < 0)
421 proc_id = 0;
422 *thread = proc_id;
423 }
424 return true;
425 }
426 return false;
427}
428
376static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int), int arg) 429static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int), int arg)
377{ 430{
378 struct device_node *dp; 431 struct device_node *dp;