* [PATCH] i2c: stm32f7: fix timing computation ignoring i2c-analog-filter
@ 2026-05-26 9:12 Guillermo Rodríguez
2026-06-03 8:59 ` Alain Volmat
0 siblings, 1 reply; 2+ messages in thread
From: Guillermo Rodríguez @ 2026-05-26 9:12 UTC (permalink / raw)
To: Pierre-Yves MORDRET, Alain Volmat, Andi Shyti, Maxime Coquelin,
Alexandre Torgue, Wolfram Sang
Cc: Guillermo Rodríguez, linux-i2c, linux-stm32,
linux-arm-kernel, linux-kernel
stm32f7_i2c_compute_timing() uses i2c_dev->analog_filter to pick
the analog filter delay, but i2c_dev->analog_filter is parsed from
the "i2c-analog-filter" DT property only after the compute_timing
loop in stm32f7_i2c_setup_timing(), so in practice the timing
calculations always ignore the analog filter. On an STM32MP1 board
with clock-frequency = <400000> and i2c-analog-filter set, measured
SCL frequency was ~382 kHz.
This also affects (widens) the computed SDADEL range. At high bus
clock speeds, this can select an SDADEL value that violates tVD;DAT
(data valid time).
Fix by parsing "i2c-analog-filter" before the compute_timing loop.
Fixes: 83c3408f7b9c ("i2c: stm32f7: support DT binding i2c-analog-filter")
Cc: stable@vger•kernel.org
Signed-off-by: Guillermo Rodríguez <guille.rodriguez@gmail•com>
---
drivers/i2c/busses/i2c-stm32f7.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 53d9df70ebe4..067af255bd22 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -694,6 +694,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;
+ i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
+ "i2c-analog-filter");
+
do {
ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
&i2c_dev->timing);
@@ -715,9 +718,6 @@ 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",
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: stm32f7: fix timing computation ignoring i2c-analog-filter
2026-05-26 9:12 [PATCH] i2c: stm32f7: fix timing computation ignoring i2c-analog-filter Guillermo Rodríguez
@ 2026-06-03 8:59 ` Alain Volmat
0 siblings, 0 replies; 2+ messages in thread
From: Alain Volmat @ 2026-06-03 8:59 UTC (permalink / raw)
To: Guillermo Rodríguez
Cc: Pierre-Yves MORDRET, Andi Shyti, Maxime Coquelin,
Alexandre Torgue, Wolfram Sang, linux-i2c, linux-stm32,
linux-arm-kernel, linux-kernel
Hi,
thank you for you patch.
On Tue, May 26, 2026 at 11:12:09AM +0200, Guillermo Rodríguez wrote:
> stm32f7_i2c_compute_timing() uses i2c_dev->analog_filter to pick
> the analog filter delay, but i2c_dev->analog_filter is parsed from
> the "i2c-analog-filter" DT property only after the compute_timing
> loop in stm32f7_i2c_setup_timing(), so in practice the timing
> calculations always ignore the analog filter. On an STM32MP1 board
> with clock-frequency = <400000> and i2c-analog-filter set, measured
> SCL frequency was ~382 kHz.
>
> This also affects (widens) the computed SDADEL range. At high bus
> clock speeds, this can select an SDADEL value that violates tVD;DAT
> (data valid time).
>
> Fix by parsing "i2c-analog-filter" before the compute_timing loop.
>
> Fixes: 83c3408f7b9c ("i2c: stm32f7: support DT binding i2c-analog-filter")
> Cc: stable@vger•kernel.org
> Signed-off-by: Guillermo Rodríguez <guille.rodriguez@gmail•com>
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index 53d9df70ebe4..067af255bd22 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -694,6 +694,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
> if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
> i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;
>
> + i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
> + "i2c-analog-filter");
> +
> do {
> ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
> &i2c_dev->timing);
> @@ -715,9 +718,6 @@ 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",
> --
> 2.25.1
>
Acked-by: Alain Volmat <alain.volmat@foss•st.com>
Regards,
Alain
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-03 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 9:12 [PATCH] i2c: stm32f7: fix timing computation ignoring i2c-analog-filter Guillermo Rodríguez
2026-06-03 8:59 ` Alain Volmat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox