summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards
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 /arch/arm/boards
parent07e59e14640400e13ff13ec00f248016325ea1e3 (diff)
downloadbarebox-7e8ac4b05e049f8e0a1bf6b60d097aa9cef1ac55.tar.gz
barebox-7e8ac4b05e049f8e0a1bf6b60d097aa9cef1ac55.tar.xz
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>
Diffstat (limited to 'arch/arm/boards')
-rw-r--r--arch/arm/boards/zii-common/board.c58
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/board.c55
2 files changed, 58 insertions, 55 deletions
diff --git a/arch/arm/boards/zii-common/board.c b/arch/arm/boards/zii-common/board.c
index 20ec64d2d4..9a9564e6d1 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 6adb0b1c6f..63367a419a 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;