summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-09-13 23:19:43 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2019-09-17 11:48:09 +0200
commit7e8ac4b05e049f8e0a1bf6b60d097aa9cef1ac55 (patch)
tree590bd9f315d41e399e24c81ffb313733fac4e3bf
parent07e59e14640400e13ff13ec00f248016325ea1e3 (diff)
downloadbarebox-7e8ac4b05e049f8e0a1bf6b60d097aa9cef1ac55.tar.gz
ARM: zii-common: Share MAC address configuration between RDU2/3
Both RDU2 and RDU3 share the same MAC address configuration mechanism. Reflect that by moving that code into zii-common and changing it to be executed on both platforms. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Chris Healy <cphealy@gmail.com> Cc: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/zii-common/board.c58
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/board.c55
-rw-r--r--arch/arm/dts/imx8mq-zii-ultra.dtsi26
3 files changed, 84 insertions, 55 deletions
diff --git a/arch/arm/boards/zii-common/board.c b/arch/arm/boards/zii-common/board.c
index 20ec64d..9a9564e 100644
--- a/arch/arm/boards/zii-common/board.c
+++ b/arch/arm/boards/zii-common/board.c
@@ -16,6 +16,64 @@
#include <globalvar.h>
#include <init.h>
#include <fs.h>
+#include <net.h>
+#include <linux/nvmem-consumer.h>
+
+static int rdu_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 rdu_ethernet_init(void)
+{
+ static const char * const 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") &&
+ !of_machine_is_compatible("zii,imx8mq-ultra"))
+ 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 = rdu_eth_register_ethaddr(np);
+ if (ret) {
+ pr_warn("Failed to register MAC for %s\n", alias);
+ continue;
+ }
+ }
+
+ return 0;
+}
+late_initcall(rdu_ethernet_init);
static int rdu_networkconfig(void)
{
diff --git a/arch/arm/boards/zii-imx6q-rdu2/board.c b/arch/arm/boards/zii-imx6q-rdu2/board.c
index 6adb0b1..63367a4 100644
--- a/arch/arm/boards/zii-imx6q-rdu2/board.c
+++ b/arch/arm/boards/zii-imx6q-rdu2/board.c
@@ -159,61 +159,6 @@ static int rdu2_devices_init(void)
}
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);
-
static int rdu2_fixup_egalax_ts(struct device_node *root, void *context)
{
struct device_node *np;
diff --git a/arch/arm/dts/imx8mq-zii-ultra.dtsi b/arch/arm/dts/imx8mq-zii-ultra.dtsi
index 1a9ba16..6180f21 100644
--- a/arch/arm/dts/imx8mq-zii-ultra.dtsi
+++ b/arch/arm/dts/imx8mq-zii-ultra.dtsi
@@ -23,6 +23,8 @@
};
aliases {
+ ethernet0 = &fec1;
+ ethernet1 = &i210;
/*
* NVMEM device corresponding to EEPROM attached to
* the switch shared DT node with it, so we use that
@@ -32,6 +34,11 @@
};
};
+&fec1 {
+ nvmem-cells = <&mac_address_0>;
+ nvmem-cell-names = "mac-address";
+};
+
&ocotp {
barebox,provide-mac-address = <&fec1 0x640>;
};
@@ -49,6 +56,25 @@
};
};
+&i210 {
+ nvmem-cells = <&mac_address_1>;
+ nvmem-cell-names = "mac-address";
+};
+
+&uart2 {
+ rave-sp {
+ eeprom@a4 {
+ mac_address_0: mac-address@180 {
+ reg = <0x180 6>;
+ };
+
+ mac_address_1: mac-address@190 {
+ reg = <0x190 6>;
+ };
+ };
+ };
+};
+
&usdhc1 {
#address-cells = <1>;
#size-cells = <1>;