brcm63xx: Add DT support for A4001N
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.14 / 367-MIPS-BCM63XX-add-support-for-loading-DTB.patch
1 From db896341299cbcb703821228574ba9b79b6a3565 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 ---
7 arch/mips/bcm63xx/boards/Kconfig | 4 ++++
8 arch/mips/bcm63xx/boards/board_common.c | 34 +++++++++++++++++++++++++++++++++
9 2 files changed, 38 insertions(+)
10
11 --- a/arch/mips/bcm63xx/boards/Kconfig
12 +++ b/arch/mips/bcm63xx/boards/Kconfig
13 @@ -1,6 +1,10 @@
14 menu "Board support"
15 depends on BCM63XX
16
17 +config BOARD_BCM63XX_DT
18 + bool "Device Tree boards (experimential)"
19 + select USE_OF
20 +
21 config BOARD_BCM963XX
22 bool "Generic Broadcom 963xx boards"
23 select SSB
24 --- a/arch/mips/bcm63xx/boards/board_common.c
25 +++ b/arch/mips/bcm63xx/boards/board_common.c
26 @@ -10,6 +10,8 @@
27 #include <linux/init.h>
28 #include <linux/kernel.h>
29 #include <linux/string.h>
30 +#include <linux/of_fdt.h>
31 +#include <linux/of_platform.h>
32 #include <linux/platform_device.h>
33 #include <linux/ssb/ssb.h>
34 #include <linux/gpio_keys.h>
35 @@ -17,6 +19,7 @@
36 #include <asm/addrspace.h>
37 #include <asm/bootinfo.h>
38 #include <asm/fw/cfe/cfe_api.h>
39 +#include <asm/prom.h>
40 #include <bcm63xx_board.h>
41 #include <bcm63xx_cpu.h>
42 #include <bcm63xx_dev_uart.h>
43 @@ -129,8 +132,23 @@ void __init board_setup(void)
44 /* make sure we're running on expected cpu */
45 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
46 panic("unexpected CPU for bcm963xx board");
47 +
48 +#if CONFIG_OF
49 + if (initial_boot_params)
50 + __dt_setup_arch(initial_boot_params);
51 +#endif
52 }
53
54 +#if CONFIG_OF
55 +void __init device_tree_init(void)
56 +{
57 + if (!initial_boot_params)
58 + return;
59 +
60 + unflatten_and_copy_device_tree();
61 +}
62 +#endif
63 +
64 static struct gpio_led_platform_data bcm63xx_led_data;
65
66 static struct platform_device bcm63xx_gpio_leds = {
67 @@ -149,6 +167,13 @@ static struct platform_device bcm63xx_gp
68 .dev.platform_data = &bcm63xx_gpio_keys_data,
69 };
70
71 +#if CONFIG_OF
72 +static struct of_device_id of_ids[] = {
73 + { /* filled at runtime */ },
74 + { .compatible = "simple-bus" },
75 + { },
76 +};
77 +#endif
78 /*
79 * third stage init callback, register all board devices.
80 */
81 @@ -158,6 +183,15 @@ int __init board_register_devices(void)
82 int led_count = 0;
83 int usbh_ports = 0;
84
85 +#if CONFIG_OF
86 + if (of_have_populated_dt()) {
87 + snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
88 + "brcm,bcm%x", bcm63xx_get_cpu_id());
89 +
90 + of_platform_populate(NULL, of_ids, NULL, NULL);
91 + }
92 +#endif
93 +
94 if (board.has_uart0)
95 bcm63xx_uart_register(0);
96