blob: d81242f4a92b8079cfb6faf03e125c5205b6734c [file] [log] [blame]
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001/*
2 * HCI based Driver for NXP PN544 NFC Chip
3 *
4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 *
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.
9 *
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#include <linux/crc-ccitt.h>
22#include <linux/module.h>
23#include <linux/delay.h>
24#include <linux/slab.h>
25#include <linux/miscdevice.h>
26#include <linux/interrupt.h>
27#include <linux/gpio.h>
28#include <linux/i2c.h>
29
30#include <linux/nfc.h>
31#include <net/nfc/hci.h>
Eric Lapuyade412fda52012-09-18 19:45:48 +020032#include <net/nfc/llc.h>
Eric Lapuyadebbed0de2012-05-07 12:31:29 +020033
34#include <linux/nfc/pn544.h>
35
36#define DRIVER_DESC "HCI NFC driver for PN544"
37
38#define PN544_HCI_DRIVER_NAME "pn544_hci"
39
40/* Timing restrictions (ms) */
41#define PN544_HCI_RESETVEN_TIME 30
42
43static struct i2c_device_id pn544_hci_id_table[] = {
44 {"pn544", 0},
45 {}
46};
47
48MODULE_DEVICE_TABLE(i2c, pn544_hci_id_table);
49
50#define HCI_MODE 0
51#define FW_MODE 1
52
53/* framing in HCI mode */
54#define PN544_HCI_LLC_LEN 1
55#define PN544_HCI_LLC_CRC 2
56#define PN544_HCI_LLC_LEN_CRC (PN544_HCI_LLC_LEN + PN544_HCI_LLC_CRC)
57#define PN544_HCI_LLC_MIN_SIZE (1 + PN544_HCI_LLC_LEN_CRC)
58#define PN544_HCI_LLC_MAX_PAYLOAD 29
59#define PN544_HCI_LLC_MAX_SIZE (PN544_HCI_LLC_LEN_CRC + 1 + \
60 PN544_HCI_LLC_MAX_PAYLOAD)
61
62enum pn544_state {
63 PN544_ST_COLD,
64 PN544_ST_FW_READY,
65 PN544_ST_READY,
66};
67
68#define FULL_VERSION_LEN 11
69
70/* Proprietary commands */
71#define PN544_WRITE 0x3f
72
73/* Proprietary gates, events, commands and registers */
74
75/* NFC_HCI_RF_READER_A_GATE additional registers and commands */
76#define PN544_RF_READER_A_AUTO_ACTIVATION 0x10
77#define PN544_RF_READER_A_CMD_CONTINUE_ACTIVATION 0x12
78#define PN544_MIFARE_CMD 0x21
79
80/* Commands that apply to all RF readers */
81#define PN544_RF_READER_CMD_PRESENCE_CHECK 0x30
82#define PN544_RF_READER_CMD_ACTIVATE_NEXT 0x32
83
84/* NFC_HCI_ID_MGMT_GATE additional registers */
85#define PN544_ID_MGMT_FULL_VERSION_SW 0x10
86
87#define PN544_RF_READER_ISO15693_GATE 0x12
88
89#define PN544_RF_READER_F_GATE 0x14
90#define PN544_FELICA_ID 0x04
91#define PN544_FELICA_RAW 0x20
92
93#define PN544_RF_READER_JEWEL_GATE 0x15
94#define PN544_JEWEL_RAW_CMD 0x23
95
96#define PN544_RF_READER_NFCIP1_INITIATOR_GATE 0x30
97#define PN544_RF_READER_NFCIP1_TARGET_GATE 0x31
98
99#define PN544_SYS_MGMT_GATE 0x90
100#define PN544_SYS_MGMT_INFO_NOTIFICATION 0x02
101
102#define PN544_POLLING_LOOP_MGMT_GATE 0x94
Arron Wang7e2afc92012-09-27 17:32:54 +0800103#define PN544_DEP_MODE 0x01
104#define PN544_DEP_ATR_REQ 0x02
105#define PN544_DEP_ATR_RES 0x03
106#define PN544_DEP_MERGE 0x0D
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200107#define PN544_PL_RDPHASES 0x06
108#define PN544_PL_EMULATION 0x07
109#define PN544_PL_NFCT_DEACTIVATED 0x09
110
111#define PN544_SWP_MGMT_GATE 0xA0
112
113#define PN544_NFC_WI_MGMT_GATE 0xA1
114
Arron Wangf7a5f6c2012-09-27 17:32:55 +0800115#define PN544_HCI_EVT_SND_DATA 0x01
116#define PN544_HCI_EVT_ACTIVATED 0x02
117#define PN544_HCI_EVT_DEACTIVATED 0x03
118#define PN544_HCI_EVT_RCV_DATA 0x04
119#define PN544_HCI_EVT_CONTINUE_MI 0x05
120
Eric Lapuyadea10d5952012-06-05 14:42:11 +0200121static struct nfc_hci_gate pn544_gates[] = {
122 {NFC_HCI_ADMIN_GATE, NFC_HCI_INVALID_PIPE},
123 {NFC_HCI_LOOPBACK_GATE, NFC_HCI_INVALID_PIPE},
124 {NFC_HCI_ID_MGMT_GATE, NFC_HCI_INVALID_PIPE},
125 {NFC_HCI_LINK_MGMT_GATE, NFC_HCI_INVALID_PIPE},
126 {NFC_HCI_RF_READER_B_GATE, NFC_HCI_INVALID_PIPE},
127 {NFC_HCI_RF_READER_A_GATE, NFC_HCI_INVALID_PIPE},
128 {PN544_SYS_MGMT_GATE, NFC_HCI_INVALID_PIPE},
129 {PN544_SWP_MGMT_GATE, NFC_HCI_INVALID_PIPE},
130 {PN544_POLLING_LOOP_MGMT_GATE, NFC_HCI_INVALID_PIPE},
131 {PN544_NFC_WI_MGMT_GATE, NFC_HCI_INVALID_PIPE},
132 {PN544_RF_READER_F_GATE, NFC_HCI_INVALID_PIPE},
133 {PN544_RF_READER_JEWEL_GATE, NFC_HCI_INVALID_PIPE},
134 {PN544_RF_READER_ISO15693_GATE, NFC_HCI_INVALID_PIPE},
135 {PN544_RF_READER_NFCIP1_INITIATOR_GATE, NFC_HCI_INVALID_PIPE},
136 {PN544_RF_READER_NFCIP1_TARGET_GATE, NFC_HCI_INVALID_PIPE}
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200137};
138
139/* Largest headroom needed for outgoing custom commands */
140#define PN544_CMDS_HEADROOM 2
Waldemar Rymarkiewiczade67202012-09-07 11:08:29 +0200141#define PN544_FRAME_HEADROOM 1
142#define PN544_FRAME_TAILROOM 2
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200143
144struct pn544_hci_info {
145 struct i2c_client *i2c_dev;
Eric Lapuyade412fda52012-09-18 19:45:48 +0200146 struct nfc_hci_dev *hdev;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200147
148 enum pn544_state state;
149
150 struct mutex info_lock;
151
152 unsigned int gpio_en;
153 unsigned int gpio_irq;
154 unsigned int gpio_fw;
155 unsigned int en_polarity;
156
157 int hard_fault; /*
158 * < 0 if hardware error occured (e.g. i2c err)
159 * and prevents normal operation.
160 */
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200161 int async_cb_type;
162 data_exchange_cb_t async_cb;
163 void *async_cb_context;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200164};
165
166static void pn544_hci_platform_init(struct pn544_hci_info *info)
167{
168 int polarity, retry, ret;
169 char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 };
170 int count = sizeof(rset_cmd);
171
172 pr_info(DRIVER_DESC ": %s\n", __func__);
173 dev_info(&info->i2c_dev->dev, "Detecting nfc_en polarity\n");
174
175 /* Disable fw download */
176 gpio_set_value(info->gpio_fw, 0);
177
178 for (polarity = 0; polarity < 2; polarity++) {
179 info->en_polarity = polarity;
180 retry = 3;
181 while (retry--) {
182 /* power off */
183 gpio_set_value(info->gpio_en, !info->en_polarity);
184 usleep_range(10000, 15000);
185
186 /* power on */
187 gpio_set_value(info->gpio_en, info->en_polarity);
188 usleep_range(10000, 15000);
189
190 /* send reset */
191 dev_dbg(&info->i2c_dev->dev, "Sending reset cmd\n");
192 ret = i2c_master_send(info->i2c_dev, rset_cmd, count);
193 if (ret == count) {
194 dev_info(&info->i2c_dev->dev,
195 "nfc_en polarity : active %s\n",
196 (polarity == 0 ? "low" : "high"));
197 goto out;
198 }
199 }
200 }
201
202 dev_err(&info->i2c_dev->dev,
203 "Could not detect nfc_en polarity, fallback to active high\n");
204
205out:
206 gpio_set_value(info->gpio_en, !info->en_polarity);
207}
208
209static int pn544_hci_enable(struct pn544_hci_info *info, int mode)
210{
211 pr_info(DRIVER_DESC ": %s\n", __func__);
212
213 gpio_set_value(info->gpio_fw, 0);
214 gpio_set_value(info->gpio_en, info->en_polarity);
215 usleep_range(10000, 15000);
216
217 return 0;
218}
219
220static void pn544_hci_disable(struct pn544_hci_info *info)
221{
222 pr_info(DRIVER_DESC ": %s\n", __func__);
223
224 gpio_set_value(info->gpio_fw, 0);
225 gpio_set_value(info->gpio_en, !info->en_polarity);
226 usleep_range(10000, 15000);
227
228 gpio_set_value(info->gpio_en, info->en_polarity);
229 usleep_range(10000, 15000);
230
231 gpio_set_value(info->gpio_en, !info->en_polarity);
232 usleep_range(10000, 15000);
233}
234
235static int pn544_hci_i2c_write(struct i2c_client *client, u8 *buf, int len)
236{
237 int r;
238
239 usleep_range(3000, 6000);
240
241 r = i2c_master_send(client, buf, len);
242
243 if (r == -EREMOTEIO) { /* Retry, chip was in standby */
244 usleep_range(6000, 10000);
245 r = i2c_master_send(client, buf, len);
246 }
247
Waldemar Rymarkiewicz96e32402012-09-20 08:59:10 +0200248 if (r >= 0) {
249 if (r != len)
250 return -EREMOTEIO;
251 else
252 return 0;
253 }
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200254
255 return r;
256}
257
258static int check_crc(u8 *buf, int buflen)
259{
Dan Carpenter885ba1d2012-05-18 10:36:47 +0300260 int len;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200261 u16 crc;
262
263 len = buf[0] + 1;
264 crc = crc_ccitt(0xffff, buf, len - 2);
265 crc = ~crc;
266
267 if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) {
268 pr_err(PN544_HCI_DRIVER_NAME ": CRC error 0x%x != 0x%x 0x%x\n",
269 crc, buf[len - 1], buf[len - 2]);
270
271 pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__);
272 print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE,
273 16, 2, buf, buflen, false);
274 return -EPERM;
275 }
276 return 0;
277}
278
279/*
280 * Reads an shdlc frame and returns it in a newly allocated sk_buff. Guarantees
281 * that i2c bus will be flushed and that next read will start on a new frame.
282 * returned skb contains only LLC header and payload.
283 * returns:
284 * -EREMOTEIO : i2c read error (fatal)
285 * -EBADMSG : frame was incorrect and discarded
286 * -ENOMEM : cannot allocate skb, frame dropped
287 */
288static int pn544_hci_i2c_read(struct i2c_client *client, struct sk_buff **skb)
289{
290 int r;
291 u8 len;
292 u8 tmp[PN544_HCI_LLC_MAX_SIZE - 1];
293
294 r = i2c_master_recv(client, &len, 1);
295 if (r != 1) {
296 dev_err(&client->dev, "cannot read len byte\n");
297 return -EREMOTEIO;
298 }
299
300 if ((len < (PN544_HCI_LLC_MIN_SIZE - 1)) ||
301 (len > (PN544_HCI_LLC_MAX_SIZE - 1))) {
302 dev_err(&client->dev, "invalid len byte\n");
303 r = -EBADMSG;
304 goto flush;
305 }
306
307 *skb = alloc_skb(1 + len, GFP_KERNEL);
308 if (*skb == NULL) {
309 r = -ENOMEM;
310 goto flush;
311 }
312
313 *skb_put(*skb, 1) = len;
314
315 r = i2c_master_recv(client, skb_put(*skb, len), len);
316 if (r != len) {
317 kfree_skb(*skb);
318 return -EREMOTEIO;
319 }
320
321 r = check_crc((*skb)->data, (*skb)->len);
322 if (r != 0) {
323 kfree_skb(*skb);
324 r = -EBADMSG;
325 goto flush;
326 }
327
328 skb_pull(*skb, 1);
329 skb_trim(*skb, (*skb)->len - 2);
330
331 usleep_range(3000, 6000);
332
333 return 0;
334
335flush:
336 if (i2c_master_recv(client, tmp, sizeof(tmp)) < 0)
337 r = -EREMOTEIO;
338
339 usleep_range(3000, 6000);
340
341 return r;
342}
343
344/*
345 * Reads an shdlc frame from the chip. This is not as straightforward as it
346 * seems. There are cases where we could loose the frame start synchronization.
347 * The frame format is len-data-crc, and corruption can occur anywhere while
348 * transiting on i2c bus, such that we could read an invalid len.
349 * In order to recover synchronization with the next frame, we must be sure
350 * to read the real amount of data without using the len byte. We do this by
351 * assuming the following:
352 * - the chip will always present only one single complete frame on the bus
353 * before triggering the interrupt
354 * - the chip will not present a new frame until we have completely read
355 * the previous one (or until we have handled the interrupt).
356 * The tricky case is when we read a corrupted len that is less than the real
357 * len. We must detect this here in order to determine that we need to flush
358 * the bus. This is the reason why we check the crc here.
359 */
360static irqreturn_t pn544_hci_irq_thread_fn(int irq, void *dev_id)
361{
362 struct pn544_hci_info *info = dev_id;
Wei Yongjunc51ad342012-09-08 21:19:44 +0800363 struct i2c_client *client;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200364 struct sk_buff *skb = NULL;
365 int r;
366
Wei Yongjunc51ad342012-09-08 21:19:44 +0800367 if (!info || irq != info->i2c_dev->irq) {
368 WARN_ON_ONCE(1);
369 return IRQ_NONE;
370 }
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200371
Wei Yongjunc51ad342012-09-08 21:19:44 +0800372 client = info->i2c_dev;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200373 dev_dbg(&client->dev, "IRQ\n");
374
375 if (info->hard_fault != 0)
376 return IRQ_HANDLED;
377
378 r = pn544_hci_i2c_read(client, &skb);
379 if (r == -EREMOTEIO) {
380 info->hard_fault = r;
381
Eric Lapuyade412fda52012-09-18 19:45:48 +0200382 nfc_hci_recv_frame(info->hdev, NULL);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200383
384 return IRQ_HANDLED;
385 } else if ((r == -ENOMEM) || (r == -EBADMSG)) {
386 return IRQ_HANDLED;
387 }
388
Eric Lapuyade412fda52012-09-18 19:45:48 +0200389 nfc_hci_recv_frame(info->hdev, skb);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200390
391 return IRQ_HANDLED;
392}
393
Eric Lapuyade412fda52012-09-18 19:45:48 +0200394static int pn544_hci_open(struct nfc_hci_dev *hdev)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200395{
Eric Lapuyade412fda52012-09-18 19:45:48 +0200396 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200397 int r = 0;
398
399 mutex_lock(&info->info_lock);
400
401 if (info->state != PN544_ST_COLD) {
402 r = -EBUSY;
403 goto out;
404 }
405
406 r = pn544_hci_enable(info, HCI_MODE);
407
Eric Lapuyadeeae202a2012-05-30 18:13:06 +0200408 if (r == 0)
409 info->state = PN544_ST_READY;
410
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200411out:
412 mutex_unlock(&info->info_lock);
413 return r;
414}
415
Eric Lapuyade412fda52012-09-18 19:45:48 +0200416static void pn544_hci_close(struct nfc_hci_dev *hdev)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200417{
Eric Lapuyade412fda52012-09-18 19:45:48 +0200418 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200419
420 mutex_lock(&info->info_lock);
421
422 if (info->state == PN544_ST_COLD)
423 goto out;
424
425 pn544_hci_disable(info);
426
Eric Lapuyadeeae202a2012-05-30 18:13:06 +0200427 info->state = PN544_ST_COLD;
428
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200429out:
430 mutex_unlock(&info->info_lock);
431}
432
Eric Lapuyade412fda52012-09-18 19:45:48 +0200433static int pn544_hci_ready(struct nfc_hci_dev *hdev)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200434{
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200435 struct sk_buff *skb;
436 static struct hw_config {
437 u8 adr[2];
438 u8 value;
439 } hw_config[] = {
440 {{0x9f, 0x9a}, 0x00},
441
442 {{0x98, 0x10}, 0xbc},
443
444 {{0x9e, 0x71}, 0x00},
445
446 {{0x98, 0x09}, 0x00},
447
448 {{0x9e, 0xb4}, 0x00},
449
450 {{0x9e, 0xd9}, 0xff},
451 {{0x9e, 0xda}, 0xff},
452 {{0x9e, 0xdb}, 0x23},
453 {{0x9e, 0xdc}, 0x21},
454 {{0x9e, 0xdd}, 0x22},
455 {{0x9e, 0xde}, 0x24},
456
457 {{0x9c, 0x01}, 0x08},
458
459 {{0x9e, 0xaa}, 0x01},
460
461 {{0x9b, 0xd1}, 0x0d},
462 {{0x9b, 0xd2}, 0x24},
463 {{0x9b, 0xd3}, 0x0a},
464 {{0x9b, 0xd4}, 0x22},
465 {{0x9b, 0xd5}, 0x08},
466 {{0x9b, 0xd6}, 0x1e},
467 {{0x9b, 0xdd}, 0x1c},
468
469 {{0x9b, 0x84}, 0x13},
470 {{0x99, 0x81}, 0x7f},
471 {{0x99, 0x31}, 0x70},
472
473 {{0x98, 0x00}, 0x3f},
474
475 {{0x9f, 0x09}, 0x00},
476
477 {{0x9f, 0x0a}, 0x05},
478
479 {{0x9e, 0xd1}, 0xa1},
480 {{0x99, 0x23}, 0x00},
481
482 {{0x9e, 0x74}, 0x80},
483
484 {{0x9f, 0x28}, 0x10},
485
486 {{0x9f, 0x35}, 0x14},
487
488 {{0x9f, 0x36}, 0x60},
489
490 {{0x9c, 0x31}, 0x00},
491
492 {{0x9c, 0x32}, 0xc8},
493
494 {{0x9c, 0x19}, 0x40},
495
496 {{0x9c, 0x1a}, 0x40},
497
498 {{0x9c, 0x0c}, 0x00},
499
500 {{0x9c, 0x0d}, 0x00},
501
502 {{0x9c, 0x12}, 0x00},
503
504 {{0x9c, 0x13}, 0x00},
505
506 {{0x98, 0xa2}, 0x0e},
507
508 {{0x98, 0x93}, 0x40},
509
510 {{0x98, 0x7d}, 0x02},
511 {{0x98, 0x7e}, 0x00},
512 {{0x9f, 0xc8}, 0x01},
513 };
514 struct hw_config *p = hw_config;
515 int count = ARRAY_SIZE(hw_config);
516 struct sk_buff *res_skb;
517 u8 param[4];
518 int r;
519
520 param[0] = 0;
521 while (count--) {
522 param[1] = p->adr[0];
523 param[2] = p->adr[1];
524 param[3] = p->value;
525
526 r = nfc_hci_send_cmd(hdev, PN544_SYS_MGMT_GATE, PN544_WRITE,
527 param, 4, &res_skb);
528 if (r < 0)
529 return r;
530
531 if (res_skb->len != 1) {
532 kfree_skb(res_skb);
533 return -EPROTO;
534 }
535
536 if (res_skb->data[0] != p->value) {
537 kfree_skb(res_skb);
538 return -EIO;
539 }
540
541 kfree_skb(res_skb);
542
543 p++;
544 }
545
546 param[0] = NFC_HCI_UICC_HOST_ID;
547 r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE,
548 NFC_HCI_ADMIN_WHITELIST, param, 1);
549 if (r < 0)
550 return r;
551
552 param[0] = 0x3d;
553 r = nfc_hci_set_param(hdev, PN544_SYS_MGMT_GATE,
554 PN544_SYS_MGMT_INFO_NOTIFICATION, param, 1);
555 if (r < 0)
556 return r;
557
558 param[0] = 0x0;
559 r = nfc_hci_set_param(hdev, NFC_HCI_RF_READER_A_GATE,
560 PN544_RF_READER_A_AUTO_ACTIVATION, param, 1);
561 if (r < 0)
562 return r;
563
564 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
565 NFC_HCI_EVT_END_OPERATION, NULL, 0);
566 if (r < 0)
567 return r;
568
569 param[0] = 0x1;
570 r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
571 PN544_PL_NFCT_DEACTIVATED, param, 1);
572 if (r < 0)
573 return r;
574
575 param[0] = 0x0;
576 r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
577 PN544_PL_RDPHASES, param, 1);
578 if (r < 0)
579 return r;
580
581 r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE,
582 PN544_ID_MGMT_FULL_VERSION_SW, &skb);
583 if (r < 0)
584 return r;
585
586 if (skb->len != FULL_VERSION_LEN) {
587 kfree_skb(skb);
588 return -EINVAL;
589 }
590
591 print_hex_dump(KERN_DEBUG, "FULL VERSION SOFTWARE INFO: ",
592 DUMP_PREFIX_NONE, 16, 1,
593 skb->data, FULL_VERSION_LEN, false);
594
595 kfree_skb(skb);
596
597 return 0;
598}
599
Waldemar Rymarkiewiczade67202012-09-07 11:08:29 +0200600static void pn544_hci_add_len_crc(struct sk_buff *skb)
601{
602 u16 crc;
603 int len;
604
605 len = skb->len + 2;
606 *skb_push(skb, 1) = len;
607
608 crc = crc_ccitt(0xffff, skb->data, skb->len);
609 crc = ~crc;
610 *skb_put(skb, 1) = crc & 0xff;
611 *skb_put(skb, 1) = crc >> 8;
612}
613
614static void pn544_hci_remove_len_crc(struct sk_buff *skb)
615{
616 skb_pull(skb, PN544_FRAME_HEADROOM);
617 skb_trim(skb, PN544_FRAME_TAILROOM);
618}
619
Eric Lapuyade412fda52012-09-18 19:45:48 +0200620static int pn544_hci_xmit(struct nfc_hci_dev *hdev, struct sk_buff *skb)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200621{
Eric Lapuyade412fda52012-09-18 19:45:48 +0200622 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200623 struct i2c_client *client = info->i2c_dev;
Waldemar Rymarkiewiczade67202012-09-07 11:08:29 +0200624 int r;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200625
626 if (info->hard_fault != 0)
627 return info->hard_fault;
628
Waldemar Rymarkiewiczade67202012-09-07 11:08:29 +0200629 pn544_hci_add_len_crc(skb);
630 r = pn544_hci_i2c_write(client, skb->data, skb->len);
631 pn544_hci_remove_len_crc(skb);
632
633 return r;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200634}
635
Eric Lapuyade412fda52012-09-18 19:45:48 +0200636static int pn544_hci_start_poll(struct nfc_hci_dev *hdev,
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200637 u32 im_protocols, u32 tm_protocols)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200638{
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200639 u8 phases = 0;
640 int r;
641 u8 duration[2];
642 u8 activated;
Arron Wang7e2afc92012-09-27 17:32:54 +0800643 u8 i_mode = 0x3f; /* Enable all supported modes */
644 u8 t_mode = 0x0f;
645 u8 t_merge = 0x01; /* Enable merge by default */
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200646
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200647 pr_info(DRIVER_DESC ": %s protocols 0x%x 0x%x\n",
648 __func__, im_protocols, tm_protocols);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200649
650 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
651 NFC_HCI_EVT_END_OPERATION, NULL, 0);
652 if (r < 0)
653 return r;
654
655 duration[0] = 0x18;
656 duration[1] = 0x6a;
657 r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
658 PN544_PL_EMULATION, duration, 2);
659 if (r < 0)
660 return r;
661
662 activated = 0;
663 r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
664 PN544_PL_NFCT_DEACTIVATED, &activated, 1);
665 if (r < 0)
666 return r;
667
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200668 if (im_protocols & (NFC_PROTO_ISO14443_MASK | NFC_PROTO_MIFARE_MASK |
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200669 NFC_PROTO_JEWEL_MASK))
670 phases |= 1; /* Type A */
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200671 if (im_protocols & NFC_PROTO_FELICA_MASK) {
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200672 phases |= (1 << 2); /* Type F 212 */
673 phases |= (1 << 3); /* Type F 424 */
674 }
675
676 phases |= (1 << 5); /* NFC active */
677
678 r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
679 PN544_PL_RDPHASES, &phases, 1);
680 if (r < 0)
681 return r;
682
Arron Wang7e2afc92012-09-27 17:32:54 +0800683 if ((im_protocols | tm_protocols) & NFC_PROTO_NFC_DEP_MASK) {
684 hdev->gb = nfc_get_local_general_bytes(hdev->ndev,
685 &hdev->gb_len);
686 pr_debug("generate local bytes %p", hdev->gb);
687 if (hdev->gb == NULL || hdev->gb_len == 0) {
688 im_protocols &= ~NFC_PROTO_NFC_DEP_MASK;
689 tm_protocols &= ~NFC_PROTO_NFC_DEP_MASK;
690 }
691 }
692
693 if (im_protocols & NFC_PROTO_NFC_DEP_MASK) {
694 r = nfc_hci_send_event(hdev,
695 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
696 NFC_HCI_EVT_END_OPERATION, NULL, 0);
697 if (r < 0)
698 return r;
699
700 r = nfc_hci_set_param(hdev,
701 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
702 PN544_DEP_MODE, &i_mode, 1);
703 if (r < 0)
704 return r;
705
706 r = nfc_hci_set_param(hdev,
707 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
708 PN544_DEP_ATR_REQ, hdev->gb, hdev->gb_len);
709 if (r < 0)
710 return r;
711
712 r = nfc_hci_send_event(hdev,
713 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
714 NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
715 if (r < 0)
716 nfc_hci_send_event(hdev,
717 PN544_RF_READER_NFCIP1_INITIATOR_GATE,
718 NFC_HCI_EVT_END_OPERATION, NULL, 0);
719 }
720
721 if (tm_protocols & NFC_PROTO_NFC_DEP_MASK) {
722 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
723 PN544_DEP_MODE, &t_mode, 1);
724 if (r < 0)
725 return r;
726
727 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
728 PN544_DEP_ATR_RES, hdev->gb, hdev->gb_len);
729 if (r < 0)
730 return r;
731
732 r = nfc_hci_set_param(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
733 PN544_DEP_MERGE, &t_merge, 1);
734 if (r < 0)
735 return r;
736 }
737
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200738 r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
739 NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
740 if (r < 0)
741 nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
742 NFC_HCI_EVT_END_OPERATION, NULL, 0);
743
744 return r;
745}
746
Eric Lapuyade412fda52012-09-18 19:45:48 +0200747static int pn544_hci_target_from_gate(struct nfc_hci_dev *hdev, u8 gate,
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200748 struct nfc_target *target)
749{
750 switch (gate) {
751 case PN544_RF_READER_F_GATE:
752 target->supported_protocols = NFC_PROTO_FELICA_MASK;
753 break;
754 case PN544_RF_READER_JEWEL_GATE:
755 target->supported_protocols = NFC_PROTO_JEWEL_MASK;
756 target->sens_res = 0x0c00;
757 break;
758 default:
759 return -EPROTO;
760 }
761
762 return 0;
763}
764
Eric Lapuyade412fda52012-09-18 19:45:48 +0200765static int pn544_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200766 u8 gate,
767 struct nfc_target *target)
768{
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200769 struct sk_buff *uid_skb;
770 int r = 0;
771
772 if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) {
773 if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
774 target->nfcid1_len != 10)
775 return -EPROTO;
776
777 r = nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
778 PN544_RF_READER_CMD_ACTIVATE_NEXT,
779 target->nfcid1, target->nfcid1_len, NULL);
780 } else if (target->supported_protocols & NFC_PROTO_FELICA_MASK) {
781 r = nfc_hci_get_param(hdev, PN544_RF_READER_F_GATE,
782 PN544_FELICA_ID, &uid_skb);
783 if (r < 0)
784 return r;
785
786 if (uid_skb->len != 8) {
787 kfree_skb(uid_skb);
788 return -EPROTO;
789 }
790
791 r = nfc_hci_send_cmd(hdev, PN544_RF_READER_F_GATE,
792 PN544_RF_READER_CMD_ACTIVATE_NEXT,
793 uid_skb->data, uid_skb->len, NULL);
794 kfree_skb(uid_skb);
795 } else if (target->supported_protocols & NFC_PROTO_ISO14443_MASK) {
796 /*
797 * TODO: maybe other ISO 14443 require some kind of continue
798 * activation, but for now we've seen only this one below.
799 */
800 if (target->sens_res == 0x4403) /* Type 4 Mifare DESFire */
801 r = nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
802 PN544_RF_READER_A_CMD_CONTINUE_ACTIVATION,
803 NULL, 0, NULL);
804 }
805
806 return r;
807}
808
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200809#define PN544_CB_TYPE_READER_F 1
810
811static void pn544_hci_data_exchange_cb(void *context, struct sk_buff *skb,
812 int err)
813{
814 struct pn544_hci_info *info = context;
815
816 switch (info->async_cb_type) {
817 case PN544_CB_TYPE_READER_F:
818 if (err == 0)
819 skb_pull(skb, 1);
820 info->async_cb(info->async_cb_context, skb, err);
821 break;
822 default:
823 if (err == 0)
824 kfree_skb(skb);
825 break;
826 }
827}
828
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200829#define MIFARE_CMD_AUTH_KEY_A 0x60
830#define MIFARE_CMD_AUTH_KEY_B 0x61
831#define MIFARE_CMD_HEADER 2
832#define MIFARE_UID_LEN 4
833#define MIFARE_KEY_LEN 6
834#define MIFARE_CMD_LEN 12
835/*
836 * Returns:
837 * <= 0: driver handled the data exchange
838 * 1: driver doesn't especially handle, please do standard processing
839 */
Eric Lapuyade412fda52012-09-18 19:45:48 +0200840static int pn544_hci_data_exchange(struct nfc_hci_dev *hdev,
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200841 struct nfc_target *target,
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200842 struct sk_buff *skb, data_exchange_cb_t cb,
843 void *cb_context)
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200844{
Eric Lapuyade412fda52012-09-18 19:45:48 +0200845 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200846
847 pr_info(DRIVER_DESC ": %s for gate=%d\n", __func__,
848 target->hci_reader_gate);
849
850 switch (target->hci_reader_gate) {
851 case NFC_HCI_RF_READER_A_GATE:
852 if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) {
853 /*
854 * It seems that pn544 is inverting key and UID for
855 * MIFARE authentication commands.
856 */
857 if (skb->len == MIFARE_CMD_LEN &&
858 (skb->data[0] == MIFARE_CMD_AUTH_KEY_A ||
859 skb->data[0] == MIFARE_CMD_AUTH_KEY_B)) {
860 u8 uid[MIFARE_UID_LEN];
861 u8 *data = skb->data + MIFARE_CMD_HEADER;
862
863 memcpy(uid, data + MIFARE_KEY_LEN,
864 MIFARE_UID_LEN);
865 memmove(data + MIFARE_UID_LEN, data,
866 MIFARE_KEY_LEN);
867 memcpy(data, uid, MIFARE_UID_LEN);
868 }
869
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200870 return nfc_hci_send_cmd_async(hdev,
871 target->hci_reader_gate,
872 PN544_MIFARE_CMD,
873 skb->data, skb->len,
874 cb, cb_context);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200875 } else
876 return 1;
877 case PN544_RF_READER_F_GATE:
878 *skb_push(skb, 1) = 0;
879 *skb_push(skb, 1) = 0;
880
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200881 info->async_cb_type = PN544_CB_TYPE_READER_F;
882 info->async_cb = cb;
883 info->async_cb_context = cb_context;
884
885 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
886 PN544_FELICA_RAW, skb->data,
887 skb->len,
888 pn544_hci_data_exchange_cb, info);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200889 case PN544_RF_READER_JEWEL_GATE:
Eric Lapuyadef3e8fb52012-09-11 10:43:50 +0200890 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
891 PN544_JEWEL_RAW_CMD, skb->data,
892 skb->len, cb, cb_context);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200893 default:
894 return 1;
895 }
896}
897
Eric Lapuyade412fda52012-09-18 19:45:48 +0200898static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200899 struct nfc_target *target)
900{
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200901 return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
902 PN544_RF_READER_CMD_PRESENCE_CHECK,
903 NULL, 0, NULL);
904}
905
Arron Wangf7a5f6c2012-09-27 17:32:55 +0800906void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
907 struct sk_buff *skb)
908{
909 struct sk_buff *rgb_skb = NULL;
910 int r = 0;
911
912 pr_debug("hci event %d", event);
913 switch (event) {
914 case PN544_HCI_EVT_ACTIVATED:
915 if (gate == PN544_RF_READER_NFCIP1_INITIATOR_GATE)
916 nfc_hci_target_discovered(hdev, gate);
917 else if (gate == PN544_RF_READER_NFCIP1_TARGET_GATE) {
918 r = nfc_hci_get_param(hdev, gate, PN544_DEP_ATR_REQ,
919 &rgb_skb);
920
921 if (r < 0)
922 goto exit;
923
924 nfc_tm_activated(hdev->ndev, NFC_PROTO_NFC_DEP_MASK,
925 NFC_COMM_PASSIVE, rgb_skb->data,
926 rgb_skb->len);
927
928 kfree_skb(rgb_skb);
929 }
930
931 break;
932 case PN544_HCI_EVT_DEACTIVATED:
933 nfc_hci_send_event(hdev, gate,
934 NFC_HCI_EVT_END_OPERATION, NULL, 0);
935 break;
936 default:
937 break;
938 }
939
940exit:
941 kfree_skb(skb);
942}
943
Eric Lapuyade412fda52012-09-18 19:45:48 +0200944static struct nfc_hci_ops pn544_hci_ops = {
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200945 .open = pn544_hci_open,
946 .close = pn544_hci_close,
947 .hci_ready = pn544_hci_ready,
948 .xmit = pn544_hci_xmit,
949 .start_poll = pn544_hci_start_poll,
950 .target_from_gate = pn544_hci_target_from_gate,
951 .complete_target_discovered = pn544_hci_complete_target_discovered,
952 .data_exchange = pn544_hci_data_exchange,
953 .check_presence = pn544_hci_check_presence,
Arron Wangf7a5f6c2012-09-27 17:32:55 +0800954 .event_received = pn544_hci_event_received,
Eric Lapuyadebbed0de2012-05-07 12:31:29 +0200955};
956
957static int __devinit pn544_hci_probe(struct i2c_client *client,
958 const struct i2c_device_id *id)
959{
960 struct pn544_hci_info *info;
961 struct pn544_nfc_platform_data *pdata;
962 int r = 0;
963 u32 protocols;
964 struct nfc_hci_init_data init_data;
965
966 dev_dbg(&client->dev, "%s\n", __func__);
967 dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
968
969 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
970 dev_err(&client->dev, "Need I2C_FUNC_I2C\n");
971 return -ENODEV;
972 }
973
974 info = kzalloc(sizeof(struct pn544_hci_info), GFP_KERNEL);
975 if (!info) {
976 dev_err(&client->dev,
977 "Cannot allocate memory for pn544_hci_info.\n");
978 r = -ENOMEM;
979 goto err_info_alloc;
980 }
981
982 info->i2c_dev = client;
983 info->state = PN544_ST_COLD;
984 mutex_init(&info->info_lock);
985 i2c_set_clientdata(client, info);
986
987 pdata = client->dev.platform_data;
988 if (pdata == NULL) {
989 dev_err(&client->dev, "No platform data\n");
990 r = -EINVAL;
991 goto err_pdata;
992 }
993
994 if (pdata->request_resources == NULL) {
995 dev_err(&client->dev, "request_resources() missing\n");
996 r = -EINVAL;
997 goto err_pdata;
998 }
999
1000 r = pdata->request_resources(client);
1001 if (r) {
1002 dev_err(&client->dev, "Cannot get platform resources\n");
1003 goto err_pdata;
1004 }
1005
1006 info->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
1007 info->gpio_fw = pdata->get_gpio(NFC_GPIO_FW_RESET);
1008 info->gpio_irq = pdata->get_gpio(NFC_GPIO_IRQ);
1009
1010 pn544_hci_platform_init(info);
1011
1012 r = request_threaded_irq(client->irq, NULL, pn544_hci_irq_thread_fn,
Samuel Ortizf2ce3982012-08-25 00:40:16 +02001013 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
1014 PN544_HCI_DRIVER_NAME, info);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001015 if (r < 0) {
1016 dev_err(&client->dev, "Unable to register IRQ handler\n");
1017 goto err_rti;
1018 }
1019
Eric Lapuyadea10d5952012-06-05 14:42:11 +02001020 init_data.gate_count = ARRAY_SIZE(pn544_gates);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001021
Eric Lapuyadea10d5952012-06-05 14:42:11 +02001022 memcpy(init_data.gates, pn544_gates, sizeof(pn544_gates));
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001023
1024 /*
1025 * TODO: Session id must include the driver name + some bus addr
1026 * persistent info to discriminate 2 identical chips
1027 */
1028 strcpy(init_data.session_id, "ID544HCI");
1029
1030 protocols = NFC_PROTO_JEWEL_MASK |
1031 NFC_PROTO_MIFARE_MASK |
1032 NFC_PROTO_FELICA_MASK |
1033 NFC_PROTO_ISO14443_MASK |
Samuel Ortiz01d719a2012-07-04 00:14:04 +02001034 NFC_PROTO_ISO14443_B_MASK |
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001035 NFC_PROTO_NFC_DEP_MASK;
1036
Eric Lapuyade412fda52012-09-18 19:45:48 +02001037 info->hdev = nfc_hci_allocate_device(&pn544_hci_ops, &init_data,
1038 protocols, LLC_SHDLC_NAME,
1039 PN544_FRAME_HEADROOM +
1040 PN544_CMDS_HEADROOM,
1041 PN544_FRAME_TAILROOM,
1042 PN544_HCI_LLC_MAX_PAYLOAD);
1043 if (!info->hdev) {
1044 dev_err(&client->dev, "Cannot allocate nfc hdev.\n");
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001045 r = -ENOMEM;
Eric Lapuyade412fda52012-09-18 19:45:48 +02001046 goto err_alloc_hdev;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001047 }
1048
Eric Lapuyade412fda52012-09-18 19:45:48 +02001049 nfc_hci_set_clientdata(info->hdev, info);
1050
1051 r = nfc_hci_register_device(info->hdev);
1052 if (r)
1053 goto err_regdev;
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001054
1055 return 0;
1056
Eric Lapuyade412fda52012-09-18 19:45:48 +02001057err_regdev:
1058 nfc_hci_free_device(info->hdev);
1059
1060err_alloc_hdev:
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001061 free_irq(client->irq, info);
1062
1063err_rti:
1064 if (pdata->free_resources != NULL)
1065 pdata->free_resources();
1066
1067err_pdata:
1068 kfree(info);
1069
1070err_info_alloc:
1071 return r;
1072}
1073
1074static __devexit int pn544_hci_remove(struct i2c_client *client)
1075{
1076 struct pn544_hci_info *info = i2c_get_clientdata(client);
1077 struct pn544_nfc_platform_data *pdata = client->dev.platform_data;
1078
1079 dev_dbg(&client->dev, "%s\n", __func__);
1080
Eric Lapuyade412fda52012-09-18 19:45:48 +02001081 nfc_hci_free_device(info->hdev);
Eric Lapuyadebbed0de2012-05-07 12:31:29 +02001082
1083 if (info->state != PN544_ST_COLD) {
1084 if (pdata->disable)
1085 pdata->disable();
1086 }
1087
1088 free_irq(client->irq, info);
1089 if (pdata->free_resources)
1090 pdata->free_resources();
1091
1092 kfree(info);
1093
1094 return 0;
1095}
1096
1097static struct i2c_driver pn544_hci_driver = {
1098 .driver = {
1099 .name = PN544_HCI_DRIVER_NAME,
1100 },
1101 .probe = pn544_hci_probe,
1102 .id_table = pn544_hci_id_table,
1103 .remove = __devexit_p(pn544_hci_remove),
1104};
1105
1106static int __init pn544_hci_init(void)
1107{
1108 int r;
1109
1110 pr_debug(DRIVER_DESC ": %s\n", __func__);
1111
1112 r = i2c_add_driver(&pn544_hci_driver);
1113 if (r) {
1114 pr_err(PN544_HCI_DRIVER_NAME ": driver registration failed\n");
1115 return r;
1116 }
1117
1118 return 0;
1119}
1120
1121static void __exit pn544_hci_exit(void)
1122{
1123 i2c_del_driver(&pn544_hci_driver);
1124}
1125
1126module_init(pn544_hci_init);
1127module_exit(pn544_hci_exit);
1128
1129MODULE_LICENSE("GPL");
1130MODULE_DESCRIPTION(DRIVER_DESC);