aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7d4c70f859e3..e4c99453adf1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -280,6 +280,31 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
280 return false; 280 return false;
281} 281}
282 282
283/*
284 * arch_find_n_match_cpu_physical_id - See if the given device node is
285 * for the cpu corresponding to logical cpu 'cpu'. Return true if so,
286 * else false. If 'thread' is non-NULL, the local thread number within the
287 * core is returned in it.
288 */
289bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
290 int cpu, unsigned int *thread)
291{
292 /* Check for non-standard "ibm,ppc-interrupt-server#s" property
293 * for thread ids on PowerPC. If it doesn't exist fallback to
294 * standard "reg" property.
295 */
296 if (IS_ENABLED(CONFIG_PPC) &&
297 __of_find_n_match_cpu_property(cpun,
298 "ibm,ppc-interrupt-server#s",
299 cpu, thread))
300 return true;
301
302 if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
303 return true;
304
305 return false;
306}
307
283/** 308/**
284 * of_get_cpu_node - Get device node associated with the given logical CPU 309 * of_get_cpu_node - Get device node associated with the given logical CPU
285 * 310 *
@@ -300,24 +325,10 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
300 */ 325 */
301struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) 326struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
302{ 327{
303 struct device_node *cpun, *cpus; 328 struct device_node *cpun;
304
305 cpus = of_find_node_by_path("/cpus");
306 if (!cpus)
307 return NULL;
308 329
309 for_each_child_of_node(cpus, cpun) { 330 for_each_node_by_type(cpun, "cpu") {
310 if (of_node_cmp(cpun->type, "cpu")) 331 if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
311 continue;
312 /* Check for non-standard "ibm,ppc-interrupt-server#s" property
313 * for thread ids on PowerPC. If it doesn't exist fallback to
314 * standard "reg" property.
315 */
316 if (IS_ENABLED(CONFIG_PPC) &&
317 __of_find_n_match_cpu_property(cpun,
318 "ibm,ppc-interrupt-server#s", cpu, thread))
319 return cpun;
320 if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
321 return cpun; 332 return cpun;
322 } 333 }
323 return NULL; 334 return NULL;