[PATCH u-boot, v2019.04-aspeed-openbmc 12/12] i2c: eeprom: Use reg property instead of offset and size
Tan Siewert
tan.siewert at hetzner.com
Fri Jan 17 20:44:31 AEDT 2025
From: Michal Simek <michal.simek at xilinx.com>
Remove adhoc dt binding for fixed-partition definition for i2c eeprom.
fixed-partition are using reg property instead of offset/size pair.
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
(cherry picked from commit f692b479f02d9b2689b0686f1f6ff2f06c6ecc59)
Signed-off-by: Tan Siewert <tan.siewert at hetzner.com>
---
arch/sandbox/dts/test.dts | 13 +++++++++++++
configs/sandbox_defconfig | 1 +
drivers/misc/i2c_eeprom.c | 15 ++++++++-------
test/dm/bootcount.c | 8 ++++++++
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index b7051610865..39e3fb712a6 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -282,6 +282,14 @@
reg = <0x2c>;
compatible = "i2c-eeprom";
sandbox,emul = <&emul_eeprom>;
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ bootcount_i2c: bootcount at 10 {
+ reg = <10 2>;
+ };
+ };
};
rtc_0: rtc at 43 {
@@ -329,6 +337,11 @@
offset = <0x13>;
};
+ bootcount {
+ compatible = "u-boot,bootcount-i2c-eeprom";
+ i2c-eeprom = <&bootcount_i2c>;
+ };
+
adc at 0 {
compatible = "sandbox,adc";
vdd-supply = <&buck2>;
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 193e41896cb..236ba5f69ba 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -90,6 +90,7 @@ CONFIG_AXI_SANDBOX=y
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_DM_BOOTCOUNT=y
CONFIG_DM_BOOTCOUNT_RTC=y
+CONFIG_DM_BOOTCOUNT_I2C_EEPROM=y
CONFIG_CLK=y
CONFIG_CPU=y
CONFIG_DM_DEMO=y
diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c
index 32a1b208567..5cfcc4729f1 100644
--- a/drivers/misc/i2c_eeprom.c
+++ b/drivers/misc/i2c_eeprom.c
@@ -300,19 +300,20 @@ static int i2c_eeprom_partition_probe(struct udevice *dev)
static int i2c_eeprom_partition_ofdata_to_platdata(struct udevice *dev)
{
struct i2c_eeprom_partition *priv = dev_get_priv(dev);
- u32 offset, size;
+ u32 reg[2];
int ret;
- ret = dev_read_u32(dev, "offset", &offset);
+ ret = dev_read_u32_array(dev, "reg", reg, 2);
if (ret)
return ret;
- ret = dev_read_u32(dev, "size", &size);
- if (ret)
- return ret;
+ if (!reg[1])
+ return -EINVAL;
+
+ priv->offset = reg[0];
+ priv->size = reg[1];
- priv->offset = offset;
- priv->size = size;
+ debug("%s: base %x, size %x\n", __func__, priv->offset, priv->size);
return 0;
}
diff --git a/test/dm/bootcount.c b/test/dm/bootcount.c
index 0817b7d3ec1..21f332d9b9d 100644
--- a/test/dm/bootcount.c
+++ b/test/dm/bootcount.c
@@ -23,6 +23,14 @@ static int dm_test_bootcount(struct unit_test_state *uts)
ut_assertok(dm_bootcount_get(dev, &val));
ut_assert(val == 0xab);
+ ut_assertok(uclass_get_device(UCLASS_BOOTCOUNT, 1, &dev));
+ ut_assertok(dm_bootcount_set(dev, 0));
+ ut_assertok(dm_bootcount_get(dev, &val));
+ ut_assert(val == 0);
+ ut_assertok(dm_bootcount_set(dev, 0xab));
+ ut_assertok(dm_bootcount_get(dev, &val));
+ ut_assert(val == 0xab);
+
return 0;
}
--
2.47.0
More information about the openbmc
mailing list