summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-06-27 21:42:27 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-06-29 07:04:53 +0200
commit4f0d5a3c97f35dcfa8931b2016877959c5f7a7b7 (patch)
treeaaf97cc7359bb81948376b8e05dded7069deea71 /arch
parent8905d0f1a4cd2d15b7aeb585f8cf39137b1b9b03 (diff)
downloadbarebox-4f0d5a3c97f35dcfa8931b2016877959c5f7a7b7.tar.gz
barebox-4f0d5a3c97f35dcfa8931b2016877959c5f7a7b7.tar.xz
ARM: rdu2: Fetch MAC address info from RAVE SP EEPROM
RDU2 stores MAC addresses for its Ethernet interfaces in main RAVE SP EEPROM. Add code to properly integrate it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/board.c57
-rw-r--r--arch/arm/dts/imx6qdl-zii-rdu2.dtsi15
2 files changed, 72 insertions, 0 deletions
diff --git a/arch/arm/boards/zii-imx6q-rdu2/board.c b/arch/arm/boards/zii-imx6q-rdu2/board.c
index 265f97e2f4..f6c908c9f1 100644
--- a/arch/arm/boards/zii-imx6q-rdu2/board.c
+++ b/arch/arm/boards/zii-imx6q-rdu2/board.c
@@ -19,6 +19,8 @@
#include <init.h>
#include <mach/bbu.h>
#include <mach/imx6.h>
+#include <net.h>
+#include <linux/nvmem-consumer.h>
#define RDU2_DAC1_RESET IMX_GPIO_NR(1, 0)
#define RDU2_DAC2_RESET IMX_GPIO_NR(1, 2)
@@ -151,3 +153,58 @@ static int rdu2_devices_init(void)
return 0;
}
device_initcall(rdu2_devices_init);
+
+static int rdu2_eth_register_ethaddr(struct device_node *np)
+{
+ u8 mac[ETH_ALEN];
+ u8 *data;
+ int i;
+
+ data = nvmem_cell_get_and_read(np, "mac-address", ETH_ALEN);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+ /*
+ * EEPROM stores MAC address in reverse (to what we expect it
+ * to be) byte order.
+ */
+ for (i = 0; i < ETH_ALEN; i++)
+ mac[i] = data[ETH_ALEN - i - 1];
+
+ free(data);
+
+ of_eth_register_ethaddr(np, mac);
+
+ return 0;
+}
+
+static int rdu2_ethernet_init(void)
+{
+ const char *aliases[] = { "ethernet0", "ethernet1" };
+ struct device_node *np, *root;
+ int i, ret;
+
+ if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") &&
+ !of_machine_is_compatible("zii,imx6qp-zii-rdu2"))
+ return 0;
+
+ root = of_get_root_node();
+
+ for (i = 0; i < ARRAY_SIZE(aliases); i++) {
+ const char *alias = aliases[i];
+
+ np = of_find_node_by_alias(root, alias);
+ if (!np) {
+ pr_warn("Failed to find %s\n", alias);
+ continue;
+ }
+
+ ret = rdu2_eth_register_ethaddr(np);
+ if (ret) {
+ pr_warn("Failed to register MAC for %s\n", alias);
+ continue;
+ }
+ }
+
+ return 0;
+}
+late_initcall(rdu2_ethernet_init);
diff --git a/arch/arm/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/dts/imx6qdl-zii-rdu2.dtsi
index 1be756c289..38c6961688 100644
--- a/arch/arm/dts/imx6qdl-zii-rdu2.dtsi
+++ b/arch/arm/dts/imx6qdl-zii-rdu2.dtsi
@@ -85,6 +85,14 @@
boot_source: boot-source@83 {
reg = <0x83 1>;
};
+
+ mac_address_0: mac-address@180 {
+ reg = <0x180 6>;
+ };
+
+ mac_address_1: mac-address@190 {
+ reg = <0x190 6>;
+ };
};
backlight {
@@ -110,6 +118,11 @@
};
};
+&fec {
+ nvmem-cells = <&mac_address_0>;
+ nvmem-cell-names = "mac-address";
+};
+
&i2c2 {
temp-sense@48 {
barebox,sensor-name = "Temp Sensor 1";
@@ -125,6 +138,8 @@
i210: i210@0 {
reg = <0 0 0 0 0>;
+ nvmem-cells = <&mac_address_1>;
+ nvmem-cell-names = "mac-address";
};
};
};