From patchwork Mon Jun 15 13:41:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 242438 List-Id: U-Boot discussion From: michal.simek at xilinx.com (Michal Simek) Date: Mon, 15 Jun 2020 15:41:29 +0200 Subject: [PATCH v2] i2c: eeprom: Use reg property instead of offset and size Message-ID: <4f3c15a6d5270cc01cd41ebcb1cc4ae4ef80f11e.1592228487.git.michal.simek@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 --- Changes in v2: - Bootcount tested on zynqmp zcu104 - Add missing address/size cells - Use dev_read_addr_size_index - Check parameters Just build tested - ge_bx50v3_defconfig Definitely please retest on hardware. --- arch/arm/dts/imx53-ppd-uboot.dtsi | 15 +++++++++------ arch/arm/dts/imx6q-bx50v3-uboot.dtsi | 12 +++++++----- drivers/misc/i2c_eeprom.c | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/arch/arm/dts/imx53-ppd-uboot.dtsi b/arch/arm/dts/imx53-ppd-uboot.dtsi index d38a1bc264c9..b308a517a73c 100644 --- a/arch/arm/dts/imx53-ppd-uboot.dtsi +++ b/arch/arm/dts/imx53-ppd-uboot.dtsi @@ -22,17 +22,20 @@ }; &eeprom { + #address-cells = <1>; + #size-cells = <0>; + partitions { compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; - vpd { - offset = <0>; - size = <1022>; + vpd at 0 { + reg = <0 1022>; }; - bootcount: bootcount { - offset = <1022>; - size = <2>; + bootcount: bootcount at 1022 { + reg = <1022 2>; }; }; }; diff --git a/arch/arm/dts/imx6q-bx50v3-uboot.dtsi b/arch/arm/dts/imx6q-bx50v3-uboot.dtsi index df446e0ed149..996eb18046c7 100644 --- a/arch/arm/dts/imx6q-bx50v3-uboot.dtsi +++ b/arch/arm/dts/imx6q-bx50v3-uboot.dtsi @@ -21,17 +21,19 @@ }; &eeprom { + #address-cells = <1>; + #size-cells = <0>; partitions { compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; - vpd { - offset = <0>; - size = <1022>; + vpd at 0 { + reg = <0 1022>; }; bootcount: bootcount { - offset = <1022>; - size = <2>; + reg = <1022 2>; }; }; }; diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c index 45c34d388c8a..335cf70e8b7e 100644 --- a/drivers/misc/i2c_eeprom.c +++ b/drivers/misc/i2c_eeprom.c @@ -301,19 +301,19 @@ 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; - int ret; + fdt_size_t addr, size; - ret = dev_read_u32(dev, "offset", &offset); - if (ret) - return ret; + addr = dev_read_addr_size_index(dev, 0, &size); + if (addr == FDT_ADDR_T_NONE) + return -EINVAL; - ret = dev_read_u32(dev, "size", &size); - if (ret) - return ret; + if (!size) + return -EINVAL; + + priv->offset = (u32)addr; + priv->size = (u32)size; - priv->offset = offset; - priv->size = size; + debug("%s: base %x, size %x\n", __func__, priv->offset, priv->size); return 0; }