Skip to content

pinctrl: samsung: Enable GPIO direction readback on Tensor G4 - #270

Open
kdegeek wants to merge 1 commit into
derekross:omamobilefrom
kdegeek:samsung-pinctrl-get-direction
Open

kdegeek wants to merge 1 commit into
derekross:omamobilefrom
kdegeek:samsung-pinctrl-get-direction

Conversation

@kdegeek

@kdegeek kdegeek commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

Enable get_direction() through the zumapro pin controller data shared by the Pixel 9 Pro Fold and Pixel 9a, for the eight controllers zumapro.dtsi describes. GSACORE0-3 and GSACTRL, which have no node yet, stay without it. The callback reads the pin's function from the bank's CON register with the bus clock enabled. It reports GPIO output for function 0x1 and input for other functions.

The shared GPIO proxy needs this callback for gpp10-2, the main camera reset shared by the IMX787 and its LC898129 lens actuator. The missing callback produced three gpiolib.c:431 warnings at boot and another when a driver requested the line.

Evidence

Earlier Comet testing with the unconditional callback found no gpiolib.c:431 warnings at boot, when the reset consumers bound, or when reading /sys/kernel/debug/gpio. The line still read as an output driven low.

On November 18, 2026, Comet's 7.3.0-rc6-omamobile-comet-rc2-cand21 had the unconditional samsung_gpio_get_direction in kallsyms. Across two boots with all interrupt consumers bound, dmesg had zero “tried to flag a GPIO set as output for IRQ” lines.

V2 merges cleanly onto 26867fc4e. checkpatch --strict reported zero warnings or checks, and pinctrl-samsung.c and pinctrl-exynos-arm64.c both built with W=1.

Merge scope

GPIO chip registration reads each pin on controllers that opt in. On those controllers, gpiochip_lock_as_irq() also reads the pin and can return -EIO for a push-pull output before exynos_irq_request_resources() switches it to EINT. That can affect an IRQ on a pin the bootloader left configured as an output.

Other SoCs retain their existing behaviour, including gs101's secure pinctrl_gsactrl. A Pixel 9a boot check is still pending.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thanks, Nate. The callback is right as far as it goes: it reads the same CON field samsung_gpio_set_direction() writes, takes the bus clock around the read, and writes nothing. The gate passes here too (clean merge, sign-off, checkpatch --strict with 0 warnings, W=1). CI hasn't run because it waits for my approval as a first contribution; I'll approve it.

I can't take it as it is, because it changes more than the warning, on every phone that uses this driver:

  1. gpiolib calls get_direction() for every line when a chip registers (gpiochip_add_data_with_key()), so every pin controller on every phone gets one CON read per pin at probe, where today registration reads nothing. On gs101 that includes pinctrl_gsactrl at 0x17940000, which gs101.dtsi leaves enabled and no board on omamobile disables. That controller belongs to the secure world: reading its CON from Linux raised a synchronous external abort on the Pixel 6 Pro (device/raven/MODEM-PLAN.md, section 3). As I read it, this patch would do that read during probe at every boot of the Pixel 6, 6 Pro and 6a. I haven't run it; the code path and the register are what I'm going by.
  2. gpiochip_lock_as_irq() starts refusing outputs. With a get_direction() it reads the pin and returns -EIO ("tried to flag a GPIO set as output for IRQ") when the function is output, and exynos_irq_request_resources() calls it before it switches the pin to the EINT function. An interrupt taken with interrupts-extended alone on a pin the bootloader left as an output works today and would fail after this.
  3. It isn't behind your own match data. Shared drivers here leave the other phones as they are unless the change has a reason and a run on them (CONTRIBUTING §6.2), and the warning needs a shared GPIO, which no board on omamobile has: I found no gpiolib.c:431 in about a thousand logs from the other phones.

What I'd like: set the callback only for the pin controllers that ask for it. A flag in struct samsung_pin_ctrl, set in the zumapro controllers' data, and gc->get_direction = samsung_gpio_get_direction in samsung_gpiolib_register() when it is set, would do. That reaches the Pixel 9a too (same data), so please say so in the message; I'll ask a 9a owner for one boot. In the message, please also describe the interrupt-path change in point 2, and add to your evidence that dmesg has no "tried to flag a GPIO set as output for IRQ" with all your interrupt consumers bound.

There is no hurry on this one: the camera device tree that shares gpp10-2 isn't in a pull request yet, and the warning is harmless until then. If you'd rather send it with the camera series, that works for me. And when it goes to linux-samsung-soc, the gs101 question in point 1 is worth raising there yourself.

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI has run on this head and passes: it merges cleanly onto today's omamobile, the sign-off, prefix and checkpatch --strict checks are clean, and pinctrl-samsung.c builds with W=1. The one skipped line is "device trees: none touched", which is right for this change. That is the same result I had locally; it covers the build, and the three points in my comment above are about what the callback does at probe on the other phones, so they stand as they are.

The Samsung GPIO chip has no get_direction() callback. gpiolib asks
for the direction of a line when a shared GPIO proxy registers its
chip and when a consumer requests a line through the proxy. It warns
at drivers/gpio/gpiolib.c:431 each time the callback is missing.

On the Pixel 9 Pro Fold, this produces three warnings at boot and one
more each time a driver takes gpp10-2, the reset GPIO shared by the
main camera and its lens actuator.

Read the function field of the bank's CON register, which
samsung_gpio_set_direction() writes. Report function 0x1 as GPIO
output and input or alternate functions as GPIO input.

Opt in through the zumapro pin controller data used by the Pixel 9
Pro Fold and the Pixel 9a, for the eight controllers zumapro.dtsi
describes (ALIVE, CUSTOM, FAR, HSI1, HSI2, HSI2UFS, PERIC0, PERIC1).
gpiolib reads each line's direction when the GPIO chip registers. The
GSACORE and GSACTRL entries, which have no node yet, stay without it,
as do the other SoCs, including gs101, whose secure pinctrl_gsactrl
must not be read by Linux.

With the callback, gpiochip_lock_as_irq() reads the pin direction and
returns -EIO for a GPIO configured as a push-pull output ("tried to
flag a GPIO set as output for IRQ"). exynos_irq_request_resources()
calls it before switching the pin to EINT, so a pin left as an output
by the bootloader can now be rejected at IRQ request time.

Earlier Pixel 9 Pro Fold testing with the unconditional callback
found no gpiolib.c:431 warning at boot, when the shared reset's
consumers bound, or when reading /sys/kernel/debug/gpio. The line
still read as an output driven low. On 2026-11-18, the Comet
integration kernel 7.3.0-rc6-omamobile-comet-rc2-cand21 had the
unconditional samsung_gpio_get_direction in kallsyms. Across two
boots with all interrupt consumers bound, dmesg had zero "tried to
flag a GPIO set as output for IRQ" lines.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
@kdegeek
kdegeek force-pushed the samsung-pinctrl-get-direction branch from 67cddd1 to 6d69ad6 Compare November 18, 2026 19:29
@derekross

Copy link
Copy Markdown
Owner

Decided on the open choice from my review: please gate the callback to the Fold's SoC (zumapro), so no other phone's behaviour changes with this commit. Widening it to every SoC can be its own change later, with a boot on the 7 Pro.

@kdegeek kdegeek changed the title pinctrl: samsung: Implement the get_direction() callback pinctrl: samsung: Enable GPIO direction readback on Tensor G4 Nov 18, 2026
@kdegeek

kdegeek commented Nov 18, 2026

Copy link
Copy Markdown
Author

Derek,

The current head, 6d69ad699, pushed at 19:29Z just before your decision, already does this. The callback is set only for zumapro, and no other SoC's data changes.

I moved get_direction() behind a flag in struct samsung_pin_ctrl, set in zumapro_pin_ctrl[] only, so it reaches the Fold and the 9a, and the message says so. I set it only on the eight controllers zumapro.dtsi describes (ALIVE, CUSTOM, FAR, HSI1, HSI2, HSI2UFS, PERIC0, PERIC1). Those are the ones the Fold probes and the evidence covers. The GSACORE and GSACTRL entries have no node yet, and I haven't checked whether zumapro's GSACTRL is secure the way gs101's is, so they stay without the flag. The other SoCs keep their existing probe and IRQ behaviour, including gs101's pinctrl_gsactrl.

The commit message now explains the IRQ path. With the callback, gpiochip_lock_as_irq() reads the pin direction and can return -EIO for an output before exynos_irq_request_resources() switches the pin to EINT.

On November 18 I checked two Comet boots on 7.3.0-rc6-omamobile-comet-rc2-cand21. That kernel has the unconditional samsung_gpio_get_direction in kallsyms. All interrupt consumers were bound, and neither boot logged “tried to flag a GPIO set as output for IRQ”. The revised patch has been checked offline: a clean merge onto omamobile, checkpatch --strict with no warnings or checks (it only flags the sign-off I still have to add), and both files build with W=1.

I'll raise the gs101 secure-controller question with linux-samsung-soc when I send this upstream.

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