Lines Matching +full:- +full:eproto
1 // SPDX-License-Identifier: GPL-2.0-only
27 * Reader gate for communication with contact-less cards using Type A
28 * protocol ISO14443-3 but not compliant with ISO14443-4
68 #define ST21NFCA_EVT_HOT_PLUG_IS_INHIBITED(x) (x->data[0] & 0x80)
121 * - It does useless EEPROM cycling in st21nfca_hci_load_session()
122 * - It might cause issue for secure elements support in st21nfca_hci_load_session()
125 * - get a pipe list for each host. in st21nfca_hci_load_session()
128 * - get pipe information in st21nfca_hci_load_session()
129 * - match retrieved pipe list in st21nfca_gates in st21nfca_hci_load_session()
148 for (i = 0; i < skb_pipe_list->len; i++) { in st21nfca_hci_load_session()
149 pipe_info[2] = skb_pipe_list->data[i]; in st21nfca_hci_load_session()
159 * - pipe state (1byte) in st21nfca_hci_load_session()
160 * - source hid (1byte) in st21nfca_hci_load_session()
161 * - source gid (1byte) in st21nfca_hci_load_session()
162 * - destination hid (1byte) in st21nfca_hci_load_session()
163 * - destination gid (1byte) in st21nfca_hci_load_session()
165 info = (struct st21nfca_pipe_info *) skb_pipe_info->data; in st21nfca_hci_load_session()
166 if (info->dst_gate_id == ST21NFCA_APDU_READER_GATE && in st21nfca_hci_load_session()
167 info->src_host_id == NFC_HCI_UICC_HOST_ID) { in st21nfca_hci_load_session()
169 info->src_host_id); in st21nfca_hci_load_session()
175 (st21nfca_gates[j].gate != info->dst_gate_id) ; j++) in st21nfca_hci_load_session()
179 st21nfca_gates[j].gate == info->dst_gate_id && in st21nfca_hci_load_session()
180 ST21NFCA_DM_IS_PIPE_OPEN(info->pipe_state)) { in st21nfca_hci_load_session()
181 hdev->init_data.gates[j].pipe = pipe_info[2]; in st21nfca_hci_load_session()
183 hdev->gate2pipe[st21nfca_gates[j].gate] = in st21nfca_hci_load_session()
185 hdev->pipes[pipe_info[2]].gate = in st21nfca_hci_load_session()
187 hdev->pipes[pipe_info[2]].dest_host = in st21nfca_hci_load_session()
188 info->src_host_id; in st21nfca_hci_load_session()
210 mutex_lock(&info->info_lock); in st21nfca_hci_open()
212 if (info->state != ST21NFCA_ST_COLD) { in st21nfca_hci_open()
213 r = -EBUSY; in st21nfca_hci_open()
217 r = info->phy_ops->enable(info->phy_id); in st21nfca_hci_open()
220 info->state = ST21NFCA_ST_READY; in st21nfca_hci_open()
223 mutex_unlock(&info->info_lock); in st21nfca_hci_open()
231 mutex_lock(&info->info_lock); in st21nfca_hci_close()
233 if (info->state == ST21NFCA_ST_COLD) in st21nfca_hci_close()
236 info->phy_ops->disable(info->phy_id); in st21nfca_hci_close()
237 info->state = ST21NFCA_ST_COLD; in st21nfca_hci_close()
240 mutex_unlock(&info->info_lock); in st21nfca_hci_close()
253 if (info->se_status->is_uicc_present) in st21nfca_hci_ready()
255 if (info->se_status->is_ese_present) in st21nfca_hci_ready()
272 param = skb->data[0]; in st21nfca_hci_ready()
293 if (skb->len != FULL_VERSION_LEN) { in st21nfca_hci_ready()
295 return -EINVAL; in st21nfca_hci_ready()
300 skb->data, FULL_VERSION_LEN, false); in st21nfca_hci_ready()
311 return info->phy_ops->write(info->phy_id, skb); in st21nfca_hci_xmit()
332 * - CLOSE pipe according to im_protocols & tm_protocols in st21nfca_hci_start_poll()
354 hdev->gb = nfc_get_local_general_bytes(hdev->ndev, in st21nfca_hci_start_poll()
355 &hdev->gb_len); in st21nfca_hci_start_poll()
357 if (hdev->gb == NULL || hdev->gb_len == 0) { in st21nfca_hci_start_poll()
409 if (datarate_skb->len > 0 && in st21nfca_hci_start_poll()
410 datarate_skb->data[0] != in st21nfca_hci_start_poll()
440 * b3 set to 0b (value b7-b6): in st21nfca_hci_start_poll()
441 * - 10b: Configured for NFC-DEP Protocol in st21nfca_hci_start_poll()
472 * - bit 0: define the default NFCID2 entry used when the in st21nfca_hci_start_poll()
474 * - bit 1: use a random value for lowest 6 bytes of in st21nfca_hci_start_poll()
476 * - bit 2: ignore polling request frame if request code in st21nfca_hci_start_poll()
478 * - Other bits are RFU in st21nfca_hci_start_poll()
511 if (atqa_skb->len != 2) { in st21nfca_get_iso14443_3_atqa()
512 r = -EPROTO; in st21nfca_get_iso14443_3_atqa()
516 *atqa = be16_to_cpu(*(__be16 *) atqa_skb->data); in st21nfca_get_iso14443_3_atqa()
533 if (sak_skb->len != 1) { in st21nfca_get_iso14443_3_sak()
534 r = -EPROTO; in st21nfca_get_iso14443_3_sak()
538 *sak = sak_skb->data[0]; in st21nfca_get_iso14443_3_sak()
556 if (uid_skb->len == 0 || uid_skb->len > NFC_NFCID1_MAXSIZE) { in st21nfca_get_iso14443_3_uid()
557 r = -EPROTO; in st21nfca_get_iso14443_3_uid()
561 memcpy(uid, uid_skb->data, uid_skb->len); in st21nfca_get_iso14443_3_uid()
562 *len = uid_skb->len; in st21nfca_get_iso14443_3_uid()
582 if (inventory_skb->len == 0 || in st21nfca_get_iso15693_inventory()
583 inventory_skb->len > NFC_ISO15693_UID_MAXSIZE) { in st21nfca_get_iso15693_inventory()
584 r = -EPROTO; in st21nfca_get_iso15693_inventory()
588 memcpy(target->iso15693_uid, inventory_skb->data, inventory_skb->len); in st21nfca_get_iso15693_inventory()
589 target->iso15693_dsfid = inventory_skb->data[1]; in st21nfca_get_iso15693_inventory()
590 target->is_iso15693 = 1; in st21nfca_get_iso15693_inventory()
602 info->dep_info.idx = target->idx; in st21nfca_hci_dep_link_up()
610 info->state = ST21NFCA_ST_READY; in st21nfca_hci_dep_link_down()
626 target->supported_protocols = NFC_PROTO_FELICA_MASK; in st21nfca_hci_target_from_gate()
629 /* ISO14443-3 type 1 or 2 tags */ in st21nfca_hci_target_from_gate()
634 target->supported_protocols = NFC_PROTO_JEWEL_MASK; in st21nfca_hci_target_from_gate()
635 target->sens_res = 0x0c00; in st21nfca_hci_target_from_gate()
645 target->supported_protocols = in st21nfca_hci_target_from_gate()
647 if (target->supported_protocols == 0xffffffff) in st21nfca_hci_target_from_gate()
648 return -EPROTO; in st21nfca_hci_target_from_gate()
650 target->sens_res = atqa; in st21nfca_hci_target_from_gate()
651 target->sel_res = sak; in st21nfca_hci_target_from_gate()
652 memcpy(target->nfcid1, uid, len); in st21nfca_hci_target_from_gate()
653 target->nfcid1_len = len; in st21nfca_hci_target_from_gate()
658 target->supported_protocols = NFC_PROTO_ISO15693_MASK; in st21nfca_hci_target_from_gate()
664 return -EPROTO; in st21nfca_hci_target_from_gate()
683 if (nfcid_skb->len > NFC_SENSF_RES_MAXSIZE) { in st21nfca_hci_complete_target_discovered()
684 r = -EPROTO; in st21nfca_hci_complete_target_discovered()
689 * - After the recepton of polling response for type F frame in st21nfca_hci_complete_target_discovered()
692 * - After the reception of SEL_RES with NFCIP-1 compliant bit in st21nfca_hci_complete_target_discovered()
695 if (nfcid_skb->len > 0) { in st21nfca_hci_complete_target_discovered()
697 memcpy(target->sensf_res, nfcid_skb->data, in st21nfca_hci_complete_target_discovered()
698 nfcid_skb->len); in st21nfca_hci_complete_target_discovered()
699 target->sensf_res_len = nfcid_skb->len; in st21nfca_hci_complete_target_discovered()
701 if (target->sensf_res[0] == 0x01 && in st21nfca_hci_complete_target_discovered()
702 target->sensf_res[1] == 0xfe) in st21nfca_hci_complete_target_discovered()
703 target->supported_protocols = in st21nfca_hci_complete_target_discovered()
706 target->supported_protocols = in st21nfca_hci_complete_target_discovered()
718 if (nfcid_skb->len > NFC_NFCID1_MAXSIZE) { in st21nfca_hci_complete_target_discovered()
719 r = -EPROTO; in st21nfca_hci_complete_target_discovered()
722 memcpy(target->sensf_res, nfcid_skb->data, in st21nfca_hci_complete_target_discovered()
723 nfcid_skb->len); in st21nfca_hci_complete_target_discovered()
724 target->sensf_res_len = nfcid_skb->len; in st21nfca_hci_complete_target_discovered()
725 target->supported_protocols = NFC_PROTO_NFC_DEP_MASK; in st21nfca_hci_complete_target_discovered()
727 target->hci_reader_gate = ST21NFCA_RF_READER_F_GATE; in st21nfca_hci_complete_target_discovered()
741 switch (info->async_cb_type) { in st21nfca_hci_data_exchange_cb()
744 skb_trim(skb, skb->len - 1); in st21nfca_hci_data_exchange_cb()
745 info->async_cb(info->async_cb_context, skb, err); in st21nfca_hci_data_exchange_cb()
767 target->hci_reader_gate, skb->len); in st21nfca_hci_im_transceive()
769 switch (target->hci_reader_gate) { in st21nfca_hci_im_transceive()
771 if (target->supported_protocols == NFC_PROTO_NFC_DEP_MASK) in st21nfca_hci_im_transceive()
775 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate, in st21nfca_hci_im_transceive()
776 ST21NFCA_WR_XCHG_DATA, skb->data, in st21nfca_hci_im_transceive()
777 skb->len, cb, cb_context); in st21nfca_hci_im_transceive()
781 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate, in st21nfca_hci_im_transceive()
782 ST21NFCA_WR_XCHG_DATA, skb->data, in st21nfca_hci_im_transceive()
783 skb->len, cb, cb_context); in st21nfca_hci_im_transceive()
785 info->async_cb_type = ST21NFCA_CB_TYPE_READER_ISO15693; in st21nfca_hci_im_transceive()
786 info->async_cb = cb; in st21nfca_hci_im_transceive()
787 info->async_cb_context = cb_context; in st21nfca_hci_im_transceive()
791 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate, in st21nfca_hci_im_transceive()
792 ST21NFCA_WR_XCHG_DATA, skb->data, in st21nfca_hci_im_transceive()
793 skb->len, in st21nfca_hci_im_transceive()
811 switch (target->hci_reader_gate) { in st21nfca_hci_check_presence()
818 * Instead, we send an empty I-Frame with a very short in st21nfca_hci_check_presence()
821 return nfc_hci_send_cmd(hdev, target->hci_reader_gate, in st21nfca_hci_check_presence()
824 return nfc_hci_send_cmd(hdev, target->hci_reader_gate, in st21nfca_hci_check_presence()
828 return -EOPNOTSUPP; in st21nfca_hci_check_presence()
836 u8 gate = hdev->pipes[pipe].gate; in st21nfca_hci_cmd_received()
843 hdev->pipes[pipe].dest_host != NFC_HCI_UICC_HOST_ID) in st21nfca_hci_cmd_received()
844 info->se_info.count_pipes++; in st21nfca_hci_cmd_received()
846 if (info->se_info.count_pipes == info->se_info.expected_pipes) { in st21nfca_hci_cmd_received()
847 del_timer_sync(&info->se_info.se_active_timer); in st21nfca_hci_cmd_received()
848 info->se_info.se_active = false; in st21nfca_hci_cmd_received()
849 info->se_info.count_pipes = 0; in st21nfca_hci_cmd_received()
850 complete(&info->se_info.req_completion); in st21nfca_hci_cmd_received()
865 if (info->se_info.se_active) { in st21nfca_admin_event_received()
867 del_timer_sync(&info->se_info.se_active_timer); in st21nfca_admin_event_received()
868 info->se_info.se_active = false; in st21nfca_admin_event_received()
869 complete(&info->se_info.req_completion); in st21nfca_admin_event_received()
871 mod_timer(&info->se_info.se_active_timer, in st21nfca_admin_event_received()
878 nfc_err(&hdev->ndev->dev, "Unexpected event on admin gate\n"); in st21nfca_admin_event_received()
892 u8 gate = hdev->pipes[pipe].gate; in st21nfca_hci_event_received()
893 u8 host = hdev->pipes[pipe].dest_host; in st21nfca_hci_event_received()
951 return -ENOMEM; in st21nfca_hci_probe()
953 info->phy_ops = phy_ops; in st21nfca_hci_probe()
954 info->phy_id = phy_id; in st21nfca_hci_probe()
955 info->state = ST21NFCA_ST_COLD; in st21nfca_hci_probe()
956 mutex_init(&info->info_lock); in st21nfca_hci_probe()
968 r = -ENODEV; in st21nfca_hci_probe()
987 info->hdev = in st21nfca_hci_probe()
993 if (!info->hdev) { in st21nfca_hci_probe()
995 r = -ENOMEM; in st21nfca_hci_probe()
999 info->se_status = se_status; in st21nfca_hci_probe()
1001 nfc_hci_set_clientdata(info->hdev, info); in st21nfca_hci_probe()
1003 r = nfc_hci_register_device(info->hdev); in st21nfca_hci_probe()
1007 *hdev = info->hdev; in st21nfca_hci_probe()
1008 st21nfca_dep_init(info->hdev); in st21nfca_hci_probe()
1009 st21nfca_se_init(info->hdev); in st21nfca_hci_probe()
1010 st21nfca_vendor_cmds_init(info->hdev); in st21nfca_hci_probe()
1015 nfc_hci_free_device(info->hdev); in st21nfca_hci_probe()