All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ramon Fried <rfried.dev@gmail.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Tom Rini <trini@konsulko.com>, Mario Six <mario.six@gdsys.cc>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH v2 10/11] test: Load mac address using RTC
Date: Mon,  4 Apr 2022 15:30:39 -0400	[thread overview]
Message-ID: <20220404193040.2305153-11-sean.anderson@seco.com> (raw)
In-Reply-To: <20220404193040.2305153-1-sean.anderson@seco.com>

This uses the nvmem API to load a mac address from an RTC.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/sandbox/dts/test.dts  |  9 ++++++++-
 drivers/rtc/i2c_rtc_emul.c | 10 ++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 72ba3b2cd6..2ea4e2365c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -532,7 +532,8 @@
 	dsa_eth0: dsa-test-eth {
 		compatible = "sandbox,eth";
 		reg = <0x10006000 0x1000>;
-		mac-address = [ 02 00 11 22 33 48 ];
+		nvmem-cells = <&eth4_addr>;
+		nvmem-cell-names = "mac-address";
 	};
 
 	dsa-test {
@@ -696,9 +697,15 @@
 		};
 
 		rtc_0: rtc@43 {
+			#address-cells = <1>;
+			#size-cells = <1>;
 			reg = <0x43>;
 			compatible = "sandbox-rtc";
 			sandbox,emul = <&emul0>;
+
+			eth4_addr: mac-address@40 {
+				reg = <0x40 6>;
+			};
 		};
 
 		rtc_1: rtc@61 {
diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c
index ba418c25da..c307d6036d 100644
--- a/drivers/rtc/i2c_rtc_emul.c
+++ b/drivers/rtc/i2c_rtc_emul.c
@@ -203,6 +203,15 @@ static int sandbox_i2c_rtc_bind(struct udevice *dev)
 	return 0;
 }
 
+static int sandbox_i2c_rtc_probe(struct udevice *dev)
+{
+	const u8 mac[] = { 0x02, 0x00, 0x11, 0x22, 0x33, 0x48 };
+	struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev);
+
+	memcpy(&plat->reg[0x40], mac, sizeof(mac));
+	return 0;
+}
+
 static const struct udevice_id sandbox_i2c_rtc_ids[] = {
 	{ .compatible = "sandbox,i2c-rtc-emul" },
 	{ }
@@ -213,6 +222,7 @@ U_BOOT_DRIVER(sandbox_i2c_rtc_emul) = {
 	.id		= UCLASS_I2C_EMUL,
 	.of_match	= sandbox_i2c_rtc_ids,
 	.bind		= sandbox_i2c_rtc_bind,
+	.probe		= sandbox_i2c_rtc_probe,
 	.priv_auto	= sizeof(struct sandbox_i2c_rtc),
 	.plat_auto	= sizeof(struct sandbox_i2c_rtc_plat_data),
 	.ops		= &sandbox_i2c_rtc_emul_ops,
-- 
2.35.1.1320.gc452695387.dirty


  parent reply	other threads:[~2022-04-04 19:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 19:30 [PATCH v2 00/11] Add support for NVMEM API Sean Anderson
2022-04-04 19:30 ` [PATCH v2 01/11] sandbox: net: Remove fake-host-hwaddr Sean Anderson
2022-04-04 19:30 ` [PATCH v2 02/11] sandbox: Remove eth2addr from environment Sean Anderson
2022-04-04 19:30 ` [PATCH v2 03/11] test: eth: Add test for ethernet addresses Sean Anderson
2022-04-18 17:03   ` Tom Rini
2022-04-18 18:27     ` Sean Anderson
2022-04-04 19:30 ` [PATCH v2 04/11] sandbox: Move some mac addresses to device tree Sean Anderson
2022-04-04 19:30 ` [PATCH v2 05/11] misc: i2c_eeprom: Make i2c_eeprom_write use a const buf Sean Anderson
2022-04-04 19:30 ` [PATCH v2 06/11] misc: Add support for nvmem cells Sean Anderson
2022-04-04 19:30 ` [PATCH v2 07/11] sandbox: Enable NVMEM Sean Anderson
2022-04-04 19:30 ` [PATCH v2 08/11] net: Add support for reading mac addresses from nvmem cells Sean Anderson
2022-04-04 19:30 ` [PATCH v2 09/11] test: Load mac address with i2c eeprom Sean Anderson
2022-04-04 19:30 ` Sean Anderson [this message]
2022-04-04 19:30 ` [PATCH v2 11/11] test: Load mac address using misc device Sean Anderson

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=20220404193040.2305153-11-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=joe.hershberger@ni.com \
    --cc=mario.six@gdsys.cc \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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.