mei.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * HCI based Driver for NXP pn544 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
  16. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/mod_devicetable.h>
  20. #include <linux/nfc.h>
  21. #include <net/nfc/hci.h>
  22. #include <net/nfc/llc.h>
  23. #include "../mei_phy.h"
  24. #include "pn544.h"
  25. #define PN544_DRIVER_NAME "pn544"
  26. static int pn544_mei_probe(struct mei_cl_device *cldev,
  27. const struct mei_cl_device_id *id)
  28. {
  29. struct nfc_mei_phy *phy;
  30. int r;
  31. pr_info("Probing NFC pn544\n");
  32. phy = nfc_mei_phy_alloc(cldev);
  33. if (!phy) {
  34. pr_err("Cannot allocate memory for pn544 mei phy.\n");
  35. return -ENOMEM;
  36. }
  37. r = pn544_hci_probe(phy, &mei_phy_ops, LLC_NOP_NAME,
  38. MEI_NFC_HEADER_SIZE, 0, MEI_NFC_MAX_HCI_PAYLOAD,
  39. NULL, &phy->hdev);
  40. if (r < 0) {
  41. nfc_mei_phy_free(phy);
  42. return r;
  43. }
  44. return 0;
  45. }
  46. static int pn544_mei_remove(struct mei_cl_device *cldev)
  47. {
  48. struct nfc_mei_phy *phy = mei_cldev_get_drvdata(cldev);
  49. pr_info("Removing pn544\n");
  50. pn544_hci_remove(phy->hdev);
  51. nfc_mei_phy_free(phy);
  52. return 0;
  53. }
  54. static struct mei_cl_device_id pn544_mei_tbl[] = {
  55. { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY},
  56. /* required last entry */
  57. { }
  58. };
  59. MODULE_DEVICE_TABLE(mei, pn544_mei_tbl);
  60. static struct mei_cl_driver pn544_driver = {
  61. .id_table = pn544_mei_tbl,
  62. .name = PN544_DRIVER_NAME,
  63. .probe = pn544_mei_probe,
  64. .remove = pn544_mei_remove,
  65. };
  66. module_mei_cl_driver(pn544_driver);
  67. MODULE_LICENSE("GPL");
  68. MODULE_DESCRIPTION(DRIVER_DESC);