2 * NCI based Driver for STMicroelectronics NFC Chip
4 * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
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.
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.
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/>.
19 #ifndef __LOCAL_ST_NCI_H_
20 #define __LOCAL_ST_NCI_H_
24 /* Define private flags: */
25 #define ST_NCI_RUNNING 1
27 #define ST_NCI_CORE_PROP 0x01
28 #define ST_NCI_SET_NFC_MODE 0x02
31 * ref ISO7816-3 chap 8.1. the initial character TS is followed by a
32 * sequence of at most 32 characters.
34 #define ST_NCI_ESE_MAX_LENGTH 33
36 #define ST_NCI_DEVICE_MGNT_GATE 0x01
38 #define ST_NCI_VENDOR_OUI 0x0080E1 /* STMicroelectronics */
39 #define ST_NCI_FACTORY_MODE 2
41 struct nci_mode_set_cmd {
46 struct nci_mode_set_rsp {
50 struct st_nci_se_status {
55 struct st_nci_se_info {
56 struct st_nci_se_status *se_status;
57 u8 atr[ST_NCI_ESE_MAX_LENGTH];
58 struct completion req_completion;
60 struct timer_list bwi_timer;
61 int wt_timeout; /* in msecs */
64 struct timer_list se_active_timer;
74 * enum nfc_vendor_cmds - supported nfc vendor commands
76 * @FACTORY_MODE: Allow to set the driver into a mode where no secure element
77 * are activated. It does not consider any NFC_ATTR_VENDOR_DATA.
78 * @HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes command.
79 * It does not consider any NFC_ATTR_VENDOR_DATA.
80 * @HCI_DM_PUT_DATA: Allow to configure specific CLF registry as for example
81 * RF trimmings or low level drivers configurations (I2C, SPI, SWP).
82 * @HCI_DM_UPDATE_AID: Allow to configure an AID routing into the CLF routing
83 * table following RF technology, CLF mode or protocol.
84 * @HCI_DM_GET_INFO: Allow to retrieve CLF information.
85 * @HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as low
86 * level drivers configurations or RF trimmings.
87 * @HCI_DM_DIRECT_LOAD: Allow to load a firmware into the CLF. A complete
88 * packet can be more than 8KB.
89 * @HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF
90 * configuration changes without CLF power off.
91 * @HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example the
93 * @HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF
94 * technology. When using this command to anti-collision is done.
95 * @LOOPBACK: Allow to echo a command and test the Dh to CLF connectivity.
96 * @HCI_DM_VDC_MEASUREMENT_VALUE: Allow to measure the field applied on the
97 * CLF antenna. A value between 0 and 0x0f is returned. 0 is maximum.
98 * @HCI_DM_FWUPD_START: Allow to put CLF into firmware update mode. It is a
99 * specific CLF command as there is no GPIO for this.
100 * @HCI_DM_FWUPD_END: Allow to complete firmware update.
101 * @HCI_DM_VDC_VALUE_COMPARISON: Allow to compare the field applied on the
102 * CLF antenna to a reference value.
103 * @MANUFACTURER_SPECIFIC: Allow to retrieve manufacturer specific data
104 * received during a NCI_CORE_INIT_CMD.
106 enum nfc_vendor_cmds {
116 HCI_DM_FIELD_GENERATOR,
120 HCI_DM_VDC_MEASUREMENT_VALUE,
121 HCI_DM_VDC_VALUE_COMPARISON,
122 MANUFACTURER_SPECIFIC,
126 struct llt_ndlc *ndlc;
129 struct st_nci_se_info se_info;
132 void st_nci_remove(struct nci_dev *ndev);
133 int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
134 int phy_tailroom, struct st_nci_se_status *se_status);
136 int st_nci_se_init(struct nci_dev *ndev, struct st_nci_se_status *se_status);
137 void st_nci_se_deinit(struct nci_dev *ndev);
139 int st_nci_discover_se(struct nci_dev *ndev);
140 int st_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
141 int st_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
142 int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
143 u8 *apdu, size_t apdu_length,
144 se_io_cb_t cb, void *cb_context);
145 int st_nci_hci_load_session(struct nci_dev *ndev);
146 void st_nci_hci_event_received(struct nci_dev *ndev, u8 pipe,
147 u8 event, struct sk_buff *skb);
148 void st_nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
149 struct sk_buff *skb);
151 int st_nci_vendor_cmds_init(struct nci_dev *ndev);
153 #endif /* __LOCAL_ST_NCI_H_ */