From: Roger Quadros <rogerq@kernel.org>
To: joe.hershberger@ni.com, nm@ti.com
Cc: rfried.dev@gmail.com, r-gunasekaran@ti.com, s-vadapalli@ti.com,
mripard@kernel.org, sjg@chromium.org, pbrobinson@gmail.com,
srk@ti.com, u-boot@lists.denx.de,
Roger Quadros <rogerq@kernel.org>
Subject: [PATCH 1/2] net: ti: am65-cpsw-nuss: Use approved property to get efuse address
Date: Fri, 21 Jul 2023 00:59:34 +0300 [thread overview]
Message-ID: <20230720215935.107398-2-rogerq@kernel.org> (raw)
In-Reply-To: <20230720215935.107398-1-rogerq@kernel.org>
The approved DT property for MAC efuse (ROM) address is
"ti,syscon-efuse".
Use that and drop custom property "mac_efuse".
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
configs/am62x_evm_a53_defconfig | 1 +
drivers/net/ti/am65-cpsw-nuss.c | 52 +++++++++++++++++++++++----------
2 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index 7c3bc184cf..6757fe662d 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -102,3 +102,4 @@ CONFIG_SYSRESET=y
CONFIG_SPL_SYSRESET=y
CONFIG_SYSRESET_TI_SCI=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
+CONFIG_SYSCON=y
diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
index 523a4c9f91..ee46676ec8 100644
--- a/drivers/net/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ti/am65-cpsw-nuss.c
@@ -21,7 +21,9 @@
#include <net.h>
#include <phy.h>
#include <power-domain.h>
+#include <regmap.h>
#include <soc.h>
+#include <syscon.h>
#include <linux/bitops.h>
#include <linux/soc/ti/ti-udma.h>
@@ -101,7 +103,6 @@ struct am65_cpsw_common {
fdt_addr_t mdio_base;
fdt_addr_t ale_base;
fdt_addr_t gmii_sel;
- fdt_addr_t mac_efuse;
struct clk fclk;
struct power_domain pwrdmn;
@@ -516,24 +517,45 @@ static void am65_cpsw_stop(struct udevice *dev)
common->started = false;
}
+static int am65_cpsw_am654_get_efuse_macid(struct udevice *dev,
+ int slave, u8 *mac_addr)
+{
+ u32 mac_lo, mac_hi, offset;
+ struct regmap *syscon;
+ int ret;
+
+ syscon = syscon_regmap_lookup_by_phandle(dev, "ti,syscon-efuse");
+ if (IS_ERR(syscon)) {
+ if (PTR_ERR(syscon) == -ENODEV)
+ return 0;
+ return PTR_ERR(syscon);
+ }
+
+ ret = dev_read_u32_index(dev, "ti,syscon-efuse", 1, &offset);
+ if (ret)
+ return ret;
+
+ regmap_read(syscon, offset, &mac_lo);
+ regmap_read(syscon, offset + 4, &mac_hi);
+
+ mac_addr[0] = (mac_hi >> 8) & 0xff;
+ mac_addr[1] = mac_hi & 0xff;
+ mac_addr[2] = (mac_lo >> 24) & 0xff;
+ mac_addr[3] = (mac_lo >> 16) & 0xff;
+ mac_addr[4] = (mac_lo >> 8) & 0xff;
+ mac_addr[5] = mac_lo & 0xff;
+
+ return 0;
+}
+
static int am65_cpsw_read_rom_hwaddr(struct udevice *dev)
{
struct am65_cpsw_priv *priv = dev_get_priv(dev);
- struct am65_cpsw_common *common = priv->cpsw_common;
struct eth_pdata *pdata = dev_get_plat(dev);
- u32 mac_hi, mac_lo;
-
- if (common->mac_efuse == FDT_ADDR_T_NONE)
- return -1;
- mac_lo = readl(common->mac_efuse);
- mac_hi = readl(common->mac_efuse + 4);
- pdata->enetaddr[0] = (mac_hi >> 8) & 0xff;
- pdata->enetaddr[1] = mac_hi & 0xff;
- pdata->enetaddr[2] = (mac_lo >> 24) & 0xff;
- pdata->enetaddr[3] = (mac_lo >> 16) & 0xff;
- pdata->enetaddr[4] = (mac_lo >> 8) & 0xff;
- pdata->enetaddr[5] = mac_lo & 0xff;
+ am65_cpsw_am654_get_efuse_macid(dev,
+ priv->port_id,
+ pdata->enetaddr);
return 0;
}
@@ -710,8 +732,6 @@ static int am65_cpsw_probe_nuss(struct udevice *dev)
cpsw_common->ss_base = dev_read_addr(dev);
if (cpsw_common->ss_base == FDT_ADDR_T_NONE)
return -EINVAL;
- cpsw_common->mac_efuse = devfdt_get_addr_name(dev, "mac_efuse");
- /* no err check - optional */
ret = power_domain_get_by_index(dev, &cpsw_common->pwrdmn, 0);
if (ret) {
--
2.34.1
next prev parent reply other threads:[~2023-07-20 22:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 21:59 [PATCH 0/2] net: ti: am65-cpsw-nuss: Drop custom property "mac_efuse" Roger Quadros
2023-07-20 21:59 ` Roger Quadros [this message]
2023-07-20 21:59 ` [RFC PATCH 2/2] arm: dts: k3-am625-sk-u-boot.dtsi: drop mac_efuse Roger Quadros
2023-07-21 13:03 ` [PATCH 0/2] net: ti: am65-cpsw-nuss: Drop custom property "mac_efuse" Maxime Ripard
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=20230720215935.107398-2-rogerq@kernel.org \
--to=rogerq@kernel.org \
--cc=joe.hershberger@ni.com \
--cc=mripard@kernel.org \
--cc=nm@ti.com \
--cc=pbrobinson@gmail.com \
--cc=r-gunasekaran@ti.com \
--cc=rfried.dev@gmail.com \
--cc=s-vadapalli@ti.com \
--cc=sjg@chromium.org \
--cc=srk@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox