diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-08-27 22:43:49 -0400 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2013-10-09 21:03:55 -0400 |
commit | 6d67a9f672f4718a3a9060a96f859d0465663b55 (patch) | |
tree | 40aaeb4101e97529d5b404432e25d6973855a114 | |
parent | 880beb8807814c7785680bcbdc81dcf076f585db (diff) |
arm: use common of_flat_dt_match_machine
Convert arm to use the common of_flat_dt_match_machine function.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
-rw-r--r-- | arch/arm/kernel/devtree.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index e7ce175b99e3..739c3dfc1da2 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c | |||
@@ -174,6 +174,19 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) | |||
174 | return (phys_id & MPIDR_HWID_BITMASK) == cpu_logical_map(cpu); | 174 | return (phys_id & MPIDR_HWID_BITMASK) == cpu_logical_map(cpu); |
175 | } | 175 | } |
176 | 176 | ||
177 | static const void * __init arch_get_next_mach(const char *const **match) | ||
178 | { | ||
179 | static const struct machine_desc *mdesc = __arch_info_begin; | ||
180 | const struct machine_desc *m = mdesc; | ||
181 | |||
182 | if (m >= __arch_info_end) | ||
183 | return NULL; | ||
184 | |||
185 | mdesc++; | ||
186 | *match = m->dt_compat; | ||
187 | return m; | ||
188 | } | ||
189 | |||
177 | /** | 190 | /** |
178 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel | 191 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel |
179 | * @dt_phys: physical address of dt blob | 192 | * @dt_phys: physical address of dt blob |
@@ -184,9 +197,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) | |||
184 | const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) | 197 | const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) |
185 | { | 198 | { |
186 | const struct machine_desc *mdesc, *mdesc_best = NULL; | 199 | const struct machine_desc *mdesc, *mdesc_best = NULL; |
187 | unsigned int score, mdesc_score = ~1; | ||
188 | unsigned long dt_root; | ||
189 | const char *model; | ||
190 | 200 | ||
191 | #ifdef CONFIG_ARCH_MULTIPLATFORM | 201 | #ifdef CONFIG_ARCH_MULTIPLATFORM |
192 | DT_MACHINE_START(GENERIC_DT, "Generic DT based system") | 202 | DT_MACHINE_START(GENERIC_DT, "Generic DT based system") |
@@ -198,23 +208,17 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) | |||
198 | if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys))) | 208 | if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys))) |
199 | return NULL; | 209 | return NULL; |
200 | 210 | ||
211 | mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); | ||
201 | 212 | ||
202 | /* Search the mdescs for the 'best' compatible value match */ | 213 | if (!mdesc) { |
203 | dt_root = of_get_flat_dt_root(); | ||
204 | for_each_machine_desc(mdesc) { | ||
205 | score = of_flat_dt_match(dt_root, mdesc->dt_compat); | ||
206 | if (score > 0 && score < mdesc_score) { | ||
207 | mdesc_best = mdesc; | ||
208 | mdesc_score = score; | ||
209 | } | ||
210 | } | ||
211 | if (!mdesc_best) { | ||
212 | const char *prop; | 214 | const char *prop; |
213 | long size; | 215 | long size; |
216 | unsigned long dt_root; | ||
214 | 217 | ||
215 | early_print("\nError: unrecognized/unsupported " | 218 | early_print("\nError: unrecognized/unsupported " |
216 | "device tree compatible list:\n[ "); | 219 | "device tree compatible list:\n[ "); |
217 | 220 | ||
221 | dt_root = of_get_flat_dt_root(); | ||
218 | prop = of_get_flat_dt_prop(dt_root, "compatible", &size); | 222 | prop = of_get_flat_dt_prop(dt_root, "compatible", &size); |
219 | while (size > 0) { | 223 | while (size > 0) { |
220 | early_print("'%s' ", prop); | 224 | early_print("'%s' ", prop); |
@@ -226,15 +230,8 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) | |||
226 | dump_machine_table(); /* does not return */ | 230 | dump_machine_table(); /* does not return */ |
227 | } | 231 | } |
228 | 232 | ||
229 | model = of_get_flat_dt_prop(dt_root, "model", NULL); | ||
230 | if (!model) | ||
231 | model = of_get_flat_dt_prop(dt_root, "compatible", NULL); | ||
232 | if (!model) | ||
233 | model = "<unknown>"; | ||
234 | pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); | ||
235 | |||
236 | /* Change machine number to match the mdesc we're using */ | 233 | /* Change machine number to match the mdesc we're using */ |
237 | __machine_arch_type = mdesc_best->nr; | 234 | __machine_arch_type = mdesc->nr; |
238 | 235 | ||
239 | return mdesc_best; | 236 | return mdesc; |
240 | } | 237 | } |