1191b0700STomas Winkler // SPDX-License-Identifier: GPL-2.0
2e0af11faSSamuel Ortiz /*
3e0af11faSSamuel Ortiz * Copyright (C) 2013 Intel Corporation. All rights reserved.
4e0af11faSSamuel Ortiz *
5191b0700STomas Winkler * HCI based Driver for Inside Secure microread NFC Chip
6e0af11faSSamuel Ortiz */
7e0af11faSSamuel Ortiz
817936b43SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
917936b43SJoe Perches
10e0af11faSSamuel Ortiz #include <linux/module.h>
114912e2feSEric Lapuyade #include <linux/mod_devicetable.h>
12e0af11faSSamuel Ortiz #include <linux/nfc.h>
13e0af11faSSamuel Ortiz #include <net/nfc/llc.h>
14e0af11faSSamuel Ortiz
154912e2feSEric Lapuyade #include "../mei_phy.h"
16e0af11faSSamuel Ortiz #include "microread.h"
17e0af11faSSamuel Ortiz
18e0af11faSSamuel Ortiz #define MICROREAD_DRIVER_NAME "microread"
19e0af11faSSamuel Ortiz
microread_mei_probe(struct mei_cl_device * cldev,const struct mei_cl_device_id * id)2089391382STomas Winkler static int microread_mei_probe(struct mei_cl_device *cldev,
219593b0b1SSamuel Ortiz const struct mei_cl_device_id *id)
22e0af11faSSamuel Ortiz {
234912e2feSEric Lapuyade struct nfc_mei_phy *phy;
24e0af11faSSamuel Ortiz int r;
25e0af11faSSamuel Ortiz
2689391382STomas Winkler phy = nfc_mei_phy_alloc(cldev);
27*270be694SKrzysztof Kozlowski if (!phy)
28e0af11faSSamuel Ortiz return -ENOMEM;
29e0af11faSSamuel Ortiz
30e0af11faSSamuel Ortiz r = microread_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
31e0af11faSSamuel Ortiz MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
32e0af11faSSamuel Ortiz &phy->hdev);
3373f3adb9SSamuel Ortiz if (r < 0) {
344912e2feSEric Lapuyade nfc_mei_phy_free(phy);
35e0af11faSSamuel Ortiz
36e0af11faSSamuel Ortiz return r;
37e0af11faSSamuel Ortiz }
38e0af11faSSamuel Ortiz
3973f3adb9SSamuel Ortiz return 0;
4073f3adb9SSamuel Ortiz }
4173f3adb9SSamuel Ortiz
microread_mei_remove(struct mei_cl_device * cldev)42bf5c9cc8SUwe Kleine-König static void microread_mei_remove(struct mei_cl_device *cldev)
43e0af11faSSamuel Ortiz {
44d49dc5e7STomas Winkler struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
45e0af11faSSamuel Ortiz
46e0af11faSSamuel Ortiz microread_remove(phy->hdev);
47e0af11faSSamuel Ortiz
484912e2feSEric Lapuyade nfc_mei_phy_free(phy);
49e0af11faSSamuel Ortiz }
50e0af11faSSamuel Ortiz
519593b0b1SSamuel Ortiz static struct mei_cl_device_id microread_mei_tbl[] = {
52b26864caSTomas Winkler { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
53cd48d8baSSamuel Ortiz
54cd48d8baSSamuel Ortiz /* required last entry */
55cd48d8baSSamuel Ortiz { }
56cd48d8baSSamuel Ortiz };
57cd48d8baSSamuel Ortiz MODULE_DEVICE_TABLE(mei, microread_mei_tbl);
58cd48d8baSSamuel Ortiz
599593b0b1SSamuel Ortiz static struct mei_cl_driver microread_driver = {
60cd48d8baSSamuel Ortiz .id_table = microread_mei_tbl,
61e0af11faSSamuel Ortiz .name = MICROREAD_DRIVER_NAME,
62e0af11faSSamuel Ortiz
63e0af11faSSamuel Ortiz .probe = microread_mei_probe,
64e0af11faSSamuel Ortiz .remove = microread_mei_remove,
65e0af11faSSamuel Ortiz };
66e0af11faSSamuel Ortiz
67094dbffeSTomas Winkler module_mei_cl_driver(microread_driver);
68e0af11faSSamuel Ortiz
69e0af11faSSamuel Ortiz MODULE_LICENSE("GPL");
70e0af11faSSamuel Ortiz MODULE_DESCRIPTION(DRIVER_DESC);
71