]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: eeprom: Use reg property instead of offset and size
authorMichal Simek <michal.simek@xilinx.com>
Thu, 28 May 2020 09:48:55 +0000 (11:48 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 20 Aug 2020 07:49:20 +0000 (09:49 +0200)
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@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/arm/dts/imx53-ppd-uboot.dtsi
arch/arm/dts/imx6q-bx50v3-uboot.dtsi
arch/sandbox/dts/test.dts
configs/sandbox_defconfig
drivers/misc/i2c_eeprom.c
test/dm/bootcount.c

index d38a1bc264c914c8691c656f9183a8f58cdb0053..d61b7cb87642918d9f2bb1fb7525df578588ba4b 100644 (file)
 &eeprom {
        partitions {
                compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
 
-               vpd {
-                       offset = <0>;
-                       size = <1022>;
+               vpd@0 {
+                       reg = <0 1022>;
                };
 
-               bootcount: bootcount {
-                       offset = <1022>;
-                       size = <2>;
+               bootcount: bootcount@1022 {
+                       reg = <1022 2>;
                };
        };
 };
index df446e0ed149fdf9084b706ad38a522e6dbdacb9..01321cab781b0816fca753d0f8f44522538992a7 100644 (file)
 &eeprom {
        partitions {
                compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
 
-               vpd {
-                       offset = <0>;
-                       size = <1022>;
+               vpd@0 {
+                       reg = <0 1022>;
                };
 
                bootcount: bootcount {
-                       offset = <1022>;
-                       size = <2>;
+                       reg = <1022 2>;
                };
        };
 };
index 491893a17dc45e2cc5584efd9c1b6178d41bf5d0..692c3775ddedc2390cfc34fdd7de07cee8813e52 100644 (file)
                        reg = <0x2c>;
                        compatible = "i2c-eeprom";
                        sandbox,emul = <&emul_eeprom>;
+                       partitions {
+                               compatible = "fixed-partitions";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               bootcount_i2c: bootcount@10 {
+                                       reg = <10 2>;
+                               };
+                       };
                };
 
                rtc_0: rtc@43 {
                offset = <0x13>;
        };
 
+       bootcount {
+               compatible = "u-boot,bootcount-i2c-eeprom";
+               i2c-eeprom = <&bootcount_i2c>;
+       };
+
        adc@0 {
                compatible = "sandbox,adc";
                vdd-supply = <&buck2>;
index fe111289049ca3026d959e15a8255e858b811042..acd70933359efb11577707e8dd5357b95290ba24 100644 (file)
@@ -119,6 +119,7 @@ CONFIG_DM_BOOTCOUNT=y
 CONFIG_DM_BOOTCOUNT_RTC=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
+CONFIG_DM_BOOTCOUNT_I2C_EEPROM=y
 CONFIG_CLK=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SANDBOX_CLK_CCF=y
index 45c34d388c8ab90827e7e08f7f80f73da6305cf3..3651ba4871efe49222a58dc380315c36117e43b8 100644 (file)
@@ -301,19 +301,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;
 }
index f911984698d89d00f15595c5430c9a2cdcd4f230..e0c47b5d7a6efddc891469d9470499e75d7bab9b 100644 (file)
@@ -25,6 +25,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;
 }