cef266fbc92ff47b288c72eebc6dafa13d505359
[openwrt.git] / target / linux / lantiq / patches-3.7 / 0100-MIPS-lantiq-honour-model-property-inside-devicetree-.patch
1 From 60bc3043590bf74ca1c9dd88a4e5f28a40d5b348 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 6 Dec 2012 10:26:05 +0100
4 Subject: [PATCH 100/123] MIPS: lantiq: honour model property inside
5  devicetree during board init
6
7 ---
8  arch/mips/lantiq/prom.c |   20 ++++++++++++++++++--
9  1 file changed, 18 insertions(+), 2 deletions(-)
10
11 diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c
12 index 9f9e875..fa12dc1 100644
13 --- a/arch/mips/lantiq/prom.c
14 +++ b/arch/mips/lantiq/prom.c
15 @@ -57,6 +57,21 @@ static void __init prom_init_cmdline(void)
16         }
17  }
18  
19 +int __init early_init_dt_scan_model(unsigned long node,
20 +                                       const char *uname, int depth,
21 +                                       void *data)
22 +{
23 +       if (!depth) {
24 +               char *model = of_get_flat_dt_prop(node, "model", NULL);
25 +               if (model) {
26 +                       pr_info("Board: %s\n", model);
27 +                       snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN, "%s - %s",
28 +                               soc_info.sys_type, model);
29 +               }
30 +       }
31 +       return 0;
32 +}
33 +
34  void __init plat_mem_setup(void)
35  {
36         ioport_resource.start = IOPORT_RESOURCE_START;
37 @@ -71,6 +86,8 @@ void __init plat_mem_setup(void)
38          * parsed resulting in our memory appearing
39          */
40         __dt_setup_arch(&__dtb_start);
41 +
42 +       of_scan_flat_dt(early_init_dt_scan_model, NULL);
43  }
44  
45  void __init device_tree_init(void)
46 @@ -93,9 +110,8 @@ void __init prom_init(void)
47  {
48         /* call the soc specific detetcion code and get it to fill soc_info */
49         ltq_soc_detect(&soc_info);
50 -       snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev %s",
51 +       snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN, "%s rev %s",
52                 soc_info.name, soc_info.rev_type);
53 -       soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
54         pr_info("SoC: %s\n", soc_info.sys_type);
55         prom_init_cmdline();
56  
57 -- 
58 1.7.10.4
59