Skip to content

nfc: nxp-nci: the ST54L (Pixel 9a) reads cards - #100

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

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

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

This makes the Pixel 9a's ST54L read cards.

The ST54L speaks plain NCI over I2C, nxp-nci's transport (the 9a's NFC node uses it today as nxp,nxp-nci-i2c). It polls but never reports a target: with a contactless card held on the back, 25 s of discovery passed with no RF_INTF_ACTIVATED_NTF. ST's HAL sends a CORE_SET_CONFIG after CORE_INIT: proprietary 0xa1, 0xa2 and 0x80, and TOTAL_DURATION 500 ms, with the values the 9a's own HAL configuration sets. With the same command sent from post_setup, the card activates (ISO-DEP over NFC-A, 15 activations in 45 s) and neard lists it as a tag. That holds with no other workaround: the periodic discovery restart I'd carried locally isn't needed.

  • dt-bindings: st,st54l, with nxp,nxp-nci-i2c as the fallback, plus a description sentence saying the binding covers this transport.
  • nfc: nxp-nci: the set-config from post_setup, only for st,st54l.

Tested on the 9a with 7.3.0-rc6-omamobile-tegu-s2mpg15-m1, using an equivalent change: the same bytes from post_setup behind a module parameter, in a debug build. I'll boot this exact driver with the DT compatible at the palmtop's next DTB round and post the result here. checkpatch --strict, the W=1 build of core.c and dt_binding_check are clean.

The 9a's NFC also needs the SoC's NFC clock pad (PMU 0x3e84 bit 16, Google's st,extpad_control_en), which I set from a local module today. Its upstream form, and the 9a's NFC DT node, come separately.

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>
@derekross

Copy link
Copy Markdown
Owner

Thank you, this is a neat fix: one CORE_SET_CONFIG from post_setup, only for st,st54l, and the reasoning in the message is easy to follow.

The checks pass on today's omamobile (clean merge, sign-offs, checkpatch, W=1, and CI's dt_binding_check). The Pixel 7 Pro uses st-nci, and this touches neither it nor the NFC core, so nothing changes there.

Three things:

  1. As you say, the run was with the same bytes behind a module parameter in a debug build. I'll merge once you've posted the run with this exact driver and the st,st54l compatible: the release, the module's blob id (git rev-parse <commit>:drivers/nfc/nxp-nci/core.c), the set-config status and a card read through neard.
  2. Could you cite where the values come from in a public source? ST's NFC HAL is in AOSP (hardware/st/nfc): the line that sends this CORE_SET_CONFIG after CORE_INIT, plus the parameter names if it has them, would do. A configuration file from the phone's vendor partition isn't something I can cite.
  3. A suggestion, not a request: nxp_nci_fw_download() speaks NXP's download protocol. For the ST54L it could return -EOPNOTSUPP, so a firmware download started through netlink never sends NXP frames to an ST chip.

@derekross

Copy link
Copy Markdown
Owner

Closing as landed: these commits went in with #131, thank you.

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