mbox series

[0/5] i2c: stm32: filter binding support & debug info

Message ID 1612515104-838-1-git-send-email-alain.volmat@foss.st.com
Headers show
Series i2c: stm32: filter binding support & debug info | expand

Message

Alain Volmat Feb. 5, 2021, 8:51 a.m. UTC
This serie add support for the analog and digital filter binding
for the stm32f7 i2c driver.
An additional patch add also debug informations, displayed in case
of errors.

Alain Volmat (5):
  i2c: stm32f7: fix configuration of the digital filter
  i2c: stm32f7: support DT binding i2c-analog-filter
  i2c: stm32f7: add support for DNF i2c-digital-filter binding
  ARM: dts: stm32: enable the analog filter for all I2C nodes in
    stm32mp151
  i2c: stm32f7: indicate the address being accessed on errors

 arch/arm/boot/dts/stm32mp151.dtsi |  6 +++
 drivers/i2c/busses/i2c-stm32f7.c  | 63 ++++++++++++++++++++-----------
 2 files changed, 46 insertions(+), 23 deletions(-)

Comments

Pierre Yves MORDRET Feb. 5, 2021, 2:58 p.m. UTC | #1
Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> The digital filter related computation are present in the driver
> however the programming of the filter within the IP is missing.
> The maximum value for the DNF is wrong and should be 15 instead of 16.
> 
> Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver")
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 9aa8e65b511e..473fbe144b7e 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -57,6 +57,8 @@
>  #define STM32F7_I2C_CR1_RXDMAEN			BIT(15)
>  #define STM32F7_I2C_CR1_TXDMAEN			BIT(14)
>  #define STM32F7_I2C_CR1_ANFOFF			BIT(12)
> +#define STM32F7_I2C_CR1_DNF_MASK		GENMASK(11, 8)
> +#define STM32F7_I2C_CR1_DNF(n)			(((n) & 0xf) << 8)
>  #define STM32F7_I2C_CR1_ERRIE			BIT(7)
>  #define STM32F7_I2C_CR1_TCIE			BIT(6)
>  #define STM32F7_I2C_CR1_STOPIE			BIT(5)
> @@ -160,7 +162,7 @@ enum {
>  };
>  
>  #define STM32F7_I2C_DNF_DEFAULT			0
> -#define STM32F7_I2C_DNF_MAX			16
> +#define STM32F7_I2C_DNF_MAX			15
>  
>  #define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
> @@ -725,6 +727,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
>  	else
>  		stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  				     STM32F7_I2C_CR1_ANFOFF);
> +
> +	/* Program the Digital Filter */
> +	stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
> +			     STM32F7_I2C_CR1_DNF_MASK);
> +	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
> +			     STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf));
> +
>  	stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  			     STM32F7_I2C_CR1_PE);
>  }
>
Pierre Yves MORDRET Feb. 5, 2021, 2:59 p.m. UTC | #2
Hello all

Looks good to me

Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> To help debugging issues, add the address of the slave being
> accessed when getting an error.
> 
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index f77cd6512a86..ef642fe1eb2c 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -1602,7 +1602,8 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
>  
>  	/* Bus error */
>  	if (status & STM32F7_I2C_ISR_BERR) {
> -		dev_err(dev, "<%s>: Bus error\n", __func__);
> +		dev_err(dev, "<%s>: Bus error accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_BERRCF, base + STM32F7_I2C_ICR);
>  		stm32f7_i2c_release_bus(&i2c_dev->adap);
>  		f7_msg->result = -EIO;
> @@ -1610,13 +1611,15 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
>  
>  	/* Arbitration loss */
>  	if (status & STM32F7_I2C_ISR_ARLO) {
> -		dev_dbg(dev, "<%s>: Arbitration loss\n", __func__);
> +		dev_dbg(dev, "<%s>: Arbitration loss accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_ARLOCF, base + STM32F7_I2C_ICR);
>  		f7_msg->result = -EAGAIN;
>  	}
>  
>  	if (status & STM32F7_I2C_ISR_PECERR) {
> -		dev_err(dev, "<%s>: PEC error in reception\n", __func__);
> +		dev_err(dev, "<%s>: PEC error in reception accessing addr 0x%x\n",
> +			__func__, f7_msg->addr);
>  		writel_relaxed(STM32F7_I2C_ICR_PECCF, base + STM32F7_I2C_ICR);
>  		f7_msg->result = -EINVAL;
>  	}
>