| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 4e9c34a37bd3442b286ba55441bfe22c1ac5b65f Mon Sep 17 00:00:00 2001 |
| 2 | From: Jonas Gorski <jogo@openwrt.org> |
| 3 | Date: Sun, 9 Mar 2014 04:08:06 +0100 |
| 4 | Subject: [PATCH 41/44] MIPS: BCM63XX: pass a mac addresss allocator to board |
| 5 | setup |
| 6 | |
| 7 | Pass a mac address allocator to board setup code to allow board |
| 8 | implementations to work with third party bootloaders not using nvram |
| 9 | for configuration storage. |
| 10 | |
| 11 | Signed-off-by: Jonas Gorski <jogo@openwrt.org> |
| 12 | --- |
| 13 | arch/mips/bcm63xx/boards/board_bcm963xx.c | 3 ++- |
| 14 | arch/mips/bcm63xx/boards/board_common.c | 16 ++++++++++------ |
| 15 | arch/mips/bcm63xx/boards/board_common.h | 3 ++- |
| 16 | 3 files changed, 14 insertions(+), 8 deletions(-) |
| 17 | |
| 18 | --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c |
| 19 | +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c |
| 20 | @@ -738,7 +738,8 @@ void __init board_prom_init(void) |
| 21 | if (strncmp(board_name, bcm963xx_boards[i]->name, 16)) |
| 22 | continue; |
| 23 | /* copy, board desc array is marked initdata */ |
| 24 | - board_early_setup(bcm963xx_boards[i]); |
| 25 | + board_early_setup(bcm963xx_boards[i], |
| 26 | + bcm63xx_nvram_get_mac_address); |
| 27 | break; |
| 28 | } |
| 29 | |
| 30 | --- a/arch/mips/bcm63xx/boards/board_common.c |
| 31 | +++ b/arch/mips/bcm63xx/boards/board_common.c |
| 32 | @@ -18,7 +18,6 @@ |
| 33 | #include <bcm63xx_dev_uart.h> |
| 34 | #include <bcm63xx_regs.h> |
| 35 | #include <bcm63xx_io.h> |
| 36 | -#include <bcm63xx_nvram.h> |
| 37 | #include <bcm63xx_gpio.h> |
| 38 | #include <bcm63xx_dev_pci.h> |
| 39 | #include <bcm63xx_dev_enet.h> |
| 40 | @@ -81,15 +80,20 @@ const char *board_get_name(void) |
| 41 | return board.name; |
| 42 | } |
| 43 | |
| 44 | +static int (*board_get_mac_address)(u8 mac[ETH_ALEN]); |
| 45 | + |
| 46 | /* |
| 47 | * setup board for device registration |
| 48 | */ |
| 49 | -void __init board_early_setup(const struct board_info *target) |
| 50 | +void __init board_early_setup(const struct board_info *target, |
| 51 | + int (*get_mac_address)(u8 mac[ETH_ALEN])) |
| 52 | { |
| 53 | u32 val; |
| 54 | |
| 55 | memcpy(&board, target, sizeof(board)); |
| 56 | |
| 57 | + board_get_mac_address = get_mac_address; |
| 58 | + |
| 59 | /* setup pin multiplexing depending on board enabled device, |
| 60 | * this has to be done this early since PCI init is done |
| 61 | * inside arch_initcall */ |
| 62 | @@ -162,15 +166,15 @@ int __init board_register_devices(void) |
| 63 | bcm63xx_pcmcia_register(); |
| 64 | |
| 65 | if (board.has_enet0 && |
| 66 | - !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr)) |
| 67 | + !board_get_mac_address(board.enet0.mac_addr)) |
| 68 | bcm63xx_enet_register(0, &board.enet0); |
| 69 | |
| 70 | if (board.has_enet1 && |
| 71 | - !bcm63xx_nvram_get_mac_address(board.enet1.mac_addr)) |
| 72 | + !board_get_mac_address(board.enet1.mac_addr)) |
| 73 | bcm63xx_enet_register(1, &board.enet1); |
| 74 | |
| 75 | if (board.has_enetsw && |
| 76 | - !bcm63xx_nvram_get_mac_address(board.enetsw.mac_addr)) |
| 77 | + !board_get_mac_address(board.enetsw.mac_addr)) |
| 78 | bcm63xx_enetsw_register(&board.enetsw); |
| 79 | |
| 80 | if (board.has_usbd) |
| 81 | @@ -186,7 +190,7 @@ int __init board_register_devices(void) |
| 82 | * do this after registering enet devices |
| 83 | */ |
| 84 | #ifdef CONFIG_SSB_PCIHOST |
| 85 | - if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) { |
| 86 | + if (!board_get_mac_address(bcm63xx_sprom.il0mac)) { |
| 87 | memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN); |
| 88 | memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN); |
| 89 | if (ssb_arch_register_fallback_sprom( |
| 90 | --- a/arch/mips/bcm63xx/boards/board_common.h |
| 91 | +++ b/arch/mips/bcm63xx/boards/board_common.h |
| 92 | @@ -3,6 +3,7 @@ |
| 93 | |
| 94 | #include <board_bcm963xx.h> |
| 95 | |
| 96 | -void board_early_setup(const struct board_info *board); |
| 97 | +void board_early_setup(const struct board_info *board, |
| 98 | + int (*get_mac_address)(u8 mac[ETH_ALEN])); |
| 99 | |
| 100 | #endif /* __BOARD_COMMON_H */ |