Skip to content

i2c: designware: Make the SDA hold time half LCNT - #6091

Merged
pelwell merged 2 commits into
raspberrypi:rpi-6.6.yfrom
pelwell:is6056
Apr 5, 2024
Merged

pelwell merged 2 commits into
raspberrypi:rpi-6.6.yfrom
pelwell:is6056

Conversation

@pelwell

@pelwell pelwell commented Apr 4, 2024 •

Copy link
Copy Markdown
Contributor

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.

pelwell added 2 commits April 4, 2024 17:03
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>
@JinShil

JinShil commented Apr 5, 2024

Copy link
Copy Markdown

I tested this on a number of different i2c slave devices and did not observe any regressions.

@pelwell
pelwell merged commit 8eadf1f into raspberrypi:rpi-6.6.y Apr 5, 2024
@pelwell

pelwell commented Apr 5, 2024

Copy link
Copy Markdown
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
@microfx

microfx commented Oct 14, 2024

Copy link
Copy Markdown

how can I install these patches?

@pelwell

pelwell commented Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

They were merged and will be in all recent kernels, including the ones installed by apt.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants