aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>2013-08-15 09:01:40 -0400
committerSudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>2013-08-21 05:24:44 -0400
commit183912d352a242a276a7877852f107459a13aff9 (patch)
treec9f10475a57b92ed1dc7f6c778e8953839955f36 /arch
parent819d596568d82ffb85b0b5989a1567810fe66098 (diff)
of: move of_get_cpu_node implementation to DT core library
This patch moves the generalized implementation of of_get_cpu_node from PowerPC to DT core library, thereby adding support for retrieving cpu node for a given logical cpu index on any architecture. The CPU subsystem can now use this function to assign of_node in the cpu device while registering CPUs. It is recommended to use these helper function only in pre-SMP/early initialisation stages to retrieve CPU device node pointers in logical ordering. Once the cpu devices are registered, it can be retrieved easily from cpu device of_node which avoids unnecessary parsing and matching. Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Grant Likely <grant.likely@linaro.org> Acked-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/prom.h3
-rw-r--r--arch/powerpc/kernel/prom.c57
2 files changed, 0 insertions, 60 deletions
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index bc2da154f68b..ac204e022922 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -43,9 +43,6 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
43 43
44extern void kdump_move_device_tree(void); 44extern void kdump_move_device_tree(void);
45 45
46/* CPU OF node matching */
47struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
48
49/* cache lookup */ 46/* cache lookup */
50struct device_node *of_find_next_cache_node(struct device_node *np); 47struct device_node *of_find_next_cache_node(struct device_node *np);
51 48
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index f7b8c0be982e..1c14cd4a5e05 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -870,63 +870,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
870 return (int)phys_id == get_hard_smp_processor_id(cpu); 870 return (int)phys_id == get_hard_smp_processor_id(cpu);
871} 871}
872 872
873static bool __of_find_n_match_cpu_property(struct device_node *cpun,
874 const char *prop_name, int cpu, unsigned int *thread)
875{
876 const __be32 *cell;
877 int ac, prop_len, tid;
878 u64 hwid;
879
880 ac = of_n_addr_cells(cpun);
881 cell = of_get_property(cpun, prop_name, &prop_len);
882 if (!cell)
883 return false;
884 prop_len /= sizeof(*cell);
885 for (tid = 0; tid < prop_len; tid++) {
886 hwid = of_read_number(cell, ac);
887 if (arch_match_cpu_phys_id(cpu, hwid)) {
888 if (thread)
889 *thread = tid;
890 return true;
891 }
892 cell += ac;
893 }
894 return false;
895}
896
897/* Find the device node for a given logical cpu number, also returns the cpu
898 * local thread number (index in ibm,interrupt-server#s) if relevant and
899 * asked for (non NULL)
900 */
901struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
902{
903 struct device_node *cpun, *cpus;
904
905 cpus = of_find_node_by_path("/cpus");
906 if (!cpus) {
907 pr_warn("Missing cpus node, bailing out\n");
908 return NULL;
909 }
910
911 for_each_child_of_node(cpus, cpun) {
912 if (of_node_cmp(cpun->type, "cpu"))
913 continue;
914
915 /* Check for non-standard "ibm,ppc-interrupt-server#s" property
916 * for thread ids on PowerPC. If it doesn't exist fallback to
917 * standard "reg" property.
918 */
919 if (__of_find_n_match_cpu_property(cpun,
920 "ibm,ppc-interrupt-server#s", cpu, thread))
921 return cpun;
922
923 if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
924 return cpun;
925 }
926 return NULL;
927}
928EXPORT_SYMBOL(of_get_cpu_node);
929
930#if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 873#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
931static struct debugfs_blob_wrapper flat_dt_blob; 874static struct debugfs_blob_wrapper flat_dt_blob;
932 875