1 From 25bf2b5836c892f091651d8a3384c9c57ce1b400 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Thu, 26 Jun 2014 12:51:00 +0200
4 Subject: [PATCH 46/48] MIPS: BCM63XX: add support for matching the board_info
7 Allow using the passed dtb's compatible property to match board_info
8 structs instead of nvram's boardname field, which is not unique anyway.
10 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
12 arch/mips/bcm63xx/boards/board_bcm963xx.c | 15 +++++++++++++++
13 arch/mips/bcm63xx/boards/board_common.c | 18 ++++++++++++++++++
14 arch/mips/bcm63xx/boards/board_common.h | 3 +++
15 3 files changed, 36 insertions(+)
17 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
18 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
19 @@ -715,6 +715,10 @@ static const struct board_info __initcon
23 +static struct of_device_id const bcm963xx_boards_dt[] = {
28 * early init callback, read nvram data from flash and checksum it
30 @@ -726,6 +730,7 @@ void __init board_bcm963xx_init(void)
31 char *board_name = NULL;
34 + const struct of_device_id *board_match;
36 /* read base address of boot chip select (0)
37 * 6328/6362 do not have MPI but boot from a fixed address
38 @@ -765,6 +770,16 @@ void __init board_bcm963xx_init(void)
40 board_name = bcm63xx_nvram_get_name();
43 + /* find board by compat */
44 + board_match = bcm63xx_match_board(bcm963xx_boards_dt);
46 + board_early_setup(board_match->data,
47 + bcm63xx_nvram_get_mac_address);
52 /* find board by name */
53 for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
54 if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
55 --- a/arch/mips/bcm63xx/boards/board_common.c
56 +++ b/arch/mips/bcm63xx/boards/board_common.c
57 @@ -281,3 +281,21 @@ int __init board_register_devices(void)
62 +const struct of_device_id * __init bcm63xx_match_board(const struct of_device_id *m)
64 + const struct of_device_id *match;
65 + unsigned long dt_root;
67 + if (!IS_ENABLED(CONFIG_OF) || !initial_boot_params)
70 + dt_root = of_get_flat_dt_root();
72 + for (match = m; match->compatible[0]; match++) {
73 + if (of_flat_dt_is_compatible(dt_root, match->compatible))
79 --- a/arch/mips/bcm63xx/boards/board_common.h
80 +++ b/arch/mips/bcm63xx/boards/board_common.h
82 #ifndef __BOARD_COMMON_H
83 #define __BOARD_COMMON_H
85 +#include <linux/of.h>
86 #include <board_bcm963xx.h>
88 void board_early_setup(const struct board_info *board,
89 int (*get_mac_address)(u8 mac[ETH_ALEN]));
91 +const struct of_device_id *bcm63xx_match_board(const struct of_device_id *);
93 #if defined(CONFIG_BOARD_BCM963XX)
94 void board_bcm963xx_init(void);