nfcmrvl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Marvell NFC driver
  3. *
  4. * Copyright (C) 2014-2015, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available on the worldwide web at
  11. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  12. *
  13. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  14. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  15. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  16. * this warranty disclaimer.
  17. **/
  18. #ifndef _NFCMRVL_H_
  19. #define _NFCMRVL_H_
  20. #include <linux/platform_data/nfcmrvl.h>
  21. #include "fw_dnld.h"
  22. /* Define private flags: */
  23. #define NFCMRVL_NCI_RUNNING 1
  24. #define NFCMRVL_PHY_ERROR 2
  25. #define NFCMRVL_EXT_COEX_ID 0xE0
  26. #define NFCMRVL_NOT_ALLOWED_ID 0xE1
  27. #define NFCMRVL_ACTIVE_ID 0xE2
  28. #define NFCMRVL_EXT_COEX_ENABLE 1
  29. #define NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED 0xA
  30. #define NFCMRVL_GPIO_PIN_NFC_ACTIVE 0xB
  31. #define NFCMRVL_NCI_MAX_EVENT_SIZE 260
  32. /*
  33. ** NCI FW Parmaters
  34. */
  35. #define NFCMRVL_PB_BAIL_OUT 0x11
  36. #define NFCMRVL_PROP_REF_CLOCK 0xF0
  37. #define NFCMRVL_PROP_SET_HI_CONFIG 0xF1
  38. /*
  39. ** HCI defines
  40. */
  41. #define NFCMRVL_HCI_EVENT_HEADER_SIZE 0x04
  42. #define NFCMRVL_HCI_EVENT_CODE 0x04
  43. #define NFCMRVL_HCI_NFC_EVENT_CODE 0xFF
  44. #define NFCMRVL_HCI_COMMAND_CODE 0x01
  45. #define NFCMRVL_HCI_OGF 0x81
  46. #define NFCMRVL_HCI_OCF 0xFE
  47. enum nfcmrvl_phy {
  48. NFCMRVL_PHY_USB = 0,
  49. NFCMRVL_PHY_UART = 1,
  50. NFCMRVL_PHY_I2C = 2,
  51. NFCMRVL_PHY_SPI = 3,
  52. };
  53. struct nfcmrvl_private {
  54. unsigned long flags;
  55. /* Platform configuration */
  56. struct nfcmrvl_platform_data config;
  57. /* Parent dev */
  58. struct nci_dev *ndev;
  59. /* FW download context */
  60. struct nfcmrvl_fw_dnld fw_dnld;
  61. /* FW download support */
  62. bool support_fw_dnld;
  63. /*
  64. ** PHY related information
  65. */
  66. /* PHY driver context */
  67. void *drv_data;
  68. /* PHY device */
  69. struct device *dev;
  70. /* PHY type */
  71. enum nfcmrvl_phy phy;
  72. /* Low level driver ops */
  73. struct nfcmrvl_if_ops *if_ops;
  74. };
  75. struct nfcmrvl_if_ops {
  76. int (*nci_open) (struct nfcmrvl_private *priv);
  77. int (*nci_close) (struct nfcmrvl_private *priv);
  78. int (*nci_send) (struct nfcmrvl_private *priv, struct sk_buff *skb);
  79. void (*nci_update_config)(struct nfcmrvl_private *priv,
  80. const void *param);
  81. };
  82. void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv);
  83. int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
  84. struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
  85. void *drv_data,
  86. struct nfcmrvl_if_ops *ops,
  87. struct device *dev,
  88. struct nfcmrvl_platform_data *pdata);
  89. void nfcmrvl_chip_reset(struct nfcmrvl_private *priv);
  90. void nfcmrvl_chip_halt(struct nfcmrvl_private *priv);
  91. int nfcmrvl_parse_dt(struct device_node *node,
  92. struct nfcmrvl_platform_data *pdata);
  93. #endif