/* * Reader gate for communication with contact-less cards using Type A * protocol ISO14443-3 but not compliant with ISO14443-4
*/ #define ST21NFCA_RF_READER_14443_3_A_GATE 0x15 #define ST21NFCA_RF_READER_14443_3_A_UID 0x02 #define ST21NFCA_RF_READER_14443_3_A_ATQA 0x03 #define ST21NFCA_RF_READER_14443_3_A_SAK 0x04
/* Secure element pipes are created by secure element host */
{ST21NFCA_CONNECTIVITY_GATE, NFC_HCI_DO_NOT_CREATE_PIPE},
{ST21NFCA_APDU_READER_GATE, NFC_HCI_DO_NOT_CREATE_PIPE},
};
/* On ST21NFCA device pipes number are dynamics * A maximum of 16 pipes can be created at the same time * If pipes are already created, hci_dev_up will fail. * Doing a clear all pipe is a bad idea because: * - It does useless EEPROM cycling * - It might cause issue for secure elements support * (such as removing connectivity or APDU reader pipe) * A better approach on ST21NFCA is to: * - get a pipe list for each host. * (eg: NFC_HCI_HOST_CONTROLLER_ID for now). * (TODO Later on UICC HOST and eSE HOST) * - get pipe information * - match retrieved pipe list in st21nfca_gates * ST21NFCA_DEVICE_MGNT_GATE is a proprietary gate * with ST21NFCA_DEVICE_MGNT_PIPE. * Pipe can be closed and need to be open.
*/
r = nfc_hci_connect_gate(hdev, NFC_HCI_HOST_CONTROLLER_ID,
ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DEVICE_MGNT_PIPE); if (r < 0) return r;
/* Get pipe list */
r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DM_GETINFO, pipe_list, sizeof(pipe_list),
&skb_pipe_list); if (r < 0) return r;
/* Complete the existing gate_pipe table */ for (i = 0; i < skb_pipe_list->len; i++) {
pipe_info[2] = skb_pipe_list->data[i];
r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DM_GETINFO, pipe_info, sizeof(pipe_info), &skb_pipe_info); if (r) continue;
/* * Match pipe ID and gate ID * Output format from ST21NFC_DM_GETINFO is: * - pipe state (1byte) * - source hid (1byte) * - source gid (1byte) * - destination hid (1byte) * - destination gid (1byte)
*/
info = (struct st21nfca_pipe_info *) skb_pipe_info->data; if (info->dst_gate_id == ST21NFCA_APDU_READER_GATE &&
info->src_host_id == NFC_HCI_UICC_HOST_ID) {
pr_err("Unexpected apdu_reader pipe on host %x\n",
info->src_host_id);
kfree_skb(skb_pipe_info); continue;
}
/* * 3 gates have a well known pipe ID. Only NFC_HCI_LINK_MGMT_GATE * is not yet open at this stage.
*/
r = nfc_hci_connect_gate(hdev, NFC_HCI_HOST_CONTROLLER_ID,
NFC_HCI_LINK_MGMT_GATE,
NFC_HCI_LINK_MGMT_PIPE);
u8 param;
u8 white_list[2]; int wl_size = 0; int r;
if (info->se_status->is_uicc_present)
white_list[wl_size++] = NFC_HCI_UICC_HOST_ID; if (info->se_status->is_ese_present)
white_list[wl_size++] = ST21NFCA_ESE_HOST_ID;
if (wl_size) {
r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE,
NFC_HCI_ADMIN_WHITELIST,
(u8 *) &white_list, wl_size); if (r < 0) return r;
}
/* Set NFC_MODE in device management gate to enable */
r = nfc_hci_get_param(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_NFC_MODE, &skb); if (r < 0) return r;
r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
NFC_HCI_EVT_END_OPERATION, NULL, 0); if (r < 0) return r; if (im_protocols) { /* * enable polling according to im_protocols & tm_protocols * - CLOSE pipe according to im_protocols & tm_protocols
*/ if ((NFC_HCI_RF_READER_B_GATE & im_protocols) == 0) {
r = nfc_hci_disconnect_gate(hdev,
NFC_HCI_RF_READER_B_GATE); if (r < 0) return r;
}
if ((NFC_HCI_RF_READER_A_GATE & im_protocols) == 0) {
r = nfc_hci_disconnect_gate(hdev,
NFC_HCI_RF_READER_A_GATE); if (r < 0) return r;
}
if ((ST21NFCA_RF_READER_F_GATE & im_protocols) == 0) {
r = nfc_hci_disconnect_gate(hdev,
ST21NFCA_RF_READER_F_GATE); if (r < 0) return r;
} else {
hdev->gb = nfc_get_local_general_bytes(hdev->ndev,
&hdev->gb_len);
/* * Configuration byte: * - bit 0: define the default NFCID2 entry used when the * system code is equal to 'FFFF' * - bit 1: use a random value for lowest 6 bytes of * NFCID2 value * - bit 2: ignore polling request frame if request code * is equal to '01' * - Other bits are RFU
*/
param[18] = 0x01;
r = nfc_hci_set_param(hdev, ST21NFCA_RF_CARD_F_GATE,
ST21NFCA_RF_CARD_F_NFCID2_LIST, param,
19); if (r < 0) return r;
if (gate == ST21NFCA_RF_READER_F_GATE) {
r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE,
ST21NFCA_RF_READER_F_NFCID2, &nfcid_skb); if (r < 0) gotoexit;
if (nfcid_skb->len > NFC_SENSF_RES_MAXSIZE) {
r = -EPROTO; gotoexit;
}
/* * - After the recepton of polling response for type F frame * at 212 or 424 Kbit/s, NFCID2 registry parameters will be * updated. * - After the reception of SEL_RES with NFCIP-1 compliant bit * set for type A frame NFCID1 will be updated
*/ if (nfcid_skb->len > 0) { /* P2P in type F */
memcpy(target->sensf_res, nfcid_skb->data,
nfcid_skb->len);
target->sensf_res_len = nfcid_skb->len; /* NFC Forum Digital Protocol Table 44 */ if (target->sensf_res[0] == 0x01 &&
target->sensf_res[1] == 0xfe)
target->supported_protocols =
NFC_PROTO_NFC_DEP_MASK; else
target->supported_protocols =
NFC_PROTO_FELICA_MASK;
} else {
kfree_skb(nfcid_skb);
nfcid_skb = NULL; /* P2P in type A */
r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE,
ST21NFCA_RF_READER_F_NFCID1,
&nfcid_skb); if (r < 0) gotoexit;
switch (target->hci_reader_gate) { case NFC_HCI_RF_READER_A_GATE: case NFC_HCI_RF_READER_B_GATE: /* * PRESENCE_CHECK on those gates is available * However, the answer to this command is taking 3 * fwi * if the card is no present. * Instead, we send an empty I-Frame with a very short * configurable fwi ~604µs.
*/ return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
ST21NFCA_WR_XCHG_DATA, &fwi, 1, NULL); case ST21NFCA_RF_READER_14443_3_A_GATE: return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
ST21NFCA_RF_READER_CMD_PRESENCE_CHECK,
NULL, 0, NULL); default: return -EOPNOTSUPP;
}
}
/* * Session id must include the driver name + i2c bus addr * persistent info to discriminate 2 identical chips
*/
dev_num = find_first_zero_bit(dev_mask, ST21NFCA_NUM_DEVICES); if (dev_num >= ST21NFCA_NUM_DEVICES) {
r = -ENODEV; goto err_alloc_hdev;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.52Bemerkung:
(vorverarbeitet am 2026-04-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.