st21nfca.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __LOCAL_ST21NFCA_H_
  17. #define __LOCAL_ST21NFCA_H_
  18. #include <net/nfc/hci.h>
  19. #include "st21nfca_dep.h"
  20. #define HCI_MODE 0
  21. /* framing in HCI mode */
  22. #define ST21NFCA_SOF_EOF_LEN 2
  23. /* Almost every time value is 0 */
  24. #define ST21NFCA_HCI_LLC_LEN 1
  25. /* Size in worst case :
  26. * In normal case CRC len = 2 but byte stuffing
  27. * may appear in case one CRC byte = ST21NFCA_SOF_EOF
  28. */
  29. #define ST21NFCA_HCI_LLC_CRC 4
  30. #define ST21NFCA_HCI_LLC_LEN_CRC (ST21NFCA_SOF_EOF_LEN + \
  31. ST21NFCA_HCI_LLC_LEN + \
  32. ST21NFCA_HCI_LLC_CRC)
  33. #define ST21NFCA_HCI_LLC_MIN_SIZE (1 + ST21NFCA_HCI_LLC_LEN_CRC)
  34. /* Worst case when adding byte stuffing between each byte */
  35. #define ST21NFCA_HCI_LLC_MAX_PAYLOAD 29
  36. #define ST21NFCA_HCI_LLC_MAX_SIZE (ST21NFCA_HCI_LLC_LEN_CRC + 1 + \
  37. ST21NFCA_HCI_LLC_MAX_PAYLOAD)
  38. #define DRIVER_DESC "HCI NFC driver for ST21NFCA"
  39. #define ST21NFCA_HCI_MODE 0
  40. #define ST21NFCA_NUM_DEVICES 256
  41. int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
  42. char *llc_name, int phy_headroom, int phy_tailroom,
  43. int phy_payload, struct nfc_hci_dev **hdev);
  44. void st21nfca_hci_remove(struct nfc_hci_dev *hdev);
  45. enum st21nfca_state {
  46. ST21NFCA_ST_COLD,
  47. ST21NFCA_ST_READY,
  48. };
  49. struct st21nfca_hci_info {
  50. struct nfc_phy_ops *phy_ops;
  51. void *phy_id;
  52. struct nfc_hci_dev *hdev;
  53. enum st21nfca_state state;
  54. struct mutex info_lock;
  55. int async_cb_type;
  56. data_exchange_cb_t async_cb;
  57. void *async_cb_context;
  58. struct st21nfca_dep_info dep_info;
  59. };
  60. /* Reader RF commands */
  61. #define ST21NFCA_WR_XCHG_DATA 0x10
  62. #define ST21NFCA_RF_READER_F_GATE 0x14
  63. #define ST21NFCA_RF_CARD_F_GATE 0x24
  64. #define ST21NFCA_EVT_SEND_DATA 0x10
  65. #endif /* __LOCAL_ST21NFCA_H_ */