Repository navigation
nfc: nxp-nci: Turn the ST54L's NFC mode on after init - #131
Conversation
The ST54L in the Google Pixel 9a speaks plain NCI over I2C with an enable line and an interrupt, the transport the nxp-nci driver implements, rather than the NDLC framing of ST's ST21NFCB family (st,st21nfcb-i2c), whose initialisation timed out on it. Add it as a compatible with nxp,nxp-nci-i2c as the fallback. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
|
With this driver as the boot driver on the palmtop (fresh boot, screen on, neard polling): a contactless payment card held on the upper back showed up in neard within 4 s as a Type 4A tag, ISO-DEP, ReadOnly false ( |
|
Thank you, @W4HO-ham. This is a really good find. The A/B/C table on derekross/omarchy-mobile#132 is what settled it: the same NACK at 3 s with no sleep at all, with and without the set-config, with and without quick retries. And the fix follows ST's own HAL instead of a workaround. The card read this morning with this driver as the boot driver is good news too. The checks pass on today's A few things before it merges:
Two small things:
Please also paste a Thanks again. A controller that goes quiet two seconds after init is the kind of bug that eats a week, and you tracked it down in a night. |
5f77a71 to
40ae7c0
Compare
|
Thanks for the careful read. All of it is in at 40ae7c0 (the branch is force-pushed, same three commits):
Small things: the message is reflowed, and the HAL link now points at commit The smoke report from the boot with this module as the boot driver is in the description. |
|
Thank you, @W4HO-ham. Everything I asked for is in, and the timing argument for the reset is a good substitute for the debug line: a skipped reset would show up as a failed open after 5 s, and six power-ons at about 60 ms rule that out. I went through the new head against each point:
The checks pass on today's A source for the set-config values. I think I found a public one for three of the four. Google's AOSP tree for the Pixel 7 and 7 Pro has the same three values in The one thing I'm waiting for is the card read on this head that you mentioned. Once it's posted here, I'll merge. Thanks again. The fix is small, follows ST's own sequence, and the history of how you got there is all on the record. |
|
Thanks. Agreed on all four, and on the opposite-order case: the mode response completes nothing on success, so a notification that arrives first can't answer the wrong request. The pantah TOTAL_DURATION 500 ms isn't in either HAL file. It's the NFC stack's default poll-loop duration (libnfc-nci's The card read on this head is the one thing left; it needs the owner's hand and is queued for when he's back today. |
|
The card read on this head (core.c blob c96704ddd480, the boot driver in updates/nfc), 2026-10-30 morning on the palmtop: a contactless payment card held on the upper back was found within a 60 s initiator poll (nfctool: Targets found for nfc0, Tags: [ tag0 ]), no I2C NAKs, the usual unknown ntf 0x107 the only kernel line. It took three tries to get there, and the reason is worth recording for #100: on this boot the NFC clock pad (PMU 0x3e84) was off. The palmtop now boots from its device package, and the hand script that used to set the pad at boot no longer runs, while the driver still came up over I2C and answered every NCI command, so neard reported Powered and Polling with nothing ever found. Setting the pad (tegu-nfc-clkpad extpad=1: 0x3e84 read 0x00000000, written 0x00010000) and rebinding the driver made the very next poll find the card. So a controller that talks NCI but never sees a tag is the clock pad, and #100's in-driver handling is what removes the trap. |
|
Thank you, @W4HO-ham, for the card read on this head. That was the last thing I was waiting for, and the clock pad story is worth having on the record for the 9a. Before I merge, the second commit's message needs the two changes from your reply: TOTAL_DURATION 500 ms is libnfc-nci's default poll duration rather than something the 9a's HAL configuration sets, and a One question, not for this PR: the "tegu-nfc-clkpad extpad=1" step writes PMU register 0x3e84. Where does that tool live, and does it go through the kernel's PMU regmap rather than |
|
Both edits at merge are fine with me, thanks. On the clock pad: the tool is a bring-up kernel module, tegu-nfc-clkpad.ko (source in my logs, logs/tegu-nfc-20261026/clkpad/tegu-nfc-clkpad.c, not in a repository), not a userspace write. It takes the kernel's SMC-backed PMU regmap with exynos_get_pmu_regmap() and does one regmap_update_bits() on 0x3e84 (EXTPAD_EN | PAD_EN), reads the register back, logs both values and is removed again; nothing touches /dev/mem. On the palmtop a hand unit runs |
The ST54L answers NCI on nxp-nci's transport and polls, but never reports a target: in 25 s of discovery with a contactless card held on the Pixel 9a, no RF_INTF_ACTIVATED_NTF came. ST's HAL sends a CORE_SET_CONFIG after CORE_INIT (proprietary parameters 0xa1, 0xa2 and 0x80, which the 9a's own HAL configuration sets, and TOTAL_DURATION 500 ms, libnfc-nci's default poll duration, NFA_DM_DISC_DURATION_POLL). Send the same from post_setup when the device is st,st54l. Tested on the Pixel 9a (7.3.0-rc6-omamobile-tegu-s2mpg15-m1, with the same command behind a module parameter in a debug build): the set-config answers status 0, and the held card activates (ISO-DEP over NFC-A, 15 activations in 45 s) and neard lists it as a tag. Link: https://android.googlesource.com/device/google/pantah/+/b9712d3e5c48fb58c93aad8b00fd77629ec77a28/nfc/libnfc-hal-st.conf#153 Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
On the Pixel 9a the ST54L stops answering on I2C about 2-3 s after init whenever no discovery runs: the next command gets no ACK, retries don't help, and every NCI request times out until the adapter is powered off and on. Its clock and the set-config sent after init aren't the cause. ST's HAL does one more step after CORE_INIT: PROP_NFC_MODE_SET with mode on (2f 02 02 02 01), after which the controller resets and is initialised again. Do the same from post_setup, before the set-config: the mode command, whose request ends with the controller's CORE_RESET_NTF rather than with its response (the HAL waits for that notification too; the NCI core completes the request from the notification, and nci_prop_cmd()'s timeout bounds the wait), then CORE_INIT again in the NCI 2.0 form, which nci_core_init() doesn't send (the ST54L rejects the 1.x form as a syntax error). The proprietary response handler refuses other NXP parts, so their behaviour doesn't change. Tested on the Pixel 9a, with the board's reference clock enabled: polling now starts 3, 10, 30, 60 s and 3 minutes after power-on with no NACK, where it failed every time from 3 s on, and stopping the poll loop no longer times out. Across two RTC-woken s2idle cycles (one with the adapter powered off around the sleep, one left powered) polling started again 20 s after the wake, with no NACK. With the request ending on the notification, six power-ons in a row each completed in about 60 ms, and polling started at 3 s and at 30 s after power-on, with no NACK. Link: https://android.googlesource.com/platform/hardware/st/nfc/+/91b182c6f6efcfb2b01ce0f77930c6a814314b5c/st21nfc/hal_wrapper.cc Link: derekross/omarchy-mobile#132 Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
40ae7c0 to
46bbbc6
Compare
This fixes the ST54L going silent on the Pixel 9a (derekross/omarchy-mobile#132). Stacked on #100; only the last commit is new.
About 2-3 s after init with no discovery running, the controller stopped answering on I2C until a power cycle. Tonight's tests ruled out the set-config, quick retries (the closed #128), forcing the clock pad on, runtime PM and the interrupt. ST's own HAL (
platform/hardware/st/nfc,hal_wrapper.cc) does one more step after CORE_INIT: PROP_NFC_MODE_SET on (2f 02 02 02 01), then CORE_INIT again once the controller has reset. This does the same frompost_setup, with a proprietary op for the response. The second CORE_INIT uses the NCI 2.0 form, becausenci_core_init()sends 1.x and the ST54L rejects that as a syntax error (that was the -71 at power-on in the first try).Tested on the palmtop: polling starts 3, 10, 30, 60 s and 3 minutes after power-on with no NACK, and stopping the poll loop no longer times out. Across two RTC-woken s2idle cycles, one with the adapter powered off around the sleep and one left powered, polling started again 20 s after the wake. That run used this patch on #119's tree, which has the reference clock patch the 9a needs; on #100's branch alone the clock pad has no consumer. The module is now the palmtop's boot NFC driver. checkpatch
--strictis clean and it builds W=1 clean.Phone
The palmtop, booted with this head's
nxp-nci.koas the boot NFC driver (release7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty,core.cblobc96704ddd480). The module is built out of tree against that kernel's build directory and installed under/lib/modules/$(uname -r)/updates/nfc/.phone-smoke: tegu
Kernel
7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, tools at34778a2, 2026-10-29T16:56Z.Packages: hyprland 0.56.2-5.1, libcamera 0.7.2-4.22, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamobile-apps 0.2.0-1, omamobile-audio 0.4.1-1, omamobile-device-tegu 0.2.0-1, omamobile-fingerprint 0.1.8-1, omamobile-firstboot 0.1.0-1, omamobile-gnss 0.2.1-1, omamobile-keyring 20261013-1, omamobile-mirror 0.1.1-1, omamobile-modem 0.1.4-1, omamobile-omarchy 0.1.12-1, omamobile-owl-widgets 0.1.1-1, omamobile-sensors 0.2.1-1, omamobile-shell 0.2.36-1, omarchy 4.0.6-1