add patches for v3.8
[openwrt/staging/lynxis/omap.git] / target / linux / ramips / patches-3.8 / 0200-MIPS-read-the-mips_machine-name-from-OF-and-output-i.patch
1 From 0184f7b64c68fe9606559e86bdd288de01c87a85 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 17 Mar 2013 10:30:48 +0100
4 Subject: [PATCH 200/208] MIPS: read the mips_machine name from OF and output
5 it in /proc/cpuinfo
6
7 This allows the userland to be compatible to the devive probing of mips_machine.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11 arch/mips/include/asm/prom.h | 3 +++
12 arch/mips/kernel/proc.c | 6 +++++-
13 arch/mips/kernel/prom.c | 24 ++++++++++++++++++++++++
14 3 files changed, 32 insertions(+), 1 deletion(-)
15
16 diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
17 index 8808bf5..a4ad354 100644
18 --- a/arch/mips/include/asm/prom.h
19 +++ b/arch/mips/include/asm/prom.h
20 @@ -44,8 +44,11 @@ extern void __dt_setup_arch(struct boot_param_header *bph);
21 __dt_setup_arch(&__dtb_##sym##_begin); \
22 })
23
24 +extern char *of_mips_get_machine_name(void);
25 +
26 #else /* CONFIG_OF */
27 static inline void device_tree_init(void) { }
28 +static char *of_mips_get_machine_name(void) { return NULL; }
29 #endif /* CONFIG_OF */
30
31 #endif /* __ASM_PROM_H */
32 diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
33 index 135c4aa..9ab3d13 100644
34 --- a/arch/mips/kernel/proc.c
35 +++ b/arch/mips/kernel/proc.c
36 @@ -12,6 +12,7 @@
37 #include <asm/cpu-features.h>
38 #include <asm/mipsregs.h>
39 #include <asm/processor.h>
40 +#include <asm/prom.h>
41 #include <asm/mips_machine.h>
42
43 unsigned int vced_count, vcei_count;
44 @@ -34,7 +35,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
45 */
46 if (n == 0) {
47 seq_printf(m, "system type\t\t: %s\n", get_system_type());
48 - if (mips_get_machine_name())
49 + if (of_mips_get_machine_name())
50 + seq_printf(m, "machine\t\t\t: %s\n",
51 + of_mips_get_machine_name());
52 + else if (mips_get_machine_name())
53 seq_printf(m, "machine\t\t\t: %s\n",
54 mips_get_machine_name());
55 }
56 diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
57 index 028f6f8..1aa68a2 100644
58 --- a/arch/mips/kernel/prom.c
59 +++ b/arch/mips/kernel/prom.c
60 @@ -23,6 +23,13 @@
61 #include <asm/page.h>
62 #include <asm/prom.h>
63
64 +static char of_mips_machine_name[64] = "Unknown";
65 +
66 +char *of_mips_get_machine_name(void)
67 +{
68 + return of_mips_machine_name;
69 +}
70 +
71 int __init early_init_dt_scan_memory_arch(unsigned long node,
72 const char *uname, int depth,
73 void *data)
74 @@ -50,6 +57,20 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
75 }
76 #endif
77
78 +int __init early_init_dt_scan_model(unsigned long node,
79 + const char *uname, int depth,
80 + void *data)
81 +{
82 + if (!depth) {
83 + char *model = of_get_flat_dt_prop(node, "model", NULL);
84 + if (model) {
85 + snprintf(of_mips_machine_name, sizeof(of_mips_machine_name), model);
86 + pr_info("MIPS: machine is %s\n", of_mips_machine_name);
87 + }
88 + }
89 + return 0;
90 +}
91 +
92 void __init early_init_devtree(void *params)
93 {
94 /* Setup flat device-tree pointer */
95 @@ -65,6 +86,9 @@ void __init early_init_devtree(void *params)
96 /* Scan memory nodes */
97 of_scan_flat_dt(early_init_dt_scan_root, NULL);
98 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
99 +
100 + /* try to load the mips machine name */
101 + of_scan_flat_dt(early_init_dt_scan_model, NULL);
102 }
103
104 void __init __dt_setup_arch(struct boot_param_header *bph)
105 --
106 1.7.10.4
107