[PATCH 5/5] ARM: phytec-som-am335x: Set MAC addresses from state
Daniel Schultz
d.schultz at phytec.de
Fri Oct 27 07:37:32 PDT 2017
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 at phytec.de>
---
arch/arm/boards/phytec-som-am335x/board.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index dc3b84a..34d4df1 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>
@@ -67,6 +69,10 @@ static char *nandslots[] = {
static int physom_devices_init(void)
{
+ struct state *state;
+ struct state_variable *sv;
+ struct state_mac *mac;
+
if (!of_machine_is_compatible("phytec,am335x-som"))
return 0;
@@ -114,6 +120,22 @@ 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) {
+ sv = state_find_var(state, "mac0");
+ if (!IS_ERR(sv)) {
+ mac = to_state_mac(sv);
+ eth_register_ethaddr(0, mac->value);
+ }
+ sv = state_find_var(state, "mac1");
+ if (!IS_ERR(sv)) {
+ mac = to_state_mac(sv);
+ eth_register_ethaddr(1, mac->value);
+ }
+ }
+ }
+
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();
--
2.7.4
More information about the barebox
mailing list