aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arc/kernel
diff options
context:
space:
mode:
authorRob Herring <rob.herring@calxeda.com>2013-08-27 22:43:12 -0400
committerRob Herring <rob.herring@calxeda.com>2013-10-09 21:03:55 -0400
commit880beb8807814c7785680bcbdc81dcf076f585db (patch)
tree7a64b685b20e5369c0af312265f60a8a627f5593 /arch/arc/kernel
parent6a903a2551ef778d60ce4341722d611144251398 (diff)
arc: use common of_flat_dt_match_machine
Convert arc to use the common of_flat_dt_match_machine function. Signed-off-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/kernel')
-rw-r--r--arch/arc/kernel/devtree.c67
-rw-r--r--arch/arc/kernel/setup.c2
2 files changed, 20 insertions, 49 deletions
diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c
index 1ab6f3569f60..d7b5322ffed5 100644
--- a/arch/arc/kernel/devtree.c
+++ b/arch/arc/kernel/devtree.c
@@ -18,6 +18,19 @@
18#include <asm/clk.h> 18#include <asm/clk.h>
19#include <asm/mach_desc.h> 19#include <asm/mach_desc.h>
20 20
21static const void * __init arch_get_next_mach(const char *const **match)
22{
23 static const struct machine_desc *mdesc = __arch_info_begin;
24 const struct machine_desc *m = mdesc;
25
26 if (m >= __arch_info_end)
27 return NULL;
28
29 mdesc++;
30 *match = m->dt_compat;
31 return m;
32}
33
21/** 34/**
22 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel 35 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
23 * @dt: virtual address pointer to dt blob 36 * @dt: virtual address pointer to dt blob
@@ -25,66 +38,24 @@
25 * If a dtb was passed to the kernel, then use it to choose the correct 38 * If a dtb was passed to the kernel, then use it to choose the correct
26 * machine_desc and to setup the system. 39 * machine_desc and to setup the system.
27 */ 40 */
28struct machine_desc * __init setup_machine_fdt(void *dt) 41const struct machine_desc * __init setup_machine_fdt(void *dt)
29{ 42{
30 struct machine_desc *mdesc = NULL, *mdesc_best = NULL; 43 const struct machine_desc *mdesc;
31 unsigned int score, mdesc_score = ~1;
32 unsigned long dt_root; 44 unsigned long dt_root;
33 const char *model, *compat;
34 void *clk; 45 void *clk;
35 char manufacturer[16];
36 unsigned long len; 46 unsigned long len;
37 47
38 if (!early_init_dt_scan(dt)) 48 if (!early_init_dt_scan(dt))
39 return NULL; 49 return NULL;
40 50
41 dt_root = of_get_flat_dt_root(); 51 mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);
42 52 if (!mdesc)
43 /*
44 * The kernel could be multi-platform enabled, thus could have many
45 * "baked-in" machine descriptors. Search thru all for the best
46 * "compatible" string match.
47 */
48 for_each_machine_desc(mdesc) {
49 score = of_flat_dt_match(dt_root, mdesc->dt_compat);
50 if (score > 0 && score < mdesc_score) {
51 mdesc_best = mdesc;
52 mdesc_score = score;
53 }
54 }
55 if (!mdesc_best) {
56 const char *prop;
57 long size;
58
59 pr_err("\n unrecognized device tree list:\n[ ");
60
61 prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
62 if (prop) {
63 while (size > 0) {
64 printk("'%s' ", prop);
65 size -= strlen(prop) + 1;
66 prop += strlen(prop) + 1;
67 }
68 }
69 printk("]\n\n");
70
71 machine_halt(); 53 machine_halt();
72 }
73
74 /* compat = "<manufacturer>,<model>" */
75 compat = mdesc_best->dt_compat[0];
76
77 model = strchr(compat, ',');
78 if (model)
79 model++;
80
81 strlcpy(manufacturer, compat, model ? model - compat : strlen(compat));
82
83 pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer);
84 54
55 dt_root = of_get_flat_dt_root();
85 clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len); 56 clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len);
86 if (clk) 57 if (clk)
87 arc_set_core_freq(of_read_ulong(clk, len/4)); 58 arc_set_core_freq(of_read_ulong(clk, len/4));
88 59
89 return mdesc_best; 60 return mdesc;
90} 61}
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 710bf895dc2c..8a9cf4e7403b 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -31,7 +31,7 @@
31int running_on_hw = 1; /* vs. on ISS */ 31int running_on_hw = 1; /* vs. on ISS */
32 32
33char __initdata command_line[COMMAND_LINE_SIZE]; 33char __initdata command_line[COMMAND_LINE_SIZE];
34struct machine_desc *machine_desc; 34const struct machine_desc *machine_desc;
35 35
36struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ 36struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
37 37