i2c: stm32f7: fix timing computation ignoring i2c-analog-filter
Subsystems (3)
PATCH 1/1 i2c: stm32f7: fix timing computation ignoring i2c-analog-filter
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.
--- drivers/i2c/busses/i2c-stm32f7.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +3 -3
@@ -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",
Signature · 1 line
2.25.1
Hi,
thank you for you patch.
Quoted 48 lines · Guillermo Rodríguez
stm32f7_i2c_compute_timing()usesi2c_dev->analog_filterto pick the analog filter delay, buti2c_dev->analog_filteris parsed from the "i2c-analog-filter" DT property only after thecompute_timingloop instm32f7_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_timingloop.Fixes 83c3408f7b9c ("i2c: stm32f7: support DT binding i2c-analog-filter")Signed-off-by Guillermo Rodríguez <[email protected]>--- drivers/i2c/busses/i2c-stm32f7.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-stm32f7.c +3
-3@@ -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",Signature · 1 line
2.25.1
Regards,
Alain
Hi Guillermo,
Quoted 12 lines · Guillermo Rodríguez
stm32f7_i2c_compute_timing()usesi2c_dev->analog_filterto pick the analog filter delay, buti2c_dev->analog_filteris parsed from the "i2c-analog-filter" DT property only after thecompute_timingloop instm32f7_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).
Quoted 5 lines
Fix by parsing "i2c-analog-filter" before the
compute_timingloop.Fixes 83c3408f7b9c ("i2c: stm32f7: support DT binding i2c-analog-filter")Signed-off-by Guillermo Rodríguez <[email protected]>
merged to i2c/i2c-host-fixes.
Thanks,
Andi