mei.c 2.1 KB

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