From: Samuel Holland Date: Sun, 12 Sep 2021 15:21:39 +0000 (-0500) Subject: i2c: mvtwsi: Add support for DM clocks and resets X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=06cec894a5c37e79afd81eaaec7f1325b55f3e32;p=u-boot.git i2c: mvtwsi: Add support for DM clocks and resets The controller may need to have clocks/resets enabled for it to work. Add support for this. Since the clocks/resets are optional on some platforms (per the device tree binding), do not prevent probing the controller if they are missing. Signed-off-by: Samuel Holland Reviewed-by: Heiko Schocher --- diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index d33e2c7c9d..236bfb8d8e 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -17,7 +17,9 @@ #include #include #if CONFIG_IS_ENABLED(DM_I2C) +#include #include +#include #endif DECLARE_GLOBAL_DATA_PTR; @@ -835,7 +837,18 @@ static int mvtwsi_i2c_bind(struct udevice *bus) static int mvtwsi_i2c_probe(struct udevice *bus) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); + struct reset_ctl reset; + struct clk clk; uint actual_speed; + int ret; + + ret = reset_get_by_index(bus, 0, &reset); + if (!ret) + reset_deassert(&reset); + + ret = clk_get_by_index(bus, 0, &clk); + if (!ret) + clk_enable(&clk); __twsi_i2c_init(dev->base, dev->speed, dev->slaveadd, &actual_speed); dev->speed = actual_speed;