aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-04-15 18:14:35 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-15 18:39:41 -0400
commitbb03dceb83852614ae3ad6b3731a31422890b0b9 (patch)
tree6c3585b278baf22ad4ee4047c8e053e7c98c9165
parent4912e2fe74811693703e9b4e21bf36c067643a03 (diff)
NFC: pn544: Add MEI physical layer
With the new mei_phy NFC driver API, the pn544 MEI physical layer is minimal and similar to the microread one. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/pn544/Kconfig13
-rw-r--r--drivers/nfc/pn544/Makefile2
-rw-r--r--drivers/nfc/pn544/mei.c121
3 files changed, 135 insertions, 1 deletions
diff --git a/drivers/nfc/pn544/Kconfig b/drivers/nfc/pn544/Kconfig
index c277790ac71c..ccf06f5f6ebb 100644
--- a/drivers/nfc/pn544/Kconfig
+++ b/drivers/nfc/pn544/Kconfig
@@ -20,4 +20,15 @@ config NFC_PN544_I2C
20 Select this if your platform is using the i2c bus. 20 Select this if your platform is using the i2c bus.
21 21
22 If you choose to build a module, it'll be called pn544_i2c. 22 If you choose to build a module, it'll be called pn544_i2c.
23 Say N if unsure. \ No newline at end of file 23 Say N if unsure.
24
25config NFC_PN544_MEI
26 tristate "NFC PN544 MEI support"
27 depends on NFC_PN544 && NFC_MEI_PHY
28 ---help---
29 This module adds support for the mei interface of adapters using
30 NXP pn544 chipsets. Select this if your pn544 chipset
31 is handled by Intel's Management Engine Interface on your platform.
32
33 If you choose to build a module, it'll be called pn544_mei.
34 Say N if unsure.
diff --git a/drivers/nfc/pn544/Makefile b/drivers/nfc/pn544/Makefile
index ac076793687d..29fb5a174036 100644
--- a/drivers/nfc/pn544/Makefile
+++ b/drivers/nfc/pn544/Makefile
@@ -3,6 +3,8 @@
3# 3#
4 4
5pn544_i2c-objs = i2c.o 5pn544_i2c-objs = i2c.o
6pn544_mei-objs = mei.o
6 7
7obj-$(CONFIG_NFC_PN544) += pn544.o 8obj-$(CONFIG_NFC_PN544) += pn544.o
8obj-$(CONFIG_NFC_PN544_I2C) += pn544_i2c.o 9obj-$(CONFIG_NFC_PN544_I2C) += pn544_i2c.o
10obj-$(CONFIG_NFC_PN544_MEI) += pn544_mei.o
diff --git a/drivers/nfc/pn544/mei.c b/drivers/nfc/pn544/mei.c
new file mode 100644
index 000000000000..1eb48848a35a
--- /dev/null
+++ b/drivers/nfc/pn544/mei.c
@@ -0,0 +1,121 @@
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
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/module.h>
22#include <linux/mod_devicetable.h>
23#include <linux/nfc.h>
24#include <net/nfc/hci.h>
25#include <net/nfc/llc.h>
26
27#include "../mei_phy.h"
28#include "pn544.h"
29
30#define PN544_DRIVER_NAME "pn544"
31
32static int pn544_mei_probe(struct mei_cl_device *device,
33 const struct mei_cl_device_id *id)
34{
35 struct nfc_mei_phy *phy;
36 int r;
37
38 pr_info("Probing NFC pn544\n");
39
40 phy = nfc_mei_phy_alloc(device);
41 if (!phy) {
42 pr_err("Cannot allocate memory for pn544 mei phy.\n");
43 return -ENOMEM;
44 }
45
46 r = mei_cl_register_event_cb(device, nfc_mei_event_cb, phy);
47 if (r) {
48 pr_err(PN544_DRIVER_NAME ": event cb registration failed\n");
49 goto err_out;
50 }
51
52 r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
53 MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
54 &phy->hdev);
55 if (r < 0)
56 goto err_out;
57
58 return 0;
59
60err_out:
61 nfc_mei_phy_free(phy);
62
63 return r;
64}
65
66static int pn544_mei_remove(struct mei_cl_device *device)
67{
68 struct nfc_mei_phy *phy = mei_cl_get_drvdata(device);
69
70 pr_info("Removing pn544\n");
71
72 pn544_hci_remove(phy->hdev);
73
74 nfc_mei_phy_disable(phy);
75
76 nfc_mei_phy_free(phy);
77
78 return 0;
79}
80
81static struct mei_cl_device_id pn544_mei_tbl[] = {
82 { PN544_DRIVER_NAME },
83
84 /* required last entry */
85 { }
86};
87MODULE_DEVICE_TABLE(mei, pn544_mei_tbl);
88
89static struct mei_cl_driver pn544_driver = {
90 .id_table = pn544_mei_tbl,
91 .name = PN544_DRIVER_NAME,
92
93 .probe = pn544_mei_probe,
94 .remove = pn544_mei_remove,
95};
96
97static int pn544_mei_init(void)
98{
99 int r;
100
101 pr_debug(DRIVER_DESC ": %s\n", __func__);
102
103 r = mei_cl_driver_register(&pn544_driver);
104 if (r) {
105 pr_err(PN544_DRIVER_NAME ": driver registration failed\n");
106 return r;
107 }
108
109 return 0;
110}
111
112static void pn544_mei_exit(void)
113{
114 mei_cl_driver_unregister(&pn544_driver);
115}
116
117module_init(pn544_mei_init);
118module_exit(pn544_mei_exit);
119
120MODULE_LICENSE("GPL");
121MODULE_DESCRIPTION(DRIVER_DESC);