mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 5/5] ARM: dts: stm32mp: retire barebox, provide-mac-address in favor of NVMEM
Date: Mon, 28 Jun 2021 08:40:36 +0200
Message-ID: <20210628064036.25991-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210628064036.25991-1-a.fatoum@pengutronix.de>

We now have generic support for populating MAC address out of NVMEM, so
use it instead of barebox,provide-mac-address. There should be no
functional change.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/dts/stm32mp151.dtsi | 11 ++++++--
 drivers/nvmem/bsec.c         | 51 +-----------------------------------
 2 files changed, 10 insertions(+), 52 deletions(-)

diff --git a/arch/arm/dts/stm32mp151.dtsi b/arch/arm/dts/stm32mp151.dtsi
index eb3c6222e785..65df4ca44115 100644
--- a/arch/arm/dts/stm32mp151.dtsi
+++ b/arch/arm/dts/stm32mp151.dtsi
@@ -64,11 +64,18 @@
 };
 
 &bsec {
-	barebox,provide-mac-address = <&ethernet0 0x39>;
-
 	otp_serial: serial-number@34 {
 		reg = <0x34 0xc>;
 	};
+
+	macaddr: mac-address@e4 {
+		reg = <0xe4 0x6>;
+	};
+};
+
+&ethernet0 {
+	nvmem-cell-names = "mac-address";
+	nvmem-cells = <&macaddr>;
 };
 
 &vrefbuf {
diff --git a/drivers/nvmem/bsec.c b/drivers/nvmem/bsec.c
index 097d34069afd..0ed4d089d46b 100644
--- a/drivers/nvmem/bsec.c
+++ b/drivers/nvmem/bsec.c
@@ -68,51 +68,6 @@ static struct regmap_bus stm32_bsec_regmap_bus = {
 	.reg_read = stm32_bsec_read_shadow,
 };
 
-static int stm32_bsec_read_mac(struct regmap *map, int offset, u8 *mac)
-{
-	u8 res[8];
-	int ret;
-
-	ret = regmap_bulk_read(map, offset * 4, res, 8);
-	if (ret)
-		return ret;
-
-	memcpy(mac, res, ETH_ALEN);
-	return 0;
-}
-
-static void stm32_bsec_init_dt(struct device_d *dev, struct regmap *map)
-{
-	struct device_node *node = dev->device_node;
-	struct device_node *rnode;
-	u32 phandle, offset;
-	char mac[ETH_ALEN];
-	const __be32 *prop;
-
-	int len;
-	int ret;
-
-	prop = of_get_property(node, "barebox,provide-mac-address", &len);
-	if (!prop)
-		return;
-
-	if (len != 2 * sizeof(__be32))
-		return;
-
-	phandle = be32_to_cpup(prop++);
-
-	rnode = of_find_node_by_phandle(phandle);
-	offset = be32_to_cpup(prop++);
-
-	ret = stm32_bsec_read_mac(map, offset, mac);
-	if (ret) {
-		dev_warn(dev, "error setting MAC address: %s\n", strerror(-ret));
-		return;
-	}
-
-	of_eth_register_ethaddr(rnode, mac);
-}
-
 static int stm32_bsec_probe(struct device_d *dev)
 {
 	struct regmap *map;
@@ -139,12 +94,8 @@ static int stm32_bsec_probe(struct device_d *dev)
 		return PTR_ERR(map);
 
 	nvmem = nvmem_regmap_register(map, "stm32-bsec");
-	if (IS_ERR(nvmem))
-		return PTR_ERR(nvmem);
-
-	stm32_bsec_init_dt(dev, map);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(nvmem);
 }
 
 static struct stm32_bsec_data stm32mp15_bsec_data = {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-06-28  6:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28  6:40 [PATCH 1/5] common: machine_id: support /chosen/barebox, machine-id-path override Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 2/5] ARM: stm32mp: migrate to barebox,machine-id-path Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 3/5] common: machine_id: deprecate machine_id_set_hashable Ahmad Fatoum
2021-06-28  9:50   ` Bastian Krause
2021-06-28 10:12     ` Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 4/5] sandbox: dts: populate $global.machine_id Ahmad Fatoum
2021-06-28  6:40 ` Ahmad Fatoum [this message]
2021-06-28  9:28 ` [PATCH 1/5] common: machine_id: support /chosen/barebox,machine-id-path override Ahmad Fatoum
2021-06-28  9:35 ` [PATCH 1/5] common: machine_id: support /chosen/barebox, machine-id-path override Bastian Krause
2021-06-28 10:11   ` Ahmad Fatoum
2021-06-28 20:20 ` Sascha Hauer
     [not found] ` <CAMHeXxOT__KBUKG6GkNAEkqz4tMBBzuZ7OgnKa0_OX5hz-JEig@mail.gmail.com>
2021-06-30 10:27   ` Ahmad Fatoum
2021-06-30 20:13     ` Trent Piepho
2021-09-15 10:55       ` Ahmad Fatoum

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=20210628064036.25991-5-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git