lantiq: add wifi eep to a803 dts file
[openwrt/openwrt.git] / target / linux / lantiq / 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 --- a/arch/mips/include/asm/prom.h
17 +++ b/arch/mips/include/asm/prom.h
18 @@ -44,8 +44,11 @@ extern void __dt_setup_arch(struct boot_
19 __dt_setup_arch(&__dtb_##sym##_begin); \
20 })
21
22 +extern char *of_mips_get_machine_name(void);
23 +
24 #else /* CONFIG_OF */
25 static inline void device_tree_init(void) { }
26 +static char *of_mips_get_machine_name(void) { return NULL; }
27 #endif /* CONFIG_OF */
28
29 #endif /* __ASM_PROM_H */
30 --- a/arch/mips/kernel/proc.c
31 +++ b/arch/mips/kernel/proc.c
32 @@ -12,6 +12,7 @@
33 #include <asm/cpu-features.h>
34 #include <asm/mipsregs.h>
35 #include <asm/processor.h>
36 +#include <asm/prom.h>
37 #include <asm/mips_machine.h>
38
39 unsigned int vced_count, vcei_count;
40 @@ -34,7 +35,10 @@ static int show_cpuinfo(struct seq_file
41 */
42 if (n == 0) {
43 seq_printf(m, "system type\t\t: %s\n", get_system_type());
44 - if (mips_get_machine_name())
45 + if (of_mips_get_machine_name())
46 + seq_printf(m, "machine\t\t\t: %s\n",
47 + of_mips_get_machine_name());
48 + else if (mips_get_machine_name())
49 seq_printf(m, "machine\t\t\t: %s\n",
50 mips_get_machine_name());
51 }
52 --- a/arch/mips/kernel/prom.c
53 +++ b/arch/mips/kernel/prom.c
54 @@ -23,6 +23,13 @@
55 #include <asm/page.h>
56 #include <asm/prom.h>
57
58 +static char of_mips_machine_name[64] = "Unknown";
59 +
60 +char *of_mips_get_machine_name(void)
61 +{
62 + return of_mips_machine_name;
63 +}
64 +
65 int __init early_init_dt_scan_memory_arch(unsigned long node,
66 const char *uname, int depth,
67 void *data)
68 @@ -50,6 +57,20 @@ void __init early_init_dt_setup_initrd_a
69 }
70 #endif
71
72 +int __init early_init_dt_scan_model(unsigned long node,
73 + const char *uname, int depth,
74 + void *data)
75 +{
76 + if (!depth) {
77 + char *model = of_get_flat_dt_prop(node, "model", NULL);
78 + if (model) {
79 + snprintf(of_mips_machine_name, sizeof(of_mips_machine_name), model);
80 + pr_info("MIPS: machine is %s\n", of_mips_machine_name);
81 + }
82 + }
83 + return 0;
84 +}
85 +
86 void __init early_init_devtree(void *params)
87 {
88 /* Setup flat device-tree pointer */
89 @@ -65,6 +86,9 @@ void __init early_init_devtree(void *par
90 /* Scan memory nodes */
91 of_scan_flat_dt(early_init_dt_scan_root, NULL);
92 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
93 +
94 + /* try to load the mips machine name */
95 + of_scan_flat_dt(early_init_dt_scan_model, NULL);
96 }
97
98 void __init __dt_setup_arch(struct boot_param_header *bph)