1/*
2 * NCI based Driver for STMicroelectronics NFC Chip
3 *
4 * Copyright (C) 2014  STMicroelectronics SAS. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef __LOCAL_ST21NFCB_SE_H_
19#define __LOCAL_ST21NFCB_SE_H_
20
21/*
22 * ref ISO7816-3 chap 8.1. the initial character TS is followed by a
23 * sequence of at most 32 characters.
24 */
25#define ST21NFCB_ESE_MAX_LENGTH		33
26#define ST21NFCB_HCI_HOST_ID_ESE	0xc0
27
28struct st21nfcb_se_info {
29	u8 atr[ST21NFCB_ESE_MAX_LENGTH];
30	struct completion req_completion;
31
32	struct timer_list bwi_timer;
33	int wt_timeout; /* in msecs */
34	bool bwi_active;
35
36	struct timer_list se_active_timer;
37	bool se_active;
38
39	bool xch_error;
40
41	se_io_cb_t cb;
42	void *cb_context;
43};
44
45int st21nfcb_se_init(struct nci_dev *ndev);
46void st21nfcb_se_deinit(struct nci_dev *ndev);
47
48int st21nfcb_nci_discover_se(struct nci_dev *ndev);
49int st21nfcb_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
50int st21nfcb_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
51int st21nfcb_nci_se_io(struct nci_dev *ndev, u32 se_idx,
52					u8 *apdu, size_t apdu_length,
53					se_io_cb_t cb, void *cb_context);
54int st21nfcb_hci_load_session(struct nci_dev *ndev);
55void st21nfcb_hci_event_received(struct nci_dev *ndev, u8 pipe,
56				 u8 event, struct sk_buff *skb);
57void st21nfcb_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
58			       struct sk_buff *skb);
59
60
61#endif /* __LOCAL_ST21NFCB_NCI_H_ */
62