Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2013  Intel Corporation. All rights reserved.
0004  *
0005  * HCI based Driver for NXP pn544 NFC Chip
0006  */
0007 
0008 #include <linux/module.h>
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/nfc.h>
0011 #include <net/nfc/hci.h>
0012 #include <net/nfc/llc.h>
0013 
0014 #include "../mei_phy.h"
0015 #include "pn544.h"
0016 
0017 #define PN544_DRIVER_NAME "pn544"
0018 
0019 static int pn544_mei_probe(struct mei_cl_device *cldev,
0020                    const struct mei_cl_device_id *id)
0021 {
0022     struct nfc_mei_phy *phy;
0023     int r;
0024 
0025     phy = nfc_mei_phy_alloc(cldev);
0026     if (!phy)
0027         return -ENOMEM;
0028 
0029     r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
0030                 MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
0031                 NULL, &phy->hdev);
0032     if (r < 0) {
0033         nfc_mei_phy_free(phy);
0034 
0035         return r;
0036     }
0037 
0038     return 0;
0039 }
0040 
0041 static void pn544_mei_remove(struct mei_cl_device *cldev)
0042 {
0043     struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
0044 
0045     pn544_hci_remove(phy->hdev);
0046 
0047     nfc_mei_phy_free(phy);
0048 }
0049 
0050 static struct mei_cl_device_id pn544_mei_tbl[] = {
0051     { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
0052 
0053     /* required last entry */
0054     { }
0055 };
0056 MODULE_DEVICE_TABLE(mei, pn544_mei_tbl);
0057 
0058 static struct mei_cl_driver pn544_driver = {
0059     .id_table = pn544_mei_tbl,
0060     .name = PN544_DRIVER_NAME,
0061 
0062     .probe = pn544_mei_probe,
0063     .remove = pn544_mei_remove,
0064 };
0065 
0066 module_mei_cl_driver(pn544_driver);
0067 
0068 MODULE_LICENSE("GPL");
0069 MODULE_DESCRIPTION(DRIVER_DESC);