[PATCH 5/5] ARM: dts: stm32mp: retire barebox, provide-mac-address in favor of NVMEM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux