Skip to content

pinctrl: rp1: Make IRQ usage set a pin to an input - #7526

Open
pelwell wants to merge 2 commits into
raspberrypi:rpi-6.18.yfrom
pelwell:is7520
Open

pinctrl: rp1: Make IRQ usage set a pin to an input#7526
pelwell wants to merge 2 commits into
raspberrypi:rpi-6.18.yfrom
pelwell:is7520

Conversation

@pelwell

@pelwell pelwell commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This is a less invasive solution to the problem that requesting that
a GPIO be used as an interrupt from Device Tree (not going via
gpio descriptors) does not automatically make it an input. This can lead
to interrupt storms.

It relies on there being an implementation of the function_is_gpio
method, hence the inclusion of Nicolai's patch from
#7522.

See: #7520

nbuchwitz and others added 2 commits July 28, 2026 17:04
Pins claimed for a peripheral function can be taken over through the
GPIO chardev, which rewrites FUNCSEL. On Pi 5 reading the USB
overcurrent pin this way trips the overcurrent latch and disables all
USB ports, and requesting GPIO 42 as output cuts VBUS entirely.

Enable strict pinmux so GPIO requests on function pins are rejected.
Implement function_is_gpio so pins muxed as GPIO, including hogs and
legacy brcm,function maps, stay requestable. This matches the BCM2712
pinctrl-brcmstb driver.

Link: raspberrypi#5870
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
This is a less invasive solution to the problem that requesting that
a GPIO be used as an interrupt from Device Tree (not going via
gpio descriptors) does not automatically make it an input. This can lead
to interrupt storms.

It relies on there being an implementation of the function_is_gpio
method, hence the inclusion of Nicolai's patch from
raspberrypi#7522.

See: raspberrypi#7520

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@nbuchwitz

Copy link
Copy Markdown
Contributor

Agreed, this is a cleaner and less instrisive approach.

But .strict = true exposed a problem in rp1.dtsi: spi0's cs-gpios pins (gpio7/8) stay muxed to function = "spi0", so cs-gpios can't claim them and the overlay fails.

nbw@rpicm5-build ~ $ pinctrl get 24    
24: no    pd | -- // GPIO24 = none
nbw@rpicm5-build ~ $ sudo pinctrl set 24 op dl
nbw@rpicm5-build ~ $ pinctrl get 24           
24: op dl pd | lo // GPIO24 = output
nbw@rpicm5-build ~ $ sudo dtoverlay sc16is75x-spi sc16is752 spi0-0 int_pin=24 xtal=14745600
nbw@rpicm5-build ~ $ pinctrl get 24                                                        
24: op dl pd | lo // GPIO24 = output

nbw@rpicm5-build ~ $ sudo dmesg -lwarn,err
[    0.380877] dwc2 1000480000.usb: supply vusb_d not found, using dummy regulator
[    0.380905] dwc2 1000480000.usb: supply vusb_a not found, using dummy regulator
[    2.617280] hci_uart_bcm serial0-0: supply vbat not found, using dummy regulator
[    2.617325] hci_uart_bcm serial0-0: supply vddio not found, using dummy regulator
[    3.197554] raspberrypi-firmware soc@107c000000:firmware: Request 0x00030097 returned status 0x80000001
[    3.218333] Unable to find swap-space signature
[    3.361553] nvme nvme0: using unchecked data buffer
[   46.281111] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /axi/pcie@1000120000/rp1/spi@50000/spidev@0/status
[   46.281128] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /axi/pcie@1000120000/rp1/spi@50000/status
[   46.289400] pinctrl-rp1 1f000d0000.gpio: pin gpio8 already requested by 1f00050000.spi; cannot claim for pinctrl-rp1:577
[   46.289414] pinctrl-rp1 1f000d0000.gpio: error -EINVAL: pin-8 (pinctrl-rp1:577)
[   46.289417] dw_spi_mmio 1f00050000.spi: error -EINVAL: problem registering spi host
[   46.289462] dw_spi_mmio 1f00050000.spi: probe with driver dw_spi_mmio failed with error -22

I've added d9118ca to #7522 and with this, it works:

nbw@rpicm5-build ~ $ pinctrl get 24                                             
24: no    pd | -- // GPIO24 = none
nbw@rpicm5-build ~ $ sudo pinctrl set 24 op dl
nbw@rpicm5-build ~ $ pinctrl get 24    
24: op dl pd | lo // GPIO24 = output
nbw@rpicm5-build ~ $ sudo dtoverlay sc16is75x-spi sc16is752 spi0-0 int_pin=24 xtal=14745600
nbw@rpicm5-build ~ $ pinctrl get 24    
24: ip    pn | lo // GPIO24 = input

nbw@rpicm5-build ~ $ sudo dmesg -lwarn,err                                                 
[    0.279913] dwc2 1000480000.usb: supply vusb_d not found, using dummy regulator
[    0.279941] dwc2 1000480000.usb: supply vusb_a not found, using dummy regulator
[    2.360939] hci_uart_bcm serial0-0: supply vbat not found, using dummy regulator
[    2.360991] hci_uart_bcm serial0-0: supply vddio not found, using dummy regulator
[    2.866494] raspberrypi-firmware soc@107c000000:firmware: Request 0x00030097 returned status 0x80000001
[    2.924515] Unable to find swap-space signature
[    3.046952] nvme nvme0: using unchecked data buffer
[   25.704297] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /axi/pcie@1000120000/rp1/spi@50000/spidev@0/status
[   25.704314] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /axi/pcie@1000120000/rp1/spi@50000/status

Also picked f0d34ae as the remaining drive-by patch from my original PR.

@pelwell

pelwell commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

It's issues like this, considering the large number of overlays, that have made me reluctant to enable strict mode in our kernels. But maybe now is the time.

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.

2 participants