lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d39593ea-ef47-5688-202b-66458f13ecc8@foss.st.com>
Date:   Fri, 5 Feb 2021 15:58:57 +0100
From:   Pierre Yves MORDRET <pierre-yves.mordret@...s.st.com>
To:     Alain Volmat <alain.volmat@...s.st.com>, <wsa@...nel.org>,
        <robh+dt@...nel.org>
CC:     <mark.rutland@....com>, <mcoquelin.stm32@...il.com>,
        <alexandre.torgue@...s.st.com>, <linux-i2c@...r.kernel.org>,
        <devicetree@...r.kernel.org>,
        <linux-stm32@...md-mailman.stormreply.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <fabrice.gasnier@...s.st.com>
Subject: Re: [PATCH 2/5] i2c: stm32f7: support DT binding i2c-analog-filter

Hello all

Looks good to me

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

Regards

On 2/5/21 9:51 AM, Alain Volmat wrote:
> Replace driver internally coded enabling/disabling of the
> analog-filter with the DT binding "i2c-analog-filter".
> 
> Signed-off-by: Alain Volmat <alain.volmat@...s.st.com>
> ---
>  drivers/i2c/busses/i2c-stm32f7.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 473fbe144b7e..0c539fea2754 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -164,7 +164,6 @@ enum {
>  #define STM32F7_I2C_DNF_DEFAULT			0
>  #define STM32F7_I2C_DNF_MAX			15
>  
> -#define STM32F7_I2C_ANALOG_FILTER_ENABLE	1
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN	50	/* ns */
>  #define STM32F7_I2C_ANALOG_FILTER_DELAY_MAX	260	/* ns */
>  
> @@ -224,7 +223,6 @@ struct stm32f7_i2c_spec {
>   * @rise_time: Rise time (ns)
>   * @fall_time: Fall time (ns)
>   * @dnf: Digital filter coefficient (0-16)
> - * @analog_filter: Analog filter delay (On/Off)
>   * @fmp_clr_offset: Fast Mode Plus clear register offset from set register
>   */
>  struct stm32f7_i2c_setup {
> @@ -233,7 +231,6 @@ struct stm32f7_i2c_setup {
>  	u32 rise_time;
>  	u32 fall_time;
>  	u8 dnf;
> -	bool analog_filter;
>  	u32 fmp_clr_offset;
>  };
>  
> @@ -312,6 +309,7 @@ struct stm32f7_i2c_msg {
>   * @wakeup_src: boolean to know if the device is a wakeup source
>   * @smbus_mode: states that the controller is configured in SMBus mode
>   * @host_notify_client: SMBus host-notify client
> + * @analog_filter: boolean to indicate enabling of the analog filter
>   */
>  struct stm32f7_i2c_dev {
>  	struct i2c_adapter adap;
> @@ -340,6 +338,7 @@ struct stm32f7_i2c_dev {
>  	bool wakeup_src;
>  	bool smbus_mode;
>  	struct i2c_client *host_notify_client;
> +	bool analog_filter;
>  };
>  
>  /*
> @@ -386,14 +385,12 @@ static const struct stm32f7_i2c_setup stm32f7_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
>  	.dnf = STM32F7_I2C_DNF_DEFAULT,
> -	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
>  };
>  
>  static const struct stm32f7_i2c_setup stm32mp15_setup = {
>  	.rise_time = STM32F7_I2C_RISE_TIME_DEFAULT,
>  	.fall_time = STM32F7_I2C_FALL_TIME_DEFAULT,
>  	.dnf = STM32F7_I2C_DNF_DEFAULT,
> -	.analog_filter = STM32F7_I2C_ANALOG_FILTER_ENABLE,
>  	.fmp_clr_offset = 0x40,
>  };
>  
> @@ -471,10 +468,10 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
>  
>  	/*  Analog and Digital Filters */
>  	af_delay_min =
> -		(setup->analog_filter ?
> +		(i2c_dev->analog_filter ?
>  		 STM32F7_I2C_ANALOG_FILTER_DELAY_MIN : 0);
>  	af_delay_max =
> -		(setup->analog_filter ?
> +		(i2c_dev->analog_filter ?
>  		 STM32F7_I2C_ANALOG_FILTER_DELAY_MAX : 0);
>  	dnf_delay = setup->dnf * i2cclk;
>  
> @@ -676,12 +673,15 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
>  		return ret;
>  	}
>  
> +	i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
> +						       "i2c-analog-filter");
> +
>  	dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
>  		setup->speed_freq, setup->clock_src);
>  	dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
>  		setup->rise_time, setup->fall_time);
>  	dev_dbg(i2c_dev->dev, "I2C Analog Filter(%s), DNF(%i)\n",
> -		(setup->analog_filter ? "On" : "Off"), setup->dnf);
> +		(i2c_dev->analog_filter ? "On" : "Off"), setup->dnf);
>  
>  	i2c_dev->bus_rate = setup->speed_freq;
>  
> @@ -720,8 +720,8 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
>  	timing |= STM32F7_I2C_TIMINGR_SCLL(t->scll);
>  	writel_relaxed(timing, i2c_dev->base + STM32F7_I2C_TIMINGR);
>  
> -	/* Enable I2C */
> -	if (i2c_dev->setup.analog_filter)
> +	/* Configure the Analog Filter */
> +	if (i2c_dev->analog_filter)
>  		stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
>  				     STM32F7_I2C_CR1_ANFOFF);
>  	else
> 

-- 
--
~ Py MORDRET
--

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ