1
2
3
4
5
6
7#ifndef __NFC_DIGITAL_H
8#define __NFC_DIGITAL_H
9
10#include <linux/skbuff.h>
11#include <net/nfc/nfc.h>
12
13
14
15
16enum {
17 NFC_DIGITAL_CONFIG_RF_TECH = 0,
18 NFC_DIGITAL_CONFIG_FRAMING,
19};
20
21
22
23
24
25enum {
26 NFC_DIGITAL_RF_TECH_106A = 0,
27 NFC_DIGITAL_RF_TECH_212F,
28 NFC_DIGITAL_RF_TECH_424F,
29 NFC_DIGITAL_RF_TECH_ISO15693,
30 NFC_DIGITAL_RF_TECH_106B,
31
32 NFC_DIGITAL_RF_TECH_LAST,
33};
34
35
36
37
38
39enum {
40 NFC_DIGITAL_FRAMING_NFCA_SHORT = 0,
41 NFC_DIGITAL_FRAMING_NFCA_STANDARD,
42 NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A,
43 NFC_DIGITAL_FRAMING_NFCA_ANTICOL_COMPLETE,
44
45 NFC_DIGITAL_FRAMING_NFCA_T1T,
46 NFC_DIGITAL_FRAMING_NFCA_T2T,
47 NFC_DIGITAL_FRAMING_NFCA_T4T,
48 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP,
49
50 NFC_DIGITAL_FRAMING_NFCF,
51 NFC_DIGITAL_FRAMING_NFCF_T3T,
52 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
53 NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,
54
55 NFC_DIGITAL_FRAMING_ISO15693_INVENTORY,
56 NFC_DIGITAL_FRAMING_ISO15693_T5T,
57
58 NFC_DIGITAL_FRAMING_NFCB,
59 NFC_DIGITAL_FRAMING_NFCB_T4T,
60
61 NFC_DIGITAL_FRAMING_LAST,
62};
63
64#define DIGITAL_MDAA_NFCID1_SIZE 3
65
66struct digital_tg_mdaa_params {
67 u16 sens_res;
68 u8 nfcid1[DIGITAL_MDAA_NFCID1_SIZE];
69 u8 sel_res;
70
71 u8 nfcid2[NFC_NFCID2_MAXSIZE];
72 u16 sc;
73};
74
75struct nfc_digital_dev;
76
77
78
79
80
81
82
83
84
85
86
87typedef void (*nfc_digital_cmd_complete_t)(struct nfc_digital_dev *ddev,
88 void *arg, struct sk_buff *resp);
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146struct nfc_digital_ops {
147 int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
148 int param);
149 int (*in_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
150 u16 timeout, nfc_digital_cmd_complete_t cb,
151 void *arg);
152
153 int (*tg_configure_hw)(struct nfc_digital_dev *ddev, int type,
154 int param);
155 int (*tg_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
156 u16 timeout, nfc_digital_cmd_complete_t cb,
157 void *arg);
158 int (*tg_listen)(struct nfc_digital_dev *ddev, u16 timeout,
159 nfc_digital_cmd_complete_t cb, void *arg);
160 int (*tg_listen_mdaa)(struct nfc_digital_dev *ddev,
161 struct digital_tg_mdaa_params *mdaa_params,
162 u16 timeout, nfc_digital_cmd_complete_t cb,
163 void *arg);
164 int (*tg_listen_md)(struct nfc_digital_dev *ddev, u16 timeout,
165 nfc_digital_cmd_complete_t cb, void *arg);
166 int (*tg_get_rf_tech)(struct nfc_digital_dev *ddev, u8 *rf_tech);
167
168 int (*switch_rf)(struct nfc_digital_dev *ddev, bool on);
169 void (*abort_cmd)(struct nfc_digital_dev *ddev);
170};
171
172#define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6
173
174typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech);
175
176struct digital_poll_tech {
177 u8 rf_tech;
178 digital_poll_t poll_func;
179};
180
181
182
183
184
185
186
187
188
189#define NFC_DIGITAL_DRV_CAPS_IN_CRC 0x0001
190#define NFC_DIGITAL_DRV_CAPS_TG_CRC 0x0002
191
192struct nfc_digital_dev {
193 struct nfc_dev *nfc_dev;
194 const struct nfc_digital_ops *ops;
195
196 u32 protocols;
197
198 int tx_headroom;
199 int tx_tailroom;
200
201 u32 driver_capabilities;
202 void *driver_data;
203
204 struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX];
205 u8 poll_tech_count;
206 u8 poll_tech_index;
207 struct mutex poll_lock;
208
209 struct work_struct cmd_work;
210 struct work_struct cmd_complete_work;
211 struct list_head cmd_queue;
212 struct mutex cmd_lock;
213
214 struct delayed_work poll_work;
215
216 u8 curr_protocol;
217 u8 curr_rf_tech;
218 u8 curr_nfc_dep_pni;
219 u8 did;
220 u16 dep_rwt;
221
222 u8 local_payload_max;
223 u8 remote_payload_max;
224
225 struct sk_buff *chaining_skb;
226 struct digital_data_exch *data_exch;
227
228 int atn_count;
229 int nack_count;
230
231 struct sk_buff *saved_skb;
232
233 u16 target_fsc;
234
235 int (*skb_check_crc)(struct sk_buff *skb);
236 void (*skb_add_crc)(struct sk_buff *skb);
237};
238
239struct nfc_digital_dev *nfc_digital_allocate_device(const struct nfc_digital_ops *ops,
240 __u32 supported_protocols,
241 __u32 driver_capabilities,
242 int tx_headroom,
243 int tx_tailroom);
244void nfc_digital_free_device(struct nfc_digital_dev *ndev);
245int nfc_digital_register_device(struct nfc_digital_dev *ndev);
246void nfc_digital_unregister_device(struct nfc_digital_dev *ndev);
247
248static inline void nfc_digital_set_parent_dev(struct nfc_digital_dev *ndev,
249 struct device *dev)
250{
251 nfc_set_parent_dev(ndev->nfc_dev, dev);
252}
253
254static inline void nfc_digital_set_drvdata(struct nfc_digital_dev *dev,
255 void *data)
256{
257 dev->driver_data = data;
258}
259
260static inline void *nfc_digital_get_drvdata(struct nfc_digital_dev *dev)
261{
262 return dev->driver_data;
263}
264
265#endif
266