summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schultz <d.schultz@phytec.de>2017-11-03 11:48:29 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-11-07 07:47:10 +0100
commit9a699780a0ae3abeef93ac615d818f0f4b095619 (patch)
treeecd0c66716ea85d5c9f818e9d471d19cdf16d40e
parent09f15cdb3817902897544296cc90d1eeff4a9487 (diff)
downloadbarebox-9a699780a0ae3abeef93ac615d818f0f4b095619.tar.gz
barebox-9a699780a0ae3abeef93ac615d818f0f4b095619.tar.xz
ARM: phytec-som-am335x: Set MAC addresses from state
If a state with the name 'am335x_phytec_mac_state' is available, valid MAC addresses from this state get registerd to their ethernet device. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/phytec-som-am335x/board.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index dc3b84a806..9f74981398 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -21,10 +21,12 @@
#include <bootsource.h>
#include <common.h>
#include <nand.h>
+#include <net.h>
#include <init.h>
#include <io.h>
#include <linux/sizes.h>
#include <envfs.h>
+#include <state.h>
#include <asm/armlinux.h>
#include <generated/mach-types.h>
#include <linux/phy.h>
@@ -65,8 +67,16 @@ static char *nandslots[] = {
"/dev/nand0.barebox_backup.bb",
};
+#define ETH_COUNT 2
+static const char *eth_names[ETH_COUNT] = {"mac0", "mac1"};
+
static int physom_devices_init(void)
{
+ struct state *state;
+ u8 mac[6];
+ int state_ret;
+ int state_i;
+
if (!of_machine_is_compatible("phytec,am335x-som"))
return 0;
@@ -114,6 +124,17 @@ static int physom_devices_init(void)
ARRAY_SIZE(nandslots));
am33xx_bbu_emmc_mlo_register_handler("MLO.emmc", "/dev/mmc1");
+ if (IS_ENABLED(CONFIG_STATE)) {
+ state = state_by_name("am335x_phytec_mac_state");
+ if (state)
+ for (state_i = 0; state_i < 2; state_i++) {
+ state_ret = state_read_mac(state,
+ eth_names[state_i], &mac[0]);
+ if (state_ret == 6)
+ eth_register_ethaddr(state_i, mac);
+ }
+ }
+
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();