xref: /linux/drivers/nfc/pn544/mei.c (revision 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2013  Intel Corporation. All rights reserved.
4  *
5  * HCI based Driver for NXP pn544 NFC Chip
6  */
7 
8 #include <linux/module.h>
9 #include <linux/nfc.h>
10 #include <net/nfc/hci.h>
11 #include <net/nfc/llc.h>
12 
13 #include "../mei_phy.h"
14 #include "pn544.h"
15 
16 #define PN544_DRIVER_NAME "pn544"
17 
18 static int pn544_mei_probe(struct mei_cl_device *cldev,
19 			       const struct mei_cl_device_id *id)
20 {
21 	struct nfc_mei_phy *phy;
22 	int r;
23 
24 	phy = nfc_mei_phy_alloc(cldev);
25 	if (!phy)
26 		return -ENOMEM;
27 
28 	r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
29 			    MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
30 			    NULL, &phy->hdev);
31 	if (r < 0) {
32 		nfc_mei_phy_free(phy);
33 
34 		return r;
35 	}
36 
37 	return 0;
38 }
39 
40 static void pn544_mei_remove(struct mei_cl_device *cldev)
41 {
42 	struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
43 
44 	pn544_hci_remove(phy->hdev);
45 
46 	nfc_mei_phy_free(phy);
47 }
48 
49 static struct mei_cl_device_id pn544_mei_tbl[] = {
50 	{
51 		.name = PN544_DRIVER_NAME,
52 		.uuid = MEI_NFC_UUID,
53 		.version = MEI_CL_VERSION_ANY,
54 	},
55 	{ /* required last entry */ }
56 };
57 MODULE_DEVICE_TABLE(mei, pn544_mei_tbl);
58 
59 static struct mei_cl_driver pn544_driver = {
60 	.id_table = pn544_mei_tbl,
61 	.name = PN544_DRIVER_NAME,
62 
63 	.probe = pn544_mei_probe,
64 	.remove = pn544_mei_remove,
65 };
66 
67 module_mei_cl_driver(pn544_driver);
68 
69 MODULE_LICENSE("GPL");
70 MODULE_DESCRIPTION(DRIVER_DESC);
71