[PATCH v2 11/11] test: Load mac address using misc device

Sean Anderson sean.anderson at seco.com
Mon Apr 4 21:30:40 CEST 2022


This loads a mac address using a misc device using the nvmem interface.

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---

(no changes since v1)

 arch/sandbox/dts/test.dts   | 9 ++++++++-
 drivers/misc/misc_sandbox.c | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 2ea4e2365c..c43bd82796 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -514,7 +514,8 @@
 	eth_5: eth at 10003000 {
 		compatible = "sandbox,eth";
 		reg = <0x10003000 0x1000>;
-		mac-address = [ 02 00 11 22 33 46 ];
+		nvmem-cells = <&eth5_addr>;
+		nvmem-cell-names = "mac-address";
 	};
 
 	eth_3: sbe5 {
@@ -887,7 +888,13 @@
 	};
 
 	misc-test {
+		#address-cells = <1>;
+		#size-cells = <1>;
 		compatible = "sandbox,misc_sandbox";
+
+		eth5_addr: mac-address at 10 {
+			reg = <0x10 6>;
+		};
 	};
 
 	mmc2 {
diff --git a/drivers/misc/misc_sandbox.c b/drivers/misc/misc_sandbox.c
index 0e4292fd0a..31cde2dbac 100644
--- a/drivers/misc/misc_sandbox.c
+++ b/drivers/misc/misc_sandbox.c
@@ -112,8 +112,11 @@ static const struct misc_ops misc_sandbox_ops = {
 int misc_sandbox_probe(struct udevice *dev)
 {
 	struct misc_sandbox_priv *priv = dev_get_priv(dev);
+	/* For eth5 */
+	const u8 mac[] = { 0x02, 0x00, 0x11, 0x22, 0x33, 0x46 };
 
 	priv->enabled = true;
+	memcpy(&priv->mem[16], mac, sizeof(mac));
 
 	return 0;
 }
-- 
2.35.1.1320.gc452695387.dirty



More information about the U-Boot mailing list