diff mbox series

[5/8] i2c: sprd: Configure the enable bit of the IIC controller before each transmission initiation

Message ID 20230817094520.21286-6-Huangzheng.Lai@unisoc.com
State Superseded
Headers show
Series i2c: sprd: Modification of UNIOC Platform IIC Driver | expand

Commit Message

Huangzheng Lai Aug. 17, 2023, 9:45 a.m. UTC
When a timeout exception occurs in the IIC driver, the IIC controller
will be reset, and after resetting, control bits such as I2C_EN and
I2C_INT_EN will be reset to 0, and the IIC master cannot initiate
Transmission unless sprd_i2c_enable() is executed. To address this issue,
this patch places sprd_i2c_enable() before each transmission initiation
to ensure that the necessary control bits of the IIC controller are
configured.

Signed-off-by: Huangzheng Lai <Huangzheng.Lai@unisoc.com>
---
 drivers/i2c/busses/i2c-sprd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Chunyan Zhang Aug. 31, 2023, 8:09 a.m. UTC | #1
On Thu, 17 Aug 2023 at 17:46, Huangzheng Lai <Huangzheng.Lai@unisoc.com> wrote:
>
> When a timeout exception occurs in the IIC driver, the IIC controller
> will be reset, and after resetting, control bits such as I2C_EN and
> I2C_INT_EN will be reset to 0, and the IIC master cannot initiate
> Transmission unless sprd_i2c_enable() is executed. To address this issue,
> this patch places sprd_i2c_enable() before each transmission initiation
> to ensure that the necessary control bits of the IIC controller are
> configured.
>
> Signed-off-by: Huangzheng Lai <Huangzheng.Lai@unisoc.com>
> ---
>  drivers/i2c/busses/i2c-sprd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
> index 02c11a9ff2da..7314c897525d 100644
> --- a/drivers/i2c/busses/i2c-sprd.c
> +++ b/drivers/i2c/busses/i2c-sprd.c
> @@ -310,6 +310,8 @@ static int sprd_i2c_handle_msg(struct i2c_adapter *i2c_adap,
>         return i2c_dev->err;
>  }
>
> +static void sprd_i2c_enable(struct sprd_i2c *i2c_dev);

Can we move this whole function above its caller?

> +
>  static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap,
>                                 struct i2c_msg *msgs, int num)
>  {
> @@ -320,6 +322,8 @@ static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap,
>         if (ret < 0)
>                 return ret;
>
> +       sprd_i2c_enable(i2c_dev);
> +
>         for (im = 0; im < num - 1; im++) {
>                 ret = sprd_i2c_handle_msg(i2c_adap, &msgs[im], 0);
>                 if (ret)
> @@ -661,8 +665,6 @@ static int __maybe_unused sprd_i2c_runtime_resume(struct device *dev)
>         if (ret)
>                 return ret;
>
> -       sprd_i2c_enable(i2c_dev);
> -
>         return 0;
>  }
>
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 02c11a9ff2da..7314c897525d 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -310,6 +310,8 @@  static int sprd_i2c_handle_msg(struct i2c_adapter *i2c_adap,
 	return i2c_dev->err;
 }
 
+static void sprd_i2c_enable(struct sprd_i2c *i2c_dev);
+
 static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap,
 				struct i2c_msg *msgs, int num)
 {
@@ -320,6 +322,8 @@  static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap,
 	if (ret < 0)
 		return ret;
 
+	sprd_i2c_enable(i2c_dev);
+
 	for (im = 0; im < num - 1; im++) {
 		ret = sprd_i2c_handle_msg(i2c_adap, &msgs[im], 0);
 		if (ret)
@@ -661,8 +665,6 @@  static int __maybe_unused sprd_i2c_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	sprd_i2c_enable(i2c_dev);
-
 	return 0;
 }