generic: add missing symbol
[openwrt.git] / target / linux / brcm63xx / patches-4.1 / 367-MIPS-BCM63XX-add-support-for-loading-DTB.patch
1 From 26546e5499d98616322fb3472b977e2e86603f3a Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Tue, 24 Jun 2014 10:57:51 +0200
4 Subject: [PATCH 45/48] MIPS: BCM63XX: add support for loading DTB
5
6 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
7 ---
8  arch/mips/bcm63xx/boards/Kconfig        |    4 ++++
9  arch/mips/bcm63xx/boards/board_common.c |   34 +++++++++++++++++++++++++++++++
10  arch/mips/bcm63xx/prom.c                |    6 ++++++
11  3 files changed, 44 insertions(+)
12
13 --- a/arch/mips/bcm63xx/boards/Kconfig
14 +++ b/arch/mips/bcm63xx/boards/Kconfig
15 @@ -1,6 +1,10 @@
16  menu "Board support"
17         depends on BCM63XX
18  
19 +config BOARD_BCM63XX_DT
20 +       bool "Device Tree boards (experimential)"
21 +       select USE_OF
22 +
23  config BOARD_BCM963XX
24         bool "Generic Broadcom 963xx boards"
25         select SSB
26 --- a/arch/mips/bcm63xx/boards/board_common.c
27 +++ b/arch/mips/bcm63xx/boards/board_common.c
28 @@ -10,6 +10,8 @@
29  #include <linux/init.h>
30  #include <linux/kernel.h>
31  #include <linux/string.h>
32 +#include <linux/of_fdt.h>
33 +#include <linux/of_platform.h>
34  #include <linux/platform_device.h>
35  #include <linux/ssb/ssb.h>
36  #include <linux/gpio_keys.h>
37 @@ -17,6 +19,7 @@
38  #include <asm/addrspace.h>
39  #include <asm/bootinfo.h>
40  #include <asm/fw/cfe/cfe_api.h>
41 +#include <asm/prom.h>
42  #include <bcm63xx_board.h>
43  #include <bcm63xx_cpu.h>
44  #include <bcm63xx_dev_uart.h>
45 @@ -129,8 +132,23 @@ void __init board_setup(void)
46         /* make sure we're running on expected cpu */
47         if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
48                 panic("unexpected CPU for bcm963xx board");
49 +
50 +#if CONFIG_OF
51 +       if (initial_boot_params)
52 +               __dt_setup_arch(initial_boot_params);
53 +#endif
54  }
55  
56 +#if CONFIG_OF
57 +void __init device_tree_init(void)
58 +{
59 +       if (!initial_boot_params)
60 +               return;
61 +
62 +       unflatten_and_copy_device_tree();
63 +}
64 +#endif
65 +
66  static struct gpio_led_platform_data bcm63xx_led_data;
67  
68  static struct platform_device bcm63xx_gpio_leds = {
69 @@ -149,6 +167,13 @@ static struct platform_device bcm63xx_gp
70         .dev.platform_data = &bcm63xx_gpio_keys_data,
71  };
72  
73 +#if CONFIG_OF
74 +static struct of_device_id of_ids[] = {
75 +       { /* filled at runtime */ },
76 +       { .compatible = "simple-bus" },
77 +       { },
78 +};
79 +#endif
80  /*
81   * third stage init callback, register all board devices.
82   */
83 @@ -158,6 +183,15 @@ int __init board_register_devices(void)
84         int led_count = 0;
85         int usbh_ports = 0;
86  
87 +#if CONFIG_OF
88 +       if (of_have_populated_dt()) {
89 +               snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
90 +                        "brcm,bcm%x", bcm63xx_get_cpu_id());
91 +
92 +               of_platform_populate(NULL, of_ids, NULL, NULL);
93 +       }
94 +#endif
95 +
96         if (board.has_uart0)
97                 bcm63xx_uart_register(0);
98  
99 --- a/arch/mips/bcm63xx/prom.c
100 +++ b/arch/mips/bcm63xx/prom.c
101 @@ -8,6 +8,7 @@
102  
103  #include <linux/init.h>
104  #include <linux/bootmem.h>
105 +#include <linux/of_fdt.h>
106  #include <linux/smp.h>
107  #include <asm/bootinfo.h>
108  #include <asm/bmips.h>
109 @@ -23,6 +24,11 @@ void __init prom_init(void)
110  {
111         u32 reg, mask;
112  
113 +#if CONFIG_OF
114 +       if (fw_arg0 == -2)
115 +               early_init_dt_verify((void *)fw_arg1);
116 +#endif
117 +
118         bcm63xx_cpu_init();
119  
120         /* stop any running watchdog */