Skip to content

pinctrl: apple: clear bit 4 of the GPIO mode on the T6050 - #2004

Open
joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/pinctrl-mode-field
Open

joshuaswarren wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
joshuaswarren:dhp4/pinctrl-mode-field

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Status note: the head moved to a0609dc on 2026-11-18 (rebased onto integration/aurora 0abc2f3); CI is rerunning at that head. Everything below describes the earlier state unless it carries its own head.

[Joshua's agent]

Split out of #1605 (the K114c touch screen), one fix per PR. #1605 lists this PR as a dependency.

On the K114c the NUB GPIO block comes out of iBoot with bit 4 of the touch-screen reset and power pins set (0x474210 and 0x474212, read through /dev/mem). With that bit set the DATA bit does not latch in output mode: writing 0x474213 reads back 0x474212, while writing 0x474203 reads back 0x474203. direction_output wrote only bits 1-3 of the mode, so the pin stayed in a state where the driver's output value never took effect.

The change adds a hw table entry for apple,t6050-pinctrl (apple_gpio_t6050_hw, mode_hi). On a T6050 block the mode is bits 1-4: direction_input, direction_output and the interrupt mode writes clear bit 4, and get_direction and get read it. Every other SoC keeps the three-bit mode, because bit 4 was not checked on them. Modes 0-7 are unchanged, and a working output (the PERST# pin of the K114c, register 0x00076a03) has the bit clear. One file, drivers/pinctrl/pinctrl-apple-gpio.c. All three T6050 pinctrl nodes in the tree already list apple,t6050-pinctrl first.

Changed after review (RevAne421): the first form made the mode four bits wide for every SoC. It is now T6050 only.

Validated on, and reach

What ran where:

  • 14-inch M5 Max MacBook Pro (K114c, T6050): the register read-backs above, measured before the change. An earlier form of this change (every SoC, mode bits 1-4) was booted there in the HID: apple-mtp-kiwi: the K114c touch screen (needs #1568) #1605 stack: the touch firmware was accepted and Kiwi interface ready with status:0 appeared. This T6050-only form was not booted, and no finger events were checked.
  • 13-inch M1 MacBook (build only): drivers/pinctrl/pinctrl-apple-gpio.o compiles with and without the change with gcc 16.1.1 and W=1, no warnings, on a depth-1 checkout of integration/aurora (580e9119). Not a full tree build and not booted.

Not checked: any other Mac. The T6050 hw table also applies to the other two T6050 pinctrl blocks (AP and AOP); on those the mode bit 4 was not read. No M1, M2, M3, M4 or M5 Pro machine was run.

m tester (omarchy-m-testing.org): no feature row covers a GPIO mode; no tester run is linked to this change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T15:37:44.376713Z
We couldn’t complete this review. Comment @codex review to try again.
729b14a PR opened
🔒 Security Review ❌ Failed 2026-11-15T15:37:50.490769Z
We couldn’t complete this review. Comment @codex security review to try again.
729b14a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 729b14a
Model: zai/glm-5.3

Checked the one-line diff against the file at this head and the claims against the code. Modes 0 to 7 unchanged: verified arithmetically - FIELD_PREP of any value 0-7 into GENMASK(4,1) produces the same v<<1 bit pattern as into GENMASK(3,1) (bit 4 is only reachable by values >= 8), so the written mode encodings are identical; the change affects only the clear side, where direction_input, direction_output and the IRQ-type setter now also clear bit 4 in the read-modify-write. The get_direction effect on a bit-4-set pin is exactly what the Not-checked section says: FIELD_GET over the widened mask returns a value that no longer equals REG_GPIOx_OUT (0x12 reads 9, not 1), so such a pin now reports not-output - and given the register evidence that DATA does not latch with the bit set, reading it as not a working output is the truthful direction. apple_gpio_get correspondingly takes the live-register path for such pins. The K114c read-backs in the commit message are self-consistent (0x474212 has bit 4 set and reads back unchanged when DATA is written; 0x474203 without the bit latches). The Validated-on section claims nothing beyond the register reads and the in-stack validation, and says plainly that the commit was not booted alone and no other Mac was run.

Model: zai/glm-5.3 (live from lane_models.py this turn).

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on 729b14a
Model: anthropic/claude-sonnet

Independent review. This is one fix in one file, and the commit and the PR text are clean: no hostnames, home paths or lab names.

I read the driver at this head. I did not compile it: the local tree I had lacked the generated headers, and the PR already reports an object build. I did not boot anything. Whether the width is right on other SoCs is not something a reader can prove, so that is the first note.

No blocking items.

Non-blocking notes:

  1. Other SoCs are unproven, and the PR says so. In drivers/pinctrl/pinctrl-apple-gpio.c, REG_GPIOx_MODE is defined once (line 64) and every compatible shares it: apple,t8140-pinctrl, t8132, t6050, t8103 and the generic apple,pinctrl (lines 656-661). Neither the driver nor the DT binding gives per-SoC field widths, and mainline Linux and U-Boot both use GENMASK(3, 1). What I can show is that bit 4 is not claimed by any other field in the driver: PERIPH is bits 6:5 and PULL is bits 8:7. So the widening cannot overwrite a defined field. It does change behaviour on every Mac that has the driver:

    • apple_gpio_get_direction (line 227) and apple_gpio_get (line 241) now read a pin in mode 1 with bit 4 set as an input, where before it read as an output.
    • direction_input (line 261), direction_output (line 274) and the IRQ mask, unmask and set-type paths (lines 313, 325, 351) now clear bit 4 on write.

    If bit 4 carries a real function on another model, the first kernel write to that pin loses it. If someone can read one GPIO register dump from an M1 or M2 with the pins that use IRQs, that would settle it. If not, say in the commit message that only the M5 Max was checked. If you want it provable, the other option is a per-compatible mask that widens only for apple,t6050-pinctrl.

  2. Put the test line in the commit message. The commit body gives the register read-backs, but not what was run with the fix. The PR body has it (a 14-inch M5 Max MacBook Pro, touch reset takes effect with this commit in the HID: apple-mtp-kiwi: the K114c touch screen (needs #1568) #1605 stack, not booted alone, and a build-only check on a 13-inch M1 MacBook). The PR body is not part of the git history, so move one or two sentences of that into the commit.

  3. The Signed-off-by uses a users.noreply.github.com address. It matches the author, so it is consistent in this tree.

@joshuaswarren
joshuaswarren force-pushed the dhp4/pinctrl-mode-field branch from 729b14a to aea7476 Compare November 15, 2026 16:17
@joshuaswarren joshuaswarren changed the title pinctrl: apple: the GPIO mode field is four bits wide pinctrl: apple: clear bit 4 of the GPIO mode on the T6050 Nov 15, 2026
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on aea7476
Model: zai/glm-5.3

Re-review at the scoped head, read against the file at this commit. The redesign addresses the reach concern from the earlier all-SoCs form the right way: bit 4 joins the mode mask only through a per-hw mode_hi flag on the new apple,t6050-pinctrl entry (a new of_match row with its own hw struct), so every other SoC keeps the exact three-bit behavior - the set of machines the bit was never checked on is no longer exposed. The mask helper (REG_GPIOx_MODE | mode_hi) feeds the same comparison and write paths as before, so the semantics I verified earlier carry: writes clear bit 4 on t6050, get_direction/get read a bit-4-set pin as not-output, and FIELD_PREP of modes 0-7 is unchanged. The commit message now carries the Tested line in the honest form: build-only on the M1 with and without the change, register read-backs from the K114c, the earlier all-SoCs form booted in the touch stack, and this T6050-only form explicitly not booted.

Model: zai/glm-5.3 (live from lane_models.py this turn).

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on aea7476
Model: anthropic/claude-sonnet

Re-review after my earlier notes. Both are addressed. No blocking items.

What I checked in drivers/pinctrl/pinctrl-apple-gpio.c at this head:

  • Other SoCs are unchanged. The mask is REG_GPIOx_MODE | pctl->mode_hi, and mode_hi is zero unless the hw table sets it. On those SoCs the new read test (reg & GENMASK(3,1)) == FIELD_PREP(GENMASK(3,1), OUT) is the same test as the old FIELD_GET(...) == OUT. All the mode writes use the same mask as before.
  • Every mode access goes through the mask. direction_input, direction_output, irq_mask, irq_unmask and irq_set_type clear bit 4 on the T6050, and get_direction and get read it. No other place touches REG_GPIOx_MODE.
  • The T6050 entry really is picked. In the device trees at this head, both nub_gpio0 and pinctrl_ap list "apple,t6050-pinctrl" first, so device_get_match_data() returns the new table. The entry keeps no_regcache = true, so the cache behaviour of the earlier entry is preserved.
  • The commit message now has a Tested paragraph. It names the 14-inch M5 Max MacBook Pro for the register read-backs, a build-only check on a 13-inch M1 MacBook, and says this T6050-only form was not booted.

I did not compile or boot it.

Non-blocking notes:

  1. The wider mask applies to every T6050 pin controller on every T6050 machine, not only the K114c touch pins. That includes the AP controller and the other T6050 boards (J714, J716, J775, J873, K116). The commit message says only the K114c was checked, and nobody has looked at a register dump from the others. The effect there would be the same as on the K114c: bit 4 is cleared on the first mode write. It is far narrower than the first version.
  2. A comment would help. One line in apple_gpio_mode_mask() saying why the T6050 reads the mode as bits 1-4 would save the next reader a search.

On the K114c the NUB GPIO block comes out of iBoot with bit 4 of the
touch-screen reset and power pins set (0x474210, 0x474212 as read through
/dev/mem). With that bit set, the DATA bit does not latch in output mode:
writing 0x474213 reads back 0x474212, writing 0x474203 reads back 0x474203.
direction_output wrote only bits 1-3 of the mode, so the pin stayed in a
state where the driver's output value never took effect.

Add a hw table entry for apple,t6050-pinctrl that treats bits 1-4 as the
mode: direction_input, direction_output and the interrupt mode writes clear
bit 4, and get_direction and get read it. Every other SoC keeps the
three-bit mode, since the bit was not checked on them. Modes 0-7 are
unchanged, and a working output (the PERST# pin of the K114c, register
0x00076a03) has the bit clear.

Tested: drivers/pinctrl/pinctrl-apple-gpio.o builds with gcc 16.1.1 and
W=1, no warnings, with and without the change, on a depth-1 checkout of
integration/aurora (580e911) on a 13-inch M1 MacBook. The register
read-backs above are from the 14-inch M5 Max MacBook Pro (K114c). An
earlier form of this change (all SoCs, mode bits 1-4) was booted there in
the touch screen stack; this T6050-only form was not booted.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@joshuaswarren
joshuaswarren force-pushed the dhp4/pinctrl-mode-field branch from aea7476 to a0609dc Compare November 18, 2026 01:12
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.

1 participant