From b1d6f3df63fc889a81e7b73128ec0fe52d427963 Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Savaliya Date: Thu, 10 Mar 2022 00:33:26 +0530 Subject: [PATCH] i2c: i2c-msm-geni: Reset i2c GPIOs using FORCE_DEFAULT If cancel command is failing due to bad IOS line and not in proper state, then reset the GPIOs using FORCE_DEFAULT. This will ensure if master side is behaving bad, it will come to the proper state else fix it from the slave side. Change-Id: I3ac143a3c5184ebc4f7f7072de9ba4f4b132dd42 Signed-off-by: Mukesh Kumar Savaliya --- drivers/i2c/busses/i2c-msm-geni.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-msm-geni.c b/drivers/i2c/busses/i2c-msm-geni.c index 9c508aa56efe..7da00921d717 100644 --- a/drivers/i2c/busses/i2c-msm-geni.c +++ b/drivers/i2c/busses/i2c-msm-geni.c @@ -249,10 +249,21 @@ static int do_pending_cancel(struct geni_i2c_dev *gi2c) geni_ios = geni_read_reg_nolog(gi2c->base, SE_GENI_IOS); if ((geni_ios & 0x3) != 0x3) { + /* Try to restore IOS with FORCE_DEFAULT */ GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev, - "%s: Can't do pending cancel, IOS bad state: 0x%x\n", - __func__, geni_ios); - return -EINVAL; + "%s: IOS:0x%x, bad state\n", __func__, geni_ios); + + geni_write_reg(FORCE_DEFAULT, + gi2c->base, GENI_FORCE_DEFAULT_REG); + geni_ios = geni_read_reg_nolog(gi2c->base, SE_GENI_IOS); + if ((geni_ios & 0x3) != 0x3) { + GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev, + "%s: IOS:0x%x, Fix from Slave side\n", + __func__, geni_ios); + return -EINVAL; + } + GENI_SE_ERR(gi2c->ipcl, true, gi2c->dev, + "%s: IOS:0x%x restored properly\n", __func__, geni_ios); } if (gi2c->se_mode == GSI_ONLY) {