2 * HCI based Driver for Inside Secure microread NFC Chip
4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
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.
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.
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.
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>
27 #include "../mei_phy.h"
28 #include "microread.h"
30 #define MICROREAD_DRIVER_NAME "microread"
32 static int microread_mei_probe(struct mei_cl_device *device,
33 const struct mei_cl_device_id *id)
35 struct nfc_mei_phy *phy;
38 pr_info("Probing NFC microread\n");
40 phy = nfc_mei_phy_alloc(device);
42 pr_err("Cannot allocate memory for microread mei phy.\n");
46 r = mei_cl_register_event_cb(device, nfc_mei_event_cb, phy);
48 pr_err(MICROREAD_DRIVER_NAME ": event cb registration failed\n");
52 r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
53 MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
61 nfc_mei_phy_free(phy);
66 static int microread_mei_remove(struct mei_cl_device *device)
68 struct nfc_mei_phy *phy = mei_cl_get_drvdata(device);
70 pr_info("Removing microread\n");
72 microread_remove(phy->hdev);
74 nfc_mei_phy_disable(phy);
76 nfc_mei_phy_free(phy);
81 static struct mei_cl_device_id microread_mei_tbl[] = {
82 { MICROREAD_DRIVER_NAME },
84 /* required last entry */
87 MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
89 static struct mei_cl_driver microread_driver = {
90 .id_table = microread_mei_tbl,
91 .name = MICROREAD_DRIVER_NAME,
93 .probe = microread_mei_probe,
94 .remove = microread_mei_remove,
97 static int microread_mei_init(void)
101 pr_debug(DRIVER_DESC ": %s\n", __func__);
103 r = mei_cl_driver_register(µread_driver);
105 pr_err(MICROREAD_DRIVER_NAME ": driver registration failed\n");
112 static void microread_mei_exit(void)
114 mei_cl_driver_unregister(µread_driver);
117 module_init(microread_mei_init);
118 module_exit(microread_mei_exit);
120 MODULE_LICENSE("GPL");
121 MODULE_DESCRIPTION(DRIVER_DESC);