summaryrefslogtreecommitdiffstats
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorRob Herring <rob.herring@calxeda.com>2013-11-07 11:34:46 -0500
committerRob Herring <rob.herring@calxeda.com>2013-11-07 11:34:46 -0500
commitb5480950c6cbb7b07ab1c1a5af0dc661a1cb6f24 (patch)
treeb5fcb00387a838beb2bcf2f8ed2fd3d6d460c8ae /drivers/of/base.c
parente363bbac316ffb5daaf45d855f82680148cafe20 (diff)
parent355e62f5ad12b005c862838156262eb2df2f8dff (diff)
Merge remote-tracking branch 'grant/devicetree/next' into for-next
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ced4c06d79b3..f2431091f4c1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -272,9 +272,9 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
272 272
273 ac = of_n_addr_cells(cpun); 273 ac = of_n_addr_cells(cpun);
274 cell = of_get_property(cpun, prop_name, &prop_len); 274 cell = of_get_property(cpun, prop_name, &prop_len);
275 if (!cell) 275 if (!cell || !ac)
276 return false; 276 return false;
277 prop_len /= sizeof(*cell); 277 prop_len /= sizeof(*cell) * ac;
278 for (tid = 0; tid < prop_len; tid++) { 278 for (tid = 0; tid < prop_len; tid++) {
279 hwid = of_read_number(cell, ac); 279 hwid = of_read_number(cell, ac);
280 if (arch_match_cpu_phys_id(cpu, hwid)) { 280 if (arch_match_cpu_phys_id(cpu, hwid)) {
@@ -287,6 +287,31 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
287 return false; 287 return false;
288} 288}
289 289
290/*
291 * arch_find_n_match_cpu_physical_id - See if the given device node is
292 * for the cpu corresponding to logical cpu 'cpu'. Return true if so,
293 * else false. If 'thread' is non-NULL, the local thread number within the
294 * core is returned in it.
295 */
296bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
297 int cpu, unsigned int *thread)
298{
299 /* Check for non-standard "ibm,ppc-interrupt-server#s" property
300 * for thread ids on PowerPC. If it doesn't exist fallback to
301 * standard "reg" property.
302 */
303 if (IS_ENABLED(CONFIG_PPC) &&
304 __of_find_n_match_cpu_property(cpun,
305 "ibm,ppc-interrupt-server#s",
306 cpu, thread))
307 return true;
308
309 if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
310 return true;
311
312 return false;
313}
314
290/** 315/**
291 * of_get_cpu_node - Get device node associated with the given logical CPU 316 * of_get_cpu_node - Get device node associated with the given logical CPU
292 * 317 *
@@ -307,26 +332,10 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
307 */ 332 */
308struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) 333struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
309{ 334{
310 struct device_node *cpun, *cpus; 335 struct device_node *cpun;
311 336
312 cpus = of_find_node_by_path("/cpus"); 337 for_each_node_by_type(cpun, "cpu") {
313 if (!cpus) { 338 if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
314 pr_warn("Missing cpus node, bailing out\n");
315 return NULL;
316 }
317
318 for_each_child_of_node(cpus, cpun) {
319 if (of_node_cmp(cpun->type, "cpu"))
320 continue;
321 /* Check for non-standard "ibm,ppc-interrupt-server#s" property
322 * for thread ids on PowerPC. If it doesn't exist fallback to
323 * standard "reg" property.
324 */
325 if (IS_ENABLED(CONFIG_PPC) &&
326 __of_find_n_match_cpu_property(cpun,
327 "ibm,ppc-interrupt-server#s", cpu, thread))
328 return cpun;
329 if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
330 return cpun; 339 return cpun;
331 } 340 }
332 return NULL; 341 return NULL;
@@ -1183,6 +1192,15 @@ int of_property_count_strings(struct device_node *np, const char *propname)
1183} 1192}
1184EXPORT_SYMBOL_GPL(of_property_count_strings); 1193EXPORT_SYMBOL_GPL(of_property_count_strings);
1185 1194
1195void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)
1196{
1197 int i;
1198 printk("%s %s", msg, of_node_full_name(args->np));
1199 for (i = 0; i < args->args_count; i++)
1200 printk(i ? ",%08x" : ":%08x", args->args[i]);
1201 printk("\n");
1202}
1203
1186static int __of_parse_phandle_with_args(const struct device_node *np, 1204static int __of_parse_phandle_with_args(const struct device_node *np,
1187 const char *list_name, 1205 const char *list_name,
1188 const char *cells_name, 1206 const char *cells_name,