Repository navigation
i2c: designware: Make the SDA hold time half LCNT - #6091
Merged
Merged
Conversation
In the absence of a value in Device Tree, set the SDA hold time to half the SCL low time. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This reverts commit a3d53c8.
|
I tested this on a number of different i2c slave devices and did not observe any regressions. |
Contributor
Author
|
Thanks again for the testing. I'm hoping now I can draw a line under the RP1 I2C issues. |
popcornmix
added a commit
to raspberrypi/firmware
that referenced
this pull request
Apr 5, 2024
See: raspberrypi/linux#6089 kernel: rp1: Support interrupt CPU affinity See: raspberrypi/linux#6090 kernel: i2c: designware: Make the SDA hold time half LCNT See: raspberrypi/linux#6091 kernel: Add support for Chipcap 2 sensor See: raspberrypi/linux#6083 kernel: nvmem: raspberrypi: Add nvmem driver for reading customer OTP See: raspberrypi/linux#6014 kernel: Add overlays and configs for several i2c sensors See: raspberrypi/linux#6093
popcornmix
added a commit
to raspberrypi/rpi-firmware
that referenced
this pull request
Apr 5, 2024
See: raspberrypi/linux#6089 kernel: rp1: Support interrupt CPU affinity See: raspberrypi/linux#6090 kernel: i2c: designware: Make the SDA hold time half LCNT See: raspberrypi/linux#6091 kernel: Add support for Chipcap 2 sensor See: raspberrypi/linux#6083 kernel: nvmem: raspberrypi: Add nvmem driver for reading customer OTP See: raspberrypi/linux#6014 kernel: Add overlays and configs for several i2c sensors See: raspberrypi/linux#6093
|
how can I install these patches? |
Contributor
Author
|
They were merged and will be in all recent kernels, including the ones installed by apt. |
This was referenced Nov 6, 2026
pelwell
pushed a commit
that referenced
this pull request
Nov 6, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
popcornmix
pushed a commit
that referenced
this pull request
Nov 9, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
pelwell
pushed a commit
that referenced
this pull request
Nov 11, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
herrnst
pushed a commit
to herrnst/linux-raspberrypi
that referenced
this pull request
Nov 13, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see raspberrypi#6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that raspberrypi#6091 and raspberrypi#6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
popcornmix
pushed a commit
that referenced
this pull request
Nov 16, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
herrnst
pushed a commit
to herrnst/linux-raspberrypi
that referenced
this pull request
Nov 18, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see raspberrypi#6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that raspberrypi#6091 and raspberrypi#6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
popcornmix
pushed a commit
that referenced
this pull request
Nov 19, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
popcornmix
pushed a commit
that referenced
this pull request
Nov 23, 2026
The "SDA hold time = LCNT / 2" default added by commit "i2c: designware: Make the SDA hold time half LCNT" (see #6091) is applied in i2c_dw_probe(), before i2c_dw_probe_master() has run i2c_dw_set_timings_master() to populate dev->fs_lcnt. fs_lcnt is therefore still 0, the default evaluates to 0, and i2c_dw_set_sda_hold() keeps the hardware reset value (1 cycle, ~5 ns) instead of the intended ~3 us. On a Pi 5 (200 MHz clk_sys, 100 kHz bus) this leaves IC_SDA_HOLD at 0x10001 rather than 0x10251 as on 6.18, and reintroduces the early-ACK failures that #6091 and #6056 fixed: an Adafruit PiOLED (SSD1306, 0x3c) fails with "SDA stuck at low" / "Remote I/O error" on 7.3.1 while it works on 6.18. Do the lcnt/2 default and i2c_dw_set_sda_hold() after i2c_dw_probe_master(), so fs_lcnt is valid. i2c_dw_init(), which writes the register, still runs afterwards. Tested on a Pi 5 running 7.3.1: IC_SDA_HOLD reads 0x10251 and the OLED works. Assisted-by: GitHub Copilot CLI:claude-sonnet-5.5 Signed-off-by: jflecool2 <1393416+jflecool2@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's another attempt at improving the Pi 5 I2C compatibility and reliability. The observation from small LCD displays discussed in #6056 is that something causes the ACK to be released early. Comparing the traces to Pi 4 showed that the ACK signal starts much earlier on Pi 5 - it's roughly halfway through the SCL low on Pi 4. Increasing the SDA hold time to half the SCL low cycle count gives the same appearance on Pi 5 and seems to fix the issue.
The new logic is dependent on there not being an explicit override from Device Tree, so the second part of this PR is a reversion of the commit that added the sda-hold-time-ns values.