rpcd: iwinfo plugin fixes
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-4.4 / 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,12 +10,15 @@
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/spi/spi.h>
37 #include <asm/addrspace.h>
38 #include <asm/bootinfo.h>
39 #include <asm/fw/cfe/cfe_api.h>
40 +#include <asm/prom.h>
41 #include <bcm63xx_board.h>
42 #include <bcm63xx_cpu.h>
43 #include <bcm63xx_dev_uart.h>
44 @@ -127,8 +130,23 @@ void __init board_setup(void)
45 /* make sure we're running on expected cpu */
46 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
47 panic("unexpected CPU for bcm963xx board");
48 +
49 +#if CONFIG_OF
50 + if (initial_boot_params)
51 + __dt_setup_arch(initial_boot_params);
52 +#endif
53 }
54
55 +#if CONFIG_OF
56 +void __init device_tree_init(void)
57 +{
58 + if (!initial_boot_params)
59 + return;
60 +
61 + unflatten_and_copy_device_tree();
62 +}
63 +#endif
64 +
65 static struct gpio_led_platform_data bcm63xx_led_data;
66
67 static struct platform_device bcm63xx_gpio_leds = {
68 @@ -137,6 +155,13 @@ static struct platform_device bcm63xx_gp
69 .dev.platform_data = &bcm63xx_led_data,
70 };
71
72 +#if CONFIG_OF
73 +static struct of_device_id of_ids[] = {
74 + { /* filled at runtime */ },
75 + { .compatible = "simple-bus" },
76 + { },
77 +};
78 +#endif
79 /*
80 * third stage init callback, register all board devices.
81 */
82 @@ -144,6 +169,15 @@ int __init board_register_devices(void)
83 {
84 int usbh_ports = 0;
85
86 +#if CONFIG_OF
87 + if (of_have_populated_dt()) {
88 + snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
89 + "brcm,bcm%x", bcm63xx_get_cpu_id());
90 +
91 + of_platform_populate(NULL, of_ids, NULL, NULL);
92 + }
93 +#endif
94 +
95 if (board.has_uart0)
96 bcm63xx_uart_register(0);
97
98 --- a/arch/mips/bcm63xx/prom.c
99 +++ b/arch/mips/bcm63xx/prom.c
100 @@ -8,6 +8,7 @@
101
102 #include <linux/init.h>
103 #include <linux/bootmem.h>
104 +#include <linux/of_fdt.h>
105 #include <linux/smp.h>
106 #include <asm/bootinfo.h>
107 #include <asm/bmips.h>
108 @@ -23,6 +24,11 @@ void __init prom_init(void)
109 {
110 u32 reg, mask;
111
112 +#if CONFIG_OF
113 + if (fw_arg0 == -2)
114 + early_init_dt_verify((void *)fw_arg1);
115 +#endif
116 +
117 bcm63xx_cpu_init();
118
119 /* stop any running watchdog */