btqca.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Bluetooth supports for Qualcomm Atheros ROME chips
  3. *
  4. * Copyright (c) 2015 The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation
  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. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #define EDL_PATCH_CMD_OPCODE (0xFC00)
  21. #define EDL_NVM_ACCESS_OPCODE (0xFC0B)
  22. #define EDL_PATCH_CMD_LEN (1)
  23. #define EDL_PATCH_VER_REQ_CMD (0x19)
  24. #define EDL_PATCH_TLV_REQ_CMD (0x1E)
  25. #define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
  26. #define MAX_SIZE_PER_TLV_SEGMENT (243)
  27. #define EDL_CMD_REQ_RES_EVT (0x00)
  28. #define EDL_PATCH_VER_RES_EVT (0x19)
  29. #define EDL_APP_VER_RES_EVT (0x02)
  30. #define EDL_TVL_DNLD_RES_EVT (0x04)
  31. #define EDL_CMD_EXE_STATUS_EVT (0x00)
  32. #define EDL_SET_BAUDRATE_RSP_EVT (0x92)
  33. #define EDL_NVM_ACCESS_CODE_EVT (0x0B)
  34. #define EDL_TAG_ID_HCI (17)
  35. #define EDL_TAG_ID_DEEP_SLEEP (27)
  36. #define QCA_WCN3990_POWERON_PULSE 0xFC
  37. #define QCA_WCN3990_POWEROFF_PULSE 0xC0
  38. enum qca_bardrate {
  39. QCA_BAUDRATE_115200 = 0,
  40. QCA_BAUDRATE_57600,
  41. QCA_BAUDRATE_38400,
  42. QCA_BAUDRATE_19200,
  43. QCA_BAUDRATE_9600,
  44. QCA_BAUDRATE_230400,
  45. QCA_BAUDRATE_250000,
  46. QCA_BAUDRATE_460800,
  47. QCA_BAUDRATE_500000,
  48. QCA_BAUDRATE_720000,
  49. QCA_BAUDRATE_921600,
  50. QCA_BAUDRATE_1000000,
  51. QCA_BAUDRATE_1250000,
  52. QCA_BAUDRATE_2000000,
  53. QCA_BAUDRATE_3000000,
  54. QCA_BAUDRATE_4000000,
  55. QCA_BAUDRATE_1600000,
  56. QCA_BAUDRATE_3200000,
  57. QCA_BAUDRATE_3500000,
  58. QCA_BAUDRATE_AUTO = 0xFE,
  59. QCA_BAUDRATE_RESERVED
  60. };
  61. enum rome_tlv_dnld_mode {
  62. ROME_SKIP_EVT_NONE,
  63. ROME_SKIP_EVT_VSE,
  64. ROME_SKIP_EVT_CC,
  65. ROME_SKIP_EVT_VSE_CC
  66. };
  67. enum rome_tlv_type {
  68. TLV_TYPE_PATCH = 1,
  69. TLV_TYPE_NVM
  70. };
  71. struct rome_config {
  72. u8 type;
  73. char fwname[64];
  74. uint8_t user_baud_rate;
  75. enum rome_tlv_dnld_mode dnld_mode;
  76. };
  77. struct edl_event_hdr {
  78. __u8 cresp;
  79. __u8 rtype;
  80. __u8 data[0];
  81. } __packed;
  82. struct rome_version {
  83. __le32 product_id;
  84. __le16 patch_ver;
  85. __le16 rome_ver;
  86. __le32 soc_id;
  87. } __packed;
  88. struct tlv_seg_resp {
  89. __u8 result;
  90. } __packed;
  91. struct tlv_type_patch {
  92. __le32 total_size;
  93. __le32 data_length;
  94. __u8 format_version;
  95. __u8 signature;
  96. __u8 download_mode;
  97. __u8 reserved1;
  98. __le16 product_id;
  99. __le16 rom_build;
  100. __le16 patch_version;
  101. __le16 reserved2;
  102. __le32 entry;
  103. } __packed;
  104. struct tlv_type_nvm {
  105. __le16 tag_id;
  106. __le16 tag_len;
  107. __le32 reserve1;
  108. __le32 reserve2;
  109. __u8 data[0];
  110. } __packed;
  111. struct tlv_type_hdr {
  112. __le32 type_len;
  113. __u8 data[0];
  114. } __packed;
  115. enum qca_btsoc_type {
  116. QCA_INVALID = -1,
  117. QCA_AR3002,
  118. QCA_ROME,
  119. QCA_WCN3990
  120. };
  121. #if IS_ENABLED(CONFIG_BT_QCA)
  122. int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
  123. int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
  124. enum qca_btsoc_type soc_type, u32 soc_ver);
  125. int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
  126. #else
  127. static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
  128. {
  129. return -EOPNOTSUPP;
  130. }
  131. static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
  132. enum qca_btsoc_type soc_type, u32 soc_ver)
  133. {
  134. return -EOPNOTSUPP;
  135. }
  136. static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
  137. {
  138. return -EOPNOTSUPP;
  139. }
  140. #endif