summaryrefslogtreecommitdiff
path: root/drivers/i2c/busses/i2c-mv64xxx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-12-16 02:53:50 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2020-12-16 02:53:50 +0300
commit9d0d886799e49e0f6d51e70c823416919544fdb7 (patch)
treea0392a5a11884941f62b4db270e75a9451e280a2 /drivers/i2c/busses/i2c-mv64xxx.c
parent605ea5aafe1341ac9b2144516f898ac78ad49c40 (diff)
parent4e970a0ada5299d017a4263074f725227c2d2852 (diff)
downloadlinux-9d0d886799e49e0f6d51e70c823416919544fdb7.tar.xz
Merge branch 'i2c/for-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: "A bit smaller this time with mostly usual driver updates. Slave support for imx stands out a little" * 'i2c/for-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (30 commits) i2c: remove check that can never be true i2c: Warn when device removing fails dt-bindings: i2c: Update DT binding docs to support SiFive FU740 SoC dt-bindings: i2c: Add compatible string for AM64 SoC i2c: designware: Make register offsets all of the same width i2c: designware: Switch header to use BIT() and GENMASK() i2c: pxa: move to generic GPIO recovery i2c: sh_mobile: Mark adapter suspended during suspend i2c: owl: Add compatible for the Actions Semi S500 I2C controller dt-bindings: i2c: owl: Convert Actions Semi Owl binding to a schema i2c: imx: support slave mode for imx I2C driver i2c: ismt: Adding support for I2C_SMBUS_BLOCK_PROC_CALL i2c: ocores: Avoid false-positive error log message. Revert "i2c: qcom-geni: Disable DMA processing on the Lenovo Yoga C630" i2c: mxs: Remove unneeded platform_device_id i2c: pca-platform: drop two members from driver data that are assigned to only i2c: imx: Remove unused .id_table support i2c: nvidia-gpu: drop empty stub for runtime pm dt-bindings: i2c: mellanox,i2c-mlxbf: convert txt to YAML schema i2c: mv64xxx: Add bus error recovery ...
Diffstat (limited to 'drivers/i2c/busses/i2c-mv64xxx.c')
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index e0e45fc19b8f..5cfe70aedced 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -17,6 +17,7 @@
#include <linux/interrupt.h>
#include <linux/mv643xx_i2c.h>
#include <linux/platform_device.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/reset.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -147,6 +148,7 @@ struct mv64xxx_i2c_data {
bool irq_clear_inverted;
/* Clk div is 2 to the power n, not 2 to the power n + 1 */
bool clk_n_base_0;
+ struct i2c_bus_recovery_info rinfo;
};
static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = {
@@ -325,7 +327,8 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
drv_data->msg->flags);
drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
mv64xxx_i2c_hw_init(drv_data);
- drv_data->rc = -EIO;
+ i2c_recover_bus(&drv_data->adapter);
+ drv_data->rc = -EAGAIN;
}
}
@@ -561,6 +564,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
"time_left: %d\n", drv_data->block,
(int)time_left);
mv64xxx_i2c_hw_init(drv_data);
+ i2c_recover_bus(&drv_data->adapter);
}
} else
spin_unlock_irqrestore(&drv_data->lock, flags);
@@ -870,6 +874,25 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
}
#endif /* CONFIG_OF */
+static int mv64xxx_i2c_init_recovery_info(struct mv64xxx_i2c_data *drv_data,
+ struct device *dev)
+{
+ struct i2c_bus_recovery_info *rinfo = &drv_data->rinfo;
+
+ rinfo->pinctrl = devm_pinctrl_get(dev);
+ if (IS_ERR(rinfo->pinctrl)) {
+ if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ dev_info(dev, "can't get pinctrl, bus recovery not supported\n");
+ return PTR_ERR(rinfo->pinctrl);
+ } else if (!rinfo->pinctrl) {
+ return -ENODEV;
+ }
+
+ drv_data->adapter.bus_recovery_info = rinfo;
+ return 0;
+}
+
static int
mv64xxx_i2c_probe(struct platform_device *pd)
{
@@ -926,6 +949,10 @@ mv64xxx_i2c_probe(struct platform_device *pd)
goto exit_reset;
}
+ rc = mv64xxx_i2c_init_recovery_info(drv_data, &pd->dev);
+ if (rc == -EPROBE_DEFER)
+ goto exit_reset;
+
drv_data->adapter.dev.parent = &pd->dev;
drv_data->adapter.algo = &mv64xxx_i2c_algo;
drv_data->adapter.owner = THIS_MODULE;