summaryrefslogtreecommitdiff
path: root/board/atmel/common
diff options
context:
space:
mode:
authorWenyou Yang <wenyou.yang@microchip.com>2017-09-01 08:26:16 (GMT)
committerTom Rini <trini@konsulko.com>2017-09-11 20:23:06 (GMT)
commitd9b23e26f0b663752e915763d6e2da2fd12fe4b2 (patch)
tree5cb19eced1797c3b8499f588ac6166cb09c30552 /board/atmel/common
parent08318317afb365a35f06df788feeed56825dbe61 (diff)
downloadu-boot-d9b23e26f0b663752e915763d6e2da2fd12fe4b2.tar.xz
board: atmel: Create board/$(VENDOR)/common folder
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>
Diffstat (limited to 'board/atmel/common')
-rw-r--r--board/atmel/common/Makefile11
-rw-r--r--board/atmel/common/board.c12
-rw-r--r--board/atmel/common/mac_eeprom.c36
3 files changed, 59 insertions, 0 deletions
diff --git a/board/atmel/common/Makefile b/board/atmel/common/Makefile
new file mode 100644
index 0000000..6d9c685
--- /dev/null
+++ b/board/atmel/common/Makefile
@@ -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
index 0000000..7e326d9
--- /dev/null
+++ b/board/atmel/common/board.c
@@ -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
index 0000000..60ddf00
--- /dev/null
+++ b/board/atmel/common/mac_eeprom.c
@@ -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;
+}