Allow appending a dtb blob to the binary and use it for identifying the board. Fall back to nvram based identification in case of no dtb passed. Signed-off-by: Jonas Gorski <jogo@openwrt.org> SVN-Revision: 42119master
parent
b61f57a5c7
commit
de8e3f2f86
@ -0,0 +1,124 @@ |
||||
From 318c1fce4aeef298cbb6153416c499c94ad7cda0 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Tue, 24 Jun 2014 10:53:15 +0200
|
||||
Subject: [PATCH RFC v3] MIPS: add support for vmlinux.bin appended DTB
|
||||
|
||||
Add support for populating initial_boot_params through a dtb
|
||||
blob appended to raw vmlinux.bin.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
Changes RFC v2 -> v3
|
||||
|
||||
* fixed !smp kernels (TODO: move it to its own patch
|
||||
|
||||
Changes RFC v1 -> v2
|
||||
|
||||
* changed all occurences of vmlinux to vmlinux.bin
|
||||
* clarified this applies to the raw vmlinux.bin without decompressor
|
||||
* s/initial_device_params/initial_boot_params/
|
||||
|
||||
Initial comments by me still valid:
|
||||
|
||||
Mostly adapted from how ARM is doing it.
|
||||
|
||||
Sent as an RFC PATCH because I am not sure if this is the right way to
|
||||
it, and whether storing the pointer in initial_boot_params is a good
|
||||
idea, or a new variable should be introduced.
|
||||
|
||||
The reasoning for initial_boot_params is that there is no common
|
||||
MIPS interface yet, so the next best thing was using that. This also
|
||||
has the advantage of keeping the original fw_args intact.
|
||||
|
||||
This patch works for me on bcm63xx, where the bootloader expects
|
||||
an lzma compressed kernel, so I didn't want to double compress using
|
||||
the in-kernel compressed kernel support.
|
||||
|
||||
Completely untested on anything except MIPS32 / big endian.
|
||||
|
||||
arch/mips/Kconfig | 18 ++++++++++++++++++
|
||||
arch/mips/kernel/head.S | 19 +++++++++++++++++++
|
||||
arch/mips/kernel/vmlinux.lds.S | 7 +++++++
|
||||
3 files changed, 43 insertions(+)
|
||||
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -2519,6 +2519,24 @@ config RAPIDIO
|
||||
|
||||
source "drivers/rapidio/Kconfig"
|
||||
|
||||
+config MIPS_APPENDED_DTB
|
||||
+ bool "Use appended device tree blob to vmlinux.bin (EXPERIMENTAL)"
|
||||
+ depends on OF
|
||||
+ help
|
||||
+ With this option, the boot code will look for a device tree binary
|
||||
+ DTB) appended to raw vmlinux.bin (without decompressor).
|
||||
+ (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
|
||||
+
|
||||
+ This is meant as a backward compatibility convenience for those
|
||||
+ systems with a bootloader that can't be upgraded to accommodate
|
||||
+ the documented boot protocol using a device tree.
|
||||
+
|
||||
+ Beware that there is very little in terms of protection against
|
||||
+ this option being confused by leftover garbage in memory that might
|
||||
+ look like a DTB header after a reboot if no actual DTB is appended
|
||||
+ to vmlinux.bin. Do not leave this option active in a production kernel
|
||||
+ if you don't intend to always append a DTB.
|
||||
+
|
||||
endmenu
|
||||
|
||||
menu "Executable file formats"
|
||||
--- a/arch/mips/kernel/head.S
|
||||
+++ b/arch/mips/kernel/head.S
|
||||
@@ -139,6 +139,22 @@ NESTED(kernel_entry, 16, sp) # kernel
|
||||
mtc0 t0, CP0_STATUS
|
||||
#endif /* CONFIG_MIPS_MT_SMTC */
|
||||
|
||||
+#ifdef CONFIG_MIPS_APPENDED_DTB
|
||||
+ PTR_LA t0, __appended_dtb
|
||||
+ PTR_LI t3, 0
|
||||
+
|
||||
+#ifdef CONFIG_CPU_BIG_ENDIAN
|
||||
+ PTR_LI t1, 0xd00dfeed
|
||||
+#else
|
||||
+ PTR_LI t1, 0xedfe0dd0
|
||||
+#endif
|
||||
+ LONG_L t2, (t0)
|
||||
+ bne t1, t2, not_found
|
||||
+
|
||||
+ PTR_LA t3, __appended_dtb
|
||||
+
|
||||
+not_found:
|
||||
+#endif
|
||||
PTR_LA t0, __bss_start # clear .bss
|
||||
LONG_S zero, (t0)
|
||||
PTR_LA t1, __bss_stop - LONGSIZE
|
||||
@@ -152,6 +168,10 @@ NESTED(kernel_entry, 16, sp) # kernel
|
||||
LONG_S a2, fw_arg2
|
||||
LONG_S a3, fw_arg3
|
||||
|
||||
+#ifdef CONFIG_MIPS_APPENDED_DTB
|
||||
+ LONG_S t3, initial_boot_params
|
||||
+#endif
|
||||
+
|
||||
MTC0 zero, CP0_CONTEXT # clear context register
|
||||
PTR_LA $28, init_thread_union
|
||||
/* Set the SP after an empty pt_regs. */
|
||||
--- a/arch/mips/kernel/vmlinux.lds.S
|
||||
+++ b/arch/mips/kernel/vmlinux.lds.S
|
||||
@@ -125,8 +125,14 @@ SECTIONS
|
||||
.exit.data : {
|
||||
EXIT_DATA
|
||||
}
|
||||
-
|
||||
+#ifdef CONFIG_SMP
|
||||
PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
|
||||
+#endif
|
||||
+#ifdef CONFIG_MIPS_APPENDED_DTB
|
||||
+ __appended_dtb = .;
|
||||
+ /* leave space for appended DTB */
|
||||
+ . = . + 0x100000;
|
||||
+#endif
|
||||
/*
|
||||
* Align to 64K in attempt to eliminate holes before the
|
||||
* .bss..swapper_pg_dir section at the start of .bss. This
|
@ -0,0 +1,96 @@ |
||||
From db896341299cbcb703821228574ba9b79b6a3565 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Tue, 24 Jun 2014 10:57:51 +0200
|
||||
Subject: [PATCH 45/48] MIPS: BCM63XX: add support for loading DTB
|
||||
|
||||
---
|
||||
arch/mips/bcm63xx/boards/Kconfig | 4 ++++
|
||||
arch/mips/bcm63xx/boards/board_common.c | 34 +++++++++++++++++++++++++++++++++
|
||||
2 files changed, 38 insertions(+)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/Kconfig
|
||||
+++ b/arch/mips/bcm63xx/boards/Kconfig
|
||||
@@ -1,6 +1,10 @@
|
||||
menu "Board support"
|
||||
depends on BCM63XX
|
||||
|
||||
+config BOARD_BCM63XX_DT
|
||||
+ bool "Device Tree boards (experimential)"
|
||||
+ select USE_OF
|
||||
+
|
||||
config BOARD_BCM963XX
|
||||
bool "Generic Broadcom 963xx boards"
|
||||
select SSB
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.c
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
+#include <linux/of_fdt.h>
|
||||
+#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <linux/gpio_keys.h>
|
||||
@@ -17,6 +19,7 @@
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/fw/cfe/cfe_api.h>
|
||||
+#include <asm/prom.h>
|
||||
#include <bcm63xx_board.h>
|
||||
#include <bcm63xx_cpu.h>
|
||||
#include <bcm63xx_dev_uart.h>
|
||||
@@ -129,8 +132,23 @@ void __init board_setup(void)
|
||||
/* make sure we're running on expected cpu */
|
||||
if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
|
||||
panic("unexpected CPU for bcm963xx board");
|
||||
+
|
||||
+#if CONFIG_OF
|
||||
+ if (initial_boot_params)
|
||||
+ __dt_setup_arch(initial_boot_params);
|
||||
+#endif
|
||||
}
|
||||
|
||||
+#if CONFIG_OF
|
||||
+void __init device_tree_init(void)
|
||||
+{
|
||||
+ if (!initial_boot_params)
|
||||
+ return;
|
||||
+
|
||||
+ unflatten_and_copy_device_tree();
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static struct gpio_led_platform_data bcm63xx_led_data;
|
||||
|
||||
static struct platform_device bcm63xx_gpio_leds = {
|
||||
@@ -149,6 +167,13 @@ static struct platform_device bcm63xx_gp
|
||||
.dev.platform_data = &bcm63xx_gpio_keys_data,
|
||||
};
|
||||
|
||||
+#if CONFIG_OF
|
||||
+static struct of_device_id of_ids[] = {
|
||||
+ { /* filled at runtime */ },
|
||||
+ { .compatible = "simple-bus" },
|
||||
+ { },
|
||||
+};
|
||||
+#endif
|
||||
/*
|
||||
* third stage init callback, register all board devices.
|
||||
*/
|
||||
@@ -158,6 +183,15 @@ int __init board_register_devices(void)
|
||||
int led_count = 0;
|
||||
int usbh_ports = 0;
|
||||
|
||||
+#if CONFIG_OF
|
||||
+ if (of_have_populated_dt()) {
|
||||
+ snprintf(of_ids[0].compatible, sizeof(of_ids[0].compatible),
|
||||
+ "brcm,bcm%x", bcm63xx_get_cpu_id());
|
||||
+
|
||||
+ of_platform_populate(NULL, of_ids, NULL, NULL);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (board.has_uart0)
|
||||
bcm63xx_uart_register(0);
|
||||
|
@ -0,0 +1,24 @@ |
||||
From e8c11c43a9eb8171d150850c498bc75205681ab8 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Thu, 26 Jun 2014 12:49:33 +0200
|
||||
Subject: [PATCH 46/48] MIPS: BCM63XX: expand board_info with an of compatible
|
||||
string
|
||||
|
||||
It will be used for matching board_info structs to a passed dtb until
|
||||
bcm63xx is fully converted.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
|
||||
+++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
struct board_info {
|
||||
u8 name[16];
|
||||
+ u8 of_board_id[32];
|
||||
unsigned int expected_cpu_id;
|
||||
|
||||
/* enabled feature/device */
|
@ -0,0 +1,61 @@ |
||||
From b9bc4eb19007fd35b57a10c4dfd442dd518ee345 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Thu, 26 Jun 2014 12:51:00 +0200
|
||||
Subject: [PATCH 47/48] MIPS: BCM63XX: add support for matching the board_info
|
||||
by dtb
|
||||
|
||||
Allow using the passed dtb's compatible property to match board_info
|
||||
structs instead of nvram's boardname field, which is not unique anyway.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 4 ++--
|
||||
arch/mips/bcm63xx/boards/board_common.c | 13 +++++++++++++
|
||||
arch/mips/bcm63xx/boards/board_common.h | 3 +++
|
||||
3 files changed, 18 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -817,9 +817,9 @@ void __init board_bcm963xx_init(void)
|
||||
}
|
||||
board_name = bcm63xx_nvram_get_name();
|
||||
}
|
||||
- /* find board by name */
|
||||
+ /* find board by name/compat */
|
||||
for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
|
||||
- if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
|
||||
+ if (!board_is_compatible(bcm963xx_boards[i], board_name))
|
||||
continue;
|
||||
/* copy, board desc array is marked initdata */
|
||||
board_early_setup(bcm963xx_boards[i],
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.c
|
||||
@@ -281,3 +281,16 @@ int __init board_register_devices(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+int __init board_is_compatible(const struct board_info *board,
|
||||
+ const char *board_name)
|
||||
+{
|
||||
+#ifdef CONFIG_OF
|
||||
+ if (initial_boot_params) {
|
||||
+ unsigned long dt_root = of_get_flat_dt_root();
|
||||
+
|
||||
+ return of_flat_dt_is_compatible(dt_root, board->of_board_id);
|
||||
+ }
|
||||
+#endif
|
||||
+ return !strncmp(board_name, board->name, 16);
|
||||
+}
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.h
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.h
|
||||
@@ -6,6 +6,9 @@
|
||||
void board_early_setup(const struct board_info *board,
|
||||
int (*get_mac_address)(u8 mac[ETH_ALEN]));
|
||||
|
||||
+int board_is_compatible(const struct board_info *board,
|
||||
+ const char *board_name);
|
||||
+
|
||||
#if defined(CONFIG_BOARD_BCM963XX)
|
||||
void board_bcm963xx_init(void);
|
||||
#else
|
@ -0,0 +1,147 @@ |
||||
From 020faee6d3cef9b3cdda257a255c4007a4b38720 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Tue, 8 Jul 2014 16:17:32 +0200
|
||||
Subject: [PATCH 48/48] MIPS: BCM63XX: add of_board_ids for all supported boards
|
||||
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 18 ++++++++++++++++++
|
||||
1 file changed, 18 insertions(+)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -41,6 +41,7 @@
|
||||
#ifdef CONFIG_BCM63XX_CPU_3368
|
||||
static struct board_info __initdata board_cvg834g = {
|
||||
.name = "CVG834G_E15R3921",
|
||||
+ .of_board_id = "netgear,cvg834g",
|
||||
.expected_cpu_id = 0x3368,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -73,6 +74,7 @@ static struct board_info __initdata boar
|
||||
#ifdef CONFIG_BCM63XX_CPU_6328
|
||||
static struct board_info __initdata board_96328avng = {
|
||||
.name = "96328avng",
|
||||
+ .of_board_id = "brcm,bcm96328avng",
|
||||
.expected_cpu_id = 0x6328,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -122,6 +124,7 @@ static struct board_info __initdata boar
|
||||
#ifdef CONFIG_BCM63XX_CPU_6338
|
||||
static struct board_info __initdata board_96338gw = {
|
||||
.name = "96338GW",
|
||||
+ .of_board_id = "brcm,bcm96338gw",
|
||||
.expected_cpu_id = 0x6338,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -165,6 +168,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96338w = {
|
||||
.name = "96338W",
|
||||
+ .of_board_id = "brcm,96338w",
|
||||
.expected_cpu_id = 0x6338,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -211,6 +215,7 @@ static struct board_info __initdata boar
|
||||
#ifdef CONFIG_BCM63XX_CPU_6345
|
||||
static struct board_info __initdata board_96345gw2 = {
|
||||
.name = "96345GW2",
|
||||
+ .of_board_id = "brcm,bcm96345gw2",
|
||||
.expected_cpu_id = 0x6345,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -223,6 +228,7 @@ static struct board_info __initdata boar
|
||||
#ifdef CONFIG_BCM63XX_CPU_6348
|
||||
static struct board_info __initdata board_96348r = {
|
||||
.name = "96348R",
|
||||
+ .of_board_id = "brcm,bcm96348r",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -268,6 +274,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96348gw_10 = {
|
||||
.name = "96348GW-10",
|
||||
+ .of_board_id = "brcm,bcm96348gw-10",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -329,6 +336,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96348gw_11 = {
|
||||
.name = "96348GW-11",
|
||||
+ .of_board_id = "brcm,bcm96348gw-11",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -394,6 +402,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96348gw = {
|
||||
.name = "96348GW",
|
||||
+ .of_board_id = "brcm,bcm96348gw",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -463,6 +472,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_FAST2404 = {
|
||||
.name = "F@ST2404",
|
||||
+ .of_board_id = "sagem,f@st2404",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -488,6 +498,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_rta1025w_16 = {
|
||||
.name = "RTA1025W_16",
|
||||
+ .of_board_id = "dynalink,rta1025w",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_enet0 = 1,
|
||||
@@ -508,6 +519,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_DV201AMR = {
|
||||
.name = "DV201AMR",
|
||||
+ .of_board_id = "davolink,dv-201amr",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -529,6 +541,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96348gw_a = {
|
||||
.name = "96348GW-A",
|
||||
+ .of_board_id = "brcm,bcm96348gw-a",
|
||||
.expected_cpu_id = 0x6348,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -556,6 +569,7 @@ static struct board_info __initdata boar
|
||||
#ifdef CONFIG_BCM63XX_CPU_6358
|
||||
static struct board_info __initdata board_96358vw = {
|
||||
.name = "96358VW",
|
||||
+ .of_board_id = "brcm,bcm96358vw",
|
||||
.expected_cpu_id = 0x6358,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -609,6 +623,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96358vw2 = {
|
||||
.name = "96358VW2",
|
||||
+ .of_board_id = "brcm,bcm96358vw2",
|
||||
.expected_cpu_id = 0x6358,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -659,6 +674,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_AGPFS0 = {
|
||||
.name = "AGPF-S0",
|
||||
+ .of_board_id = "pirelli,agpf-s0",
|
||||
.expected_cpu_id = 0x6358,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -682,6 +698,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_DWVS0 = {
|
||||
.name = "DWV-S0",
|
||||
+ .of_board_id = "pirelli,a226g",
|
||||
.expected_cpu_id = 0x6358,
|
||||
|
||||
.has_enet0 = 1,
|
Loading…
Reference in new issue