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
53 NFC_DIGITAL_FRAMING_NFCA_T1T,
54 NFC_DIGITAL_FRAMING_NFCA_T2T,
55 NFC_DIGITAL_FRAMING_NFCA_T4T,
56 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP,
57
58 NFC_DIGITAL_FRAMING_NFCF,
59 NFC_DIGITAL_FRAMING_NFCF_T3T,
60 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
61 NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,
62
63 NFC_DIGITAL_FRAMING_ISO15693_INVENTORY,
64 NFC_DIGITAL_FRAMING_ISO15693_T5T,
65
66 NFC_DIGITAL_FRAMING_NFCB,
67 NFC_DIGITAL_FRAMING_NFCB_T4T,
68
69 NFC_DIGITAL_FRAMING_LAST,
70};
71
72#define DIGITAL_MDAA_NFCID1_SIZE 3
73
74struct digital_tg_mdaa_params {
75 u16 sens_res;
76 u8 nfcid1[DIGITAL_MDAA_NFCID1_SIZE];
77 u8 sel_res;
78
79 u8 nfcid2[NFC_NFCID2_MAXSIZE];
80 u16 sc;
81};
82
83struct nfc_digital_dev;
84
85
86
87
88
89
90
91
92
93
94
95typedef void (*nfc_digital_cmd_complete_t)(struct nfc_digital_dev *ddev,
96 void *arg, struct sk_buff *resp);
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
145struct nfc_digital_ops {
146 int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
147 int param);
148 int (*in_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
149 u16 timeout, nfc_digital_cmd_complete_t cb,
150 void *arg);
151
152 int (*tg_configure_hw)(struct nfc_digital_dev *ddev, int type,
153 int param);
154 int (*tg_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
155 u16 timeout, nfc_digital_cmd_complete_t cb,
156 void *arg);
157 int (*tg_listen)(struct nfc_digital_dev *ddev, u16 timeout,
158 nfc_digital_cmd_complete_t cb, void *arg);
159 int (*tg_listen_mdaa)(struct nfc_digital_dev *ddev,
160 struct digital_tg_mdaa_params *mdaa_params,
161 u16 timeout, nfc_digital_cmd_complete_t cb,
162 void *arg);
163
164 int (*switch_rf)(struct nfc_digital_dev *ddev, bool on);
165 void (*abort_cmd)(struct nfc_digital_dev *ddev);
166};
167
168#define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6
169
170typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech);
171
172struct digital_poll_tech {
173 u8 rf_tech;
174 digital_poll_t poll_func;
175};
176
177
178
179
180
181
182
183
184
185#define NFC_DIGITAL_DRV_CAPS_IN_CRC 0x0001
186#define NFC_DIGITAL_DRV_CAPS_TG_CRC 0x0002
187
188struct nfc_digital_dev {
189 struct nfc_dev *nfc_dev;
190 struct nfc_digital_ops *ops;
191
192 u32 protocols;
193
194 int tx_headroom;
195 int tx_tailroom;
196
197 u32 driver_capabilities;
198 void *driver_data;
199
200 struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX];
201 u8 poll_tech_count;
202 u8 poll_tech_index;
203 struct mutex poll_lock;
204
205 struct work_struct cmd_work;
206 struct work_struct cmd_complete_work;
207 struct list_head cmd_queue;
208 struct mutex cmd_lock;
209
210 struct work_struct poll_work;
211
212 u8 curr_protocol;
213 u8 curr_rf_tech;
214 u8 curr_nfc_dep_pni;
215
216 u16 target_fsc;
217
218 int (*skb_check_crc)(struct sk_buff *skb);
219 void (*skb_add_crc)(struct sk_buff *skb);
220};
221
222struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
223 __u32 supported_protocols,
224 __u32 driver_capabilities,
225 int tx_headroom,
226 int tx_tailroom);
227void nfc_digital_free_device(struct nfc_digital_dev *ndev);
228int nfc_digital_register_device(struct nfc_digital_dev *ndev);
229void nfc_digital_unregister_device(struct nfc_digital_dev *ndev);
230
231static inline void nfc_digital_set_parent_dev(struct nfc_digital_dev *ndev,
232 struct device *dev)
233{
234 nfc_set_parent_dev(ndev->nfc_dev, dev);
235}
236
237static inline void nfc_digital_set_drvdata(struct nfc_digital_dev *dev,
238 void *data)
239{
240 dev->driver_data = data;
241}
242
243static inline void *nfc_digital_get_drvdata(struct nfc_digital_dev *dev)
244{
245 return dev->driver_data;
246}
247
248#endif
249