summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey V.Kosteltsev <AKosteltsev@IBS.RU>2022-06-03 10:12:51 +0300
committerNikita Kosenkov <NKosenkov@IBS.RU>2022-06-14 13:31:51 +0300
commitfa4f08443f25886708c4ab1c081f935321a96e11 (patch)
treed25a3aac99e4921d159343b1c9061b679c4ffc6a
parent5c3f71d93e5b1c2358cd8ecea0a75e20a299c6f3 (diff)
downloadopenbmc-fa4f08443f25886708c4ab1c081f935321a96e11.tar.xz
U-Boot: Use hardware MAC by default
-rw-r--r--meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/0001-drivers-ftgmac100-use-hardware-MAC-by-default.patch74
-rw-r--r--meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/mii_enable.cfg1
-rw-r--r--meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend6
l---------meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-fw-utils-aspeed_%.bbappend1
4 files changed, 82 insertions, 0 deletions
diff --git a/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/0001-drivers-ftgmac100-use-hardware-MAC-by-default.patch b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/0001-drivers-ftgmac100-use-hardware-MAC-by-default.patch
new file mode 100644
index 0000000000..2cac891644
--- /dev/null
+++ b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/0001-drivers-ftgmac100-use-hardware-MAC-by-default.patch
@@ -0,0 +1,74 @@
+From eaa2edca99f7f416541c49d936b76db9799ee9c0 Mon Sep 17 00:00:00 2001
+From: Alexander Filippov <a.filippov@yadro.com>
+Date: Fri, 7 Aug 2020 13:32:27 +0300
+Subject: [PATCH] drivers: ftgmac100: use hardware MAC by default
+
+During the network interface initialization in ast_g5_phy based
+configurations the original hardware MAC address is ignored and the
+actual value is filled with zeros until the appropriate environment
+variable is set.
+Probably, others PHY-based configurations are also affected.
+For example: The MAC addresses specified in command line arguments for
+qemu are ignored and all ethernet interfaces have randomly generated MAC
+addresses.
+
+This commit makes ftg100 driver to read the hardware MAC address during
+device initialization and do not fill it with zeros if the environment
+has no definitions for this interface.
+
+Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
+Signed-off-by: Andrey V.Kosteltsev <AKosteltsev@IBS.RU>
+---
+ drivers/net/ftgmac100.c | 22 +++++++++++++++++++++-
+ 1 file changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
+index 5779057ba8..5aaad533e5 100644
+--- a/drivers/net/ftgmac100.c
++++ b/drivers/net/ftgmac100.c
+@@ -481,6 +481,23 @@ static void ftgmac100_set_mac(struct eth_device *dev,
+ __raw_writel(laddr, &ftgmac100->mac_ladr);
+ }
+
++/*
++ * Get actual MAC address
++ */
++static void ftgmac100_get_hw_mac(struct eth_device *dev)
++{
++ struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
++ unsigned int maddr = __raw_readl(&ftgmac100->mac_madr);
++ unsigned int laddr = __raw_readl(&ftgmac100->mac_ladr);
++
++ dev->enetaddr[0] = (maddr >> 8) & 0xFF;
++ dev->enetaddr[1] = (maddr >> 0) & 0xFF;
++ dev->enetaddr[2] = (laddr >> 24) & 0xFF;
++ dev->enetaddr[3] = (laddr >> 16) & 0xFF;
++ dev->enetaddr[4] = (laddr >> 8) & 0xFF;
++ dev->enetaddr[5] = (laddr >> 0) & 0xFF;
++}
++
+ static void ftgmac100_set_mac_from_env(struct eth_device *dev)
+ {
+ #ifdef CONFIG_SYS_I2C_MAC_OFFSET
+@@ -513,7 +530,9 @@ static void ftgmac100_set_mac_from_env(struct eth_device *dev)
+
+ ftgmac100_set_mac(dev, dev->enetaddr);
+ #else
+- eth_getenv_enetaddr_by_index("eth", dev->index, dev->enetaddr);
++ unsigned char enetaddr[6];
++ if (eth_getenv_enetaddr_by_index("eth", dev->index, enetaddr))
++ memcpy(dev->enetaddr, enetaddr, sizeof(enetaddr));
+ // eth_getenv_enetaddr("ethaddr", dev->enetaddr);
+ ftgmac100_set_mac(dev, dev->enetaddr);
+ #endif
+@@ -794,6 +813,7 @@ int ftgmac100_initialize(bd_t *bd)
+ ftgmac100_reset(dev);
+
+ /* set the ethernet address */
++ ftgmac100_get_hw_mac(dev);
+ ftgmac100_set_mac_from_env(dev);
+
+ card_number++;
+--
+2.35.1
+
diff --git a/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/mii_enable.cfg b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/mii_enable.cfg
new file mode 100644
index 0000000000..5ef5626689
--- /dev/null
+++ b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/files/mii_enable.cfg
@@ -0,0 +1 @@
+CONFIG_CMD_MII=y
diff --git a/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend
new file mode 100644
index 0000000000..b053ea2c55
--- /dev/null
+++ b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-aspeed_%.bbappend
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " \
+ file://mii_enable.cfg \
+ file://0001-drivers-ftgmac100-use-hardware-MAC-by-default.patch \
+ "
diff --git a/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-fw-utils-aspeed_%.bbappend b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-fw-utils-aspeed_%.bbappend
new file mode 120000
index 0000000000..f725cd47a3
--- /dev/null
+++ b/meta-ibs/meta-ast2500/recipes-bsp/u-boot/u-boot-fw-utils-aspeed_%.bbappend
@@ -0,0 +1 @@
+./u-boot-aspeed_%.bbappend \ No newline at end of file