netfilter: arp_tables: register table in initns
[linux-2.6/btrfs-unstable.git] / drivers / nfc / st-nci / st-nci.h
blob8b9f77b0249cba10bafcc9512a1ea01a18d8a50a
1 /*
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_
22 #include "ndlc.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
35 #define ST_NCI_HCI_HOST_ID_ESE 0xc0
37 #define ST_NCI_DEVICE_MGNT_GATE 0x01
39 #define ST_NCI_VENDOR_OUI 0x0080E1 /* STMicroelectronics */
40 #define ST_NCI_FACTORY_MODE 2
42 struct nci_mode_set_cmd {
43 u8 cmd_type;
44 u8 mode;
45 } __packed;
47 struct nci_mode_set_rsp {
48 u8 status;
49 } __packed;
51 struct st_nci_se_status {
52 bool is_ese_present;
53 bool is_uicc_present;
56 struct st_nci_se_info {
57 struct st_nci_se_status *se_status;
58 u8 atr[ST_NCI_ESE_MAX_LENGTH];
59 struct completion req_completion;
61 struct timer_list bwi_timer;
62 int wt_timeout; /* in msecs */
63 bool bwi_active;
65 struct timer_list se_active_timer;
66 bool se_active;
68 bool xch_error;
70 se_io_cb_t cb;
71 void *cb_context;
74 /**
75 * enum nfc_vendor_cmds - supported nfc vendor commands
77 * @FACTORY_MODE: Allow to set the driver into a mode where no secure element
78 * are activated. It does not consider any NFC_ATTR_VENDOR_DATA.
79 * @HCI_CLEAR_ALL_PIPES: Allow to execute a HCI clear all pipes command.
80 * It does not consider any NFC_ATTR_VENDOR_DATA.
81 * @HCI_DM_PUT_DATA: Allow to configure specific CLF registry as for example
82 * RF trimmings or low level drivers configurations (I2C, SPI, SWP).
83 * @HCI_DM_UPDATE_AID: Allow to configure an AID routing into the CLF routing
84 * table following RF technology, CLF mode or protocol.
85 * @HCI_DM_GET_INFO: Allow to retrieve CLF information.
86 * @HCI_DM_GET_DATA: Allow to retrieve CLF configurable data such as low
87 * level drivers configurations or RF trimmings.
88 * @HCI_DM_DIRECT_LOAD: Allow to load a firmware into the CLF. A complete
89 * packet can be more than 8KB.
90 * @HCI_DM_RESET: Allow to run a CLF reset in order to "commit" CLF
91 * configuration changes without CLF power off.
92 * @HCI_GET_PARAM: Allow to retrieve an HCI CLF parameter (for example the
93 * white list).
94 * @HCI_DM_FIELD_GENERATOR: Allow to generate different kind of RF
95 * technology. When using this command to anti-collision is done.
96 * @HCI_LOOPBACK: Allow to echo a command and test the Dh to CLF
97 * connectivity.
98 * @HCI_DM_VDC_MEASUREMENT_VALUE: Allow to measure the field applied on the
99 * CLF antenna. A value between 0 and 0x0f is returned. 0 is maximum.
100 * @HCI_DM_FWUPD_START: Allow to put CLF into firmware update mode. It is a
101 * specific CLF command as there is no GPIO for this.
102 * @HCI_DM_FWUPD_END: Allow to complete firmware update.
103 * @HCI_DM_VDC_VALUE_COMPARISON: Allow to compare the field applied on the
104 * CLF antenna to a reference value.
105 * @MANUFACTURER_SPECIFIC: Allow to retrieve manufacturer specific data
106 * received during a NCI_CORE_INIT_CMD.
108 enum nfc_vendor_cmds {
109 FACTORY_MODE,
110 HCI_CLEAR_ALL_PIPES,
111 HCI_DM_PUT_DATA,
112 HCI_DM_UPDATE_AID,
113 HCI_DM_GET_INFO,
114 HCI_DM_GET_DATA,
115 HCI_DM_DIRECT_LOAD,
116 HCI_DM_RESET,
117 HCI_GET_PARAM,
118 HCI_DM_FIELD_GENERATOR,
119 HCI_LOOPBACK,
120 HCI_DM_FWUPD_START,
121 HCI_DM_FWUPD_END,
122 HCI_DM_VDC_MEASUREMENT_VALUE,
123 HCI_DM_VDC_VALUE_COMPARISON,
124 MANUFACTURER_SPECIFIC,
127 struct st_nci_vendor_info {
128 struct completion req_completion;
129 struct sk_buff *rx_skb;
132 struct st_nci_info {
133 struct llt_ndlc *ndlc;
134 unsigned long flags;
136 struct st_nci_se_info se_info;
137 struct st_nci_vendor_info vendor_info;
140 void st_nci_remove(struct nci_dev *ndev);
141 int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
142 int phy_tailroom, struct st_nci_se_status *se_status);
144 int st_nci_se_init(struct nci_dev *ndev, struct st_nci_se_status *se_status);
145 void st_nci_se_deinit(struct nci_dev *ndev);
147 int st_nci_discover_se(struct nci_dev *ndev);
148 int st_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
149 int st_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
150 int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
151 u8 *apdu, size_t apdu_length,
152 se_io_cb_t cb, void *cb_context);
153 int st_nci_hci_load_session(struct nci_dev *ndev);
154 void st_nci_hci_event_received(struct nci_dev *ndev, u8 pipe,
155 u8 event, struct sk_buff *skb);
156 void st_nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
157 struct sk_buff *skb);
159 void st_nci_hci_loopback_event_received(struct nci_dev *ndev, u8 event,
160 struct sk_buff *skb);
161 int st_nci_vendor_cmds_init(struct nci_dev *ndev);
163 #endif /* __LOCAL_ST_NCI_H_ */