Lines Matching +full:ese +full:- +full:present
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
14 #include "st-nci.h"
45 #define ST_NCI_EVT_HOT_PLUG_IS_INHIBITED(x) (x->data[0] & 0x80)
85 /* If TA is present bit 0 is set */
87 /* If TB is present bit 1 is set */
121 td = ST_NCI_ATR_GET_Y_FROM_TD(info->se_info.atr[i]); in st_nci_se_get_bwi()
126 return info->se_info.atr[i] >> 4; in st_nci_se_get_bwi()
143 if (skb->len <= ST_NCI_ESE_MAX_LENGTH) { in st_nci_se_get_atr()
144 memcpy(info->se_info.atr, skb->data, skb->len); in st_nci_se_get_atr()
146 info->se_info.wt_timeout = in st_nci_se_get_atr()
165 * - It does useless EEPROM cycling in st_nci_hci_load_session()
166 * - It might cause issue for secure elements support in st_nci_hci_load_session()
169 * - get a pipe list for each host. in st_nci_hci_load_session()
171 * (TODO Later on UICC HOST and eSE HOST) in st_nci_hci_load_session()
172 * - get pipe information in st_nci_hci_load_session()
173 * - match retrieved pipe list in st_nci_gates in st_nci_hci_load_session()
192 for (i = 0; i < skb_pipe_list->len; i++) { in st_nci_hci_load_session()
193 pipe_info[2] = skb_pipe_list->data[i]; in st_nci_hci_load_session()
204 * - pipe state (1byte) in st_nci_hci_load_session()
205 * - source hid (1byte) in st_nci_hci_load_session()
206 * - source gid (1byte) in st_nci_hci_load_session()
207 * - destination hid (1byte) in st_nci_hci_load_session()
208 * - destination gid (1byte) in st_nci_hci_load_session()
210 dm_pipe_info = (struct st_nci_pipe_info *)skb_pipe_info->data; in st_nci_hci_load_session()
211 if (dm_pipe_info->dst_gate_id == ST_NCI_APDU_READER_GATE && in st_nci_hci_load_session()
212 dm_pipe_info->src_host_id == ST_NCI_UICC_HOST_ID) { in st_nci_hci_load_session()
214 dm_pipe_info->src_host_id); in st_nci_hci_load_session()
220 (st_nci_gates[j].gate != dm_pipe_info->dst_gate_id); j++) in st_nci_hci_load_session()
224 st_nci_gates[j].gate == dm_pipe_info->dst_gate_id && in st_nci_hci_load_session()
225 ST_NCI_DM_IS_PIPE_OPEN(dm_pipe_info->pipe_state)) { in st_nci_hci_load_session()
226 ndev->hci_dev->init_data.gates[j].pipe = pipe_info[2]; in st_nci_hci_load_session()
228 ndev->hci_dev->gate2pipe[st_nci_gates[j].gate] = in st_nci_hci_load_session()
230 ndev->hci_dev->pipes[pipe_info[2]].gate = in st_nci_hci_load_session()
232 ndev->hci_dev->pipes[pipe_info[2]].host = in st_nci_hci_load_session()
233 dm_pipe_info->src_host_id; in st_nci_hci_load_session()
258 if (info->se_info.se_active) { in st_nci_hci_admin_event_received()
260 del_timer_sync(&info->se_info.se_active_timer); in st_nci_hci_admin_event_received()
261 info->se_info.se_active = false; in st_nci_hci_admin_event_received()
262 complete(&info->se_info.req_completion); in st_nci_hci_admin_event_received()
264 mod_timer(&info->se_info.se_active_timer, in st_nci_hci_admin_event_received()
271 nfc_err(&ndev->nfc_dev->dev, "Unexpected event on admin gate\n"); in st_nci_hci_admin_event_received()
285 del_timer_sync(&info->se_info.bwi_timer); in st_nci_hci_apdu_reader_event_received()
286 info->se_info.bwi_active = false; in st_nci_hci_apdu_reader_event_received()
287 info->se_info.cb(info->se_info.cb_context, in st_nci_hci_apdu_reader_event_received()
288 skb->data, skb->len, 0); in st_nci_hci_apdu_reader_event_received()
291 mod_timer(&info->se_info.bwi_timer, jiffies + in st_nci_hci_apdu_reader_event_received()
292 msecs_to_jiffies(info->se_info.wt_timeout)); in st_nci_hci_apdu_reader_event_received()
295 nfc_err(&ndev->nfc_dev->dev, "Unexpected event on apdu reader gate\n"); in st_nci_hci_apdu_reader_event_received()
313 struct device *dev = &ndev->nfc_dev->dev; in st_nci_hci_connectivity_event_received()
322 r = nfc_se_connectivity(ndev->nfc_dev, host); in st_nci_hci_connectivity_event_received()
337 * size(b): 1 1 5-16 1 1 0-255 in st_nci_hci_connectivity_event_received()
340 * example: 0x81 5-16 X 0x82 0-255 X in st_nci_hci_connectivity_event_received()
342 if (skb->len < 2 || skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG) in st_nci_hci_connectivity_event_received()
343 return -EPROTO; in st_nci_hci_connectivity_event_received()
345 aid_len = skb->data[1]; in st_nci_hci_connectivity_event_received()
347 if (skb->len < aid_len + 4 || in st_nci_hci_connectivity_event_received()
348 aid_len > sizeof(transaction->aid)) in st_nci_hci_connectivity_event_received()
349 return -EPROTO; in st_nci_hci_connectivity_event_received()
351 params_len = skb->data[aid_len + 3]; in st_nci_hci_connectivity_event_received()
356 if (skb->data[aid_len + 2] != NFC_EVT_TRANSACTION_PARAMS_TAG || in st_nci_hci_connectivity_event_received()
357 skb->len < aid_len + 4 + params_len) in st_nci_hci_connectivity_event_received()
358 return -EPROTO; in st_nci_hci_connectivity_event_received()
363 return -ENOMEM; in st_nci_hci_connectivity_event_received()
365 transaction->aid_len = aid_len; in st_nci_hci_connectivity_event_received()
366 transaction->params_len = params_len; in st_nci_hci_connectivity_event_received()
368 memcpy(transaction->aid, &skb->data[2], aid_len); in st_nci_hci_connectivity_event_received()
369 memcpy(transaction->params, &skb->data[aid_len + 4], in st_nci_hci_connectivity_event_received()
372 r = nfc_se_transaction(ndev->nfc_dev, host, transaction); in st_nci_hci_connectivity_event_received()
375 nfc_err(&ndev->nfc_dev->dev, "Unexpected event on connectivity gate\n"); in st_nci_hci_connectivity_event_received()
385 u8 gate = ndev->hci_dev->pipes[pipe].gate; in st_nci_hci_event_received()
386 u8 host = ndev->hci_dev->pipes[pipe].host; in st_nci_hci_event_received()
406 u8 gate = ndev->hci_dev->pipes[pipe].gate; in st_nci_hci_cmd_received()
413 ndev->hci_dev->pipes[pipe].host != ST_NCI_UICC_HOST_ID) in st_nci_hci_cmd_received()
414 ndev->hci_dev->count_pipes++; in st_nci_hci_cmd_received()
416 if (ndev->hci_dev->count_pipes == in st_nci_hci_cmd_received()
417 ndev->hci_dev->expected_pipes) { in st_nci_hci_cmd_received()
418 del_timer_sync(&info->se_info.se_active_timer); in st_nci_hci_cmd_received()
419 info->se_info.se_active = false; in st_nci_hci_cmd_received()
420 ndev->hci_dev->count_pipes = 0; in st_nci_hci_cmd_received()
421 complete(&info->se_info.req_completion); in st_nci_hci_cmd_received()
438 ndev->hci_dev->count_pipes = 0; in st_nci_control_se()
439 ndev->hci_dev->expected_pipes = ST_NCI_SE_COUNT_PIPE_UICC; in st_nci_control_se()
442 ndev->hci_dev->count_pipes = 0; in st_nci_control_se()
443 ndev->hci_dev->expected_pipes = ST_NCI_SE_COUNT_PIPE_EMBEDDED; in st_nci_control_se()
446 return -EINVAL; in st_nci_control_se()
453 reinit_completion(&info->se_info.req_completion); in st_nci_control_se()
458 mod_timer(&info->se_info.se_active_timer, jiffies + in st_nci_control_se()
460 info->se_info.se_active = true; in st_nci_control_se()
463 wait_for_completion_interruptible(&info->se_info.req_completion); in st_nci_control_se()
470 if (info->se_info.se_status->is_ese_present && in st_nci_control_se()
471 info->se_info.se_status->is_uicc_present) in st_nci_control_se()
479 for (i = 0; i < sk_host_list->len && in st_nci_control_se()
480 sk_host_list->data[i] != se_idx; i++) in st_nci_control_se()
482 host_id = sk_host_list->data[i]; in st_nci_control_se()
489 return -1; in st_nci_control_se()
498 * info->se_info.se_status->is_uicc_enable is true should never happen in st_nci_disable_se()
499 * Same for eSE. in st_nci_disable_se()
522 * info->se_info.se_status->is_uicc_enable is true should never happen. in st_nci_enable_se()
523 * Same for eSE. in st_nci_enable_se()
537 nfc_remove_se(ndev->nfc_dev, se_idx); in st_nci_enable_se()
557 return -ENOMEM; in st_nci_hci_network_init()
559 dest_params->type = NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE; in st_nci_hci_network_init()
560 dest_params->length = sizeof(struct dest_spec_params); in st_nci_hci_network_init()
561 spec_params.id = ndev->hci_dev->nfcee_id; in st_nci_hci_network_init()
563 memcpy(dest_params->value, &spec_params, in st_nci_hci_network_init()
572 conn_info = ndev->hci_dev->conn_info; in st_nci_hci_network_init()
576 ndev->hci_dev->init_data.gate_count = ARRAY_SIZE(st_nci_gates); in st_nci_hci_network_init()
577 memcpy(ndev->hci_dev->init_data.gates, st_nci_gates, in st_nci_hci_network_init()
586 r = -ENODEV; in st_nci_hci_network_init()
590 scnprintf(ndev->hci_dev->init_data.session_id, in st_nci_hci_network_init()
591 sizeof(ndev->hci_dev->init_data.session_id), in st_nci_hci_network_init()
603 if (test_bit(ST_NCI_FACTORY_MODE, &info->flags)) in st_nci_hci_network_init()
605 ndev->hci_dev->conn_info->dest_params->id, in st_nci_hci_network_init()
609 ndev->hci_dev->conn_info->dest_params->id, in st_nci_hci_network_init()
628 if (test_bit(ST_NCI_FACTORY_MODE, &info->flags)) in st_nci_discover_se()
631 if (info->se_info.se_status->is_uicc_present) in st_nci_discover_se()
633 if (info->se_info.se_status->is_ese_present) in st_nci_discover_se()
644 if (info->se_info.se_status->is_uicc_present) { in st_nci_discover_se()
645 nfc_add_se(ndev->nfc_dev, ST_NCI_UICC_HOST_ID, NFC_SE_UICC); in st_nci_discover_se()
649 if (info->se_info.se_status->is_ese_present) { in st_nci_discover_se()
650 nfc_add_se(ndev->nfc_dev, ST_NCI_ESE_HOST_ID, NFC_SE_EMBEDDED); in st_nci_discover_se()
666 info->se_info.cb = cb; in st_nci_se_io()
667 info->se_info.cb_context = cb_context; in st_nci_se_io()
668 mod_timer(&info->se_info.bwi_timer, jiffies + in st_nci_se_io()
669 msecs_to_jiffies(info->se_info.wt_timeout)); in st_nci_se_io()
670 info->se_info.bwi_active = true; in st_nci_se_io()
675 return -ENODEV; in st_nci_se_io()
695 info->se_info.bwi_active = false; in st_nci_se_wt_timeout()
697 if (!info->se_info.xch_error) { in st_nci_se_wt_timeout()
698 info->se_info.xch_error = true; in st_nci_se_wt_timeout()
699 nci_hci_send_event(info->ndlc->ndev, ST_NCI_APDU_READER_GATE, in st_nci_se_wt_timeout()
702 info->se_info.xch_error = false; in st_nci_se_wt_timeout()
703 nci_hci_send_event(info->ndlc->ndev, ST_NCI_DEVICE_MGNT_GATE, in st_nci_se_wt_timeout()
706 info->se_info.cb(info->se_info.cb_context, NULL, 0, -ETIME); in st_nci_se_wt_timeout()
714 info->se_info.se_active = false; in st_nci_se_activation_timeout()
716 complete(&info->se_info.req_completion); in st_nci_se_activation_timeout()
723 init_completion(&info->se_info.req_completion); in st_nci_se_init()
725 timer_setup(&info->se_info.bwi_timer, st_nci_se_wt_timeout, 0); in st_nci_se_init()
726 info->se_info.bwi_active = false; in st_nci_se_init()
728 timer_setup(&info->se_info.se_active_timer, in st_nci_se_init()
730 info->se_info.se_active = false; in st_nci_se_init()
732 info->se_info.xch_error = false; in st_nci_se_init()
734 info->se_info.wt_timeout = in st_nci_se_init()
737 info->se_info.se_status = se_status; in st_nci_se_init()
747 if (info->se_info.bwi_active) in st_nci_se_deinit()
748 del_timer_sync(&info->se_info.bwi_timer); in st_nci_se_deinit()
749 if (info->se_info.se_active) in st_nci_se_deinit()
750 del_timer_sync(&info->se_info.se_active_timer); in st_nci_se_deinit()
752 info->se_info.se_active = false; in st_nci_se_deinit()
753 info->se_info.bwi_active = false; in st_nci_se_deinit()