[PATCH v2 10/11] test: Load mac address using RTC
Sean Anderson
sean.anderson at seco.com
Mon Apr 4 21:30:39 CEST 2022
This uses the nvmem API to load a mac address from an RTC.
Signed-off-by: Sean Anderson <sean.anderson at seco.com>
Reviewed-by: Simon Glass <sjg at 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 = <ð4_addr>;
+ nvmem-cell-names = "mac-address";
};
dsa-test {
@@ -696,9 +697,15 @@
};
rtc_0: rtc at 43 {
+ #address-cells = <1>;
+ #size-cells = <1>;
reg = <0x43>;
compatible = "sandbox-rtc";
sandbox,emul = <&emul0>;
+
+ eth4_addr: mac-address at 40 {
+ reg = <0x40 6>;
+ };
};
rtc_1: rtc at 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
More information about the U-Boot
mailing list