i2c: designware: fix master is holding SCL low while ENABLE bit is disabled
HI andi
Due to a 12 time difference,I had been off work.
I am very sorry that I can't reply email in time. I will reply to your email immediately after going to work tomorrow.
发自我的 iPhone
Quoted 3 lines
From: Andi Shyti <[email protected]>
To: Kimriver Liu <[email protected]>
Cc: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected]
Quoted 16 lines
Subject: Re: [PATCH v7] i2c: designware: fix master is holding SCL low while ENABLE bit is disabled
Date: Mon, 9 Sep 2024 15:08:25 +0200 [thread overview]
Message-ID: <traj5uhqbny5yro3hf72k2qpga7ez7cuqv2mesvl73fku2b5xq@uw5dqjdc6mms> (raw)
In-Reply-To: <[email protected]>Hi Kimriver,
Quoted 8 lines · Kimriver Liu
It was observed issuing ABORT
bit(IC_ENABLE[1])will not work whenIC_ENABLEis already disabled.Check if ENABLE
bit(IC_ENABLE[0])is disabled when the master is holding SCL low. If ENABLE bit is disabled, the software need enable it before trying to issue ABORT bit. otherwise, the controller ignores any write to ABORT bit.
Quoted 5 lines
Quoted 1 line
Signed-off-by Kimriver Liu <[email protected]>You forgot:
Reviewed-by Mika Westerberg <[email protected]>
Thank you for telling me
Quoted 20 lines
Quoted 6 lines
---
V6->V7:
1. add Subject versioning [PATCH v7]
2. change fsleep(25) tousleep_range(25, 250)
3. Add macro definitionDW_iC_ENABLE_ENABLEto fix compile errors
4. base: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=masterThanks a lot for following up! :-)
Quoted 11 lines
V5->V6: restorei2c_dw_is_master_idling()function checkingV4->V5: delete master idling checkingV3->V4:
1. update commit messages and add patch version and changelog
2. move print the error message ini2c_dw_xferV2->V3: change (!enable) to (!(enable &DW_IC_ENABLE_ENABLE))V1->V2: used standard words in function names and addressed review commentslink to V1:
https://lore.kernel.org/lkml/[email protected]/
---
...
Quoted 21 lines
Quoted 6 lines
drivers/i2c/busses/i2c-designware-common.c +0
-0@@ -453,6 +453,18 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev) abort_needed = raw_intr_stats &DW_IC_INTR_MST_ON_HOLD ;if (abort_needed) {drivers/i2c/busses/i2c-designware-common.c void __i2c_dw_disable(struct dw_i2c_dev *dev) · line 465
Quoted 10 lines
drivers/i2c/busses/i2c-designware-common.c +10
-0+if (!(enable &DW_IC_ENABLE_ENABLE )) { +regmap_write (dev->map,DW_IC_ENABLE ,DW_IC_ENABLE_ENABLE ); + enable |=DW_IC_ENABLE_ENABLE ; +/* +* Need two ic_clk delay when enabling the I2C to ensure ENABLE bit +* is already set. Wait 10 times the signaling period of the highest +* I2C transfer supported by the driver(for 400KHz this is 25us) +* as described in the DesignWare I2C databook. +*/ +usleep_range (25 ,250 );I think there is a misunderstanding here. Andy asked you to use flseep and improve the calculation: "Please, calculate this delay based on the actual speed in use (or about to be in use)."[*]
Quoted 1 line
Andy can you please clarify with Kimriver here?
if we use 400kHz ,need setting flseep(25);
if we use 100kHz ,need setting flseep(100);
Overall, take the maximum value:flseep(100);
Quoted 2 lines
--
2.17.1
Andi Shyti
maintainerHi Kimriver,
Quoted 5 lines · Liu Kimriver/刘金河
HI andi
Due to a 12 time difference,I had been off work.
I am very sorry that I can't reply email in time. I will reply to your email immediately after going to work tomorrow.
It's not a problem, take your time! :-)
Quoted 21 lines
Quoted 20 lines
Quoted 6 lines
drivers/i2c/busses/i2c-designware-common.c +0
-0@@ -453,6 +453,18 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev) abort_needed = raw_intr_stats &DW_IC_INTR_MST_ON_HOLD ;if (abort_needed) {drivers/i2c/busses/i2c-designware-common.c void __i2c_dw_disable(struct dw_i2c_dev *dev) · line 465
Quoted 10 lines
drivers/i2c/busses/i2c-designware-common.c +10
-0+if (!(enable &DW_IC_ENABLE_ENABLE )) { +regmap_write (dev->map,DW_IC_ENABLE ,DW_IC_ENABLE_ENABLE ); + enable |=DW_IC_ENABLE_ENABLE ; +/* +* Need two ic_clk delay when enabling the I2C to ensure ENABLE bit +* is already set. Wait 10 times the signaling period of the highest +* I2C transfer supported by the driver(for 400KHz this is 25us) +* as described in the DesignWare I2C databook. +*/ +usleep_range (25 ,250 );I think there is a misunderstanding here. Andy asked you to use flseep and improve the calculation: "Please, calculate this delay based on the actual speed in use (or about to be in use)."[*]
Quoted 5 lines
Quoted 1 line
Andy can you please clarify with Kimriver here?
if we use 400kHz ,need setting flseep(25);
if we use 100kHz ,need setting flseep(100);
Overall, take the maximum value:flseep(100);
Thanks for clarifying, then this is what Andy asked to do, instead of waiting an average random amount from 25 to 250us. Does it make sense to you?
Thanks,
Andi
Hi Andi
Quoted 39 lines
-----Original Message-----
From: Andi Shyti <[email protected]>
Sent: 2024年9月10日 1:37
To: Liu Kimriver/刘金河 <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7] i2c: designware: fix master is holding SCL low while ENABLE bit is disabledHi Kimriver,
Quoted 5 lines · Liu Kimriver/刘金河
HI andi
Due to a 12 time difference,I had been off work.
I am very sorry that I can't reply email in time. I will reply to your email immediately after going to work tomorrow.It's not a problem, take your time! :-)
Quoted 21 lines
Quoted 20 lines
Quoted 6 lines
drivers/i2c/busses/i2c-designware-common.c +0
-0@@ -453,6 +453,18 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev) abort_needed = raw_intr_stats &DW_IC_INTR_MST_ON_HOLD ;if (abort_needed) {drivers/i2c/busses/i2c-designware-common.c void __i2c_dw_disable(struct dw_i2c_dev *dev) · line 465
Quoted 10 lines
drivers/i2c/busses/i2c-designware-common.c +10
-0+if (!(enable &DW_IC_ENABLE_ENABLE )) { +regmap_write (dev->map,DW_IC_ENABLE ,DW_IC_ENABLE_ENABLE ); + enable |=DW_IC_ENABLE_ENABLE ; +/* +* Need two ic_clk delay when enabling the I2C to ensure ENABLE bit +* is already set. Wait 10 times the signaling period of the highest +* I2C transfer supported by the driver(for 400KHz this is 25us) +* as described in the DesignWare I2C databook. +*/ +usleep_range (25 ,250 );I think there is a misunderstanding here. Andy asked you to use flseep and improve the calculation: "Please, calculate this delay based on the actual speed in use (or about to be in use)."[*]
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Andy can you please clarify with Kimriver here?
if we use 400kHz ,need setting flseep(25); if we use 100kHz ,need
setting flseep(100); Overall, take the maximum value:flseep(100);Thanks for clarifying, then this is what Andy asked to do, instead of waiting an average random amount from 25 to 250us. Does it make sense to you?
as described in the DesignWare I2C databook:
Define a timer interval (ti2c_poll) equal to the 10 times the signaling period for the highest I2C transfer speed used in the system and supported by DW_apb_i2c. For example, if the highest I2C transfer mode is 400 kb/s, then this ti2c_poll is 25μs.
Now I understand how to calculate this delay based on actual usage speed:
fsleep(DIV_ROUND_CLOSEST_ULL(10 * MICRO, t->bus_freq_hz));
I will update code and re-send it as V8.
Thanks.
------------------------------------------
Best Regards
Kimriver Liu