nxp-nci.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2014 NXP Semiconductors All rights reserved.
  4. *
  5. * Authors: Clément Perrochaud <[email protected]>
  6. *
  7. * Derived from PN544 device driver:
  8. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  9. */
  10. #ifndef __LOCAL_NXP_NCI_H_
  11. #define __LOCAL_NXP_NCI_H_
  12. #include <linux/completion.h>
  13. #include <linux/firmware.h>
  14. #include <linux/nfc.h>
  15. #include <net/nfc/nci_core.h>
  16. #define NXP_NCI_FW_HDR_LEN 2
  17. #define NXP_NCI_FW_CRC_LEN 2
  18. #define NXP_NCI_FW_FRAME_LEN_MASK 0x03FF
  19. enum nxp_nci_mode {
  20. NXP_NCI_MODE_COLD,
  21. NXP_NCI_MODE_NCI,
  22. NXP_NCI_MODE_FW
  23. };
  24. struct nxp_nci_phy_ops {
  25. int (*set_mode)(void *id, enum nxp_nci_mode mode);
  26. int (*write)(void *id, struct sk_buff *skb);
  27. };
  28. struct nxp_nci_fw_info {
  29. char name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
  30. const struct firmware *fw;
  31. size_t size;
  32. size_t written;
  33. const u8 *data;
  34. size_t frame_size;
  35. struct work_struct work;
  36. struct completion cmd_completion;
  37. int cmd_result;
  38. };
  39. struct nxp_nci_info {
  40. struct nci_dev *ndev;
  41. void *phy_id;
  42. struct device *pdev;
  43. enum nxp_nci_mode mode;
  44. const struct nxp_nci_phy_ops *phy_ops;
  45. unsigned int max_payload;
  46. struct mutex info_lock;
  47. struct nxp_nci_fw_info fw_info;
  48. };
  49. int nxp_nci_fw_download(struct nci_dev *ndev, const char *firmware_name);
  50. void nxp_nci_fw_work(struct work_struct *work);
  51. void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
  52. void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
  53. int nxp_nci_probe(void *phy_id, struct device *pdev,
  54. const struct nxp_nci_phy_ops *phy_ops,
  55. unsigned int max_payload,
  56. struct nci_dev **ndev);
  57. void nxp_nci_remove(struct nci_dev *ndev);
  58. #endif /* __LOCAL_NXP_NCI_H_ */