]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: designware: fix reset handling on socfpga gen5
authorSimon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Thu, 28 Mar 2019 20:11:48 +0000 (21:11 +0100)
committerMarek Vasut <marex@denx.de>
Wed, 24 Apr 2019 22:00:49 +0000 (00:00 +0200)
Using this driver on socfpga gen5 with DM_I2C enabled leads to a data abort
as the 'i2c' reset property cannot be found (the gen5 dtsi does not provide
reset-names).

The actual bug was to check 'if (&priv->reset_ctl)', which is never false.

While at it, convert the driver to use 'reset_get_bulk' instead of looking
at a specific named reset and also make it release the reset on driver
remove before starting the OS.

Fixes: 622597dee4f6 ("i2c: designware: add reset ctrl to driver")
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
drivers/i2c/designware_i2c.c

index 63e40823f121f680b2d0b214c0e45b16f8f18db9..9ccc2411a62a521bbaad9cadcdf46273136d7801 100644 (file)
@@ -34,7 +34,7 @@ static struct dw_scl_sda_cfg byt_config = {
 struct dw_i2c {
        struct i2c_regs *regs;
        struct dw_scl_sda_cfg *scl_sda_cfg;
-       struct reset_ctl reset_ctl;
+       struct reset_ctl_bulk resets;
 };
 
 #ifdef CONFIG_SYS_I2C_DW_ENABLE_STATUS_UNSUPPORTED
@@ -562,16 +562,22 @@ static int designware_i2c_probe(struct udevice *bus)
                priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
        }
 
-       ret = reset_get_by_name(bus, "i2c", &priv->reset_ctl);
+       ret = reset_get_bulk(bus, &priv->resets);
        if (ret)
-               pr_info("reset_get_by_name() failed: %d\n", ret);
-
-       if (&priv->reset_ctl)
-               reset_deassert(&priv->reset_ctl);
+               dev_warn(bus, "Can't get reset: %d\n", ret);
+       else
+               reset_deassert_bulk(&priv->resets);
 
        return __dw_i2c_init(priv->regs, 0, 0);
 }
 
+static int designware_i2c_remove(struct udevice *dev)
+{
+       struct dw_i2c *priv = dev_get_priv(dev);
+
+       return reset_release_bulk(&priv->resets);
+}
+
 static int designware_i2c_bind(struct udevice *dev)
 {
        static int num_cards;
@@ -613,6 +619,8 @@ U_BOOT_DRIVER(i2c_designware) = {
        .bind   = designware_i2c_bind,
        .probe  = designware_i2c_probe,
        .priv_auto_alloc_size = sizeof(struct dw_i2c),
+       .remove = designware_i2c_remove,
+       .flags = DM_FLAG_OS_PREPARE,
        .ops    = &designware_i2c_ops,
 };