From: Philip Oberfichtner <pro@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>,
festevam@denx.de, peng.fan@nxp.com,
Christoph Niedermaier <cniedermaier@dh-electronics.com>,
u-boot@dh-electronics.com, sbabic@denx.de,
Patrice Chotard <patrice.chotard@foss.st.com>,
Simon Glass <sjg@chromium.org>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Philip Oberfichtner <pro@denx.de>,
Andreas Geisreiter <ageisreiter@dh-electronics.de>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v4 2/4] ARM: imx6: DH: Use common MAC address functions
Date: Tue, 26 Jul 2022 15:04:51 +0200 [thread overview]
Message-ID: <20220726130454.2829205-3-pro@denx.de> (raw)
In-Reply-To: <20220726130454.2829205-1-pro@denx.de>
To reduce code duplication, let the imx6 based DH boards use the common
code for setting up their MAC addresses.
Signed-off-by: Philip Oberfichtner <pro@denx.de>
Tested-by: Marek Vasut <marex@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
---
(no changes since v3)
Changes in v3:
- Reviewed by Marek
Changes in v2:
- Tested-by Marek
board/dhelectronics/dh_imx6/dh_imx6.c | 47 ++++++++-------------------
1 file changed, 14 insertions(+), 33 deletions(-)
diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index e8aba83e1a..07fc9b1fe6 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -36,6 +36,9 @@
#include <linux/delay.h>
#include <usb/ehci-ci.h>
+#include "../common/dh_common.h"
+#include "../common/dh_imx.h"
+
DECLARE_GLOBAL_DATA_PTR;
int dram_init(void)
@@ -82,46 +85,24 @@ int board_usb_phy_mode(int port)
}
#endif
-static int setup_dhcom_mac_from_fuse(void)
+int dh_setup_mac_address(void)
{
- struct udevice *dev;
- ofnode eeprom;
unsigned char enetaddr[6];
- int ret;
- ret = eth_env_get_enetaddr("ethaddr", enetaddr);
- if (ret) /* ethaddr is already set */
+ if (dh_mac_is_in_env("ethaddr"))
return 0;
- imx_get_mac_from_fuse(0, enetaddr);
-
- if (is_valid_ethaddr(enetaddr)) {
- eth_env_set_enetaddr("ethaddr", enetaddr);
- return 0;
- }
-
- eeprom = ofnode_get_aliases_node("eeprom0");
- if (!ofnode_valid(eeprom)) {
- printf("Can't find eeprom0 alias!\n");
- return -ENODEV;
- }
+ if (!dh_imx_get_mac_from_fuse(enetaddr))
+ goto out;
- ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev);
- if (ret) {
- printf("Cannot find EEPROM!\n");
- return ret;
- }
+ if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
+ goto out;
- ret = i2c_eeprom_read(dev, 0xfa, enetaddr, 0x6);
- if (ret) {
- printf("Error reading configuration EEPROM!\n");
- return ret;
- }
+ printf("%s: Unable to get MAC address!\n", __func__);
+ return -ENXIO;
- if (is_valid_ethaddr(enetaddr))
- eth_env_set_enetaddr("ethaddr", enetaddr);
-
- return 0;
+out:
+ return eth_env_set_enetaddr("ethaddr", enetaddr);
}
int board_early_init_f(void)
@@ -188,7 +169,7 @@ int board_late_init(void)
u32 hw_code;
char buf[16];
- setup_dhcom_mac_from_fuse();
+ dh_setup_mac_address();
hw_code = board_get_hwcode();
--
2.37.1
next prev parent reply other threads:[~2022-07-26 13:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 13:04 [PATCH v4 0/4] Deduplicate dhelectronics board files Philip Oberfichtner
2022-07-26 13:04 ` [PATCH v4 1/4] board: dhelectronics: Implement common MAC address functions Philip Oberfichtner
2022-08-13 1:41 ` Tom Rini
2022-07-26 13:04 ` Philip Oberfichtner [this message]
2022-08-13 1:41 ` [PATCH v4 2/4] ARM: imx6: DH: Use " Tom Rini
2022-07-26 13:04 ` [PATCH v4 3/4] ARM: imx8: " Philip Oberfichtner
2022-08-13 1:41 ` Tom Rini
2022-07-26 13:04 ` [PATCH v4 4/4] ARM: stm32: " Philip Oberfichtner
2022-08-13 1:41 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220726130454.2829205-3-pro@denx.de \
--to=pro@denx.de \
--cc=ageisreiter@dh-electronics.de \
--cc=cniedermaier@dh-electronics.com \
--cc=festevam@denx.de \
--cc=marex@denx.de \
--cc=patrice.chotard@foss.st.com \
--cc=patrick.delaunay@foss.st.com \
--cc=peng.fan@nxp.com \
--cc=sbabic@denx.de \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@dh-electronics.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.