blob: eb5eddf1794e21598eb27f0bd93df5cc65f91842 [file] [log] [blame]
Samuel Ortize0af11f2013-01-14 20:35:22 +01001/*
2 * HCI based Driver for Inside Secure microread 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
Jeff Kirsher98b32de2013-12-06 08:56:16 -080016 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Samuel Ortize0af11f2013-01-14 20:35:22 +010017 */
18
Joe Perches17936b42013-04-05 12:27:39 -070019#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
Samuel Ortize0af11f2013-01-14 20:35:22 +010021#include <linux/module.h>
Eric Lapuyade4912e2f2013-04-15 11:19:20 +020022#include <linux/mod_devicetable.h>
Samuel Ortize0af11f2013-01-14 20:35:22 +010023#include <linux/nfc.h>
24#include <net/nfc/hci.h>
25#include <net/nfc/llc.h>
26
Eric Lapuyade4912e2f2013-04-15 11:19:20 +020027#include "../mei_phy.h"
Samuel Ortize0af11f2013-01-14 20:35:22 +010028#include "microread.h"
29
30#define MICROREAD_DRIVER_NAME "microread"
31
Tomas Winkler89391382015-09-10 10:18:04 +030032static int microread_mei_probe(struct mei_cl_device *cldev,
Samuel Ortiz9593b0b2013-03-28 10:39:28 +010033 const struct mei_cl_device_id *id)
Samuel Ortize0af11f2013-01-14 20:35:22 +010034{
Eric Lapuyade4912e2f2013-04-15 11:19:20 +020035 struct nfc_mei_phy *phy;
Samuel Ortize0af11f2013-01-14 20:35:22 +010036 int r;
37
38 pr_info("Probing NFC microread\n");
39
Tomas Winkler89391382015-09-10 10:18:04 +030040 phy = nfc_mei_phy_alloc(cldev);
Samuel Ortize0af11f2013-01-14 20:35:22 +010041 if (!phy) {
42 pr_err("Cannot allocate memory for microread mei phy.\n");
43 return -ENOMEM;
44 }
45
Samuel Ortize0af11f2013-01-14 20:35:22 +010046 r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
47 MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
48 &phy->hdev);
Samuel Ortiz73f3adb2013-04-30 23:48:50 +020049 if (r < 0) {
50 nfc_mei_phy_free(phy);
51
52 return r;
53 }
Samuel Ortize0af11f2013-01-14 20:35:22 +010054
55 return 0;
Samuel Ortize0af11f2013-01-14 20:35:22 +010056}
57
Tomas Winkler89391382015-09-10 10:18:04 +030058static int microread_mei_remove(struct mei_cl_device *cldev)
Samuel Ortize0af11f2013-01-14 20:35:22 +010059{
Tomas Winklerd49dc5e2015-09-10 10:18:05 +030060 struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
Samuel Ortize0af11f2013-01-14 20:35:22 +010061
Samuel Ortize0af11f2013-01-14 20:35:22 +010062 microread_remove(phy->hdev);
63
Eric Lapuyade4912e2f2013-04-15 11:19:20 +020064 nfc_mei_phy_free(phy);
Samuel Ortize0af11f2013-01-14 20:35:22 +010065
66 return 0;
67}
68
Samuel Ortiz9593b0b2013-03-28 10:39:28 +010069static struct mei_cl_device_id microread_mei_tbl[] = {
Tomas Winklerb26864c2015-09-10 10:18:01 +030070 { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
Samuel Ortizcd48d8b2013-02-11 10:30:04 +010071
72 /* required last entry */
73 { }
74};
Samuel Ortizcd48d8b2013-02-11 10:30:04 +010075MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
76
Samuel Ortiz9593b0b2013-03-28 10:39:28 +010077static struct mei_cl_driver microread_driver = {
Samuel Ortizcd48d8b2013-02-11 10:30:04 +010078 .id_table = microread_mei_tbl,
79 .name = MICROREAD_DRIVER_NAME,
Samuel Ortize0af11f2013-01-14 20:35:22 +010080
81 .probe = microread_mei_probe,
82 .remove = microread_mei_remove,
83};
84
Tomas Winkler094dbff2016-10-19 16:33:29 +030085module_mei_cl_driver(microread_driver);
Samuel Ortize0af11f2013-01-14 20:35:22 +010086
87MODULE_LICENSE("GPL");
88MODULE_DESCRIPTION(DRIVER_DESC);