Commit 173ec351 ("i2c: mvtwsi: disable i2c slave on Armada 38x") adds
slave disabling code on port 0 into bind method. This does not work
on Turris Omnia in SPL, because at the time the bind method is called in
SPL, arch/arm/mach-mvebu/spl.c has not yet set DM translation offset,
so the bind function reads from bad memory place, which causes a fault.

Move the i2c slave disabling code into the probe method of mvtwsi, by
that time dm_set_translation_offset is already called.

Signed-off-by: Marek Behún <[email protected]>
Cc: Baruch Siach <[email protected]>
Cc: Heiko Schocher <[email protected]>
Cc: Chris Packham <[email protected]>
Cc: Stefan Roese <[email protected]>
---
 drivers/i2c/mvtwsi.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 74ac0a4aa7..b0f7c3e057 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -804,22 +804,15 @@ static void twsi_disable_i2c_slave(struct 
mvtwsi_registers *twsi)
        clrbits_le32(&twsi->debug, BIT(18));
 }
 
-static int mvtwsi_i2c_bind(struct udevice *bus)
+static int mvtwsi_i2c_probe(struct udevice *bus)
 {
-       struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus);
+       struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
+       uint actual_speed;
 
        /* Disable the hidden slave in i2c0 of these platforms */
        if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_KIRKWOOD))
                        && bus->req_seq == 0)
-               twsi_disable_i2c_slave(twsi);
-
-       return 0;
-}
-
-static int mvtwsi_i2c_probe(struct udevice *bus)
-{
-       struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
-       uint actual_speed;
+               twsi_disable_i2c_slave(dev->base);
 
        __twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed);
        dev->speed = actual_speed;
@@ -871,7 +864,6 @@ U_BOOT_DRIVER(i2c_mvtwsi) = {
        .name = "i2c_mvtwsi",
        .id = UCLASS_I2C,
        .of_match = mvtwsi_i2c_ids,
-       .bind = mvtwsi_i2c_bind,
        .probe = mvtwsi_i2c_probe,
        .ofdata_to_platdata = mvtwsi_i2c_ofdata_to_platdata,
        .priv_auto_alloc_size = sizeof(struct mvtwsi_i2c_dev),
-- 
2.21.0

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to