Skip to content

nfc: nxp-nci: i2c: Wake the ST54L with quick retries - #128

Closed
W4HO-ham wants to merge 3 commits into
derekross:omamobilefrom
W4HO-ham:tegu-nfc-st54l-wake
Closed

W4HO-ham wants to merge 3 commits into
derekross:omamobilefrom
W4HO-ham:tegu-nfc-st54l-wake

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

Draft until the palmtop test (derekross/omarchy-mobile#132). Stacked on #100; only the last commit is new.

On the 9a, about 2 s after init with discovery not running, the ST54L NACKs the next command, the single 110 ms retry fails too, and every NCI request times out until a power cycle. This gives st,st54l five quick retries, 2 ms apart, before the existing 110 ms one. Stock's ST driver has a pidle-gpios line in tegu's DT, which fits a controller that idles into standby.

checkpatch --strict is clean and it builds W=1 clean. Not tested yet. This exact build is staged on the palmtop for the next boot, alongside the variant that skips the set-config, to see which of the two the NACK depends on.

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>
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, and TOTAL_DURATION 500 ms, as the 9a's own HAL configuration sets
them). 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.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
On the Pixel 9a the ST54L stops answering on I2C about 2 s after init
whenever discovery isn't running: the first command then fails with
-ENXIO (no ACK), the 110 ms retry fails too, and every NCI request times
out until the adapter is powered off and on. The single 110 ms retry
suits the PN5xx standby; the ST54L NACKs the transfer that wakes it and
may be back in standby by the time of that retry.

For "st,st54l", retry a NACKed write up to five times 2 ms apart before
the existing 110 ms retry.

Link: derekross/omarchy-mobile#132
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Closing: the palmtop test on derekross/omarchy-mobile#132 shows quick retries don't wake the ST54L (five 2 ms retries still end in -6). The controller stops answering about 2-3 s after power-on when idle, whatever the driver does, so the fix goes in userspace (power on only together with polling).

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