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