Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / nfc / st21nfca / st21nfca.h
1 /*
2  * Copyright (C) 2014  STMicroelectronics SAS. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #ifndef __LOCAL_ST21NFCA_H_
18 #define __LOCAL_ST21NFCA_H_
19
20 #include <net/nfc/hci.h>
21
22 #include "st21nfca_dep.h"
23 #include "st21nfca_se.h"
24
25 #define HCI_MODE 0
26
27 /* framing in HCI mode */
28 #define ST21NFCA_SOF_EOF_LEN    2
29
30 /* Almost every time value is 0 */
31 #define ST21NFCA_HCI_LLC_LEN    1
32
33 /* Size in worst case :
34  * In normal case CRC len = 2 but byte stuffing
35  * may appear in case one CRC byte = ST21NFCA_SOF_EOF
36  */
37 #define ST21NFCA_HCI_LLC_CRC    4
38
39 #define ST21NFCA_HCI_LLC_LEN_CRC        (ST21NFCA_SOF_EOF_LEN + \
40                                                 ST21NFCA_HCI_LLC_LEN + \
41                                                 ST21NFCA_HCI_LLC_CRC)
42 #define ST21NFCA_HCI_LLC_MIN_SIZE       (1 + ST21NFCA_HCI_LLC_LEN_CRC)
43
44 /* Worst case when adding byte stuffing between each byte */
45 #define ST21NFCA_HCI_LLC_MAX_PAYLOAD    29
46 #define ST21NFCA_HCI_LLC_MAX_SIZE       (ST21NFCA_HCI_LLC_LEN_CRC + 1 + \
47                                         ST21NFCA_HCI_LLC_MAX_PAYLOAD)
48
49 #define DRIVER_DESC "HCI NFC driver for ST21NFCA"
50
51 #define ST21NFCA_HCI_MODE 0
52
53 #define ST21NFCA_NUM_DEVICES 256
54
55 struct st21nfca_se_status {
56         bool is_ese_present;
57         bool is_uicc_present;
58 };
59
60 int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
61                        char *llc_name, int phy_headroom, int phy_tailroom,
62                        int phy_payload, struct nfc_hci_dev **hdev,
63                            struct st21nfca_se_status *se_status);
64 void st21nfca_hci_remove(struct nfc_hci_dev *hdev);
65
66 enum st21nfca_state {
67         ST21NFCA_ST_COLD,
68         ST21NFCA_ST_READY,
69 };
70
71 struct st21nfca_hci_info {
72         struct nfc_phy_ops *phy_ops;
73         void *phy_id;
74
75         struct nfc_hci_dev *hdev;
76         struct st21nfca_se_status *se_status;
77
78         enum st21nfca_state state;
79
80         struct mutex info_lock;
81
82         int async_cb_type;
83         data_exchange_cb_t async_cb;
84         void *async_cb_context;
85
86         struct st21nfca_dep_info dep_info;
87         struct st21nfca_se_info se_info;
88 };
89
90 /* Reader RF commands */
91 #define ST21NFCA_WR_XCHG_DATA           0x10
92
93 #define ST21NFCA_DEVICE_MGNT_GATE       0x01
94 #define ST21NFCA_RF_READER_F_GATE       0x14
95 #define ST21NFCA_RF_CARD_F_GATE                 0x24
96 #define ST21NFCA_APDU_READER_GATE               0xf0
97 #define ST21NFCA_CONNECTIVITY_GATE              0x41
98
99 #endif /* __LOCAL_ST21NFCA_H_ */