Skip to content

soc, nfc: the Pixel 9a's NFC clock pad as a PMU clock - #104

Closed
W4HO-ham wants to merge 7 commits into
derekross:omamobilefrom
W4HO-ham:tegu-nfc-clkpad
Closed

W4HO-ham wants to merge 7 commits into
derekross:omamobilefrom
W4HO-ham:tegu-nfc-clkpad

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

The ST54L asks the SoC for its reference clock on CLK_REQ. That reaches it only once the PMU follows the line: PMU 0x3e84 bit 16 (EXTPAD_EN), which Google's st21nfc sets from pmu_clk_pad = <0x3e84> and st,extpad_control_en. Without it the controller doesn't ACK its I2C address. I've been setting it from a local module; this does it the upstream way:

  1. dt-bindings: exynos-pmu: on google,zuma-pmu, #clock-cells clock 0 is the NFC pad.
  2. soc: gs101-pmu: when the zuma PMU node has #clock-cells, register that bit as a gate through the SMC regmap, and add 0x3e84 to zuma's access table.
  3. dt-bindings: nxp,nci: one optional clock.
  4. nfc: nxp-nci: i2c: devm_clk_get_optional_enabled().

Tested on the 9a (7.3.0-rc6-omamobile-tegu-s2mpg15-m1, with the PMU node's #clock-cells = <1> and the NFC node's clocks = <&pmu_system_controller 0>, the local module no longer loaded):

  • clk_summary shows zuma_pmu_nfc_clk_pad enabled by 25-0008;
  • the controller answers and polls.

A card read on this exact build waits for the owner tomorrow; the same bit set by the old module read cards today (#100). checkpatch --strict, W=1 of both objects and dt_binding_check of both schemas are clean on today's omamobile. Together with #100, the 9a's NFC node becomes compatible = "st,st54l", "nxp,nxp-nci-i2c" with this clock. That comes with the board DT.

@derekross

Copy link
Copy Markdown
Owner

Thank you. This is the right shape: the pad bit as a clock from the PMU, written through the SMC regmap, with nxp-nci taking an optional clock. It matches stock tegu's NFC node (pmu_clk_pad = <0x3e84>; st,extpad_control_en; in zuma-tegu-nfc.dtsi), and 0x3e84 goes into zuma's access table for reads and writes, with the write's return checked. The clock is registered only when the PMU node has #clock-cells, and husky's zuma.dtsi PMU node doesn't, so the Pixel 8 Pro gets only the table entry.

The checks pass on today's omamobile (clean merge, sign-offs, checkpatch, W=1 on both objects, CI's dt_binding_check). On the Pixel 7 Pro's config, only zuma_pmu_regmap_init and the three new clock ops change in gs101-pmu.o, and the gs101/gs201 functions are untouched.

Before I merge, two small fixes in soc: samsung: gs101-pmu: Provide zuma's NFC clock pad as a clock:

  1. The new code went in between the existing comment "zuma's TF-A refuses core power-down … PMU_INFORM0" and zuma_pmu_regmap_init(), so that comment now sits on top of struct zuma_pmu_clk_pad. Please move the new block above it.
  2. The new comment says that without EXTPAD_EN the ST54L "answers NCI but never finds a card", but the commit message says it doesn't ACK its I2C address, and nfc: nxp-nci: the ST54L (Pixel 9a) reads cards #100 puts the missing card down to the set-config. I think the comment should say what the message says.

And one wording point in the binding: "On google,zuma-pmu, clock 0 is the NFC controller's reference clock pad" also covers the Tensor G3, and only tegu's DT is cited. Please say Tensor G4, unless you have the Pixel 8 Pro's stock NFC node too.

The card read on this exact build that you mention is welcome when you have it.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Tested on the palmtop this morning (7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, with this series' clock pad as PMU clock 0 and the NFC node from #105): a credit card held on the back was detected twice (nci_start_poll: there is an active target). neard then logs "Error while reading NFC bytes", as expected for a payment card with no NDEF data. Discovery, the RF field and the target activation all work with the clock coming from the PMU provider.

@derekross

Copy link
Copy Markdown
Owner

Thank you for the card read. Discovery, the RF field and a target activation with the clock coming from the PMU provider is exactly what I wanted to see, and neard's "Error while reading NFC bytes" is what a payment card with no NDEF data gives. That closes the last open question on the behaviour.

The branch hasn't moved since my comment (it's still at 72a0c673a720), so the three small text fixes are still to do:

  1. In soc: samsung: gs101-pmu: Provide zuma's NFC clock pad as a clock, move the new block above the existing comment "zuma's TF-A refuses core power-down … PMU_INFORM0", which now sits on top of struct zuma_pmu_clk_pad.
  2. In the same commit, make the new comment agree with the commit message: without EXTPAD_EN the ST54L doesn't ACK its I2C address. "Answers NCI but never finds a card" is the missing set-config, which is nfc: nxp-nci: the ST54L (Pixel 9a) reads cards #100.
  3. In the binding, say Tensor G4 rather than google,zuma-pmu in general, unless you have the Pixel 8 Pro's stock NFC node.

The run was on your integration kernel (…-g991042e2eff3-dirty), so when you push, please add the blob ids of drivers/soc/samsung/gs101-pmu.c and drivers/nfc/nxp-nci/i2c.c from the tree you tested (git rev-parse HEAD:<path>). If the blobs differ only by the comment moves above, a sentence saying so is all I need. At this head they are e70ceb9c2066 and 6d81a9778435.

I re-ran the checks on today's omamobile: it merges cleanly, and sign-offs, checkpatch (no warnings) and W=1 on both objects all pass. On the Pixel 7 Pro's config, gs101-pmu.o changes only in zuma_pmu_regmap_init and the three new clock ops, and nxp-nci's i2c.o only in nxp_nci_i2c_probe. Once the three fixes are in, I'll merge it.

@derekross

Copy link
Copy Markdown
Owner

@W4HO-ham, a decision on how the PMU clock pad gets provided, since it affects this PR. This makes gs101-pmu.c a clock provider for zuma's pad at 0x3e84 (EXTPAD_EN, bit 16). My Pixel 7 Pro series (draft #146) drives the same register family (0x3e80 + 4n) on gs101 and gs201 through the existing clk-exynos-clkout driver, which is already upstream and already models these PMU clock outputs. Two drivers for one PMU block would be a duplicate mechanism, so I'd like one approach.

I'd like it to be clk-exynos-clkout. Could you rework this as a zumapro variant there (its compatible and the pad's register and bit in that driver's match data), rather than a clock provider in gs101-pmu.c? #146 shows the pattern for gs101/gs201 (455f0d4c6fb1, 3e89bf197973), and the DT side becomes a clock-controller node under the PMU like the other Exynos SoCs. The three comment fixes from 10-28 still apply to whatever carries over. Once that's in, #105 rebases on top and the NFC clock-pad hand step can go.

@derekross

Copy link
Copy Markdown
Owner

A gentle check-in on the clk-exynos-clkout rework, no hurry. #146 is still a draft, so please base the zumapro variant on its two commits (455f0d4, 3e89bf1). #105 will then need its PMU node changed to match.

derekross and others added 7 commits October 31, 2026 09:28
GS101 and GS201 have two clock output pads, CLKOUT0 and CLKOUT1, each
with its own PMU register (PAD_CTRL_CLKOUT0/1 at 0x3e80/0x3e84): bit 0
drives the clock onto the pad and bits 13:8 select its source, 0 being
the TCXO. Google's downstream kernel uses CLKOUT1 as the reference clock
of the NFC controller (google-modules/nfc st21nfc.c sets bit 0 while the
device is open; soc/gs cal-if clkout_gs201.c selects the TCXO).

The PMU on these SoCs only accepts writes through the secure monitor, so
the pads cannot use the existing MMIO mux and gate. Register one gate per
pad that goes through the PMU's regmap instead, parented to mux input 0
("clkout0", the TCXO), and expose them as clocks 0 and 1 of the PMU node.

The pads may feed devices that Linux doesn't describe, so they are marked
CLK_IGNORE_UNUSED and left as the bootloader left them until a consumer
enables them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
Google's sources disagree on PAD_CTRL_CLKOUTn bit 0: st21nfc.c sets it
while the NFC device is open, the cal-if clkout code clears it to enable
the clock. Add a writable parameter, gs101_pad_en_active_low, read at
every enable, disable and is_enabled, so both can be tried in one boot,
and pr_debug() the register after each change (a regmap read).

Bring-up only: drop the parameter once a board settles the polarity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Derek Ross <derekross@gmail.com>
The Tensor G4 PMU (google,zumapro-pmu) gates the NFC controller's
reference clock pad, which clk-exynos-clkout provides like the Exynos
CLKOUT clocks. Say what #clock-cells numbers there: clock 0 is that pad.

Only the Pixel 9a's devicetree is known to use it, so this names Tensor
G4 rather than google,zuma-pmu in general.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
Tensor G4's NFC controller takes its reference clock from a PMU pad,
PAD_CTRL 0x3e84, which clk-exynos-clkout drives through this regmap.
zuma's access tables admit only the registers in use, so add that one.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a's NFC controller (an ST54L) asks the SoC for its reference
clock on a clock request line, which the PMU follows only once EXTPAD_EN,
bit 16 of PMU register 0x3e84, is set; Google's st21nfc driver sets it
from its devicetree (pmu_clk_pad = <0x3e84>, st,extpad_control_en).
Without it the controller does not ACK its I2C address.

Provide that bit as clock 0 of the google,zumapro-pmu node, beside the
GS101 and GS201 pads. The pads' register, enable bit and source field
move from constants into per-variant descriptors, since this pad has a
different register and bit and no source field we know of; the GS101
pads keep their bring-up polarity parameter, which does not apply here.
A PMU node that names no clkout0 gets its pads as root clocks, since
this register's source is not described.

The register and bit were proven on the Pixel 9a with an earlier
provider inside the PMU driver (7.3.0-rc6-omamobile-tegu-s2mpg15-m1,
the NFC node's clocks = <&pmu_system_controller 0>): nxp-nci's probe
enabled the clock and the controller answered CORE_RESET and polled,
with nothing else touching the pad. This driver's version has only been
compiled so far.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
Some boards gate the controller's reference clock, or the SoC pad it
comes from, in a clock provider: the Pixel 9a's ST54L takes its clock
from a pad the PMU enables. Allow one clock.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
Take an optional clock and keep it enabled while the device is bound, for
boards whose controller clock (or the pad it comes from) is gated: the
Pixel 9a's ST54L needs the PMU's NFC clock pad.

Tested on the Pixel 9a: the clock is enabled at probe and the
controller answers and polls.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

W4HO-ham commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Reworked onto clk-exynos-clkout as you asked, on #146's two commits (455f0d4 and 3e89bf1, carried as 9e89cec and 018411b with your authorship), and force-pushed. Five commits of mine on top:

  • exynos-pmu binding: clock 0 on google,zumapro-pmu is the NFC reference clock pad.
  • gs101-pmu.c: only the access-table entry for 0x3e84 remains. The provider, its struct and the extra includes are gone, so nothing sits above the TF-A comment (your first point).
  • clk-exynos-clkout: a Tensor G4 variant for google,zumapro-pmu. Each pad is now a descriptor with its register, enable bit and source mask. GS101/GS201 keep 0x3e80+4n, bit 0 and bits 13:8. Tensor G4 gets 0x3e84, bit 16, and no source field. The comment and the message say the ST54L doesn't ACK its I2C address without EXTPAD_EN (your second point). Your bring-up polarity parameter applies only to the GS101 pads.
  • The nxp,nci binding and the nxp-nci-i2c reference clock commits, unchanged.

One fix came out of the test: the clkout0 parent is optional for pad variants, but of_clk_get_by_name() returns -EINVAL, not -ENOENT, when the node has no clock-names at all. So the first boot failed with "failed to get TCXO clock". It now looks the name up with of_property_match_string() first, and that's folded into the clock-out commit.

Tested on the palmtop today with #105's two DT commits on #96 (branch tegu-dt-nfc, kernel 7.3.0-rc6-omamobile-push1-gb45a0d400e49, defconfig + omarchy-mobile's fragment):

  • pmu-clkout0 is registered and enabled, with consumer 1-0008.
  • nfc0 lists all six protocols.
  • With omarchy-mobile#235's device package doing it at boot, neard and omamobile-nfc-open came up active and nfc0 was already polling.
  • 0 nxp-nci I2C errors.

The gs101 and gs201 paths are unchanged apart from the optional parent, which only affects a node that names no clock.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @W4HO-ham, for the rework. It's the shape I asked for, and the of_property_match_string() fix is a good catch: with no clock-names at all, of_clk_get_by_name() gives -EINVAL, so a "no parent is fine" check on -ENOENT alone would never have worked.

I went through it against my earlier points:

  1. The comment above the TF-A block: this is moot now. gs101-pmu.c gains only the ZUMA_PAD_CTRL_NFC_CLK define and its access-table entry, with nothing between the TF-A comment and its code.
  2. The comment and the message: both now say the ST54L doesn't ACK its I2C address without EXTPAD_EN.
  3. The binding: it names Tensor G4 (google,zumapro-pmu), not zuma in general.
  4. My two commits: they're carried unchanged (same patch ids as 455f0d4c6fb1 and 3e89bf197973), with my authorship and sign-off.
  5. The tested tree: your release's hash, b45a0d400e49, has the same tree as arm64: dts: exynos: google: zumapro-tegu: Add the NFC controller #105's head d2d5b382a2bf (git rev-parse of both trees gives 9e02fc9980fa). arm64: dts: exynos: google: zumapro-tegu: Add the NFC controller #105's seven copies of these commits are the same patches as this PR's. So your boot ran exactly this code, with the fix folded in, and no blob ids are needed.

Checks, run on today's omamobile (caf5f8a2b):

  • It merges cleanly. The sign-offs and prefixes pass, and checkpatch has no errors. Its only warnings are the Co-Authored-By: trailers on my two commits, which are mine to sort out, not yours.
  • W=1 builds of the three touched C files pass, and clk-exynos-clkout.c builds at each of the three commits that change it.
  • With these bindings, the 9a's DTB from arm64: dts: exynos: google: zumapro-tegu: Add the NFC controller #105 passes dt-validate with no messages. Against the base's bindings, the same DTB is refused for the NFC node's clocks, so the check really tests the new property.
  • CI is green on this head.

One small, optional point. zuma_pmu_registers is shared with the Pixel 8 Pro (google,zuma-pmu binds the same data), so its PMU regmap now admits 0x3e84 too. Nothing writes it there, because clock-out has no zuma entry, so it's harmless. If you touch the commit again, one sentence in its message saying so would help the next reader.

Nothing more is needed from you here. Before merging, I'll settle on my side how my two commits land alongside the rest of my Pixel 7 Pro NFC series. Then I'll rebase-merge this, after #96 or before it, since the two are independent. #105 then rebases onto it, leaving your two device-tree commits.

@derekross

Copy link
Copy Markdown
Owner

Pixel 7 Pro boot with this series: 7.3.0-rc6-omamobile-push1-gc96f2e2fdbc9, my integration kernel with my two older clock-out commits reverted and this PR's seven on top, so clk-exynos-clkout.c, gs101-pmu.c and nxp-nci/i2c.c match this head exactly, plus my gs201 PMU clock commit. phone-smoke passed every row. pmu-clkout0 and pmu-clkout1 register under the gs201 PMU, the 7 Pro's ST54J takes pmu-clkout1 (enabled, 24.576 MHz), st_nci_i2c binds and nfc0 is up with neard running. So the refactored probe works on gs201 with and without a consumer.

When this merges I'll change the trailer on my two commits from Co-Authored-By: to Assisted-by: LLM, as Documentation/process/coding-assistants.rst asks, so nothing is needed from you. #105's copies drop out by themselves when it rebases.

@derekross

Copy link
Copy Markdown
Owner

Landed on omamobile as 5d0c3dc..8e84093: your five commits as they are, my two clock-out commits with Assisted-by: LLM in place of the Co-Authored-By trailer, and my gs201 PMU clock commit on top, as planned. Thank you, @W4HO-ham. #105 can rebase onto omamobile now, and the duplicate commits will drop out.

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