pn553.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (C) 2010 Trusted Logic S.A.
  3. * Copyright (C) 2021 XiaoMi, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. /******************************************************************************
  17. *
  18. * The original Work has been changed by NXP Semiconductors.
  19. *
  20. * Copyright (C) 2013-2019 NXP Semiconductors
  21. * *
  22. * This program is free software; you can redistribute it and/or modify
  23. * it under the terms of the GNU General Public License as published by
  24. * the Free Software Foundation; either version 2 of the License, or
  25. * (at your option) any later version.
  26. *
  27. * This program is distributed in the hope that it will be useful,
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. * GNU General Public License for more details.
  31. *
  32. *
  33. ******************************************************************************/
  34. #ifndef _PN553_H_
  35. #define _PN553_H_
  36. #define PN544_MAGIC 0xE9
  37. /*
  38. * PN544 power control via ioctl
  39. * PN544_SET_PWR(0): power off
  40. * PN544_SET_PWR(1): power on
  41. * PN544_SET_PWR(2): reset and power on with firmware download enabled
  42. */
  43. #define PN544_SET_PWR _IOW(PN544_MAGIC, 0x01, unsigned int)
  44. /*
  45. * SPI Request NFCC to enable p61 power, only in param
  46. * Only for SPI
  47. * level 1 = Enable power
  48. * level 0 = Disable power
  49. */
  50. #define P61_SET_SPI_PWR _IOW(PN544_MAGIC, 0x02, unsigned int)
  51. /* SPI or DWP can call this ioctl to get the current
  52. * power state of P61
  53. *
  54. */
  55. #define P61_GET_PWR_STATUS _IOR(PN544_MAGIC, 0x03, unsigned int)
  56. /* DWP side this ioctl will be called
  57. * level 1 = Wired access is enabled/ongoing
  58. * level 0 = Wired access is disalbed/stopped
  59. */
  60. #define P61_SET_WIRED_ACCESS _IOW(PN544_MAGIC, 0x04, unsigned int)
  61. /*
  62. NFC Init will call the ioctl to register the PID with the i2c driver
  63. */
  64. #define P544_SET_NFC_SERVICE_PID _IOW(PN544_MAGIC, 0x05, unsigned int)
  65. /*
  66. NFC and SPI will call the ioctl to get the i2c/spi bus access
  67. */
  68. #define P544_GET_ESE_ACCESS _IOW(PN544_MAGIC, 0x06, unsigned int)
  69. /*
  70. NFC and SPI will call the ioctl to update the power scheme
  71. */
  72. #define P544_SET_POWER_SCHEME _IOW(PN544_MAGIC, 0x07, unsigned int)
  73. /*
  74. NFC will call the ioctl to release the svdd protection
  75. */
  76. #define P544_REL_SVDD_WAIT _IOW(PN544_MAGIC, 0x08, unsigned int)
  77. /* SPI or DWP can call this ioctl to get the current
  78. * power state of P61
  79. *
  80. */
  81. #define PN544_SET_DWNLD_STATUS _IOW(PN544_MAGIC, 0x09, unsigned int)
  82. /*
  83. NFC will call the ioctl to release the dwp on/off protection
  84. */
  85. #define P544_REL_DWPONOFF_WAIT _IOW(PN544_MAGIC, 0x0A, unsigned int)
  86. /*
  87. NFC will call the ioctl to start Secure Timer
  88. */
  89. #define P544_SECURE_TIMER_SESSION _IOW(PN544_MAGIC, 0x0B, unsigned int)
  90. #define MAX_ESE_ACCESS_TIME_OUT_MS 200 /*100 milliseconds */
  91. #define NFCC_INITIAL_CORE_RESET_NTF _IOW(PN544_MAGIC, 0x10, unsigned int)
  92. /*
  93. NFC_ON: Driver is being used by the NFC service
  94. */
  95. #define P544_FLAG_NFC_ON 0x01
  96. /*
  97. FW_DNLD: NFC_ON and FW download is going on
  98. */
  99. #define P544_FLAG_FW_DNLD 0x02
  100. /*
  101. COLD_RESET: eSE cold reset is triggered by driver
  102. */
  103. #define P544_FLAG_ESE_COLD_RESET_FROM_DRIVER 0x04
  104. typedef enum p61_access_state {
  105. P61_STATE_INVALID = 0x0000,
  106. P61_STATE_IDLE = 0x0100, /* p61 is free to use */
  107. P61_STATE_WIRED = 0x0200, /* p61 is being accessed by DWP (NFCC) */
  108. P61_STATE_SPI = 0x0400, /* P61 is being accessed by SPI */
  109. P61_STATE_DWNLD = 0x0800, /* NFCC fw download is in progress */
  110. P61_STATE_SPI_PRIO = 0x1000, /*Start of p61 access by SPI on priority */
  111. P61_STATE_SPI_PRIO_END = 0x2000, /*End of p61 access by SPI on priority */
  112. P61_STATE_SPI_END = 0x4000,
  113. P61_STATE_JCP_DWNLD = 0x8000, /* JCOP downlad in progress */
  114. P61_STATE_SECURE_MODE = 0x100000, /* secure mode state */
  115. P61_STATE_SPI_SVDD_SYNC_START = 0x0001, /*ESE_VDD Low req by SPI */
  116. P61_STATE_SPI_SVDD_SYNC_END = 0x0002, /*ESE_VDD is Low by SPI */
  117. P61_STATE_DWP_SVDD_SYNC_START = 0x0004, /*ESE_VDD Low req by Nfc */
  118. P61_STATE_DWP_SVDD_SYNC_END = 0x0008 /*ESE_VDD is Low by Nfc */
  119. } p61_access_state_t;
  120. typedef enum chip_type_pwr_scheme {
  121. PN67T_PWR_SCHEME = 0x01,
  122. PN80T_LEGACY_PWR_SCHEME,
  123. PN80T_EXT_PMU_SCHEME,
  124. } chip_pwr_scheme_t;
  125. typedef enum jcop_dwnld_state {
  126. JCP_DWNLD_IDLE = P61_STATE_JCP_DWNLD, /* jcop dwnld is ongoing */
  127. JCP_DWNLD_INIT = 0x8010, /* jcop dwonload init state */
  128. JCP_DWNLD_START = 0x8020, /* download started */
  129. JCP_SPI_DWNLD_COMPLETE = 0x8040, /* jcop download complete in spi interface */
  130. JCP_DWP_DWNLD_COMPLETE = 0x8080, /* jcop download complete */
  131. } jcop_dwnld_state_t;
  132. struct pn544_i2c_platform_data {
  133. unsigned int irq_gpio;
  134. unsigned int ven_gpio;
  135. unsigned int firm_gpio;
  136. unsigned int iso_rst_gpio; /* gpio used for ISO hard reset P73 */
  137. };
  138. struct hw_type_info {
  139. /*
  140. * Response of get_version_cmd will be stored in data
  141. * byte structure :
  142. * byte 0-1 : Header
  143. * byte 2 : Status
  144. * byte 3 : Hardware Version
  145. * byte 4 : ROM code
  146. * byte 5 : 0x00 constant
  147. * byte 6-7 : Protected data version
  148. * byte 8-9 : Trim data version
  149. * byte 10-11 : FW version
  150. * byte 12-13 : CRC
  151. * */
  152. char data[20];
  153. int len;
  154. };
  155. #endif