]> git.sur5r.net Git - u-boot/commitdiff
board: atmel: Create board/$(VENDOR)/common folder
authorWenyou Yang <wenyou.yang@microchip.com>
Fri, 1 Sep 2017 08:26:16 +0000 (16:26 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 11 Sep 2017 20:23:06 +0000 (16:23 -0400)
Create board/$(VENDOR)/common folder to accommodate the common code
shared by other atmel boards, now put the code to set ethernet mac
address from eeprom, which uses the i2c eeprom driver.

Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/arm/mach-at91/include/mach/at91_common.h
board/atmel/common/Makefile [new file with mode: 0644]
board/atmel/common/board.c [new file with mode: 0644]
board/atmel/common/mac_eeprom.c [new file with mode: 0644]

index 0742ffc56f8a059a6aca6aa39e16be8a7970069a..a95fe4161039a0f3a1ee8c4d7d2572b16a4ef726 100644 (file)
@@ -36,4 +36,6 @@ void matrix_init(void);
 void redirect_int_from_saic_to_aic(void);
 void configure_2nd_sram_as_l2_cache(void);
 
+int at91_set_ethaddr(int offset);
+
 #endif /* AT91_COMMON_H */
diff --git a/board/atmel/common/Makefile b/board/atmel/common/Makefile
new file mode 100644 (file)
index 0000000..6d9c685
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2017 Microchip
+#                    Wenyou Yang <wenyou.yang@microchip.com>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += board.o
+ifndef CONFIG_SPL_BUILD
+obj-$(CONFIG_I2C_EEPROM) += mac_eeprom.o
+endif
diff --git a/board/atmel/common/board.c b/board/atmel/common/board.c
new file mode 100644 (file)
index 0000000..7e326d9
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2017 Microchip
+ *                   Wenyou Yang <wenyou.yang@microchip.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+void dummy(void)
+{
+}
diff --git a/board/atmel/common/mac_eeprom.c b/board/atmel/common/mac_eeprom.c
new file mode 100644 (file)
index 0000000..60ddf00
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Microchip
+ *                   Wenyou Yang <wenyou.yang@microchip.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <i2c_eeprom.h>
+#include <netdev.h>
+
+int at91_set_ethaddr(int offset)
+{
+       const int ETH_ADDR_LEN = 6;
+       unsigned char ethaddr[ETH_ADDR_LEN];
+       const char *ETHADDR_NAME = "ethaddr";
+       struct udevice *dev;
+       int ret;
+
+       if (env_get(ETHADDR_NAME))
+               return 0;
+
+       ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
+       if (ret)
+               return ret;
+
+       ret = i2c_eeprom_read(dev, offset, ethaddr, 6);
+       if (ret)
+               return ret;
+
+       if (is_valid_ethaddr(ethaddr))
+               eth_env_set_enetaddr(ETHADDR_NAME, ethaddr);
+
+       return 0;
+}