mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-13 08:27:23 +00:00
i2c: eeprom: Use reg property instead of offset and size
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>
This commit is contained in:
parent
2d06361a11
commit
f692b479f0
6 changed files with 41 additions and 18 deletions
|
@ -24,15 +24,15 @@
|
||||||
&eeprom {
|
&eeprom {
|
||||||
partitions {
|
partitions {
|
||||||
compatible = "fixed-partitions";
|
compatible = "fixed-partitions";
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
vpd {
|
vpd@0 {
|
||||||
offset = <0>;
|
reg = <0 1022>;
|
||||||
size = <1022>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bootcount: bootcount {
|
bootcount: bootcount@1022 {
|
||||||
offset = <1022>;
|
reg = <1022 2>;
|
||||||
size = <2>;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,15 +23,15 @@
|
||||||
&eeprom {
|
&eeprom {
|
||||||
partitions {
|
partitions {
|
||||||
compatible = "fixed-partitions";
|
compatible = "fixed-partitions";
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
vpd {
|
vpd@0 {
|
||||||
offset = <0>;
|
reg = <0 1022>;
|
||||||
size = <1022>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bootcount: bootcount {
|
bootcount: bootcount {
|
||||||
offset = <1022>;
|
reg = <1022 2>;
|
||||||
size = <2>;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -415,6 +415,14 @@
|
||||||
reg = <0x2c>;
|
reg = <0x2c>;
|
||||||
compatible = "i2c-eeprom";
|
compatible = "i2c-eeprom";
|
||||||
sandbox,emul = <&emul_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 {
|
rtc_0: rtc@43 {
|
||||||
|
@ -462,6 +470,11 @@
|
||||||
offset = <0x13>;
|
offset = <0x13>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bootcount {
|
||||||
|
compatible = "u-boot,bootcount-i2c-eeprom";
|
||||||
|
i2c-eeprom = <&bootcount_i2c>;
|
||||||
|
};
|
||||||
|
|
||||||
adc@0 {
|
adc@0 {
|
||||||
compatible = "sandbox,adc";
|
compatible = "sandbox,adc";
|
||||||
vdd-supply = <&buck2>;
|
vdd-supply = <&buck2>;
|
||||||
|
|
|
@ -119,6 +119,7 @@ CONFIG_DM_BOOTCOUNT=y
|
||||||
CONFIG_DM_BOOTCOUNT_RTC=y
|
CONFIG_DM_BOOTCOUNT_RTC=y
|
||||||
CONFIG_BUTTON=y
|
CONFIG_BUTTON=y
|
||||||
CONFIG_BUTTON_GPIO=y
|
CONFIG_BUTTON_GPIO=y
|
||||||
|
CONFIG_DM_BOOTCOUNT_I2C_EEPROM=y
|
||||||
CONFIG_CLK=y
|
CONFIG_CLK=y
|
||||||
CONFIG_CLK_COMPOSITE_CCF=y
|
CONFIG_CLK_COMPOSITE_CCF=y
|
||||||
CONFIG_SANDBOX_CLK_CCF=y
|
CONFIG_SANDBOX_CLK_CCF=y
|
||||||
|
|
|
@ -301,19 +301,20 @@ static int i2c_eeprom_partition_probe(struct udevice *dev)
|
||||||
static int i2c_eeprom_partition_ofdata_to_platdata(struct udevice *dev)
|
static int i2c_eeprom_partition_ofdata_to_platdata(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct i2c_eeprom_partition *priv = dev_get_priv(dev);
|
struct i2c_eeprom_partition *priv = dev_get_priv(dev);
|
||||||
u32 offset, size;
|
u32 reg[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = dev_read_u32(dev, "offset", &offset);
|
ret = dev_read_u32_array(dev, "reg", reg, 2);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = dev_read_u32(dev, "size", &size);
|
if (!reg[1])
|
||||||
if (ret)
|
return -EINVAL;
|
||||||
return ret;
|
|
||||||
|
|
||||||
priv->offset = offset;
|
priv->offset = reg[0];
|
||||||
priv->size = size;
|
priv->size = reg[1];
|
||||||
|
|
||||||
|
debug("%s: base %x, size %x\n", __func__, priv->offset, priv->size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,14 @@ static int dm_test_bootcount(struct unit_test_state *uts)
|
||||||
ut_assertok(dm_bootcount_get(dev, &val));
|
ut_assertok(dm_bootcount_get(dev, &val));
|
||||||
ut_assert(val == 0xab);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue