Skip to content

gpio: macsmc: Take the gP13 write-only templated output from the device tree - #2305

Draft
RyanTheTide wants to merge 6 commits into
mainfrom
sweep/macsmc-gpio
Draft

RyanTheTide wants to merge 6 commits into
mainfrom
sweep/macsmc-gpio

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

gpio-macsmc drives gP13 with its command template (0x00800000 | level) and reports the last successful write as its level, because no readback of that line is established. This is selected by machine: apple_t8132_managed_radio() || of_machine_is_compatible("apple,j716s") at drivers/gpio/gpio-macsmc.c:530 (from 5f9edb2, with J716s added later). The template and the missing readback are properties of the board's line. The driver already takes such templates from the device tree (apple,output-templates) for other lines, for example gPe on the J616s.

Change

  • New binding property apple,write-only-outputs on apple,smc-gpio: GPIO numbers from apple,output-templates that cannot be read back. Reading one reports the last level written, or -EOPNOTSUPP before the first write.
  • The DTs now describe gP13 with apple,output-templates = <0x13 0x00800000> and apple,write-only-outputs = <0x13>. This goes in t8132-jxxx.dtsi, which every T8132 board includes (J604, J623, J624, J713, J715, J773g), the same set apple_t8132_managed_radio() matched, and in t6050-j716s.dts.
  • The driver drops the J713-specific path. The old machine match stays only as a fallback for device trees without the property (kernel-only updates with the boot loader's older DTB): there gP13 gets the old template and write-only. A DT that describes gP13 always wins; the fallback goes once a boot loader release ships the DTB with the property. A templated line that is not marked write-only still reads back the output latch, as before. The write and the cached level stay under one lock, and a failed write keeps the previous level.
  • The macsmc-j713.py selftest now drives the line as the DT describes it, and also covers a readable templated line.

Credit: Eryk Wieliczko wrote the J713 gP13 path (5f9edb2). apple_t8132_managed_radio() keeps its other users (apple-dart, pcie-apple).

Testing

  • Compiles clean with the W=1 warning set (drivers/gpio/gpio-macsmc.o), and the DTBs build. See below.
  • tools/testing/selftests/drivers/apple/macsmc-j713.py: ok 1 - 2321 production SMC GPIO checks passed (host build with a mocked SMC).
  • The DT diff below shows the gpio properties on all seven boards and on no others (the J716s also shows the lid property from the companion input change in the combined build).
  • Not run on hardware yet.

Still to run

  • J616s: unaffected (it has no gP13 template). Wi-Fi still comes up: ip link shows the wlan interface. Expected: unchanged.
  • M4 Air (J713/J715) or J716s, if one is available: Wi-Fi/BT come up, and gpioinfo on the macsmc-pmu-gpio chip shows line 19 (0x13) as an output.
  • Neo, M1 Pro, M2: no DT change. Smoke check only: Wi-Fi up.
DT diff (dtc -I dtb -O dts, before and after)

Every Apple .dts at the base and at this branch, built with cpp+dtc and decompiled; only these boards differ:

### t6050-j716s
+			apple,lid-open-wake-holdoff-ms = <0x7d0>;
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j604
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j623
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j624
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j713
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j715
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
### t8132-j773g
+				apple,output-templates = <0x13 0x800000>;
+				apple,write-only-outputs = <0x13>;
Build log

Compiled with the release config's kbuild flags plus the W=1 warning set (clang, -fsyntax-only):

== drivers/gpio/gpio-macsmc.c  base: 0 warnings, 0 errors | patched: 0 warnings, 0 errors

The full kbuild object build in a clean O= tree is pending and will be added here.

Some templated SMC outputs have no established readback of their output
latch. Let the device tree list them, so the driver reports the level it
last wrote instead of querying the SMC.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…output

On the M4 Macs (J604, J623, J624, J713, J715, J773g) and on the J716s,
the radio's reg-on (the J716s: the N1's power) is the SMC's gP13, driven
with the ADT's pKW4("gP13", 0x00800000) template: 0x00800000 | level.
gpio-macsmc selects that by machine today. Describe it on the boards'
SMC GPIO node instead, with apple,output-templates, and mark it
apple,write-only-outputs, as no readback of the line is established.

t8132-jxxx.dtsi is included by every T8132 board, which is exactly the
set the driver's apple_t8132_managed_radio() matches.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Commit 5f9edb2 ("gpio: macsmc: use the qualified J713 radio
action") drives gP13 with its 0x00800000 template, and reports the last
successful write as its level, on the boards apple_t8132_managed_radio()
matches, and since then also on the J716s. The template and the
missing readback are properties of the board's line, which the device
tree already describes for other lines with apple,output-templates.

Take the line from apple,output-templates and the missing readback from
apple,write-only-outputs, which the boards now describe, and drop the
board list. A templated line the device tree does not mark write-only
keeps reading the output latch back, as before. The write and the
cached level stay serialised under one lock, and a failed write keeps
the previous level.

The selftest now drives the line as the device tree describes it,
rather than through the board list; as it stood it no longer ran, as
the J716s match was not in its list of known boards.

Fixes: 5f9edb2 ("gpio: macsmc: use the qualified J713 radio action")
Suggested-by: Eryk Wieliczko <eryk@wieliczko.ninja>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 2.

The new path itself is correct (checked at 43c0796). The write-only bit is only accepted on a line that already has a template (drivers/gpio/gpio-macsmc.c:512-515). A write and the cached level change under output_lock, and a failed write keeps the old level (:283-295). Templated lines that are not marked write-only, such as gPe on the J616s, still read back the latch as before.

  1. drivers/gpio/gpio-macsmc.c:541 (where smcgp->j713 = ... was removed): a kernel with this change booted with a DTB that predates it no longer has a template for gP13. On the J604/J623/J624/J713/J715/J773g and the J716s, pwren-gpios = <&smc_gpio 0x13 ...> (t8132-jxxx.dtsi, port00) then reaches the generic path at :330. That path writes CMD_OUTPUT | value (0x01000000 | level), which is not the line's 0x00800000 template, so Wi-Fi (and on the J716s the N1) loses power control. Kernel-only updates with a boot-loader DTB are normal on these Macs. Keep today's behaviour as the fallback, used only when the node has no apple,output-templates entry for 0x13: take the template and write-only from the existing machine check there, and say in a comment that it goes away once a boot loader release ships the DTB with the property. A DT that has the property then always wins.
  2. The PR does not merge. The base has since changed tools/testing/selftests/drivers/apple/macsmc-j713.py (6de2bf9 adds the J716s to the known boards, which the description lists as still broken) and t8132-jxxx.dtsi. Rebase, and drop the selftest wording about the J716s now that the base fixes it.
  3. No hardware run. This is the radio power line on seven boards, and the J713 is available. "Wi-Fi up" alone does not show the template was used. Show gpioinfo reporting line 0x13 as an output, and show that a read before the first write returns -EOPNOTSUPP rather than a latch value.

HW row: on the rebased head: J713 with the new DTB and again with the previous DTB (fallback). Both get wlan up, BT up, and Wi-Fi back after 3x s2idle, with gP13 reported as an output. Plus J616s Wi-Fi unchanged, 0 AVC, 0 failed units, no new kernel errors. A J716s owner boot with the N1 up would cover the T6050 side.

Assisted-by: LLM (Claude:Opus 5.5)

Conflict: tools/testing/selftests/drivers/apple/macsmc-j713.py (kept the PR's DT-template test; integration's J716s board entry is covered by the J716s apple,write-only-outputs DT the PR adds).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora (d1b022d); conflict in tools/testing/selftests/drivers/apple/macsmc-j713.py resolved (kept the DT-template test; the J716s case is covered by its new DT), gpio-macsmc.o, t6050-j716s and all t8132 dtbs build (only the two new properties differ from integration) and macsmc-j713.py passes.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The rebase is done and it merges cleanly. Still open from review: keep today's gP13 template as a fallback when the device tree has no apple,output-templates entry for 0x13 (kernel-only updates with an older DTB otherwise lose Wi-Fi power control), and a J713 row showing gpioinfo with line 0x13 as an output and Wi-Fi coming up.

@ja-818

ja-818 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

One more piece for the J716s: on T6050, macsmc doesn't register the apple,smc-gpio (gP) bank at all; it's only in the non-T6050 cell list. So pwren-gpios = <&smc_gpio 0x13 ...> on the J716s's N1 port defers pcie-apple's port probe forever (no PCIe, Wi-Fi or Bluetooth on my J716s). Dropping pwren-gpios makes it work; registering the bank with the T6050 described cells should be the proper fix. I have that change built (ja-818/linux macsmc-t6050-gp-gpio) and will test it on my J716s before sending it.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A kernel-only update boots with the boot loader's DTB, which on the
T8132 boards and the J716s does not list gP13 in apple,output-templates
yet. Without a template the radio power line would take the generic
CMD_OUTPUT write, which is not this line's command, and Wi-Fi (on the
J716s the N1) would lose power control.

When the gP bank has no template for gP13 on those machines, use the
one the driver used before: 0x00800000 with the level in the low bits,
write-only. A device tree that describes gP13 always wins. The fallback
goes once a boot loader release that ships the DTB with the property is
the oldest one supported.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forward-merged main f02bd68 (c93b83a, clean) and addressed the 11-21 review in 8ff4c11:

  1. Old-DTB fallback: when the gP bank has no apple,output-templates entry for 0x13 on the machines the old code matched (apple_t8132_managed_radio() or J716s), probe installs the old 0x00800000 template as write-only and logs it once. A tree with the property always wins; the comment says the fallback goes once a boot loader release ships the DTB with it.
  2. Merge done; the selftest wording about the J716s is dropped from the description (main's 6de2bf9 covers it).

Local: drivers/gpio/gpio-macsmc.o W=1 (arm64 LLVM) no warnings; tools/testing/selftests/drivers/apple/macsmc-j713.py: ok 1 - 2321 production SMC GPIO checks passed.

Still needed (review point 3): J713 rows with this head's DTB and again with the previous DTB (fallback path): wlan and BT up, Wi-Fi back after 3x s2idle, gpioinfo shows line 0x13 as an output, and a read before the first write returns -EOPNOTSUPP; plus J616s Wi-Fi unchanged. Queued for the lab.

@RyanTheTide

RyanTheTide commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hardware row at exact head 8ff4c1101913 on the J616s (regression only): PASS.

  • Wi-Fi up with gateway ping ok and BT powered on boot; gateway ping ok again after one s2idle (BT not re-checked then); nothing in the kernel log about gP13 or a missing template (expected: this Mac doesn't use that path).
  • Not covered: the J713 rows with and without this head's DTB.

How: one combined test kernel for eight PRs, not this PR alone. Kernel 7.3.0-aurora-ci = main d0684a06 + merge commits of linux#2371 59f4d06c, #2350 5f18911e, #2361 cbabdb3a, #3741 5504c96d, #1814 775f31d2, #2305 8ff4c110, #2712 b6887f88, #2398 75b30c6c (all merged clean, test commit eb57c039, cloud build https://github.com/aurora-silicon/linux/actions/runs/47486534991). Booted as a one-shot on the lab J616s (M4 Pro, T6040, 26.6.2 stub) with this kernel's own J616s DTBs (plain and tether variants) in a trial Stage 2 (live aura 1.0.0b19 + U-Boot, only the DTBs swapped), default cmdline, silent. PR-kernel boots: 0 error-level kernel lines, 0 AVC, 0 failed units. Note: the #1814 hibernation dry run reset this kernel once (see linux#1814); the rest ran on a re-armed boot of the same kernel. Saved default restored after.

This branch has not been deployed

No deployments
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