diff options
author | David Miller <davem@davemloft.net> | 2013-10-03 17:24:51 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2013-10-15 15:09:10 -0400 |
commit | d1cb9d1af0bc11b7450a6032f43935c746609418 (patch) | |
tree | 061b56dbd9e656730262445b373bacd399c0678e /drivers/of | |
parent | 444c91e5720cb5b825356e32c67c2c5184d1c09a (diff) |
of: Make cpu node handling more portable.
Use for_each_node_by_type() to iterate all cpu nodes in the
system.
Provide and overridable function arch_find_n_match_cpu_physical_id,
which sees if the given device node matches 'cpu' and if so sets
'*thread' when non-NULL to the cpu thread number within the core.
The default implementation behaves the same as the existing code.
Add a sparc64 implementation.
Signed-off-by: David S. Miller <davem@davemloft.net>
Tested-by: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 45 |
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 | */ | ||
289 | bool __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 | */ |
301 | struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) | 326 | struct 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; |