[v2,7/8] i2c: designware: Add debug print for SDA hold time value

Message ID 20180601134725.1375-8-jarkko.nikula@linux.intel.com
State New
Headers show
Series
  • i2c: designware: Improve debug prints
Related show

Commit Message

Jarkko Nikula June 1, 2018, 1:47 p.m.
SDA hold time is an important timing parameter and often reason for
arbitration lost errors if not set to a correct value. Add a debug print
for it in order to see what value gets programmed to a HW.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-common.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andy Shevchenko June 4, 2018, 12:50 p.m. | #1
On Fri, 2018-06-01 at 16:47 +0300, Jarkko Nikula wrote:
> SDA hold time is an important timing parameter and often reason for
> arbitration lost errors if not set to a correct value. Add a debug
> print
> for it in order to see what value gets programmed to a HW.
> 

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

with a caveat that explicit casting like other proposed (by me)
solutions are not ideal, so, let's stick with this one for now.

> Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> ---
>  drivers/i2c/busses/i2c-designware-common.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-common.c
> b/drivers/i2c/busses/i2c-designware-common.c
> index 1b542d3e5a2e..1742f1910cfd 100644
> --- a/drivers/i2c/busses/i2c-designware-common.c
> +++ b/drivers/i2c/busses/i2c-designware-common.c
> @@ -209,6 +209,10 @@ void i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)
>  		 */
>  		if (!(dev->sda_hold_time & DW_IC_SDA_HOLD_RX_MASK))
>  			dev->sda_hold_time |= 1 <<
> DW_IC_SDA_HOLD_RX_SHIFT;
> +
> +		dev_dbg(dev->dev, "SDA Hold Time TX:RX = %d:%d\n",
> +			dev->sda_hold_time &
> ~(u32)DW_IC_SDA_HOLD_RX_MASK,
> +			dev->sda_hold_time >>
> DW_IC_SDA_HOLD_RX_SHIFT);
>  	} else if (dev->sda_hold_time) {
>  		dev_warn(dev->dev,
>  			"Hardware too old to adjust SDA hold
> time.\n");

Patch

diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 1b542d3e5a2e..1742f1910cfd 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -209,6 +209,10 @@  void i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)
 		 */
 		if (!(dev->sda_hold_time & DW_IC_SDA_HOLD_RX_MASK))
 			dev->sda_hold_time |= 1 << DW_IC_SDA_HOLD_RX_SHIFT;
+
+		dev_dbg(dev->dev, "SDA Hold Time TX:RX = %d:%d\n",
+			dev->sda_hold_time & ~(u32)DW_IC_SDA_HOLD_RX_MASK,
+			dev->sda_hold_time >> DW_IC_SDA_HOLD_RX_SHIFT);
 	} else if (dev->sda_hold_time) {
 		dev_warn(dev->dev,
 			"Hardware too old to adjust SDA hold time.\n");