OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
1 | From 25bf2b5836c892f091651d8a3384c9c57ce1b400 Mon Sep 17 00:00:00 2001 |
1 | From 25bf2b5836c892f091651d8a3384c9c57ce1b400 Mon Sep 17 00:00:00 2001 |
|
2 | From: Jonas Gorski <jogo@openwrt.org> |
2 | From: Jonas Gorski <jogo@openwrt.org> |
|
3 | Date: Thu, 26 Jun 2014 12:51:00 +0200 |
3 | Date: Thu, 26 Jun 2014 12:51:00 +0200 |
|
4 | Subject: [PATCH 46/48] MIPS: BCM63XX: add support for matching the board_info |
4 | Subject: [PATCH 46/48] MIPS: BCM63XX: add support for matching the board_info |
|
5 | by dtb |
5 | by dtb |
|
6 | |
6 | |
|
7 | Allow using the passed dtb's compatible property to match 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. |
8 | structs instead of nvram's boardname field, which is not unique anyway. |
|
9 | |
9 | |
|
10 | Signed-off-by: Jonas Gorski <jogo@openwrt.org> |
10 | Signed-off-by: Jonas Gorski <jogo@openwrt.org> |
|
11 | --- |
11 | --- |
|
12 | arch/mips/bcm63xx/boards/board_bcm963xx.c | 15 +++++++++++++++ |
12 | arch/mips/bcm63xx/boards/board_bcm963xx.c | 15 +++++++++++++++ |
|
13 | arch/mips/bcm63xx/boards/board_common.c | 18 ++++++++++++++++++ |
13 | arch/mips/bcm63xx/boards/board_common.c | 18 ++++++++++++++++++ |
|
14 | arch/mips/bcm63xx/boards/board_common.h | 3 +++ |
14 | arch/mips/bcm63xx/boards/board_common.h | 3 +++ |
|
15 | 3 files changed, 36 insertions(+) |
15 | 3 files changed, 36 insertions(+) |
|
16 | |
16 | |
|
17 | --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c |
17 | --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c |
|
18 | +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c |
18 | +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c |
|
19 | @@ -695,6 +695,10 @@ static const struct board_info __initcon |
19 | @@ -711,6 +711,10 @@ static const struct board_info __initcon |
|
20 | #endif |
20 | #endif |
|
21 | }; |
21 | }; |
|
22 | |
22 | |
|
23 | +static struct of_device_id const bcm963xx_boards_dt[] = { |
23 | +static struct of_device_id const bcm963xx_boards_dt[] = { |
|
24 | + { }, |
24 | + { }, |
|
25 | +}; |
25 | +}; |
|
26 | + |
26 | + |
|
27 | /* |
27 | /* |
|
28 | * early init callback, read nvram data from flash and checksum it |
28 | * early init callback, read nvram data from flash and checksum it |
|
29 | */ |
29 | */ |
|
30 | @@ -706,6 +710,7 @@ void __init board_bcm963xx_init(void) |
30 | @@ -722,6 +726,7 @@ void __init board_bcm963xx_init(void) |
|
31 | char *board_name = NULL; |
31 | char *board_name = NULL; |
|
32 | u32 val; |
32 | u32 val; |
|
33 | struct bcm_hcs *hcs; |
33 | struct bcm_hcs *hcs; |
|
34 | + const struct of_device_id *board_match; |
34 | + const struct of_device_id *board_match; |
|
35 | |
35 | |
|
36 | /* read base address of boot chip select (0) |
36 | /* read base address of boot chip select (0) |
|
37 | * 6328/6362 do not have MPI but boot from a fixed address |
37 | * 6328/6362 do not have MPI but boot from a fixed address |
|
38 | @@ -745,6 +750,16 @@ void __init board_bcm963xx_init(void) |
38 | @@ -761,6 +766,16 @@ void __init board_bcm963xx_init(void) |
|
39 | } else { |
39 | } else { |
|
40 | board_name = bcm63xx_nvram_get_name(); |
40 | board_name = bcm63xx_nvram_get_name(); |
|
41 | } |
41 | } |
|
42 | + |
42 | + |
|
43 | + /* find board by compat */ |
43 | + /* find board by compat */ |
|
44 | + board_match = bcm63xx_match_board(bcm963xx_boards_dt); |
44 | + board_match = bcm63xx_match_board(bcm963xx_boards_dt); |
|
45 | + if (board_match) { |
45 | + if (board_match) { |
|
46 | + board_early_setup(board_match->data, |
46 | + board_early_setup(board_match->data, |
|
47 | + bcm63xx_nvram_get_mac_address); |
47 | + bcm63xx_nvram_get_mac_address); |
|
48 | + |
48 | + |
|
49 | + return; |
49 | + return; |
|
50 | + } |
50 | + } |
|
51 | + |
51 | + |
|
52 | /* find board by name */ |
52 | /* find board by name */ |
|
53 | for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) { |
53 | for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) { |
|
54 | if (strncmp(board_name, bcm963xx_boards[i]->name, 16)) |
54 | if (strncmp(board_name, bcm963xx_boards[i]->name, 16)) |
|
55 | --- a/arch/mips/bcm63xx/boards/board_common.c |
55 | --- a/arch/mips/bcm63xx/boards/board_common.c |
|
56 | +++ b/arch/mips/bcm63xx/boards/board_common.c |
56 | +++ b/arch/mips/bcm63xx/boards/board_common.c |
|
57 | @@ -239,3 +239,21 @@ int __init board_register_devices(void) |
57 | @@ -243,3 +243,21 @@ int __init board_register_devices(void) |
|
58 | |
58 | |
|
59 | return 0; |
59 | return 0; |
|
60 | } |
60 | } |
|
61 | + |
61 | + |
|
62 | +const struct of_device_id * __init bcm63xx_match_board(const struct of_device_id *m) |
62 | +const struct of_device_id * __init bcm63xx_match_board(const struct of_device_id *m) |
|
63 | +{ |
63 | +{ |
|
64 | + const struct of_device_id *match; |
64 | + const struct of_device_id *match; |
|
65 | + unsigned long dt_root; |
65 | + unsigned long dt_root; |
|
66 | + |
66 | + |
|
67 | + if (!IS_ENABLED(CONFIG_OF) || !initial_boot_params) |
67 | + if (!IS_ENABLED(CONFIG_OF) || !initial_boot_params) |
|
68 | + return NULL; |
68 | + return NULL; |
|
69 | + |
69 | + |
|
70 | + dt_root = of_get_flat_dt_root(); |
70 | + dt_root = of_get_flat_dt_root(); |
|
71 | + |
71 | + |
|
72 | + for (match = m; match->compatible[0]; match++) { |
72 | + for (match = m; match->compatible[0]; match++) { |
|
73 | + if (of_flat_dt_is_compatible(dt_root, match->compatible)) |
73 | + if (of_flat_dt_is_compatible(dt_root, match->compatible)) |
|
74 | + return match; |
74 | + return match; |
|
75 | + } |
75 | + } |
|
76 | + |
76 | + |
|
77 | + return NULL; |
77 | + return NULL; |
|
78 | +} |
78 | +} |
|
79 | --- a/arch/mips/bcm63xx/boards/board_common.h |
79 | --- a/arch/mips/bcm63xx/boards/board_common.h |
|
80 | +++ b/arch/mips/bcm63xx/boards/board_common.h |
80 | +++ b/arch/mips/bcm63xx/boards/board_common.h |
|
81 | @@ -1,11 +1,14 @@ |
81 | @@ -1,11 +1,14 @@ |
|
82 | #ifndef __BOARD_COMMON_H |
82 | #ifndef __BOARD_COMMON_H |
|
83 | #define __BOARD_COMMON_H |
83 | #define __BOARD_COMMON_H |
|
84 | |
84 | |
|
85 | +#include <linux/of.h> |
85 | +#include <linux/of.h> |
|
86 | #include <board_bcm963xx.h> |
86 | #include <board_bcm963xx.h> |
|
87 | |
87 | |
|
88 | void board_early_setup(const struct board_info *board, |
88 | void board_early_setup(const struct board_info *board, |
|
89 | int (*get_mac_address)(u8 mac[ETH_ALEN])); |
89 | int (*get_mac_address)(u8 mac[ETH_ALEN])); |
|
90 | |
90 | |
|
91 | +const struct of_device_id *bcm63xx_match_board(const struct of_device_id *); |
91 | +const struct of_device_id *bcm63xx_match_board(const struct of_device_id *); |
|
92 | + |
92 | + |
|
93 | #if defined(CONFIG_BOARD_BCM963XX) |
93 | #if defined(CONFIG_BOARD_BCM963XX) |
|
94 | void board_bcm963xx_init(void); |
94 | void board_bcm963xx_init(void); |
|
95 | #else |
95 | #else |
|
96 | |
96 | |