Skip to contentSkip to conversation

DM_I2C_COMPAT removal for all ti platforms

PATCH Superseded Jean-Jacques Hiblot 5 participants 46 messages Oct 22, 2018 – Dec 7, 2018

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

It would be nice it some of you could try to boot them.

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with

    DM_I2C

configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

 arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
 arch/arm/dts/omap5-u-boot.dtsi               |   4 +
 arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
 arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
 arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
 arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
 arch/arm/include/asm/omap_i2c.h              |  24 ++
 arch/arm/mach-keystone/ddr3_spd.c            |   7 +
 arch/arm/mach-omap2/am33xx/board.c           |  24 +-
 arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
 arch/arm/mach-omap2/clocks-common.c          |   2 +
 arch/arm/mach-omap2/hwinit-common.c          |  23 +-
 board/eets/pdu001/board.c                    |   1 -
 board/ti/am335x/board.c                      |  17 +-
 board/ti/am335x/mux.c                        |  11 +
 board/ti/am43xx/board.c                      |  46 ++-
 board/ti/am57xx/board.c                      |  25 +-
 board/ti/common/board_detect.c               | 110 +++----
 board/ti/ks2_evm/board_k2g.c                 |  11 +
 cmd/Kconfig                                  |   1 +
 configs/am335x_pdu001_defconfig              |   1 +
 configs/am57xx_evm_defconfig                 |   1 +
 configs/am57xx_hs_evm_defconfig              |   1 +
 configs/dra7xx_evm_defconfig                 |   4 +-
 configs/dra7xx_hs_evm_defconfig              |   1 +
 configs/omap3_logic_defconfig                |   1 +
 doc/README.fdt-control                       |  18 ++
 drivers/core/Kconfig                         |  12 +-
 drivers/core/device.c                        |  10 +-
 drivers/core/root.c                          |   1 +
 drivers/core/uclass.c                        |  24 ++
 drivers/i2c/i2c-uclass.c                     |  11 +
 drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
 drivers/power/palmas.c                       |  39 +++
 drivers/power/pmic/pmic_tps62362.c           |  24 ++
 drivers/power/pmic/pmic_tps65217.c           |  44 ++-
 drivers/power/pmic/pmic_tps65218.c           |  85 +++++
 drivers/power/pmic/pmic_tps65910.c           |  57 +++-
 drivers/power/twl4030.c                      |  39 +++
 drivers/power/twl6030.c                      |  39 +++
 include/asm-generic/global_data.h            |   4 +
 include/configs/am43xx_evm.h                 |   2 +
 include/configs/pdu001.h                     |   6 -
 include/configs/ti_armv7_common.h            |  18 +-
 include/dm/uclass-internal.h                 |  13 +
 include/fdtdec.h                             |  21 ++
 include/palmas.h                             |   5 +
 include/power/tps65217.h                     |   2 +
 include/power/tps65910.h                     |   1 +
 include/twl4030.h                            |   6 +-
 include/twl6030.h                            |   5 +
 lib/fdtdec.c                                 |  43 ++-
 52 files changed, 1083 insertions(+), 472 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_i2c.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/19 cmd: Kconfig: Do not include EEPROM if DM_I2C is used without DM_I2C_COMPAT

The implementation of the EEPROM commands does not support the DM I2C API. Prevent compilation breakage by not enabling it if the non-DM API is not available (if DM_I2C is used without DM_I2C_COMPAT)

---

Changes in v3: None
Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available

 cmd/Kconfig | 1 +
 1 file changed, 1 insertion(+)
cmd/Kconfig +1 -0
index d66f710..2f9a754 100644
@@ -445,6 +445,7 @@ config CRC32_VERIFY
 
 config CMD_EEPROM
 	bool "eeprom - EEPROM subsystem"
+	depends on !DM_I2C || DM_I2C_COMPAT
 	help
 	  (deprecated, needs conversion to driver model)
 	  Provides commands to read and write EEPROM (Electrically Erasable
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 1/19 cmd: Kconfig: Do not include EEPROM if DM_I2C is used without DM_I2C_COMPAT

Quoted 7 lines · Jean-Jacques Hiblot

The implementation of the EEPROM commands does not support the DM I2C API. Prevent compilation breakage by not enabling it if the non-DM API is not available (if DM_I2C is used without DM_I2C_COMPAT)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/77a64e51/attachment.sig>
#3 lore raw

PATCH v3 1/19 cmd: Kconfig: Do not include EEPROM if DM_I2C is used without DM_I2C_COMPAT

In reply to Jean-Jacques Hiblot
Quoted 10 lines · Jean-Jacques Hiblot

The implementation of the EEPROM commands does not support the DM I2C API. Prevent compilation breakage by not enabling it if the non-DM API is not available (if DM_I2C is used without DM_I2C_COMPAT)

---

Quoted 7 lines

Changes in v3: None
Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available

 cmd/Kconfig | 1 +
 1 file changed, 1 insertion(+)
#4 lore raw

PATCH v3 2/19 dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not detected

In reply to Jean-Jacques Hiblot

i2c_get_chip_for_busnum() really should check the presence of the chip on the bus. Most of the users of this function assume that this is done.

---

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().

Changes in v2: None

 drivers/i2c/i2c-uclass.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/i2c/i2c-uclass.c +11 -0
index c5a3c4e..975318e 100644
@@ -347,6 +347,17 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
 		debug("Cannot find I2C bus %d\n", busnum);
 		return ret;
 	}
+
+	/* detect the presence of the chip on the bus */
+	ret = i2c_probe_chip(bus, chip_addr, 0);
+	debug("%s: bus='%s', address %02x, ret=%d\n", __func__, bus->name,
+	      chip_addr, ret);
+	if (ret) {
+		debug("Cannot detect I2C chip %02x on bus %d\n", chip_addr,
+		      busnum);
+		return ret;
+	}
+
 	ret = i2c_get_chip(bus, chip_addr, offset_len, devp);
 	if (ret) {
 		debug("Cannot find I2C chip %02x on bus %d\n", chip_addr,
Signature · 1 line
2.7.4
#5 lore raw

PATCH v3 2/19 dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not detected

Hi Jean-Jacques,

Quoted 25 lines · Jean-Jacques Hiblot

i2c_get_chip_for_busnum() really should check the presence of the chip on the bus. Most of the users of this function assume that this is done.

---

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().

Changes in v2: None

 drivers/i2c/i2c-uclass.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/i2c/i2c-uclass.c +1 -0
index c5a3c4e..975318e 100644
@@ -347,6 +347,17 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
                debug("Cannot find I2C bus %d\n", busnum);
                return ret;
        }
+

drivers/i2c/i2c-uclass.c int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, · line 360

Quoted 10 lines
drivers/i2c/i2c-uclass.c +10 -0
+       /* detect the presence of the chip on the bus */
+       ret = i2c_probe_chip(bus, chip_addr, 0);
+       debug("%s: bus='%s', address %02x, ret=%d\n", __func__, bus->name,
+             chip_addr, ret);
+       if (ret) {
+               debug("Cannot detect I2C chip %02x on bus %d\n", chip_addr,
+                     busnum);
+               return ret;
+       }
+

I really don't like to keep going on about this, but I think this is still not quite right.

If the chip is not present that is generally an error, or at least it is assumed to be by the callers.

i2c_get_chip() is called just above the code you add. This normally probes an existing device at that i2c address, which presumably checks that it is present. However if there is no device at the given address, it calls device_bind():

debug("%s: Searching bus '%s' for address %02x: ", __func__,

      bus->name, chip_addr);
for (device_find_first_child(bus, &dev); dev;
    device_find_next_child(&dev)) {
        struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        int ret;

        if (chip->chip_addr == chip_addr) {
            ret = device_probe(dev);
            debug("found, ret=%d\n", ret);
            f (ret)
                return ret;
            *devp = dev;
            return 0;
        }
    }

debug("not found\n");
return i2c_bind_driver(bus, chip_addr, offset_len, devp);

So I think your new code below should only be used in the case where device_bind() was called.

What is the case where you:

a) Don't put the I2C device in the device tree
b) Expect it to be bound
c) Want to know if it is not present

Looking at it closely, i2c_get_chip() is not consistent. It probes the device it is is already bound, but if not, it binds a device and then fails to probe it. I think it should call device_prove() after binding it.

Would that be good enough?

Otherwise, perhaps we just need a function like:

i2c_probe_device(struct udevice *dev)

which calls i2c_probe_chip() on the appropriate address?

Quoted 6 lines
drivers/i2c/i2c-uclass.c +0 -1
        ret = i2c_get_chip(bus, chip_addr, offset_len, devp);
        if (ret) {
                debug("Cannot find I2C chip %02x on bus %d\n", chip_addr,
--

2.7.4

Again I'm sorry for all the back and forth. I think it would help to have more information in the commit message about the circumstances in which this change is needed.

Regards,
Simon

#6 lore raw

PATCH v3 2/19 dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not detected

Hi Simon,

Quoted 32 lines · Simon Glass

Hi Jean-Jacques,

Quoted 29 lines · Jean-Jacques Hiblot

i2c_get_chip_for_busnum() really should check the presence of the chip on the bus. Most of the users of this function assume that this is done.

---

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().

Changes in v2: None

  drivers/i2c/i2c-uclass.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/i2c/i2c-uclass.c +5 -0
index c5a3c4e..975318e 100644
@@ -347,6 +347,17 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
                 debug("Cannot find I2C bus %d\n", busnum);
                 return ret;
         }
+
+       /* detect the presence of the chip on the bus */
+       ret = i2c_probe_chip(bus, chip_addr, 0);
+       debug("%s: bus='%s', address %02x, ret=%d\n", __func__, bus->name,
+             chip_addr, ret);
Quoted 8 lines

drivers/i2c/i2c-uclass.c int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, · line 360

Quoted 6 lines
drivers/i2c/i2c-uclass.c +6 -0
+       if (ret) {
+               debug("Cannot detect I2C chip %02x on bus %d\n", chip_addr,
+                     busnum);
+               return ret;
+       }
+

I really don't like to keep going on about this, but I think this is still not quite right.

That is the development model of many open source projects that made their success. So I don't mind.

Quoted 3 lines

If the chip is not present that is generally an error, or at least it is assumed to be by the callers.

agreed. That is the purpose of the modification

Quoted 22 lines

i2c_get_chip() is called just above the code you add. This normally probes an existing device at that i2c address, which presumably checks that it is present. However if there is no device at the given address, it calls device_bind():

debug("%s: Searching bus '%s' for address %02x: ", __func__,

       bus->name, chip_addr);
for (device_find_first_child(bus, &dev); dev;
     device_find_next_child(&dev)) {
         struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
         int ret;

         if (chip->chip_addr == chip_addr) {
             ret = device_probe(dev);
             debug("found, ret=%d\n", ret);
             f (ret)
                 return ret;
             *devp = dev;
             return 0;
         }
     }
Quoted 5 lines

debug("not found\n");
return i2c_bind_driver(bus, chip_addr, offset_len, devp);

So I think your new code below should only be used in the case where device_bind() was called.

I don't think it hurts to probe the presence of the chip after the device_probe() is called.

And I am not sure that the all drivers detect the chip in their probe() functions.

Quoted 6 lines

What is the case where you:

a) Don't put the I2C device in the device tree
b) Expect it to be bound
c) Want to know if it is not present

This is exactly the use case I'm trying to address. There are several possible cases:

- Some platforms haven't gone full DM yet and don't put the I2C device in the DT.

- Other just don't have a DM I2C driver for the chip and only send a few commands to initialize it. Adding a real I2C-driver may be overkill.

- Other platforms rely on the detection of external devices to further identify the platform with no need to actually use the external chip.

Quoted 5 lines

Looking at it closely, i2c_get_chip() is not consistent. It probes the device it is is already bound, but if not, it binds a device and then fails to probe it. I think it should call device_prove() after binding it.

Calling device_probe() would work only if a DM I2C driver exists for the chip and if a description exists in the DT. So I don't think it would work for the cases I mentioned above.

Quoted 8 lines

Would that be good enough?

Otherwise, perhaps we just need a function like:

i2c_probe_device(struct udevice *dev)

which calls i2c_probe_chip() on the appropriate address?

That works, it was what was done in the first version. But I think this version is better as it doesn't introduce a new function and make i2c_get_chip_for_busnum() behave as people expect it to behave: fail if the chip is not there.  The cost is a systematic and sometimes unnecessary I2C probe sequence. That penalty is small.

There is another solution: add a probe() function to the i2c_generic_chip_drv driver that fails if it doesn't detect the chip. It would do the job.

Quoted 15 lines
Quoted 7 lines
drivers/i2c/i2c-uclass.c +0 -1
         ret = i2c_get_chip(bus, chip_addr, offset_len, devp);
         if (ret) {
                 debug("Cannot find I2C chip %02x on bus %d\n", chip_addr,
--

2.7.4

Again I'm sorry for all the back and forth. I think it would help to have more information in the commit message about the circumstances in which this change is needed.

Regards,
Simon

#7 lore raw

PATCH v3 2/19 dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not detected

Hi Jean-Jacques,

Quoted 52 lines · Jean-Jacques Hiblot

Hi Simon,

Quoted 38 lines · Simon Glass

Hi Jean-Jacques,

Quoted 34 lines · Jean-Jacques Hiblot

i2c_get_chip_for_busnum() really should check the presence of the chip on the bus. Most of the users of this function assume that this is done.

---

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().

Changes in v2: None

  drivers/i2c/i2c-uclass.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/i2c/i2c-uclass.c +7 -0
index c5a3c4e..975318e 100644
@@ -347,6 +347,17 @@ int i2c_get_chip_for_busnum(int busnum, int
 chip_addr, uint offset_len,
                 debug("Cannot find I2C bus %d\n", busnum);
                 return ret;
         }
+
+       /* detect the presence of the chip on the bus */
+       ret = i2c_probe_chip(bus, chip_addr, 0);
+       debug("%s: bus='%s', address %02x, ret=%d\n", __func__,
 bus->name,
+             chip_addr, ret);
+       if (ret) {
+               debug("Cannot detect I2C chip %02x on bus %d\n",
Quoted 8 lines

drivers/i2c/i2c-uclass.c int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, · line 360

Quoted 5 lines
drivers/i2c/i2c-uclass.c +4 -0
 chip_addr,
+                     busnum);
+               return ret;
+       }
+

I really don't like to keep going on about this, but I think this is still not quite right.

Quoted 2 lines

That is the development model of many open source projects that made their success. So I don't mind.

OK good :-)

Quoted 32 lines
Quoted 4 lines

If the chip is not present that is generally an error, or at least it is assumed to be by the callers.

agreed. That is the purpose of the modification

Quoted 26 lines

i2c_get_chip() is called just above the code you add. This normally probes an existing device at that i2c address, which presumably checks that it is present. However if there is no device at the given address, it calls device_bind():

debug("%s: Searching bus '%s' for address %02x: ", __func__,

       bus->name, chip_addr);
for (device_find_first_child(bus, &dev); dev;
     device_find_next_child(&dev)) {
         struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
         int ret;

         if (chip->chip_addr == chip_addr) {
             ret = device_probe(dev);
             debug("found, ret=%d\n", ret);
             f (ret)
                 return ret;
             *devp = dev;
             return 0;
         }
     }

debug("not found\n");
return i2c_bind_driver(bus, chip_addr, offset_len, devp);

Quoted 6 lines
Quoted 2 lines

So I think your new code below should only be used in the case where device_bind() was called.

I don't think it hurts to probe the presence of the chip after the device_probe() is called.

It costs time and is pointless if the chip is present. On the other hand, this function is presumably only used when there is nothing int the DT, so perhaps people don't care.

Quoted 3 lines

And I am not sure that the all drivers detect the chip in their probe() functions.

Agreed, I suspect that many don't, although I have not looked.

Quoted 12 lines
Quoted 7 lines

What is the case where you:

a) Don't put the I2C device in the device tree
b) Expect it to be bound
c) Want to know if it is not present

This is exactly the use case I'm trying to address. There are several possible cases:

Quoted 8 lines

- Some platforms haven't gone full DM yet and don't put the I2C device in the DT.

- Other just don't have a DM I2C driver for the chip and only send a few commands to initialize it. Adding a real I2C-driver may be overkill.

- Other platforms rely on the detection of external devices to further identify the platform with no need to actually use the external chip.

OK that all sounds fine to me. For the last case I think it makes sense to have a function that the platform has to call.

Quoted 11 lines
Quoted 7 lines

Looking at it closely, i2c_get_chip() is not consistent. It probes the device it is is already bound, but if not, it binds a device and then fails to probe it. I think it should call device_prove() after binding it.

Calling device_probe() would work only if a DM I2C driver exists for the chip and if a description exists in the DT. So I don't think it would work for the cases I mentioned above.

OK I see. Your patch is for the other case.

Quoted 17 lines
Quoted 9 lines

Would that be good enough?

Otherwise, perhaps we just need a function like:

i2c_probe_device(struct udevice *dev)

which calls i2c_probe_chip() on the appropriate address?

That works, it was what was done in the first version. But I think this version is better as it doesn't introduce a new function and make i2c_get_chip_for_busnum() behave as people expect it to behave: fail if the chip is not there. The cost is a systematic and sometimes unnecessary I2C probe sequence. That penalty is small.

Quoted 3 lines

There is another solution: add a probe() function to the i2c_generic_chip_drv driver that fails if it doesn't detect the chip. It would do the job.

Yes that seems somewhat equivalent.

At this point, I think we should take this patch, with a few changes:

1. Rename i2c_bind_driver() to i2c_bind_and_probe_driver(), since it always probes, and add a function comment (should be a separate patch)

2. Update the header file comment for i2c_get_chip_for_busnum() to describe exactly what it does

3. Expand the commit message to explain that this function is only used in the non-DT case, and that it is probed on the bus before binding the driver...

Regards,
Simon

#8 lore raw

PATCH v3 3/19 dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL

In reply to Jean-Jacques Hiblot

If OF_CONTROL is not enabled and DM_SEQ_ALIAS is enabled, we must assign an alias (requested sequence number) to devices that belongs to a class with the DM_UC_FLAG_SEQ_ALIAS flag. Otherwise uclass_find_device_by_seq() cannot be used to get/probe a device. In particular i2c_get_chip_for_busnum() cannot be used.

---

Changes in v3: None
Changes in v2:
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.

 drivers/core/device.c        | 10 ++++++----
 drivers/core/uclass.c        | 24 ++++++++++++++++++++++++
 include/dm/uclass-internal.h | 13 +++++++++++++
 3 files changed, 43 insertions(+), 4 deletions(-)
drivers/core/device.c +6 -4
index 5176aa3..04ce472 100644
@@ -70,7 +70,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 
 	dev->seq = -1;
 	dev->req_seq = -1;
-	if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS)) {
+	if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
+	    (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
 		/*
 		 * Some devices, such as a SPI bus, I2C bus and serial ports
 		 * are numbered using aliases.
@@ -78,10 +79,11 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 		 * This is just a 'requested' sequence, and will be
 		 * resolved (and ->seq updated) when the device is probed.
 		 */
-		if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
-			if (uc->uc_drv->name && ofnode_valid(node)) {
+		if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
+			if (uc->uc_drv->name && ofnode_valid(node))
 				dev_read_alias_seq(dev, &dev->req_seq);
-			}
+		} else {
+			dev->req_seq = uclass_find_next_free_req_seq(drv->id);
 		}
 	}
 
drivers/core/uclass.c +24 -0
index 3113d6a..07dd6f9 100644
@@ -269,6 +269,30 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
 	return -ENODEV;
 }
 
+#if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_PLATDATA)
+int uclass_find_next_free_req_seq(enum uclass_id id)
+{
+	struct uclass *uc;
+	struct udevice *dev;
+	int ret;
+	int max = -1;
+
+	ret = uclass_get(id, &uc);
+	if (ret)
+		return ret;
+
+	list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+		if ((dev->req_seq != -1) && (dev->req_seq > max))
+			max = dev->req_seq;
+	}
+
+	if (max == -1)
+		return 0;
+
+	return max + 1;
+}
+#endif
+
 int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
 			      bool find_req_seq, struct udevice **devp)
 {
include/dm/uclass-internal.h +13 -0
index 30d5a4f..18a838c 100644
@@ -12,6 +12,19 @@
 #include <dm/ofnode.h>
 
 /**
+ * uclass_find_next_free_req_seq() - Get the next free req_seq number
+ *
+ * This returns the next free req_seq number. This is useful only if
+ * OF_CONTROL is not used. The next free req_seq number is simply the
+ * maximum req_seq of the uclass + 1.
+ * This allows assiging req_seq number in the binding order.
+ *
+ * @id:		Id number of the uclass
+ * @return	The next free req_seq number
+ */
+int uclass_find_next_free_req_seq(enum uclass_id id);
+
+/**
  * uclass_get_device_tail() - handle the end of a get_device call
  *
  * This handles returning an error or probing a device as needed.
Signature · 1 line
2.7.4
#9 lore raw

PATCH v3 4/19 configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS

In reply to Jean-Jacques Hiblot

Those platforms need CONFIG_SPL_DM_SEQ_ALIAS because they enable both DM_I2C and SPL_DM. Without CONFIG_SPL_DM_SEQ_ALIAS, it is not possible to get the I2C bus with i2c_get_chip_for_busnum().

---

Changes in v3: None
Changes in v2: None

 configs/am335x_pdu001_defconfig | 1 +
 configs/am57xx_evm_defconfig    | 1 +
 configs/am57xx_hs_evm_defconfig | 1 +
 configs/dra7xx_hs_evm_defconfig | 1 +
 configs/omap3_logic_defconfig   | 1 +
 5 files changed, 5 insertions(+)
configs/am335x_pdu001_defconfig +1 -0
index 8a61d84..a666318 100644
@@ -35,6 +35,7 @@ CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-pdu001"
 # CONFIG_NET is not set
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_MMC_OMAP_HS=y
configs/am57xx_evm_defconfig +1 -0
index da347f3..56335f4 100644
@@ -37,6 +37,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SCSI_AHCI=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
configs/am57xx_hs_evm_defconfig +1 -0
index 6cf4f9a..7c404d3 100644
@@ -40,6 +40,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SCSI_AHCI=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
configs/dra7xx_hs_evm_defconfig +1 -0
index bd4ae0e..35c626d 100644
@@ -41,6 +41,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 CONFIG_DWC_AHCI=y
configs/omap3_logic_defconfig +1 -0
index 9b50a30..b8c8738 100644
@@ -34,6 +34,7 @@ CONFIG_SPL_OF_PLATDATA=y
 # CONFIG_ENV_IS_IN_FAT is not set
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_DM_I2C=y
Signature · 1 line
2.7.4
#10 lore raw

PATCH v3 4/19 configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS

Quoted 7 lines · Jean-Jacques Hiblot

Those platforms need CONFIG_SPL_DM_SEQ_ALIAS because they enable both DM_I2C and SPL_DM. Without CONFIG_SPL_DM_SEQ_ALIAS, it is not possible to get the I2C bus with i2c_get_chip_for_busnum().

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/ad523029/attachment.sig>
#11 lore raw

PATCH v3 5/19 i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

In reply to Jean-Jacques Hiblot

From: Vignesh R <[email protected]>

Move away from SoC specific headers to handle different register layout. Instead use driver data to get appropriate register layouts like in the kernel. While at it, perform some mostly cosmetic alignment/cleanup in the functions being updated.

---

Changes in v3: None
Changes in v2: None

 arch/arm/include/asm/arch-am33xx/i2c.h |  45 ----
 arch/arm/include/asm/arch-omap3/i2c.h  |  47 ----
 arch/arm/include/asm/arch-omap4/i2c.h  |  45 ----
 arch/arm/include/asm/arch-omap5/i2c.h  |  45 ----
 drivers/i2c/omap24xx_i2c.c             | 458 ++++++++++++++++++++++-----------
 5 files changed, 314 insertions(+), 326 deletions(-)
arch/arm/include/asm/arch-am33xx/i2c.h +0 -45
index 491fca9..b3cc3df 100644
@@ -12,51 +12,6 @@
 
 #define I2C_DEFAULT_BASE		I2C_BASE1
 
-struct i2c {
-	unsigned short revnb_lo;        /* 0x00 */
-	unsigned short res1;
-	unsigned short revnb_hi;        /* 0x04 */
-	unsigned short res2[5];
-	unsigned short sysc;		/* 0x10 */
-	unsigned short res3[9];
-	unsigned short irqstatus_raw;   /* 0x24 */
-	unsigned short res4;
-	unsigned short stat;            /* 0x28 */
-	unsigned short res5;
-	unsigned short ie;              /* 0x2C */
-	unsigned short res6;
-	unsigned short irqenable_clr;   /* 0x30 */
-	unsigned short res7;
-	unsigned short iv;              /* 0x34 */
-	unsigned short res8[45];
-	unsigned short syss;            /* 0x90 */
-	unsigned short res9;
-	unsigned short buf;             /* 0x94 */
-	unsigned short res10;
-	unsigned short cnt;             /* 0x98 */
-	unsigned short res11;
-	unsigned short data;            /* 0x9C */
-	unsigned short res13;
-	unsigned short res14;           /* 0xA0 */
-	unsigned short res15;
-	unsigned short con;             /* 0xA4 */
-	unsigned short res16;
-	unsigned short oa;              /* 0xA8 */
-	unsigned short res17;
-	unsigned short sa;              /* 0xAC */
-	unsigned short res18;
-	unsigned short psc;             /* 0xB0 */
-	unsigned short res19;
-	unsigned short scll;            /* 0xB4 */
-	unsigned short res20;
-	unsigned short sclh;            /* 0xB8 */
-	unsigned short res21;
-	unsigned short systest;         /* 0xBC */
-	unsigned short res22;
-	unsigned short bufstat;         /* 0xC0 */
-	unsigned short res23;
-};
-
 #define I2C_IP_CLK			48000000
 #define I2C_INTERNAL_SAMPLING_CLK	12000000
 
arch/arm/include/asm/arch-omap3/i2c.h +0 -47

51 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/i2c.h +0 -45

49 lines not on this page · raw message

arch/arm/include/asm/arch-omap5/i2c.h +0 -45

49 lines not on this page · raw message

drivers/i2c/omap24xx_i2c.c +314 -144

859 lines not on this page · raw message

Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 5/19 i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

Quoted 10 lines · Jean-Jacques Hiblot

From: Vignesh R <[email protected]>

Move away from SoC specific headers to handle different register layout. Instead use driver data to get appropriate register layouts like in the kernel. While at it, perform some mostly cosmetic alignment/cleanup in the functions being updated.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/a274f133/attachment.sig>
#13 lore raw

PATCH v3 6/19 i2c: omap24xx_i2c: Use platdata to probe the device

In reply to Jean-Jacques Hiblot

This allows the driver to be used without OF_CONTROL.
AM335x support DM_SPL but does not use SPL_OF_CONTROL. Enabling DM_I2C in SPL thus requires that the omap I2C can be passed platdata.

---

Changes in v3: None
Changes in v2: None

 arch/arm/include/asm/arch-am33xx/i2c.h |  2 ++
 arch/arm/include/asm/omap_i2c.h        | 24 ++++++++++++++++++++++++
 drivers/i2c/omap24xx_i2c.c             | 21 +++++++++++----------
 3 files changed, 37 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_i2c.h
arch/arm/include/asm/arch-am33xx/i2c.h +2 -0
index b3cc3df..c2a9850 100644
@@ -6,6 +6,8 @@
 #ifndef _I2C_AM33XX_H_
 #define _I2C_AM33XX_H_
 
+#include <asm/omap_i2c.h>
+
 #define  I2C_BASE1		0x44E0B000
 #define  I2C_BASE2		0x4802A000
 #define  I2C_BASE3		0x4819C000
arch/arm/include/asm/omap_i2c.h new file +24 -0
new file mode 100644
index 0000000..c1695cb
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _OMAP_I2C_H
+#define _OMAP_I2C_H
+
+#include <asm/arch/cpu.h>
+
+#ifdef CONFIG_DM_I2C
+
+/* Information about a GPIO bank */
+struct omap_i2c_platdata {
+	ulong base;	/* address of registers in physical memory */
+	int speed;
+	int ip_rev;
+};
+
+#endif
+
+enum {
+	OMAP_I2C_REV_V1 = 0,
+	OMAP_I2C_REV_V2 = 1,
+};
+
+#endif /* _OMAP_I2C_H */
drivers/i2c/omap24xx_i2c.c +11 -10
index dacaded..134d622 100644
@@ -43,6 +43,7 @@
 #include <i2c.h>
 
 #include <asm/io.h>
+#include <asm/omap_i2c.h>
 
 /*
  * Provide access to architecture-specific I2C header files for platforms
@@ -62,11 +63,6 @@
 #define I2C_WAIT	200
 
 enum {
-	OMAP_I2C_REV_V1 = 0,
-	OMAP_I2C_REV_V2 = 1,
-};
-
-enum {
 	OMAP_I2C_REV_REG = 0,		/* Only on IP V1 (OMAP34XX) */
 	OMAP_I2C_IE_REG,		/* Only on IP V1 (OMAP34XX) */
 	OMAP_I2C_STAT_REG,
@@ -1051,8 +1047,12 @@ static int omap_i2c_probe_chip(struct udevice *bus, uint chip_addr,
 static int omap_i2c_probe(struct udevice *bus)
 {
 	struct omap_i2c *priv = dev_get_priv(bus);
+	struct omap_i2c_platdata *plat = dev_get_platdata(bus);
 
-	priv->ip_rev = dev_get_driver_data(bus);
+	priv->speed = plat->speed;
+	priv->regs = map_physmem(plat->base, sizeof(void *),
+				 MAP_NOCACHE);
+	priv->ip_rev = plat->ip_rev;
 
 	__omap24_i2c_init(priv->regs, priv->ip_rev, priv->speed, 0,
 			  &priv->waitdelay);
@@ -1063,11 +1063,11 @@ static int omap_i2c_probe(struct udevice *bus)
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int omap_i2c_ofdata_to_platdata(struct udevice *bus)
 {
-	struct omap_i2c *priv = dev_get_priv(bus);
+	struct omap_i2c_platdata *plat = dev_get_platdata(bus);
 
-	priv->regs = map_physmem(devfdt_get_addr(bus), sizeof(void *),
-				 MAP_NOCACHE);
-	priv->speed = CONFIG_SYS_OMAP24_I2C_SPEED;
+	plat->base = devfdt_get_addr(bus);
+	plat->speed = dev_read_u32_default(bus, "clock-frequency", 100000);
+	plat->ip_rev = dev_get_driver_data(bus);
 
 	return 0;
 }
@@ -1091,6 +1091,7 @@ U_BOOT_DRIVER(i2c_omap) = {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	.of_match = omap_i2c_ids,
 	.ofdata_to_platdata = omap_i2c_ofdata_to_platdata,
+	.platdata_auto_alloc_size = sizeof(struct omap_i2c_platdata),
 #endif
 	.probe	= omap_i2c_probe,
 	.priv_auto_alloc_size = sizeof(struct omap_i2c),
Signature · 1 line
2.7.4
#14 lore raw

PATCH v3 6/19 i2c: omap24xx_i2c: Use platdata to probe the device

Quoted 5 lines · Jean-Jacques Hiblot

This allows the driver to be used without OF_CONTROL.
AM335x support DM_SPL but does not use SPL_OF_CONTROL. Enabling DM_I2C in SPL thus requires that the omap I2C can be passed platdata.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/68970f18/attachment.sig>
#15 lore raw

PATCH v3 7/19 am335x: Register the I2C controllers if DM_I2C is used.

In reply to Jean-Jacques Hiblot

If DM_I2C is used , the I2C controllers must be registered as U_BOOT_DEVICE because OF_CONTROL is not used in the SPL.

---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-omap2/am33xx/board.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-omap2/am33xx/board.c +15 -0
index f5f2bd5..c121f27 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr_defs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/i2c.h>
 #include <asm/arch/mem.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
@@ -93,6 +94,20 @@ U_BOOT_DEVICES(am33xx_uarts) = {
 #  endif
 };
 
+#ifdef CONFIG_DM_I2C
+static const struct omap_i2c_platdata am33xx_i2c[] = {
+	{ I2C_BASE1, 100000, OMAP_I2C_REV_V2},
+	{ I2C_BASE2, 100000, OMAP_I2C_REV_V2},
+	{ I2C_BASE3, 100000, OMAP_I2C_REV_V2},
+};
+
+U_BOOT_DEVICES(am33xx_i2c) = {
+	{ "i2c_omap", &am33xx_i2c[0] },
+	{ "i2c_omap", &am33xx_i2c[1] },
+	{ "i2c_omap", &am33xx_i2c[2] },
+};
+#endif
+
 #ifdef CONFIG_DM_GPIO
 static const struct omap_gpio_platdata am33xx_gpio[] = {
 	{ 0, AM33XX_GPIO0_BASE },
Signature · 1 line
2.7.4
#16 lore raw

PATCH v3 7/19 am335x: Register the I2C controllers if DM_I2C is used.

Quoted 4 lines · Jean-Jacques Hiblot

If DM_I2C is used , the I2C controllers must be registered as U_BOOT_DEVICE because OF_CONTROL is not used in the SPL.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/5af235cd/attachment.sig>
#17 lore raw

PATCH v3 8/19 dts: am43x: omap5: Add node for I2C in SPL

In reply to Jean-Jacques Hiblot

---

Changes in v3: None
Changes in v2: None

 arch/arm/dts/am437x-gp-evm-u-boot.dtsi | 4 ++++
 arch/arm/dts/omap5-u-boot.dtsi         | 4 ++++
 2 files changed, 8 insertions(+)
arch/arm/dts/am437x-gp-evm-u-boot.dtsi +4 -0
index 530f549..03a1c1d 100644
@@ -36,3 +36,7 @@
 &phy_sel {
 	u-boot,dm-spl;
 };
+
+&i2c0 {
+	u-boot,dm-spl;
+};
arch/arm/dts/omap5-u-boot.dtsi +4 -0
index bf2684c..30833a3 100644
@@ -91,3 +91,7 @@
 &gpio7 {
 	u-boot,dm-spl;
 };
+
+&i2c1 {
+	u-boot,dm-spl;
+};
Signature · 1 line
2.7.4
#18 lore raw

PATCH v3 8/19 dts: am43x: omap5: Add node for I2C in SPL

Quoted 2 lines · Jean-Jacques Hiblot
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/418930ef/attachment.sig>
#19 lore raw

PATCH v3 9/19 omap: detect the board after DM is available

In reply to Jean-Jacques Hiblot

In order to use DM_I2C, we need to move the board detection after the early SPL initialization.

---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-omap2/am33xx/board.c  | 9 ++++++---
 arch/arm/mach-omap2/hwinit-common.c | 5 ++---
 2 files changed, 8 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/am33xx/board.c +6 -3
index c121f27..2fc364d 100644
@@ -472,12 +472,15 @@ void early_system_init(void)
 #ifdef CONFIG_DEBUG_UART_OMAP
 	debug_uart_init();
 #endif
-#ifdef CONFIG_TI_I2C_BOARD_DETECT
-	do_board_detect();
-#endif
+
 #ifdef CONFIG_SPL_BUILD
 	spl_early_init();
 #endif
+
+#ifdef CONFIG_TI_I2C_BOARD_DETECT
+	do_board_detect();
+#endif
+
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
 	/* Enable RTC32K clock */
 	rtc32k_enable();
arch/arm/mach-omap2/hwinit-common.c +2 -3
index 1a24acb..d0781d7 100644
@@ -193,11 +193,10 @@ void early_system_init(void)
 	 * to prevent overwrites.
 	 */
 	save_omap_boot_params();
-#endif
-	do_board_detect();
-#ifdef CONFIG_SPL_BUILD
 	spl_early_init();
 #endif
+	do_board_detect();
+
 	vcores_init();
 #ifdef CONFIG_DEBUG_UART_OMAP
 	debug_uart_init();
Signature · 1 line
2.7.4
#20 lore raw

PATCH v3 9/19 omap: detect the board after DM is available

Quoted 4 lines · Jean-Jacques Hiblot

In order to use DM_I2C, we need to move the board detection after the early SPL initialization.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/feab6de5/attachment.sig>
#21 lore raw

PATCH v3 10/19 power: make most tps drivers and the twl4030 driver compatible with DM_I2C

In reply to Jean-Jacques Hiblot

Those driver are not DM drivers per se (not using the PMIC/regulator framework) and are using the legacy I2C API. Make them compatible with the DM_I2C API.

This impacts the following drivers:
- palmas (used by am57xx/dra7xx evms)
- tps65218 (used by am43xx evms)
- tps65217 and tps65910 (used by am335x evms and am335x boneblack vboot)
- twl4030 (used by omap3_logicpd)
- tps65217 (used by brppt1)
- twl6030

---

Changes in v3: None
Changes in v2:
- Also add DM_I2C support to the twl6030 driver

 drivers/power/palmas.c             | 39 +++++++++++++++++
 drivers/power/pmic/pmic_tps62362.c | 24 +++++++++++
 drivers/power/pmic/pmic_tps65217.c | 44 +++++++++++++++++++-
 drivers/power/pmic/pmic_tps65218.c | 85 ++++++++++++++++++++++++++++++++++++++
 drivers/power/pmic/pmic_tps65910.c | 57 +++++++++++++++++++++----
 drivers/power/twl4030.c            | 39 +++++++++++++++++
 drivers/power/twl6030.c            | 39 +++++++++++++++++
 include/palmas.h                   |  5 +++
 include/power/tps65217.h           |  2 +
 include/power/tps65910.h           |  1 +
 include/twl4030.h                  |  6 ++-
 include/twl6030.h                  |  5 +++
 12 files changed, 335 insertions(+), 11 deletions(-)
drivers/power/palmas.c +39 -0
index 6d5abba..2584bea 100644
@@ -175,3 +175,42 @@ int twl603x_enable_bb_charge(u8 bb_fields)
 		       val, err);
 	return err;
 }
+
+#ifdef CONFIG_DM_I2C
+int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_write(dev, reg, val);
+	if (ret) {
+		pr_err("writing to palmas failed. ret %d\n", ret);
+		return ret;
+	}
+	return 0;
+}
+
+int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_read(dev, reg);
+	if (ret < 0) {
+		pr_err("reading from palmas failed. ret %d\n", ret);
+		return ret;
+	}
+	*valp = (u8)ret;
+	return 0;
+}
+#endif
drivers/power/pmic/pmic_tps62362.c +24 -0
index f2987de..c3977fc 100644
@@ -10,6 +10,10 @@
 #include <power/pmic.h>
 #include <power/tps62362.h>
 
+#ifdef CONFIG_DM_I2C
+struct udevice *tps62362_dev __attribute__((section(".data"))) = NULL;
+#endif
+
 /**
  * tps62362_voltage_update() - Function to change a voltage level, as this
  *			       is a multi-step process.
@@ -22,9 +26,16 @@ int tps62362_voltage_update(unsigned char reg, unsigned char volt_sel)
 	if (reg > TPS62362_NUM_REGS)
 		return 1;
 
+#ifndef CONFIG_DM_I2C
 	return i2c_write(TPS62362_I2C_ADDR, reg, 1, &volt_sel, 1);
+#else
+	if (!tps62362_dev)
+		return -ENODEV;
+	return dm_i2c_reg_write(tps62362_dev, reg, volt_sel);
+#endif
 }
 
+#ifndef CONFIG_DM_I2C
 int power_tps62362_init(unsigned char bus)
 {
 	static const char name[] = "TPS62362";
@@ -44,3 +55,16 @@ int power_tps62362_init(unsigned char bus)
 
 	return 0;
 }
+#else
+int power_tps62362_init(unsigned char bus)
+{
+	struct udevice *dev = NULL;
+	int rc;
+
+	rc = i2c_get_chip_for_busnum(bus, TPS62362_I2C_ADDR, 1, &dev);
+	if (rc)
+		return rc;
+	tps62362_dev = dev;
+	return 0;
+}
+#endif
drivers/power/pmic/pmic_tps65217.c +43 -1

91 lines not on this page · raw message

drivers/power/pmic/pmic_tps65218.c +85 -0

106 lines not on this page · raw message

drivers/power/pmic/pmic_tps65910.c +48 -9

99 lines not on this page · raw message

drivers/power/twl4030.c +39 -0
index 5246001..42c9001 100644
@@ -179,3 +179,42 @@ int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_DM_I2C
+int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_write(dev, reg, val);
+	if (ret) {
+		pr_err("writing to twl4030 failed. ret %d\n", ret);
+		return ret;
+	}
+	return 0;
+}
+
+int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_read(dev, reg);
+	if (ret < 0) {
+		pr_err("reading from twl4030 failed. ret %d\n", ret);
+		return ret;
+	}
+	*valp = (u8)ret;
+	return 0;
+}
+#endif
drivers/power/twl6030.c +39 -0
index e0cbda1..103960d 100644
@@ -268,3 +268,42 @@ void twl6030_usb_device_settings()
 	value &= ~TWL6030_MISC2_VUSB_IN_PMID;
 	twl6030_i2c_write_u8(TWL6030_CHIP_PM, TWL6030_MISC2, value);
 }
+
+#ifdef CONFIG_DM_I2C
+int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_write(dev, reg, val);
+	if (ret) {
+		pr_err("writing to twl6030 failed. ret %d\n", ret);
+		return ret;
+	}
+	return 0;
+}
+
+int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(0, chip_no, 1, &dev);
+	if (ret) {
+		pr_err("unable to get I2C bus. ret %d\n", ret);
+		return ret;
+	}
+	ret = dm_i2c_reg_read(dev, reg);
+	if (ret < 0) {
+		pr_err("reading from twl6030 failed. ret %d\n", ret);
+		return ret;
+	}
+	*valp = (u8)ret;
+	return 0;
+}
+#endif
include/palmas.h +5 -0
index 229de53..20c7e48 100644
@@ -117,6 +117,7 @@
 #define BB_VSEL_VBAT		(3 << 1)
 #define BB_CHRG_EN		(1 << 0)
 
+#ifndef CONFIG_DM_I2C
 /*
  * Functions to read and write from TPS659038/TWL6035/TWL6037
  * or other Palmas family of TI PMICs
@@ -130,6 +131,10 @@ static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 {
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
+#else
+int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
+int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
+#endif
 
 void palmas_init_settings(void);
 int palmas_mmc1_poweron_ldo(uint ldo_volt, uint ldo_ctrl, uint voltage);
include/power/tps65217.h +2 -0
index 00fbab8..669a94a 100644
@@ -80,6 +80,8 @@ enum {
 #define TPS65217_PWR_SRC_USB_BITMASK		0x4
 #define TPS65217_PWR_SRC_AC_BITMASK		0x8
 
+int power_tps65217_init(unsigned char bus);
+
 int tps65217_reg_read(uchar src_reg, uchar *src_val);
 int tps65217_reg_write(uchar prot_level, uchar dest_reg, uchar dest_val,
 		       uchar mask);
include/power/tps65910.h +1 -0
index 48e0b2c..21b2a21 100644
@@ -72,6 +72,7 @@ enum {
 #define TPS65910_DEVCTRL_REG_SR_CTL_I2C_SEL_SR_I2C	(0x0 << 4)
 #define TPS65910_DEVCTRL_REG_SR_CTL_I2C_SEL_CTL_I2C	(0x1 << 4)
 
+int power_tps65910_init(unsigned char bus);
 int tps65910_set_i2c_control(void);
 int tps65910_voltage_update(unsigned int module, unsigned char vddx_op_vol_sel);
 #endif	/* __POWER_TPS65910_H__ */
include/twl4030.h +5 -1
index 46a9306..c27ad61 100644
@@ -648,6 +648,7 @@
  *   examples are TWL4030_PM_RECEIVER_VMMC1_DEV_GRP and
  *   TWL4030_LED_LEDEN.
  */
+#ifndef CONFIG_DM_I2C
 static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 {
 	return i2c_write(chip_no, reg, 1, &val, 1);
@@ -657,7 +658,10 @@ static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 {
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
-
+#else
+int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
+int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
+#endif
 /*
  * Power
  */
include/twl6030.h +5 -0
index 6685343..41f17de 100644
@@ -186,6 +186,7 @@ struct twl6030_data{
 };
 
 /* Functions to read and write from TWL6030 */
+#ifndef CONFIG_DM_I2C
 static inline int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 {
 	return i2c_write(chip_no, reg, 1, &val, 1);
@@ -195,6 +196,10 @@ static inline int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 {
 	return i2c_read(chip_no, reg, 1, val, 1);
 }
+#else
+int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
+int twl6030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
+#endif
 
 /*
  * Power
Signature · 1 line
2.7.4
#22 lore raw

PATCH v3 10/19 power: make most tps drivers and the twl4030 driver compatible with DM_I2C

Quoted 12 lines · Jean-Jacques Hiblot

Those driver are not DM drivers per se (not using the PMIC/regulator framework) and are using the legacy I2C API. Make them compatible with the DM_I2C API.

This impacts the following drivers:
- palmas (used by am57xx/dra7xx evms)
- tps65218 (used by am43xx evms)
- tps65217 and tps65910 (used by am335x evms and am335x boneblack vboot)
- twl4030 (used by omap3_logicpd)
- tps65217 (used by brppt1)
- twl6030

Quoted 2 lines
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/76c2718c/attachment.sig>
#23 lore raw

PATCH v3 11/19 ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

In reply to Jean-Jacques Hiblot

From: Andreas Dannenberg <[email protected]>

The EEPROM reading in the board detection code is done through legacy I2C functions which on platforms using DM_I2C this functionality is provided via the CONFIG_DM_I2C_COMPAT layer. To allow newer platforms to use the board detection code without relying on CONFIG_DM_I2C_COMPAT go ahead and add an I2C handling implementation that directly uses the I2C DM functionality.

---

Changes in v3: None
Changes in v2: None

 board/ti/common/board_detect.c | 54 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)
board/ti/common/board_detect.c +52 -2
index c475f10..085e732 100644
@@ -50,6 +50,7 @@ int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
 }
 #endif
 
+#if !defined(CONFIG_DM_I2C) || defined(CONFIG_DM_I2C_COMPAT)
 /**
  * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
  * @i2c_bus: i2c bus number to initialize
@@ -94,6 +95,7 @@ static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset,
 
 	return i2c_read(dev_addr, offset, alen, ep, epsize);
 }
+#endif
 
 /**
  * ti_eeprom_string_cleanup() - Handle eeprom programming errors
@@ -122,9 +124,57 @@ __weak void gpi2c_init(void)
 static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 					    u32 header, u32 size, uint8_t *ep)
 {
-	u32 byte, hdr_read;
+	u32 hdr_read;
 	int rc;
 
+#if defined(CONFIG_DM_I2C) && !defined(CONFIG_DM_I2C_COMPAT)
+	struct udevice *dev;
+	struct udevice *bus;
+
+	rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus);
+	if (rc)
+		return rc;
+	rc = i2c_get_chip(bus, dev_addr, 1, &dev);
+	if (rc)
+		return rc;
+
+	/*
+	 * Read the header first then only read the other contents.
+	 */
+	rc = i2c_set_chip_offset_len(dev, 2);
+	if (rc)
+		return rc;
+
+	rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+	if (rc)
+		return rc;
+
+	/* Corrupted data??? */
+	if (hdr_read != header) {
+		rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+		/*
+		 * read the eeprom header using i2c again, but use only a
+		 * 1 byte address (some legacy boards need this..)
+		 */
+		if (rc) {
+			rc =  i2c_set_chip_offset_len(dev, 1);
+			if (rc)
+				return rc;
+
+			rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+		}
+		if (rc)
+			return rc;
+	}
+	if (hdr_read != header)
+		return -1;
+
+	rc = dm_i2c_read(dev, 0, ep, size);
+	if (rc)
+		return rc;
+#else
+	u32 byte;
+
 	gpi2c_init();
 	rc = ti_i2c_eeprom_init(bus_addr, dev_addr);
 	if (rc)
@@ -168,7 +218,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 	rc = i2c_read(dev_addr, 0x0, byte, ep, size);
 	if (rc)
 		return rc;
-
+#endif
 	return 0;
 }
 
Signature · 1 line
2.7.4
#24 lore raw

PATCH v3 11/19 ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Quoted 11 lines · Jean-Jacques Hiblot

From: Andreas Dannenberg <[email protected]>

The EEPROM reading in the board detection code is done through legacy I2C functions which on platforms using DM_I2C this functionality is provided via the CONFIG_DM_I2C_COMPAT layer. To allow newer platforms to use the board detection code without relying on CONFIG_DM_I2C_COMPAT go ahead and add an I2C handling implementation that directly uses the I2C DM functionality.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/0a00388e/attachment.sig>
#25 lore raw

PATCH v3 12/19 configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT

In reply to Jean-Jacques Hiblot

Remove the last call to the non-DM I2C API.
Also remove the #undef CONFIG_DM_I2C_COMPAT because it is not defined in the common header file anymore.

---

Changes in v3: None
Changes in v2:
- remove the remaining non-DM I2C API call for pdu001 board.

 board/eets/pdu001/board.c | 1 -
 include/configs/pdu001.h  | 6 ------
 2 files changed, 7 deletions(-)
board/eets/pdu001/board.c +0 -1
index b4b8081..b857a5a 100644
@@ -209,7 +209,6 @@ void am33xx_spl_board_init(void)
 const struct dpll_params *get_dpll_ddr_params(void)
 {
 	enable_i2c0_pin_mux();
-	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 
 	return &dpll_ddr;
 }
include/configs/pdu001.h +0 -6
index 7b809e2..e4c2872 100644
@@ -12,12 +12,6 @@
 
 #include <configs/ti_am335x_common.h>
 
-/* No more need for I2C legacy compatibility for this board.
- * CONFIG_DM_I2C_COMPAT is defined in ti_armv7_common.h. See the comment there
- * for the right moment to delete the following line.
- */
-#undef CONFIG_DM_I2C_COMPAT
-
 /* Using 32K of volatile storage for environment */
 #define CONFIG_ENV_SIZE		0x4000
 
Signature · 1 line
2.7.4
#26 lore raw

PATCH v3 12/19 configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT

Quoted 8 lines · Jean-Jacques Hiblot

Remove the last call to the non-DM I2C API.
Also remove the #undef CONFIG_DM_I2C_COMPAT because it is not defined in the common header file anymore.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/d6cba46f/attachment.sig>
#27 lore raw

PATCH v3 13/19 ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL

In reply to Jean-Jacques Hiblot

DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used. The goal is to eventually remove DM_I2C_COMPAT when all I2C "clients" have been migrated to use the DM API. This a step in that direction for the TI based platforms. Build tested with buildman:
buildman -dle am33xx ti omap3 omap4 omap5 davinci keystone

boot tested with:
am335x_evm, am335x_boneblack, am335x_boneblack_vboot (DM version), am57xx_evm, dra7xx_evm, k2g_evm, am437x_evm

---

Changes in v3: None
Changes in v2:
- Fixed warning in power_init_board() for the am43xx ti boards.

 arch/arm/mach-keystone/ddr3_spd.c            |  7 ++++
 arch/arm/mach-omap2/am33xx/clk_synthesizer.c | 56 +++++++++++++++++++++-----
 arch/arm/mach-omap2/clocks-common.c          |  2 +
 board/ti/am335x/board.c                      | 17 +++++++-
 board/ti/am335x/mux.c                        | 11 +++++
 board/ti/am43xx/board.c                      | 46 ++++++++++++++++-----
 board/ti/am57xx/board.c                      | 29 +++++++++++++-
 board/ti/common/board_detect.c               | 60 ++--------------------------
 board/ti/ks2_evm/board_k2g.c                 | 11 +++++
 include/configs/am43xx_evm.h                 |  2 +
 include/configs/ti_armv7_common.h            | 18 +--------
 11 files changed, 161 insertions(+), 98 deletions(-)
arch/arm/mach-keystone/ddr3_spd.c +7 -0
index 2613092..6eee9ad 100644
@@ -403,6 +403,7 @@ static void init_ddr3param(struct ddr3_spd_cb *spd_cb,
 static int ddr3_read_spd(ddr3_spd_eeprom_t *spd_params)
 {
 	int ret;
+#ifndef CONFIG_DM_I2C
 	int old_bus;
 
 	i2c_init(CONFIG_SYS_DAVINCI_I2C_SPEED, CONFIG_SYS_DAVINCI_I2C_SLAVE);
@@ -413,7 +414,13 @@ static int ddr3_read_spd(ddr3_spd_eeprom_t *spd_params)
 	ret = i2c_read(0x53, 0, 1, (unsigned char *)spd_params, 256);
 
 	i2c_set_bus_num(old_bus);
+#else
+	struct udevice *dev;
 
+	ret = i2c_get_chip_for_busnum(1, 0x53, 1, &dev);
+	if (!ret)
+		ret = dm_i2c_read(dev, 0, (unsigned char *)spd_params, 256);
+#endif
 	if (ret) {
 		printf("Cannot read DIMM params\n");
 		return 1;
arch/arm/mach-omap2/am33xx/clk_synthesizer.c +45 -11

120 lines not on this page · raw message

arch/arm/mach-omap2/clocks-common.c +2 -0
index 790548e..5932d69 100644
@@ -909,6 +909,7 @@ void prcm_init(void)
 		enable_basic_uboot_clocks();
 }
 
+#if !defined(CONFIG_DM_I2C)
 void gpi2c_init(void)
 {
 	static int gpi2c = 1;
@@ -919,3 +920,4 @@ void gpi2c_init(void)
 		gpi2c = 0;
 	}
 }
+#endif
board/ti/am335x/board.c +15 -2
index 1384525..d67f94a 100644
@@ -70,8 +70,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 void do_board_detect(void)
 {
 	enable_i2c0_pin_mux();
+#ifndef CONFIG_DM_I2C
 	i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
-
+#endif
 	if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
 				 CONFIG_EEPROM_CHIP_ADDRESS))
 		printf("ti_i2c_eeprom_init failed\n");
@@ -328,8 +329,14 @@ static void scale_vcores_bone(int freq)
 	if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4))
 		return;
 
+#ifndef CONFIG_DM_I2C
 	if (i2c_probe(TPS65217_CHIP_PM))
 		return;
+#else
+	if (power_tps65217_init(0))
+		return;
+#endif
+
 
 	/*
 	 * On Beaglebone White we need to ensure we have AC power
@@ -421,9 +428,13 @@ void scale_vcores_generic(int freq)
 	 * 1.10V.  For MPU voltage we need to switch based on
 	 * the frequency we are running at.
 	 */
+#ifndef CONFIG_DM_I2C
 	if (i2c_probe(TPS65910_CTRL_I2C_ADDR))
 		return;
-
+#else
+	if (power_tps65910_init(0))
+		return;
+#endif
 	/*
 	 * Depending on MPU clock and PG we will need a different
 	 * VDD to drive at that speed.
@@ -451,8 +462,10 @@ void gpi2c_init(void)
 
 	if (first_time) {
 		enable_i2c0_pin_mux();
+#ifndef CONFIG_DM_I2C
 		i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED,
 			 CONFIG_SYS_OMAP24_I2C_SLAVE);
+#endif
 		first_time = false;
 	}
 }
board/ti/am335x/mux.c +11 -0
index 41333f9..04f4b8e 100644
@@ -329,12 +329,23 @@ static unsigned short detect_daughter_board_profile(void)
 {
 	unsigned short val;
 
+#ifndef CONFIG_DM_I2C
 	if (i2c_probe(I2C_CPLD_ADDR))
 		return PROFILE_NONE;
 
 	if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2))
 		return PROFILE_NONE;
+#else
+	struct udevice *dev = NULL;
+	int rc;
 
+	rc = i2c_get_chip_for_busnum(0, I2C_CPLD_ADDR, 1, &dev);
+	if (rc)
+		return PROFILE_NONE;
+	rc = dm_i2c_read(dev, CFG_REG, (unsigned char *)(&val), 2);
+	if (rc)
+		return PROFILE_NONE;
+#endif
 	return (1 << (val & PROFILE_MASK));
 }
 
board/ti/am43xx/board.c +35 -11

99 lines not on this page · raw message

board/ti/am57xx/board.c +28 -1
index 177a324..355ea55 100644
@@ -623,7 +623,7 @@ void am57x_idk_lcd_detect(void)
 {
 	int r = -ENODEV;
 	char *idk_lcd = "no";
-	uint8_t buf = 0;
+	u8 buf = 0;
 
 	/* Only valid for IDKs */
 	if (board_is_x15() || board_is_am572x_evm())
@@ -633,6 +633,7 @@ void am57x_idk_lcd_detect(void)
 	if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
 		goto out;
 
+#ifndef CONFIG_DM_I2C
 	r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
 	if (r) {
 		printf("%s: Failed to set bus address to %d: %d\n",
@@ -657,6 +658,32 @@ void am57x_idk_lcd_detect(void)
 		       OSD_TS_FT_REG_ID, r);
 		goto out;
 	}
+#else
+	struct udevice *dev;
+
+	r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
+				    OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
+	if (r) {
+		printf("%s: Failed to get I2C device %d/%d (ret %d)\n",
+		       __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
+		       r);
+		/* AM572x IDK has no explicit settings for optional LCD kit */
+		if (board_is_am571x_idk())
+			printf("%s: Touch screen detect failed: %d!\n",
+			       __func__, r);
+		goto out;
+	}
+
+	/* Read FT ID */
+	r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID);
+	if (r < 0) {
+		printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
+		       __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
+		       OSD_TS_FT_REG_ID, r);
+		goto out;
+	}
+	buf = (u8)r;
+#endif
 
 	switch (buf) {
 	case OSD_TS_FT_ID_5606:
board/ti/common/board_detect.c +3 -57

90 lines not on this page · raw message

board/ti/ks2_evm/board_k2g.c +11 -0
index 9bc94fb..f3a42f1 100644
@@ -251,6 +251,7 @@ int board_fit_config_name_match(const char *name)
 #if defined(CONFIG_DTB_RESELECT)
 static int k2g_alt_board_detect(void)
 {
+#ifndef CONFIG_DM_I2C
 	int rc;
 
 	rc = i2c_set_bus_num(1);
@@ -260,7 +261,17 @@ static int k2g_alt_board_detect(void)
 	rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS);
 	if (rc)
 		return rc;
+#else
+	struct udevice *bus, *dev;
+	int rc;
 
+	rc = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
+	if (rc)
+		return rc;
+	rc = dm_i2c_probe(bus, K2G_GP_AUDIO_CODEC_ADDRESS, 0, &dev);
+	if (rc)
+		return rc;
+#endif
 	ti_i2c_eeprom_am_set("66AK2GGP", "1.0X");
 
 	return 0;
include/configs/am43xx_evm.h +2 -0
index 9d0d342..ed71f4c 100644
@@ -27,8 +27,10 @@
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
 
 /* Power */
+#ifndef CONFIG_DM_I2C
 #define CONFIG_POWER
 #define CONFIG_POWER_I2C
+#endif
 #define CONFIG_POWER_TPS65218
 #define CONFIG_POWER_TPS62362
 
include/configs/ti_armv7_common.h +2 -16
index 55b9b45..4aca3f9 100644
@@ -74,24 +74,10 @@
 /* Timer information. */
 #define CONFIG_SYS_PTV			2	/* Divisor: 2^(PTV+1) => 8 */
 
-/*
- * Disable DM_* for SPL build and can be re-enabled after adding
- * DM support in SPL
- */
-#ifdef CONFIG_SPL_BUILD
-#undef CONFIG_DM_I2C
-#endif
-
-/* I2C IP block */
+/* If DM_I2C, enable non-DM I2C support */
+#if !defined(CONFIG_DM_I2C)
 #define CONFIG_I2C
-#ifndef CONFIG_DM_I2C
 #define CONFIG_SYS_I2C
-#else
-/*
- * Enable CONFIG_DM_I2C_COMPAT temporarily until all the i2c client
- * devices are adopted to DM
- */
-#define CONFIG_DM_I2C_COMPAT
 #endif
 
 /*
Signature · 1 line
2.7.4
#28 lore raw

PATCH v3 13/19 ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL

Quoted 7 lines · Jean-Jacques Hiblot

DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used. The goal is to eventually remove DM_I2C_COMPAT when all I2C "clients" have been migrated to use the DM API. This a step in that direction for the TI based platforms. Build tested with buildman:
buildman -dle am33xx ti omap3 omap4 omap5 davinci keystone

Quoted 6 lines

boot tested with:
am335x_evm, am335x_boneblack, am335x_boneblack_vboot (DM version), am57xx_evm, dra7xx_evm, k2g_evm, am437x_evm

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/d1b3fa82/attachment.sig>
#29 lore raw

PATCH v3 14/19 am57xx: remove non-DM I2C code

In reply to Jean-Jacques Hiblot

am57xx configs uses DM_I2C both in SPL and u-boot. Remove code for non-DM I2C support.

---

Changes in v3: None
Changes in v2: None

 board/ti/am57xx/board.c | 36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)
board/ti/am57xx/board.c +3 -33
index 355ea55..9738beb 100644
@@ -623,7 +623,7 @@ void am57x_idk_lcd_detect(void)
 {
 	int r = -ENODEV;
 	char *idk_lcd = "no";
-	u8 buf = 0;
+	struct udevice *dev;
 
 	/* Only valid for IDKs */
 	if (board_is_x15() || board_is_am572x_evm())
@@ -633,34 +633,6 @@ void am57x_idk_lcd_detect(void)
 	if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
 		goto out;
 
-#ifndef CONFIG_DM_I2C
-	r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
-	if (r) {
-		printf("%s: Failed to set bus address to %d: %d\n",
-		       __func__, OSD_TS_FT_BUS_ADDRESS, r);
-		goto out;
-	}
-	r = i2c_probe(OSD_TS_FT_CHIP_ADDRESS);
-	if (r) {
-		/* AM572x IDK has no explicit settings for optional LCD kit */
-		if (board_is_am571x_idk()) {
-			printf("%s: Touch screen detect failed: %d!\n",
-			       __func__, r);
-		}
-		goto out;
-	}
-
-	/* Read FT ID */
-	r = i2c_read(OSD_TS_FT_CHIP_ADDRESS, OSD_TS_FT_REG_ID, 1, &buf, 1);
-	if (r) {
-		printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
-		       __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
-		       OSD_TS_FT_REG_ID, r);
-		goto out;
-	}
-#else
-	struct udevice *dev;
-
 	r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
 				    OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
 	if (r) {
@@ -682,10 +654,8 @@ void am57x_idk_lcd_detect(void)
 		       OSD_TS_FT_REG_ID, r);
 		goto out;
 	}
-	buf = (u8)r;
-#endif
 
-	switch (buf) {
+	switch (r) {
 	case OSD_TS_FT_ID_5606:
 		idk_lcd = "osd101t2045";
 		break;
@@ -694,7 +664,7 @@ void am57x_idk_lcd_detect(void)
 		break;
 	default:
 		printf("%s: Unidentifed Touch screen ID 0x%02x\n",
-		       __func__, buf);
+		       __func__, r);
 		/* we will let default be "no lcd" */
 	}
 out:
Signature · 1 line
2.7.4
#30 lore raw

PATCH v3 14/19 am57xx: remove non-DM I2C code

Quoted 4 lines · Jean-Jacques Hiblot

am57xx configs uses DM_I2C both in SPL and u-boot. Remove code for non-DM I2C support.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/173f2001/attachment.sig>
#31 lore raw

PATCH v3 15/19 configs: dra7xx-evm: increase the size of the malloc's pool before relocation

In reply to Jean-Jacques Hiblot

This is required to take advantage of MULTI_DTB_FIT before relocation. If it is too low, DM will be initialized only after relocation has taken place. That is too late for the DRA7 because I2C DM is used before the relocation to setup the voltages required, among other things, to properly initialize the DRAM.

---

Changes in v3: None
Changes in v2: None

 configs/dra7xx_evm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/dra7xx_evm_defconfig +1 -1
index 14adaab..9546b5e 100644
@@ -1,7 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_TI_COMMON_CMD_OPTIONS=y
-CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_MALLOC_F_LEN=0x18000
 CONFIG_OMAP54XX=y
 CONFIG_TARGET_DRA7XX_EVM=y
 CONFIG_SPL=y
Signature · 1 line
2.7.4
#32 lore raw

PATCH v3 15/19 configs: dra7xx-evm: increase the size of the malloc's pool before relocation

Quoted 7 lines · Jean-Jacques Hiblot

This is required to take advantage of MULTI_DTB_FIT before relocation. If it is too low, DM will be initialized only after relocation has taken place. That is too late for the DRA7 because I2C DM is used before the relocation to setup the voltages required, among other things, to properly initialize the DRAM.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/1b099cd7/attachment.sig>
#33 lore raw

PATCH v3 16/19 lib: fdtdec: Add function re-setup the fdt more effeciently

In reply to Jean-Jacques Hiblot

In some cases it may be useful to be able to change the fdt we have been using and use another one instead. For example, the TI platforms uses an EEPROM to store board information and, based on the type of board, different dtbs are used by the SPL. When DM_I2C is used, a first dtb must be used before the I2C is initialized and only then the final dtb can be selected.
To speed up the process and reduce memory usage, introduce a new function fdtdec_setup_best_match() that re-use the DTBs loaded in memory by fdtdec_setup() to select the best match.

---

Changes in v3:
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2: None

 doc/README.fdt-control            | 18 ++++++++++++++++
 include/asm-generic/global_data.h |  4 ++++
 include/fdtdec.h                  | 21 +++++++++++++++++++
 lib/fdtdec.c                      | 43 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 85 insertions(+), 1 deletion(-)
doc/README.fdt-control +18 -0
index d6ab7bf..446401c 100644
@@ -184,6 +184,24 @@ The full device tree is available to U-Boot proper, but normally only a subset
 'SPL Support' in doc/driver-model/README.txt for more details.
 
 
+Using several DTBs in the SPL (CONFIG_SPL_MULTI_DTB)
+----------------------------------------------------
+In some rare cases it is desirable to let SPL be able to select one DTB among
+many. This usually not very useful as the DTB for the SPL is small and usually
+fits several platforms. However the DTB sometimes include information that do
+work on several platforms (like IO tuning parameters).
+In this case it is possible to use CONFIG_SPL_MULTI_DTB. This option appends to
+the SPL a FIT image containing several DTBs listed in SPL_OF_LIST.
+board_fit_config_name_match() is called to select the right DTB.
+
+If board_fit_config_name_match() relies on DM (DM driver to access an EEPROM
+containing the board ID for example), it possible to start with a generic DTB
+and then switch over to the right DTB after the detection. For this purpose,
+the platform code must call fdtdec_resetup(). Based on the returned flag, the
+platform may have to re-initiliaze the DM subusystem using dm_uninit() and
+dm_init_and_scan().
+
+
 Limitations
 -----------
 
include/asm-generic/global_data.h +4 -0
index c83fc01..a23aaee 100644
@@ -77,6 +77,10 @@ typedef struct global_data {
 #ifdef CONFIG_OF_LIVE
 	struct device_node *of_root;
 #endif
+
+#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
+	const void *multi_dtb_fit;	/* uncompressed multi-dtb FIT image */
+#endif
 	struct jt_funcs *jt;		/* jump table */
 	char env_buf[32];		/* buffer for env_get() before reloc. */
 #ifdef CONFIG_TRACE
include/fdtdec.h +21 -0
index c26df50..d414ba2 100644
@@ -951,6 +951,27 @@ int fdtdec_setup_memory_banksize(void);
  */
 int fdtdec_setup(void);
 
+#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
+/**
+ * fdtdec_resetup()  - Set up the device tree again
+ *
+ * The main difference with fdtdec_setup() is that it returns if the fdt has
+ * changed because a better match has been found.
+ * This is typically used for boards that rely on a DM driver to detect the
+ * board type. This function sould be called by the board code after the stuff
+ * needed by board_fit_config_name_match() to operate porperly is available.
+ * If this functions signals that a rescan is necessary, the board code must
+ * unbind all the drivers using dm_uninit() and then rescan the DT with
+ * dm_init_and_scan().
+ *
+ * @param rescan Returns a flag indicating that fdt has changed and rescanning
+ *               the fdt is required
+ *
+ * @return 0 if OK, -ve on error
+ */
+int fdtdec_resetup(int *rescan);
+#endif
+
 /**
  * Board-specific FDT initialization. Returns the address to a device tree blob.
  * Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
lib/fdtdec.c +42 -1

56 lines not on this page · raw message

Signature · 1 line
2.7.4
#34 lore raw

PATCH v3 16/19 lib: fdtdec: Add function re-setup the fdt more effeciently

Quoted 20 lines · Jean-Jacques Hiblot

In some cases it may be useful to be able to change the fdt we have been using and use another one instead. For example, the TI platforms uses an EEPROM to store board information and, based on the type of board, different dtbs are used by the SPL. When DM_I2C is used, a first dtb must be used before the I2C is initialized and only then the final dtb can be selected.
To speed up the process and reduce memory usage, introduce a new function fdtdec_setup_best_match() that re-use the DTBs loaded in memory by fdtdec_setup() to select the best match.

---

Changes in v3:
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Quoted 7 lines

Changes in v2: None

 doc/README.fdt-control            | 18 ++++++++++++++++
 include/asm-generic/global_data.h |  4 ++++
 include/fdtdec.h                  | 21 +++++++++++++++++++
 lib/fdtdec.c                      | 43 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 85 insertions(+), 1 deletion(-)
#35 lore raw

PATCH v3 17/19 drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig

In reply to Jean-Jacques Hiblot

It is currently not possible to include the support to remove devices in the SPL. This is however needed by platforms that re-select their dtb after DM is initialized; they need to remove all the previously bound devices before triggering a scan of the new DT.

Add a Kconfig option to be able to include the support for device removal in the SPL.

Seeries-changes:3
- update commit message

---

Changes in v3: None
Changes in v2: None

 drivers/core/Kconfig | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/core/Kconfig +10 -2
index e8ba20c..046b87a 100644
@@ -57,13 +57,21 @@ config DM_DEVICE_REMOVE
 	default y
 	help
 	  We can save some code space by dropping support for removing a
-	  device. This is not normally required in SPL, so by default this
-	  option is disabled for SPL.
+	  device.
 
 	  Note that this may have undesirable results in the USB subsystem as
 	  it causes unplugged devices to linger around in the dm-tree, and it
 	  causes USB host controllers to not be stopped when booting the OS.
 
+config SPL_DM_DEVICE_REMOVE
+	bool "Support device removal in SPL"
+	depends on SPL_DM
+	default n
+	help
+	  We can save some code space by dropping support for removing a
+	  device. This is not normally required in SPL, so by default this
+	  option is disabled for SPL.
+
 config DM_STDIO
 	bool "Support stdio registration"
 	depends on DM
Signature · 1 line
2.7.4
#36 lore raw

PATCH v3 17/19 drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig

Quoted 5 lines · Jean-Jacques Hiblot

It is currently not possible to include the support to remove devices in the SPL. This is however needed by platforms that re-select their dtb after DM is initialized; they need to remove all the previously bound devices before triggering a scan of the new DT.

Quoted 9 lines

Add a Kconfig option to be able to include the support for device removal in the SPL.

Seeries-changes:3
- update commit message

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/f16770cc/attachment.sig>
#37 lore raw

PATCH v3 17/19 drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig

In reply to Jean-Jacques Hiblot
Quoted 14 lines · Jean-Jacques Hiblot

It is currently not possible to include the support to remove devices in the SPL. This is however needed by platforms that re-select their dtb after DM is initialized; they need to remove all the previously bound devices before triggering a scan of the new DT.

Add a Kconfig option to be able to include the support for device removal in the SPL.

Seeries-changes:3
- update commit message

Quoted 8 lines

---

Changes in v3: None
Changes in v2: None

 drivers/core/Kconfig | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
#38 lore raw

PATCH v3 18/19 drivers: core: nullify gd->dm_root after dm_uninit()

In reply to Jean-Jacques Hiblot

To reset the DM after a new dtb is loaded, we need to call dm_uninit() and then dm_init(). This fails however because gd->dm_root is not nullified by dm_uninit().
Fixing it by setting gd->dm_root in dm_uninit().

---

Changes in v3: None
Changes in v2: None

 drivers/core/root.c | 1 +
 1 file changed, 1 insertion(+)
drivers/core/root.c +1 -0
index b54bf5b..34d0586 100644
@@ -187,6 +187,7 @@ int dm_uninit(void)
 {
 	device_remove(dm_root(), DM_REMOVE_NORMAL);
 	device_unbind(dm_root());
+	gd->dm_root = NULL;
 
 	return 0;
 }
Signature · 1 line
2.7.4
#39 lore raw

PATCH v3 19/19 dra7: Allow selecting a new dtb after board detection.

In reply to Jean-Jacques Hiblot

The DRA7 platforms requires that the dtb used in the SPL really matches the platform to have the best MMC performances.
To detect the board type/version an I2C EEPROM is read. This requires that DM is initialized before the detection. As a consequence we must reset the DM after the board detection is a new dtb would better match the platform.

---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-omap2/hwinit-common.c | 20 ++++++++++++++++++++
 configs/dra7xx_evm_defconfig        |  2 ++
 2 files changed, 22 insertions(+)
arch/arm/mach-omap2/hwinit-common.c +20 -0
index d0781d7..772b4c4 100644
@@ -12,6 +12,7 @@
  */
 #include <common.h>
 #include <debug_uart.h>
+#include <fdtdec.h>
 #include <spl.h>
 #include <asm/arch/sys_proto.h>
 #include <linux/sizes.h>
@@ -19,6 +20,7 @@
 #include <asm/omap_common.h>
 #include <linux/compiler.h>
 #include <asm/system.h>
+#include <dm/root.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -171,6 +173,10 @@ void __weak init_package_revision(void)
  */
 void early_system_init(void)
 {
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB_FIT)
+	int ret;
+	int rescan;
+#endif
 	init_omap_revision();
 	hw_data_init();
 	init_package_revision();
@@ -186,6 +192,7 @@ void early_system_init(void)
 	do_io_settings();
 #endif
 	setup_early_clocks();
+
 #ifdef CONFIG_SPL_BUILD
 	/*
 	 * Save the boot parameters passed from romcode.
@@ -197,6 +204,19 @@ void early_system_init(void)
 #endif
 	do_board_detect();
 
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB_FIT)
+	/*
+	 * Board detection has been done.
+	 * Let us see if another dtb wouldn't be a better match
+	 * for our board
+	 */
+	ret = fdtdec_resetup(&rescan);
+	if (!ret && rescan) {
+		dm_uninit();
+		dm_init_and_scan(true);
+	}
+#endif
+
 	vcores_init();
 #ifdef CONFIG_DEBUG_UART_OMAP
 	debug_uart_init();
configs/dra7xx_evm_defconfig +2 -0
index 9546b5e..b4825a5 100644
@@ -34,11 +34,13 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="dra7-evm"
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm dra76-evm"
 CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0x9000
 CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_DEVICE_REMOVE=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
Signature · 1 line
2.7.4
#40 lore raw

PATCH v3 19/19 dra7: Allow selecting a new dtb after board detection.

Quoted 8 lines · Jean-Jacques Hiblot

The DRA7 platforms requires that the dtb used in the SPL really matches the platform to have the best MMC performances.
To detect the board type/version an I2C EEPROM is read. This requires that DM is initialized before the detection. As a consequence we must reset the DM after the board detection is a new dtb would better match the platform.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/bcfa5852/attachment.sig>
#41 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

In reply to Jean-Jacques Hiblot
Quoted 36 lines · Jean-Jacques Hiblot

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

Quoted 3 lines

It would be nice it some of you could try to boot them.

I applied the entire 19-patch series and it worked for me. Thanks!

Tested-by Adam Ford <[email protected]> #omap3_logic & am3517_evm

adam

Quoted 104 lines

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with

    DM_I2C

configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

 arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
 arch/arm/dts/omap5-u-boot.dtsi               |   4 +
 arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
 arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
 arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
 arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
 arch/arm/include/asm/omap_i2c.h              |  24 ++
 arch/arm/mach-keystone/ddr3_spd.c            |   7 +
 arch/arm/mach-omap2/am33xx/board.c           |  24 +-
 arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
 arch/arm/mach-omap2/clocks-common.c          |   2 +
 arch/arm/mach-omap2/hwinit-common.c          |  23 +-
 board/eets/pdu001/board.c                    |   1 -
 board/ti/am335x/board.c                      |  17 +-
 board/ti/am335x/mux.c                        |  11 +
 board/ti/am43xx/board.c                      |  46 ++-
 board/ti/am57xx/board.c                      |  25 +-
 board/ti/common/board_detect.c               | 110 +++----
 board/ti/ks2_evm/board_k2g.c                 |  11 +
 cmd/Kconfig                                  |   1 +
 configs/am335x_pdu001_defconfig              |   1 +
 configs/am57xx_evm_defconfig                 |   1 +
 configs/am57xx_hs_evm_defconfig              |   1 +
 configs/dra7xx_evm_defconfig                 |   4 +-
 configs/dra7xx_hs_evm_defconfig              |   1 +
 configs/omap3_logic_defconfig                |   1 +
 doc/README.fdt-control                       |  18 ++
 drivers/core/Kconfig                         |  12 +-
 drivers/core/device.c                        |  10 +-
 drivers/core/root.c                          |   1 +
 drivers/core/uclass.c                        |  24 ++
 drivers/i2c/i2c-uclass.c                     |  11 +
 drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
 drivers/power/palmas.c                       |  39 +++
 drivers/power/pmic/pmic_tps62362.c           |  24 ++
 drivers/power/pmic/pmic_tps65217.c           |  44 ++-
 drivers/power/pmic/pmic_tps65218.c           |  85 +++++
 drivers/power/pmic/pmic_tps65910.c           |  57 +++-
 drivers/power/twl4030.c                      |  39 +++
 drivers/power/twl6030.c                      |  39 +++
 include/asm-generic/global_data.h            |   4 +
 include/configs/am43xx_evm.h                 |   2 +
 include/configs/pdu001.h                     |   6 -
 include/configs/ti_armv7_common.h            |  18 +-
 include/dm/uclass-internal.h                 |  13 +
 include/fdtdec.h                             |  21 ++
 include/palmas.h                             |   5 +
 include/power/tps65217.h                     |   2 +
 include/power/tps65910.h                     |   1 +
 include/twl4030.h                            |   6 +-
 include/twl6030.h                            |   5 +
 lib/fdtdec.c                                 |  43 ++-
 52 files changed, 1083 insertions(+), 472 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_i2c.h

--
2.7.4

#42 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

Quoted 38 lines · Adam Ford
Quoted 36 lines · Jean-Jacques Hiblot

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

Quoted 7 lines
Quoted 3 lines

It would be nice it some of you could try to boot them.

I applied the entire 19-patch series and it worked for me. Thanks!

Tested-by Adam Ford <[email protected]> #omap3_logic & am3517_evm

Out of curiosity, are there any pending reasons we cannot apply this? I was hoping to see the warning reminding me that DM_I2C_COMPAT should be removed, and this seems to address that.

thanks

adam

Quoted 106 lines

adam

Quoted 104 lines

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with

    DM_I2C

configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

 arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
 arch/arm/dts/omap5-u-boot.dtsi               |   4 +
 arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
 arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
 arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
 arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
 arch/arm/include/asm/omap_i2c.h              |  24 ++
 arch/arm/mach-keystone/ddr3_spd.c            |   7 +
 arch/arm/mach-omap2/am33xx/board.c           |  24 +-
 arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
 arch/arm/mach-omap2/clocks-common.c          |   2 +
 arch/arm/mach-omap2/hwinit-common.c          |  23 +-
 board/eets/pdu001/board.c                    |   1 -
 board/ti/am335x/board.c                      |  17 +-
 board/ti/am335x/mux.c                        |  11 +
 board/ti/am43xx/board.c                      |  46 ++-
 board/ti/am57xx/board.c                      |  25 +-
 board/ti/common/board_detect.c               | 110 +++----
 board/ti/ks2_evm/board_k2g.c                 |  11 +
 cmd/Kconfig                                  |   1 +
 configs/am335x_pdu001_defconfig              |   1 +
 configs/am57xx_evm_defconfig                 |   1 +
 configs/am57xx_hs_evm_defconfig              |   1 +
 configs/dra7xx_evm_defconfig                 |   4 +-
 configs/dra7xx_hs_evm_defconfig              |   1 +
 configs/omap3_logic_defconfig                |   1 +
 doc/README.fdt-control                       |  18 ++
 drivers/core/Kconfig                         |  12 +-
 drivers/core/device.c                        |  10 +-
 drivers/core/root.c                          |   1 +
 drivers/core/uclass.c                        |  24 ++
 drivers/i2c/i2c-uclass.c                     |  11 +
 drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
 drivers/power/palmas.c                       |  39 +++
 drivers/power/pmic/pmic_tps62362.c           |  24 ++
 drivers/power/pmic/pmic_tps65217.c           |  44 ++-
 drivers/power/pmic/pmic_tps65218.c           |  85 +++++
 drivers/power/pmic/pmic_tps65910.c           |  57 +++-
 drivers/power/twl4030.c                      |  39 +++
 drivers/power/twl6030.c                      |  39 +++
 include/asm-generic/global_data.h            |   4 +
 include/configs/am43xx_evm.h                 |   2 +
 include/configs/pdu001.h                     |   6 -
 include/configs/ti_armv7_common.h            |  18 +-
 include/dm/uclass-internal.h                 |  13 +
 include/fdtdec.h                             |  21 ++
 include/palmas.h                             |   5 +
 include/power/tps65217.h                     |   2 +
 include/power/tps65910.h                     |   1 +
 include/twl4030.h                            |   6 +-
 include/twl6030.h                            |   5 +
 lib/fdtdec.c                                 |  43 ++-
 52 files changed, 1083 insertions(+), 472 deletions(-)
 create mode 100644 arch/arm/include/asm/omap_i2c.h

--
2.7.4

#43 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

Hello Adam,

Am 26.11.2018 um 20:18 schrieb Adam Ford:

Quoted 42 lines · Adam Ford
Quoted 41 lines · Jean-Jacques Hiblot
Quoted 39 lines

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

It would be nice it some of you could try to boot them.

Quoted 8 lines
Quoted 4 lines

I applied the entire 19-patch series and it worked for me. Thanks!

Tested-by Adam Ford <[email protected]> #omap3_logic & am3517_evm

Out of curiosity, are there any pending reasons we cannot apply this? I was hoping to see the warning reminding me that DM_I2C_COMPAT should be removed, and this seems to address that.

Yes, good question ... v3 looks good to me ... Hmm... I cannot find your patches in patchwork, may this is the reason, why I missed them!

Aha, just saved your email to a file ... and see:
[...]
Subject: [U-Boot] [PATCH v3 01/19] cmd: Kconfig: Do not include EEPROM if DM_I2C is used
without DM_I2C_COMPAT
X-BeenThere: u-boot at lists.denx.de
X-Mailman-Version: 2.1.18
[...]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Errors-To: u-boot-bounces at lists.denx.de
Sender: "U-Boot" <[email protected]>

VGhlIGltcGxlbWVudGF0aW9uIG9mIHRoZSBFRVBST00gY29tbWFuZHMgZG9lcyBub3Qgc3VwcG9y dCB0aGUgRE0gSTJDIEFQSS4KUHJldmVudCBjb21waWxhdGlvbiBicmVha2FnZSBieSBub3QgZW5h [...]

May patchwork has problems with:

Content-Transfer-Encoding: base64

I also have to find out now, how te get to your patch ... Hmm, seems when I mark all the text in my EMail client and than copy&paste the text into a file, this works ... but doing this is errorprone and makes a lot of work ...

May I ask you, if you can resend your series in plain text ?

Beside of this I am fine with this patchseries, many thanks for doing this work! You can add my

bye,
Heiko

Quoted 111 lines

thanks

adam

Quoted 106 lines

adam

Quoted 104 lines

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with

     DM_I2C

configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

  arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
  arch/arm/dts/omap5-u-boot.dtsi               |   4 +
  arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
  arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
  arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
  arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
  arch/arm/include/asm/omap_i2c.h              |  24 ++
  arch/arm/mach-keystone/ddr3_spd.c            |   7 +
  arch/arm/mach-omap2/am33xx/board.c           |  24 +-
  arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
  arch/arm/mach-omap2/clocks-common.c          |   2 +
  arch/arm/mach-omap2/hwinit-common.c          |  23 +-
  board/eets/pdu001/board.c                    |   1 -
  board/ti/am335x/board.c                      |  17 +-
  board/ti/am335x/mux.c                        |  11 +
  board/ti/am43xx/board.c                      |  46 ++-
  board/ti/am57xx/board.c                      |  25 +-
  board/ti/common/board_detect.c               | 110 +++----
  board/ti/ks2_evm/board_k2g.c                 |  11 +
  cmd/Kconfig                                  |   1 +
  configs/am335x_pdu001_defconfig              |   1 +
  configs/am57xx_evm_defconfig                 |   1 +
  configs/am57xx_hs_evm_defconfig              |   1 +
  configs/dra7xx_evm_defconfig                 |   4 +-
  configs/dra7xx_hs_evm_defconfig              |   1 +
  configs/omap3_logic_defconfig                |   1 +
  doc/README.fdt-control                       |  18 ++
  drivers/core/Kconfig                         |  12 +-
  drivers/core/device.c                        |  10 +-
  drivers/core/root.c                          |   1 +
  drivers/core/uclass.c                        |  24 ++
  drivers/i2c/i2c-uclass.c                     |  11 +
  drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
  drivers/power/palmas.c                       |  39 +++
  drivers/power/pmic/pmic_tps62362.c           |  24 ++
  drivers/power/pmic/pmic_tps65217.c           |  44 ++-
  drivers/power/pmic/pmic_tps65218.c           |  85 +++++
  drivers/power/pmic/pmic_tps65910.c           |  57 +++-
  drivers/power/twl4030.c                      |  39 +++
  drivers/power/twl6030.c                      |  39 +++
  include/asm-generic/global_data.h            |   4 +
  include/configs/am43xx_evm.h                 |   2 +
  include/configs/pdu001.h                     |   6 -
  include/configs/ti_armv7_common.h            |  18 +-
  include/dm/uclass-internal.h                 |  13 +
  include/fdtdec.h                             |  21 ++
  include/palmas.h                             |   5 +
  include/power/tps65217.h                     |   2 +
  include/power/tps65910.h                     |   1 +
  include/twl4030.h                            |   6 +-
  include/twl6030.h                            |   5 +
  lib/fdtdec.c                                 |  43 ++-
  52 files changed, 1083 insertions(+), 472 deletions(-)

create mode 100644 arch/arm/include/asm/omap_i2c.h

--
2.7.4

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#44 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

Quoted 76 lines · Heiko Schocher

Hello Adam,

Am 26.11.2018 um 20:18 schrieb Adam Ford:

Quoted 42 lines · Adam Ford
Quoted 41 lines · Jean-Jacques Hiblot
Quoted 39 lines

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

It would be nice it some of you could try to boot them.

Quoted 8 lines
Quoted 4 lines

I applied the entire 19-patch series and it worked for me. Thanks!

Tested-by Adam Ford <[email protected]> #omap3_logic & am3517_evm

Out of curiosity, are there any pending reasons we cannot apply this? I was hoping to see the warning reminding me that DM_I2C_COMPAT should be removed, and this seems to address that.

Yes, good question ... v3 looks good to me ... Hmm... I cannot find your patches in patchwork, may this is the reason, why I missed them!

Aha, just saved your email to a file ... and see:
[...]
Subject: [U-Boot] [PATCH v3 01/19] cmd: Kconfig: Do not include EEPROM if DM_I2C is used
without DM_I2C_COMPAT
X-BeenThere: u-boot at lists.denx.de
X-Mailman-Version: 2.1.18
[...]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Errors-To: u-boot-bounces at lists.denx.de
Sender: "U-Boot" <[email protected]>

VGhlIGltcGxlbWVudGF0aW9uIG9mIHRoZSBFRVBST00gY29tbWFuZHMgZG9lcyBub3Qgc3VwcG9y dCB0aGUgRE0gSTJDIEFQSS4KUHJldmVudCBjb21waWxhdGlvbiBicmVha2FnZSBieSBub3QgZW5h [...]

May patchwork has problems with:

Quoted 9 lines

Content-Transfer-Encoding: base64

I also have to find out now, how te get to your patch ... Hmm, seems when I mark all the text in my EMail client and than copy&paste the text into a file, this works ... but doing this is errorprone and makes a lot of work ...

May I ask you, if you can resend your series in plain text ?

Jean-Jacques -

Can you comment and/or resend?

I'd love to see these patches applied.

Thanks

adam

Quoted 123 lines

Beside of this I am fine with this patchseries, many thanks for doing this work! You can add my

bye,
Heiko

Quoted 111 lines

thanks

adam

Quoted 106 lines

adam

Quoted 104 lines

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with

     DM_I2C

configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

  arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
  arch/arm/dts/omap5-u-boot.dtsi               |   4 +
  arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
  arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
  arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
  arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
  arch/arm/include/asm/omap_i2c.h              |  24 ++
  arch/arm/mach-keystone/ddr3_spd.c            |   7 +
  arch/arm/mach-omap2/am33xx/board.c           |  24 +-
  arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
  arch/arm/mach-omap2/clocks-common.c          |   2 +
  arch/arm/mach-omap2/hwinit-common.c          |  23 +-
  board/eets/pdu001/board.c                    |   1 -
  board/ti/am335x/board.c                      |  17 +-
  board/ti/am335x/mux.c                        |  11 +
  board/ti/am43xx/board.c                      |  46 ++-
  board/ti/am57xx/board.c                      |  25 +-
  board/ti/common/board_detect.c               | 110 +++----
  board/ti/ks2_evm/board_k2g.c                 |  11 +
  cmd/Kconfig                                  |   1 +
  configs/am335x_pdu001_defconfig              |   1 +
  configs/am57xx_evm_defconfig                 |   1 +
  configs/am57xx_hs_evm_defconfig              |   1 +
  configs/dra7xx_evm_defconfig                 |   4 +-
  configs/dra7xx_hs_evm_defconfig              |   1 +
  configs/omap3_logic_defconfig                |   1 +
  doc/README.fdt-control                       |  18 ++
  drivers/core/Kconfig                         |  12 +-
  drivers/core/device.c                        |  10 +-
  drivers/core/root.c                          |   1 +
  drivers/core/uclass.c                        |  24 ++
  drivers/i2c/i2c-uclass.c                     |  11 +
  drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
  drivers/power/palmas.c                       |  39 +++
  drivers/power/pmic/pmic_tps62362.c           |  24 ++
  drivers/power/pmic/pmic_tps65217.c           |  44 ++-
  drivers/power/pmic/pmic_tps65218.c           |  85 +++++
  drivers/power/pmic/pmic_tps65910.c           |  57 +++-
  drivers/power/twl4030.c                      |  39 +++
  drivers/power/twl6030.c                      |  39 +++
  include/asm-generic/global_data.h            |   4 +
  include/configs/am43xx_evm.h                 |   2 +
  include/configs/pdu001.h                     |   6 -
  include/configs/ti_armv7_common.h            |  18 +-
  include/dm/uclass-internal.h                 |  13 +
  include/fdtdec.h                             |  21 ++
  include/palmas.h                             |   5 +
  include/power/tps65217.h                     |   2 +
  include/power/tps65910.h                     |   1 +
  include/twl4030.h                            |   6 +-
  include/twl6030.h                            |   5 +
  lib/fdtdec.c                                 |  43 ++-
  52 files changed, 1083 insertions(+), 472 deletions(-)

create mode 100644 arch/arm/include/asm/omap_i2c.h

--
2.7.4

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de

#45 lore raw

v3 cover DM_I2C_COMPAT removal for all ti platforms

Quoted 79 lines · Adam Ford
Quoted 78 lines · Heiko Schocher

Hello Adam,

Am 26.11.2018 um 20:18 schrieb Adam Ford:

Quoted 40 lines · Adam Ford
Quoted 39 lines · Jean-Jacques Hiblot
Quoted 38 lines

This series remove the usage of the DM_I2C_COMPAT option for all the ti platforms. It also takes this opportunity to not disable DM_I2C in the SPL.

There are a couples of issues to fix:
- CMD_EEPROM does not support the DM API. Fixed by removing this option when DM_I2C is used without DM_I2C_COMPAT
- i2c_get_chip_for_busnum() does not work when OF_CONTROL is not used (as is the case with am33xx SPL).
- The I2C driver do not support DM_I2C without OF_CONTROL.
- Most of the PMIC drivers do not support the I2C DM API.
- Board detection is done prior DM initialization. Fixed by moving it after DM is initialized. That move breaks the DRA7 platforms (The fixes for that are at the last 5 patches this series)

When all this is taken care of DM_I2C_COMPAT can be removed and DM_I2C enabled in the SPL.

This has been tested with the following boards:
- am437x SK
- am335x SK
- am335x beaglebone (both DM and non-DM config)
- dra76 evm
- am572 evm
- k2g evm

The following targets may be impacted by the changes related to SPL_OF_CONTROL and SPL_OF_PLATDATA:
- am3517_evm_defconfig
- omap3_logic_defconfig
- chromebit_mickey_defconfig
- chromebook_jerry_defconfig
- chromebook_minnie_defconfig
- evb-rk3399_defconfig
- rock_defconfig

It would be nice it some of you could try to boot them.

Quoted 7 lines
Quoted 4 lines

I applied the entire 19-patch series and it worked for me. Thanks!

Tested-by Adam Ford <[email protected]> #omap3_logic & am3517_evm

Out of curiosity, are there any pending reasons we cannot apply this? I was hoping to see the warning reminding me that DM_I2C_COMPAT should be removed, and this seems to address that.

Yes, good question ... v3 looks good to me ... Hmm... I cannot find your patches in patchwork, may this is the reason, why I missed them!

Aha, just saved your email to a file ... and see:
[...]
Subject: [U-Boot] [PATCH v3 01/19] cmd: Kconfig: Do not include EEPROM if DM_I2C is used
without DM_I2C_COMPAT
X-BeenThere: u-boot at lists.denx.de
X-Mailman-Version: 2.1.18
[...]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Errors-To: u-boot-bounces at lists.denx.de
Sender: "U-Boot" <[email protected]>

VGhlIGltcGxlbWVudGF0aW9uIG9mIHRoZSBFRVBST00gY29tbWFuZHMgZG9lcyBub3Qgc3VwcG9y dCB0aGUgRE0gSTJDIEFQSS4KUHJldmVudCBjb21waWxhdGlvbiBicmVha2FnZSBieSBub3QgZW5h [...]

May patchwork has problems with:

Content-Transfer-Encoding: base64

I also have to find out now, how te get to your patch ... Hmm, seems when I mark all the text in my EMail client and than copy&paste the text into a file, this works ... but doing this is errorprone and makes a lot of work ...

Quoted 7 lines
Quoted 2 lines

May I ask you, if you can resend your series in plain text ?

Jean-Jacques -

Can you comment and/or resend?

I'd love to see these patches applied.

Me too.

resending this series now.

JJ

Quoted 123 lines

Thanks

adam

Quoted 119 lines

Beside of this I am fine with this patchseries, many thanks for doing this work! You can add my

bye,
Heiko

Quoted 108 lines

thanks

adam

Quoted 105 lines

adam

Quoted 104 lines

Changes in v3:
- removed commit introducing dm_i2c_probe_device(). Instead probe the presence of the chip on the I2C bus in i2c_get_chip_for_busnum().
- fdtdec_resetup() need not call fdtdec_setup() when only a single DTB is used.
- Add documentation in README-fdt-control explaining why and how to use fdtdec_resetup()

Changes in v2:
- Add missing commit log to the commit disabling CMD_EEPROM when non-DM API is not available
- don't use the DT to find the req_seq number if SPL_OF_PLATDATA is used. Instead do it as if SPL_OF_CONTROL is not defined.
- Also add DM_I2C support to the twl6030 driver
- remove the remaining non-DM I2C API call for pdu001 board.
- Fixed warning in power_init_board() for the am43xx ti boards.

Andreas Dannenberg (1):
ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT

Jean-Jacques Hiblot (17):
cmd: Kconfig: Do not include EEPROM if DM_I2C is used without
DM_I2C_COMPAT
dm: i2c: Make i2c_get_chip_for_busnum() fail if the chip is not
detected
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
configs: am335x: am57x: dra7x: Enable CONFIG_SPL_DM_SEQ_ALIAS
i2c: omap24xx_i2c: Use platdata to probe the device
am335x: Register the I2C controllers if DM_I2C is used.
dts: am43x: omap5: Add node for I2C in SPL
omap: detect the board after DM is available
power: make most tps drivers and the twl4030 driver compatible with
DM_I2C
configs: am335x_pdu001: remove CONFIG_DM_I2C_COMPAT
ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
am57xx: remove non-DM I2C code
configs: dra7xx-evm: increase the size of the malloc's pool before
relocation
lib: fdtdec: Add function re-setup the fdt more effeciently
drivers: core: Add the option SPL_DM_DEVICE_REMOVE to the Kconfig
drivers: core: nullify gd->dm_root after dm_uninit()
dra7: Allow selecting a new dtb after board detection.

Vignesh R (1):
i2c: omap24xx_i2c: Move away from SoC specific headers for reg offset

   arch/arm/dts/am437x-gp-evm-u-boot.dtsi       |   4 +
   arch/arm/dts/omap5-u-boot.dtsi               |   4 +
   arch/arm/include/asm/arch-am33xx/i2c.h       |  47 +--
   arch/arm/include/asm/arch-omap3/i2c.h        |  47 ---
   arch/arm/include/asm/arch-omap4/i2c.h        |  45 ---
   arch/arm/include/asm/arch-omap5/i2c.h        |  45 ---
   arch/arm/include/asm/omap_i2c.h              |  24 ++
   arch/arm/mach-keystone/ddr3_spd.c            |   7 +
   arch/arm/mach-omap2/am33xx/board.c           |  24 +-
   arch/arm/mach-omap2/am33xx/clk_synthesizer.c |  56 +++-
   arch/arm/mach-omap2/clocks-common.c          |   2 +
   arch/arm/mach-omap2/hwinit-common.c          |  23 +-
   board/eets/pdu001/board.c                    |   1 -
   board/ti/am335x/board.c                      |  17 +-
   board/ti/am335x/mux.c                        |  11 +
   board/ti/am43xx/board.c                      |  46 ++-
   board/ti/am57xx/board.c                      |  25 +-
   board/ti/common/board_detect.c               | 110 +++----
   board/ti/ks2_evm/board_k2g.c                 |  11 +
   cmd/Kconfig                                  |   1 +
   configs/am335x_pdu001_defconfig              |   1 +
   configs/am57xx_evm_defconfig                 |   1 +
   configs/am57xx_hs_evm_defconfig              |   1 +
   configs/dra7xx_evm_defconfig                 |   4 +-
   configs/dra7xx_hs_evm_defconfig              |   1 +
   configs/omap3_logic_defconfig                |   1 +
   doc/README.fdt-control                       |  18 ++
   drivers/core/Kconfig                         |  12 +-
   drivers/core/device.c                        |  10 +-
   drivers/core/root.c                          |   1 +
   drivers/core/uclass.c                        |  24 ++
   drivers/i2c/i2c-uclass.c                     |  11 +
   drivers/i2c/omap24xx_i2c.c                   | 467 ++++++++++++++++++---------
   drivers/power/palmas.c                       |  39 +++
   drivers/power/pmic/pmic_tps62362.c           |  24 ++
   drivers/power/pmic/pmic_tps65217.c           |  44 ++-
   drivers/power/pmic/pmic_tps65218.c           |  85 +++++
   drivers/power/pmic/pmic_tps65910.c           |  57 +++-
   drivers/power/twl4030.c                      |  39 +++
   drivers/power/twl6030.c                      |  39 +++
   include/asm-generic/global_data.h            |   4 +
   include/configs/am43xx_evm.h                 |   2 +
   include/configs/pdu001.h                     |   6 -
   include/configs/ti_armv7_common.h            |  18 +-
   include/dm/uclass-internal.h                 |  13 +
   include/fdtdec.h                             |  21 ++
   include/palmas.h                             |   5 +
   include/power/tps65217.h                     |   2 +
   include/power/tps65910.h                     |   1 +
   include/twl4030.h                            |   6 +-
   include/twl6030.h                            |   5 +
   lib/fdtdec.c                                 |  43 ++-
   52 files changed, 1083 insertions(+), 472 deletions(-)

create mode 100644 arch/arm/include/asm/omap_i2c.h

--
2.7.4

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de