]>
Commit | Line | Data |
---|---|---|
bb03dceb SO |
1 | /* |
2 | * HCI based Driver for NXP pn544 NFC Chip | |
3 | * | |
4 | * Copyright (C) 2013 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 | |
98b32dec | 16 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
bb03dceb SO |
17 | */ |
18 | ||
19 | #include <linux/module.h> | |
20 | #include <linux/mod_devicetable.h> | |
21 | #include <linux/nfc.h> | |
22 | #include <net/nfc/hci.h> | |
23 | #include <net/nfc/llc.h> | |
24 | ||
25 | #include "../mei_phy.h" | |
26 | #include "pn544.h" | |
27 | ||
28 | #define PN544_DRIVER_NAME "pn544" | |
29 | ||
89391382 | 30 | static int pn544_mei_probe(struct mei_cl_device *cldev, |
bb03dceb SO |
31 | const struct mei_cl_device_id *id) |
32 | { | |
33 | struct nfc_mei_phy *phy; | |
34 | int r; | |
35 | ||
36 | pr_info("Probing NFC pn544\n"); | |
37 | ||
89391382 | 38 | phy = nfc_mei_phy_alloc(cldev); |
bb03dceb SO |
39 | if (!phy) { |
40 | pr_err("Cannot allocate memory for pn544 mei phy.\n"); | |
41 | return -ENOMEM; | |
42 | } | |
43 | ||
bb03dceb SO |
44 | r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME, |
45 | MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD, | |
8bd7fc89 | 46 | NULL, &phy->hdev); |
73f3adb9 SO |
47 | if (r < 0) { |
48 | nfc_mei_phy_free(phy); | |
bb03dceb | 49 | |
73f3adb9 SO |
50 | return r; |
51 | } | |
bb03dceb | 52 | |
73f3adb9 | 53 | return 0; |
bb03dceb SO |
54 | } |
55 | ||
89391382 | 56 | static int pn544_mei_remove(struct mei_cl_device *cldev) |
bb03dceb | 57 | { |
d49dc5e7 | 58 | struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev); |
bb03dceb SO |
59 | |
60 | pr_info("Removing pn544\n"); | |
61 | ||
62 | pn544_hci_remove(phy->hdev); | |
63 | ||
bb03dceb SO |
64 | nfc_mei_phy_free(phy); |
65 | ||
66 | return 0; | |
67 | } | |
68 | ||
69 | static struct mei_cl_device_id pn544_mei_tbl[] = { | |
b26864ca | 70 | { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY}, |
bb03dceb SO |
71 | |
72 | /* required last entry */ | |
73 | { } | |
74 | }; | |
75 | MODULE_DEVICE_TABLE(mei, pn544_mei_tbl); | |
76 | ||
77 | static struct mei_cl_driver pn544_driver = { | |
78 | .id_table = pn544_mei_tbl, | |
79 | .name = PN544_DRIVER_NAME, | |
80 | ||
81 | .probe = pn544_mei_probe, | |
82 | .remove = pn544_mei_remove, | |
83 | }; | |
84 | ||
094dbffe | 85 | module_mei_cl_driver(pn544_driver); |
bb03dceb SO |
86 | |
87 | MODULE_LICENSE("GPL"); | |
88 | MODULE_DESCRIPTION(DRIVER_DESC); |