nxp-nci.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2014 NXP Semiconductors All rights reserved.
  3. *
  4. * Authors: Clément Perrochaud <clement.perrochaud@nxp.com>
  5. *
  6. * Derived from PN544 device driver:
  7. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms and conditions of the GNU General Public License,
  11. * version 2, as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __LOCAL_NXP_NCI_H_
  22. #define __LOCAL_NXP_NCI_H_
  23. #include <linux/completion.h>
  24. #include <linux/firmware.h>
  25. #include <linux/nfc.h>
  26. #include <linux/platform_data/nxp-nci.h>
  27. #include <net/nfc/nci_core.h>
  28. #define NXP_NCI_FW_HDR_LEN 2
  29. #define NXP_NCI_FW_CRC_LEN 2
  30. #define NXP_NCI_FW_FRAME_LEN_MASK 0x03FF
  31. enum nxp_nci_mode {
  32. NXP_NCI_MODE_COLD,
  33. NXP_NCI_MODE_NCI,
  34. NXP_NCI_MODE_FW
  35. };
  36. struct nxp_nci_phy_ops {
  37. int (*set_mode)(void *id, enum nxp_nci_mode mode);
  38. int (*write)(void *id, struct sk_buff *skb);
  39. };
  40. struct nxp_nci_fw_info {
  41. char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
  42. const struct firmware *fw;
  43. size_t size;
  44. size_t written;
  45. const u8 *data;
  46. size_t frame_size;
  47. struct work_struct work;
  48. struct completion cmd_completion;
  49. int cmd_result;
  50. };
  51. struct nxp_nci_info {
  52. struct nci_dev *ndev;
  53. void *phy_id;
  54. struct device *pdev;
  55. enum nxp_nci_mode mode;
  56. const struct nxp_nci_phy_ops *phy_ops;
  57. unsigned int max_payload;
  58. struct mutex info_lock;
  59. struct nxp_nci_fw_info fw_info;
  60. };
  61. int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name);
  62. void nxp_nci_fw_work(struct work_struct *work);
  63. void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
  64. void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
  65. int nxp_nci_probe(void *phy_id, struct device *pdev,
  66. const struct nxp_nci_phy_ops *phy_ops,
  67. unsigned int max_payload,
  68. struct nci_dev **ndev);
  69. void nxp_nci_remove(struct nci_dev *ndev);
  70. #endif /* __LOCAL_NXP_NCI_H_ */