diff mbox series

[v1,1/1] i2c: designware: Adjust bus_freq_hz when refuse high speed mode set

Message ID 20210331110510.67523-1-andriy.shevchenko@linux.intel.com
State Accepted
Commit 5e729bc54bda705f64941008b018b4e41a4322bf
Headers show
Series [v1,1/1] i2c: designware: Adjust bus_freq_hz when refuse high speed mode set | expand

Commit Message

Andy Shevchenko March 31, 2021, 11:05 a.m. UTC
When hardware doesn't support High Speed Mode, we forget bus_freq_hz
timing adjustment. This makes the timings and real registers being
unsynchronized. Adjust bus_freq_hz when refuse high speed mode set.

Fixes: b6e67145f149 ("i2c: designware: Enable high speed mode")
Reported-by: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-master.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Song Bao Hua (Barry Song) March 31, 2021, 9:37 p.m. UTC | #1
> -----Original Message-----
> From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]
> Sent: Thursday, April 1, 2021 12:05 AM
> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Serge Semin
> <Sergey.Semin@baikalelectronics.ru>; linux-i2c@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>; Mika Westerberg
> <mika.westerberg@linux.intel.com>; wsa@kernel.org; yangyicong
> <yangyicong@huawei.com>; Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com>
> Subject: [PATCH v1 1/1] i2c: designware: Adjust bus_freq_hz when refuse high
> speed mode set
> 
> When hardware doesn't support High Speed Mode, we forget bus_freq_hz
> timing adjustment. This makes the timings and real registers being
> unsynchronized. Adjust bus_freq_hz when refuse high speed mode set.
> 
> Fixes: b6e67145f149 ("i2c: designware: Enable high speed mode")
> Reported-by: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Thanks for fixing that.

Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>

>  drivers/i2c/busses/i2c-designware-master.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-master.c
> b/drivers/i2c/busses/i2c-designware-master.c
> index 34bb4e21bcc3..9bfa06e31eec 100644
> --- a/drivers/i2c/busses/i2c-designware-master.c
> +++ b/drivers/i2c/busses/i2c-designware-master.c
> @@ -129,6 +129,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev
> *dev)
>  		if ((comp_param1 & DW_IC_COMP_PARAM_1_SPEED_MODE_MASK)
>  			!= DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH) {
>  			dev_err(dev->dev, "High Speed not supported!\n");
> +			t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
>  			dev->master_cfg &= ~DW_IC_CON_SPEED_MASK;
>  			dev->master_cfg |= DW_IC_CON_SPEED_FAST;
>  			dev->hs_hcnt = 0;
> --
> 2.30.2
Andy Shevchenko April 5, 2021, 11:55 a.m. UTC | #2
On Wed, Mar 31, 2021 at 09:37:41PM +0000, Song Bao Hua (Barry Song) wrote:
> > From: Andy Shevchenko [mailto:andriy.shevchenko@linux.intel.com]

> > Sent: Thursday, April 1, 2021 12:05 AM

> > To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Serge Semin

> > <Sergey.Semin@baikalelectronics.ru>; linux-i2c@vger.kernel.org;

> > linux-kernel@vger.kernel.org


...

> > Fixes: b6e67145f149 ("i2c: designware: Enable high speed mode")

> > Reported-by: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>

> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 

> Thanks for fixing that.

> 

> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>


Thanks!
Wolfram, can be this applied for v5.12-rc7?

-- 
With Best Regards,
Andy Shevchenko
Wolfram Sang April 5, 2021, 8:50 p.m. UTC | #3
On Wed, Mar 31, 2021 at 02:05:10PM +0300, Andy Shevchenko wrote:
> When hardware doesn't support High Speed Mode, we forget bus_freq_hz

> timing adjustment. This makes the timings and real registers being

> unsynchronized. Adjust bus_freq_hz when refuse high speed mode set.

> 

> Fixes: b6e67145f149 ("i2c: designware: Enable high speed mode")

> Reported-by: "Song Bao Hua (Barry Song)" <song.bao.hua@hisilicon.com>

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 34bb4e21bcc3..9bfa06e31eec 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -129,6 +129,7 @@  static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 		if ((comp_param1 & DW_IC_COMP_PARAM_1_SPEED_MODE_MASK)
 			!= DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH) {
 			dev_err(dev->dev, "High Speed not supported!\n");
+			t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
 			dev->master_cfg &= ~DW_IC_CON_SPEED_MASK;
 			dev->master_cfg |= DW_IC_CON_SPEED_FAST;
 			dev->hs_hcnt = 0;