Move compatible strings from board structs into separate table. This allows for several board compatibles to match to the same board in case e.g. only the flash size / partitions differ. Signed-off-by: Jonas Gorski <jogo@openwrt.org> SVN-Revision: 43341master
parent
f80596c9df
commit
2bab3e2796
@ -0,0 +1,95 @@ |
||||
From 25bf2b5836c892f091651d8a3384c9c57ce1b400 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Thu, 26 Jun 2014 12:51:00 +0200
|
||||
Subject: [PATCH 46/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 | 15 +++++++++++++++
|
||||
arch/mips/bcm63xx/boards/board_common.c | 18 ++++++++++++++++++
|
||||
arch/mips/bcm63xx/boards/board_common.h | 3 +++
|
||||
3 files changed, 36 insertions(+)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -735,6 +735,10 @@ static const struct board_info __initcon
|
||||
#endif
|
||||
};
|
||||
|
||||
+static struct of_device_id const bcm963xx_boards_dt[] = {
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
/*
|
||||
* early init callback, read nvram data from flash and checksum it
|
||||
*/
|
||||
@@ -746,6 +750,7 @@ void __init board_bcm963xx_init(void)
|
||||
char *board_name = NULL;
|
||||
u32 val;
|
||||
struct bcm_hcs *hcs;
|
||||
+ const struct of_device_id *board_match;
|
||||
|
||||
/* read base address of boot chip select (0)
|
||||
* 6328/6362 do not have MPI but boot from a fixed address
|
||||
@@ -785,6 +790,16 @@ void __init board_bcm963xx_init(void)
|
||||
} else {
|
||||
board_name = bcm63xx_nvram_get_name();
|
||||
}
|
||||
+
|
||||
+ /* find board by compat */
|
||||
+ board_match = bcm63xx_match_board(bcm963xx_boards_dt);
|
||||
+ if (board_match) {
|
||||
+ board_early_setup(board_match->data,
|
||||
+ bcm63xx_nvram_get_mac_address);
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
/* find board by name */
|
||||
for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
|
||||
if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.c
|
||||
@@ -281,3 +281,21 @@ int __init board_register_devices(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+const struct of_device_id * __init bcm63xx_match_board(const struct of_device_id *m)
|
||||
+{
|
||||
+ const struct of_device_id *match;
|
||||
+ unsigned long dt_root;
|
||||
+
|
||||
+ if (!IS_ENABLED(CONFIG_OF) || !initial_boot_params)
|
||||
+ return NULL;
|
||||
+
|
||||
+ dt_root = of_get_flat_dt_root();
|
||||
+
|
||||
+ for (match = m; match->compatible[0]; match++) {
|
||||
+ if (of_flat_dt_is_compatible(dt_root, match->compatible))
|
||||
+ return match;
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
--- a/arch/mips/bcm63xx/boards/board_common.h
|
||||
+++ b/arch/mips/bcm63xx/boards/board_common.h
|
||||
@@ -1,11 +1,14 @@
|
||||
#ifndef __BOARD_COMMON_H
|
||||
#define __BOARD_COMMON_H
|
||||
|
||||
+#include <linux/of.h>
|
||||
#include <board_bcm963xx.h>
|
||||
|
||||
void board_early_setup(const struct board_info *board,
|
||||
int (*get_mac_address)(u8 mac[ETH_ALEN]));
|
||||
|
||||
+const struct of_device_id *bcm63xx_match_board(const struct of_device_id *);
|
||||
+
|
||||
#if defined(CONFIG_BOARD_BCM963XX)
|
||||
void board_bcm963xx_init(void);
|
||||
#else
|
@ -1,24 +0,0 @@ |
||||
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 */
|
@ -1,61 +0,0 @@ |
||||
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
|
||||
@@ -785,9 +785,9 @@ void __init board_bcm963xx_init(void)
|
||||
} else {
|
||||
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,58 @@ |
||||
From e71eea9953c774dfadb754258824fb1888c279f4 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Fri, 21 Nov 2014 16:54:06 +0100
|
||||
Subject: [PATCH 47/48] MIPS: BCM63XX: populate the compatible to board_info
|
||||
list
|
||||
|
||||
Populate the compatible to board_info list to allow dtbs to be used
|
||||
for known boards.
|
||||
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 35 +++++++++++++++++++++++++++++
|
||||
1 file changed, 35 insertions(+)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -736,6 +736,41 @@ static const struct board_info __initcon
|
||||
};
|
||||
|
||||
static struct of_device_id const bcm963xx_boards_dt[] = {
|
||||
+#ifdef CONFIG_OF
|
||||
+#ifdef CONFIG_BCM63XX_CPU_3368
|
||||
+ { .compatible = "netgear,cvg834g", .data = &board_cvg834g, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6328
|
||||
+ { .compatible = "brcm,bcm96328avng", .data = &board_96328avng, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6338
|
||||
+ { .compatible = "brcm,bcm96338gw", .data = &board_96338gw, },
|
||||
+ { .compatible = "brcm,bcm96338w", .data = &board_96338w, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6345
|
||||
+ { .compatible = "brcm,bcm96345gw2", .data = &board_96345gw2, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6348
|
||||
+ { .compatible = "brcm,bcm96348r", .data = &board_96348r, },
|
||||
+ { .compatible = "brcm,bcm96348gw-10", .data = &board_96348gw_10, },
|
||||
+ { .compatible = "brcm,bcm96348gw-11", .data = &board_96348gw_11, },
|
||||
+ { .compatible = "brcm,bcm96348gw-a", .data = &board_96348gw_a, },
|
||||
+ { .compatible = "dynalink,rta1025w", .data = &board_rta1025w_16, },
|
||||
+ { .compatible = "sagem,f@st2404", .data = &board_FAST2404, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6358
|
||||
+ { .compatible = "brcm,bcm96358vw", .data = &board_96358vw, },
|
||||
+ { .compatible = "brcm,bcm96358vw2", .data = &board_96358vw2, },
|
||||
+ { .compatible = "pirelli,a226g", .data = &board_DWVS0, },
|
||||
+ { .compatible = "pirelli,a226m", .data = &board_DWVS0, },
|
||||
+ { .compatible = "pirelli,agpf-s0", .data = &board_AGPFS0, },
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_6368
|
||||
+#endif
|
||||
+#ifdef CONFIG_BCM63XX_CPU_63268
|
||||
+ { .compatible = "brcm,bcm963268bu_p300", .data = &board_963268bu_p300, },
|
||||
+#endif
|
||||
+#endif /* CONFIG_OF */
|
||||
{ },
|
||||
};
|
||||
|
@ -1,147 +0,0 @@ |
||||
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
|
||||
@@ -37,6 +37,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,
|
||||
@@ -69,6 +70,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,
|
||||
@@ -118,6 +120,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,
|
||||
@@ -161,6 +164,7 @@ static struct board_info __initdata boar
|
||||
|
||||
static struct board_info __initdata board_96338w = {
|
||||
.name = "96338W",
|
||||
+ .of_board_id = "brcm,bcm96338w",
|
||||
.expected_cpu_id = 0x6338,
|
||||
|
||||
.has_uart0 = 1,
|
||||
@@ -207,6 +211,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,
|
||||
@@ -219,6 +224,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,
|
||||
@@ -264,6 +270,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,
|
||||
@@ -325,6 +332,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,
|
||||
@@ -390,6 +398,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,
|
||||
@@ -459,6 +468,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,
|
||||
@@ -484,6 +494,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,
|
||||
@@ -504,6 +515,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,
|
||||
@@ -525,6 +537,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,
|
||||
@@ -552,6 +565,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,
|
||||
@@ -605,6 +619,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,
|
||||
@@ -655,6 +670,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,
|
||||
@@ -678,6 +694,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