diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-08-27 22:43:12 -0400 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2013-10-09 21:03:55 -0400 |
commit | 880beb8807814c7785680bcbdc81dcf076f585db (patch) | |
tree | 7a64b685b20e5369c0af312265f60a8a627f5593 /arch | |
parent | 6a903a2551ef778d60ce4341722d611144251398 (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')
-rw-r--r-- | arch/arc/include/asm/mach_desc.h | 16 | ||||
-rw-r--r-- | arch/arc/kernel/devtree.c | 67 | ||||
-rw-r--r-- | arch/arc/kernel/setup.c | 2 |
3 files changed, 23 insertions, 62 deletions
diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h index d3e9c0a05be8..e8993a2be6c2 100644 --- a/arch/arc/include/asm/mach_desc.h +++ b/arch/arc/include/asm/mach_desc.h | |||
@@ -51,22 +51,12 @@ struct machine_desc { | |||
51 | /* | 51 | /* |
52 | * Current machine - only accessible during boot. | 52 | * Current machine - only accessible during boot. |
53 | */ | 53 | */ |
54 | extern struct machine_desc *machine_desc; | 54 | extern const struct machine_desc *machine_desc; |
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Machine type table - also only accessible during boot | 57 | * Machine type table - also only accessible during boot |
58 | */ | 58 | */ |
59 | extern struct machine_desc __arch_info_begin[], __arch_info_end[]; | 59 | extern const struct machine_desc __arch_info_begin[], __arch_info_end[]; |
60 | #define for_each_machine_desc(p) \ | ||
61 | for (p = __arch_info_begin; p < __arch_info_end; p++) | ||
62 | |||
63 | static inline struct machine_desc *default_machine_desc(void) | ||
64 | { | ||
65 | /* the default machine is the last one linked in */ | ||
66 | if (__arch_info_end - 1 < __arch_info_begin) | ||
67 | return NULL; | ||
68 | return __arch_info_end - 1; | ||
69 | } | ||
70 | 60 | ||
71 | /* | 61 | /* |
72 | * Set of macros to define architecture features. | 62 | * Set of macros to define architecture features. |
@@ -81,6 +71,6 @@ __attribute__((__section__(".arch.info.init"))) = { \ | |||
81 | #define MACHINE_END \ | 71 | #define MACHINE_END \ |
82 | }; | 72 | }; |
83 | 73 | ||
84 | extern struct machine_desc *setup_machine_fdt(void *dt); | 74 | extern const struct machine_desc *setup_machine_fdt(void *dt); |
85 | 75 | ||
86 | #endif | 76 | #endif |
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 | ||
21 | static 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 | */ |
28 | struct machine_desc * __init setup_machine_fdt(void *dt) | 41 | const 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 @@ | |||
31 | int running_on_hw = 1; /* vs. on ISS */ | 31 | int running_on_hw = 1; /* vs. on ISS */ |
32 | 32 | ||
33 | char __initdata command_line[COMMAND_LINE_SIZE]; | 33 | char __initdata command_line[COMMAND_LINE_SIZE]; |
34 | struct machine_desc *machine_desc; | 34 | const struct machine_desc *machine_desc; |
35 | 35 | ||
36 | struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ | 36 | struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ |
37 | 37 | ||