Skip to content

spi: rp2040-gpio-bridge: Fix fast_xfer with strict RP1 pinmux - #7728

Merged
pelwell merged 2 commits into
raspberrypi:rpi-6.18.yfrom
jlab13:rp2040-gbdg-strict-pinmux
Nov 12, 2026
Merged

pelwell merged 2 commits into
raspberrypi:rpi-6.18.yfrom
jlab13:rp2040-gbdg-strict-pinmux

Conversation

@jlab13

@jlab13 jlab13 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Problem

Since #7522 (strict pinmux in pinctrl-rp1), the RP2040 bridge on the AI Camera (IMX500) can't use its fast transfer mode on Pi 5.

The fast_xfer data pin is the SDA line of the camera I2C bus. The I2C controller already owns this pin, so the GPIO request now fails at probe:

pinctrl-rp1 1f000d0000.gpio: pin gpio38 already requested by 1f00088000.i2c; cannot claim for pinctrl-rp1:609
rp2040-gpio-bridge 10-0040: Could not acquire fast_xfer-gpios

The camera still works, but all data goes to the RP2040 over plain I2C at 100 kHz. Uploading a network that is not cached yet becomes about 10 times slower.

Fix

The driver already switches both pins itself: it saves and restores their mux around a fast transfer, with the I2C bus locked. gpiolib was only used to make the data pin an output.

  • Commit 1: make the data pin an output through the RP1 registers, with the same steps as rp1_gpio_direction_output(). Only the clock pin is still requested from gpiolib. It is not muxed to anything, so strict mode allows it.
  • Commit 2: use of_property_present() for fast_xfer_requires_i2c_lock. The overlays give it a value (<1>), so of_property_read_bool() now prints a warning.

Testing

Pi 5, AI Camera on CAM0, kernel 6.18.59-v8-16k+ (rpi-update). The networks were not cached on the RP2040 yet. Time is the whole rpicam-hello -t 1000 run.

Driver Network Size Time
Without patch squeezenet1.0 1.6 MB 189.6 s
With patch posenet 1.66 MB 18.0 s
With patch higherhrnet_coco 2.1 MB 22.8 s
  • All blocks passed the driver's MD5 check. There was no unable to send data to device.
  • After each transfer GPIO38 is back on i2c6, and the camera keeps working.
  • Cached networks still load in about 2 s.

Not tested: CAM1, and kernels without strict pinmux.

checkpatch: the only warnings are the long log lines in the commit messages and the Fixes: commit id, because my clone is shallow.

🤖 Generated with Claude Code

jlab13 and others added 2 commits October 30, 2026 17:03
Since commit 11c58b5 ("pinctrl: rp1: enable strict pinmux mode"),
a pin that is muxed to a peripheral can no longer be requested through
gpiolib. The fast_xfer data pin of the AI Camera is the SDA line of the
camera I2C bus (GPIO38 on i2c6 for CAM0 on Pi 5), which the I2C
controller owns, so probe now fails to get it:

  pinctrl-rp1 1f000d0000.gpio: pin gpio38 already requested by 1f00088000.i2c; cannot claim for pinctrl-rp1:609
  rp2040-gpio-bridge 10-0040: Could not acquire fast_xfer-gpios

and every transfer to the RP2040 falls back to plain I2C, which makes
uploading a network that isn't cached yet about ten times slower.

The driver already saves and restores the RP1 mux of both pins around a
fast transfer, and drives them through the RIO registers with the I2C
bus locked. gpiolib was only used to switch the data pin to an output,
so do that through the registers directly, like
rp1_gpio_direction_output() does, and only request the clock pin, which
isn't muxed to anything.

Fixes: 11c58b5 ("pinctrl: rp1: enable strict pinmux mode")
Signed-off-by: JLab13 <jlab13@icloud.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The overlays set fast_xfer_requires_i2c_lock = <1>, so now that probe
gets that far, reading it with of_property_read_bool() warns:

  OF: /axi/pcie@1000120000/rp1/i2c@88000/spi@40: Read of boolean property 'fast_xfer_requires_i2c_lock' with a value.

Only its presence matters, so use of_property_present().

Signed-off-by: JLab13 <jlab13@icloud.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pelwell
pelwell requested a review from roliver-rpi November 12, 2026 13:51
@pelwell

pelwell commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This is all a bit horrible, but Linux makes this kind of runtime mux switching quite difficult. The pin owner - the I2C driver - does have a mechanism for doing so, but at present there is no way for a client of the I2C driver to do so. Given where we are with this driver, these commits don't make things significantly worse from a cleanliness perspective ("I am in blood stepped in so far", etc.), so we may as well get this committed and agree to never speak of it again.

@roliver-rpi

Copy link
Copy Markdown
Contributor

This looks fine to me.

@pelwell
pelwell merged commit 8cc8cd1 into raspberrypi:rpi-6.18.y Nov 12, 2026
11 of 12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Nov 17, 2026
kernel: spi: rp2040-gpio-bridge: Fix fast_xfer with strict RP1 pinmux
See: raspberrypi/linux#7728

kernel: drm/vc4: hdmi: Reset the MAI FIFO when preparing audio
See: raspberrypi/linux#7751

kernel: configs: Enable NET_SWITCHDEV and ADIN1110 support
See: raspberrypi/linux#7687

kernel: drm/vc4: Use the HVS field bit for interlaced scanout position
See: raspberrypi/linux#7763

kernel: xhci: drop the VL805 XHCI_EP_CTX_BROKEN_DCS cycle-state quirk
See: raspberrypi/linux#7754
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Nov 17, 2026
kernel: spi: rp2040-gpio-bridge: Fix fast_xfer with strict RP1 pinmux
See: raspberrypi/linux#7728

kernel: drm/vc4: hdmi: Reset the MAI FIFO when preparing audio
See: raspberrypi/linux#7751

kernel: configs: Enable NET_SWITCHDEV and ADIN1110 support
See: raspberrypi/linux#7687

kernel: drm/vc4: Use the HVS field bit for interlaced scanout position
See: raspberrypi/linux#7763

kernel: xhci: drop the VL805 XHCI_EP_CTX_BROKEN_DCS cycle-state quirk
See: raspberrypi/linux#7754
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