nfcmrvl.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Marvell NFC driver
  4. *
  5. * Copyright (C) 2014-2015, Marvell International Ltd.
  6. */
  7. #ifndef _NFCMRVL_H_
  8. #define _NFCMRVL_H_
  9. #include <linux/platform_data/nfcmrvl.h>
  10. #include "fw_dnld.h"
  11. /* Define private flags: */
  12. #define NFCMRVL_NCI_RUNNING 1
  13. #define NFCMRVL_PHY_ERROR 2
  14. #define NFCMRVL_EXT_COEX_ID 0xE0
  15. #define NFCMRVL_NOT_ALLOWED_ID 0xE1
  16. #define NFCMRVL_ACTIVE_ID 0xE2
  17. #define NFCMRVL_EXT_COEX_ENABLE 1
  18. #define NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED 0xA
  19. #define NFCMRVL_GPIO_PIN_NFC_ACTIVE 0xB
  20. #define NFCMRVL_NCI_MAX_EVENT_SIZE 260
  21. /*
  22. * NCI FW Parameters
  23. */
  24. #define NFCMRVL_PB_BAIL_OUT 0x11
  25. #define NFCMRVL_PROP_REF_CLOCK 0xF0
  26. #define NFCMRVL_PROP_SET_HI_CONFIG 0xF1
  27. /*
  28. * HCI defines
  29. */
  30. #define NFCMRVL_HCI_EVENT_HEADER_SIZE 0x04
  31. #define NFCMRVL_HCI_EVENT_CODE 0x04
  32. #define NFCMRVL_HCI_NFC_EVENT_CODE 0xFF
  33. #define NFCMRVL_HCI_COMMAND_CODE 0x01
  34. #define NFCMRVL_HCI_OGF 0x81
  35. #define NFCMRVL_HCI_OCF 0xFE
  36. enum nfcmrvl_phy {
  37. NFCMRVL_PHY_USB = 0,
  38. NFCMRVL_PHY_UART = 1,
  39. NFCMRVL_PHY_I2C = 2,
  40. NFCMRVL_PHY_SPI = 3,
  41. };
  42. struct nfcmrvl_private {
  43. unsigned long flags;
  44. /* Platform configuration */
  45. struct nfcmrvl_platform_data config;
  46. /* Parent dev */
  47. struct nci_dev *ndev;
  48. /* FW download context */
  49. struct nfcmrvl_fw_dnld fw_dnld;
  50. /* FW download support */
  51. bool support_fw_dnld;
  52. /*
  53. * PHY related information
  54. */
  55. /* PHY driver context */
  56. void *drv_data;
  57. /* PHY device */
  58. struct device *dev;
  59. /* PHY type */
  60. enum nfcmrvl_phy phy;
  61. /* Low level driver ops */
  62. const struct nfcmrvl_if_ops *if_ops;
  63. };
  64. struct nfcmrvl_if_ops {
  65. int (*nci_open) (struct nfcmrvl_private *priv);
  66. int (*nci_close) (struct nfcmrvl_private *priv);
  67. int (*nci_send) (struct nfcmrvl_private *priv, struct sk_buff *skb);
  68. void (*nci_update_config)(struct nfcmrvl_private *priv,
  69. const void *param);
  70. };
  71. void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv);
  72. int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
  73. struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
  74. void *drv_data,
  75. const struct nfcmrvl_if_ops *ops,
  76. struct device *dev,
  77. const struct nfcmrvl_platform_data *pdata);
  78. void nfcmrvl_chip_reset(struct nfcmrvl_private *priv);
  79. void nfcmrvl_chip_halt(struct nfcmrvl_private *priv);
  80. int nfcmrvl_parse_dt(struct device_node *node,
  81. struct nfcmrvl_platform_data *pdata);
  82. #endif