btintel.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * Bluetooth support for Intel devices
  5. *
  6. * Copyright (C) 2015 Intel Corporation
  7. */
  8. /* List of tlv type */
  9. enum {
  10. INTEL_TLV_CNVI_TOP = 0x10,
  11. INTEL_TLV_CNVR_TOP,
  12. INTEL_TLV_CNVI_BT,
  13. INTEL_TLV_CNVR_BT,
  14. INTEL_TLV_CNVI_OTP,
  15. INTEL_TLV_CNVR_OTP,
  16. INTEL_TLV_DEV_REV_ID,
  17. INTEL_TLV_USB_VENDOR_ID,
  18. INTEL_TLV_USB_PRODUCT_ID,
  19. INTEL_TLV_PCIE_VENDOR_ID,
  20. INTEL_TLV_PCIE_DEVICE_ID,
  21. INTEL_TLV_PCIE_SUBSYSTEM_ID,
  22. INTEL_TLV_IMAGE_TYPE,
  23. INTEL_TLV_TIME_STAMP,
  24. INTEL_TLV_BUILD_TYPE,
  25. INTEL_TLV_BUILD_NUM,
  26. INTEL_TLV_FW_BUILD_PRODUCT,
  27. INTEL_TLV_FW_BUILD_HW,
  28. INTEL_TLV_FW_STEP,
  29. INTEL_TLV_BT_SPEC,
  30. INTEL_TLV_MFG_NAME,
  31. INTEL_TLV_HCI_REV,
  32. INTEL_TLV_LMP_SUBVER,
  33. INTEL_TLV_OTP_PATCH_VER,
  34. INTEL_TLV_SECURE_BOOT,
  35. INTEL_TLV_KEY_FROM_HDR,
  36. INTEL_TLV_OTP_LOCK,
  37. INTEL_TLV_API_LOCK,
  38. INTEL_TLV_DEBUG_LOCK,
  39. INTEL_TLV_MIN_FW,
  40. INTEL_TLV_LIMITED_CCE,
  41. INTEL_TLV_SBE_TYPE,
  42. INTEL_TLV_OTP_BDADDR,
  43. INTEL_TLV_UNLOCKED_STATE
  44. };
  45. struct intel_tlv {
  46. u8 type;
  47. u8 len;
  48. u8 val[];
  49. } __packed;
  50. struct intel_version_tlv {
  51. u32 cnvi_top;
  52. u32 cnvr_top;
  53. u32 cnvi_bt;
  54. u32 cnvr_bt;
  55. u16 dev_rev_id;
  56. u8 img_type;
  57. u16 timestamp;
  58. u8 build_type;
  59. u32 build_num;
  60. u8 secure_boot;
  61. u8 otp_lock;
  62. u8 api_lock;
  63. u8 debug_lock;
  64. u8 min_fw_build_nn;
  65. u8 min_fw_build_cw;
  66. u8 min_fw_build_yy;
  67. u8 limited_cce;
  68. u8 sbe_type;
  69. bdaddr_t otp_bd_addr;
  70. };
  71. struct intel_version {
  72. u8 status;
  73. u8 hw_platform;
  74. u8 hw_variant;
  75. u8 hw_revision;
  76. u8 fw_variant;
  77. u8 fw_revision;
  78. u8 fw_build_num;
  79. u8 fw_build_ww;
  80. u8 fw_build_yy;
  81. u8 fw_patch_num;
  82. } __packed;
  83. struct intel_boot_params {
  84. __u8 status;
  85. __u8 otp_format;
  86. __u8 otp_content;
  87. __u8 otp_patch;
  88. __le16 dev_revid;
  89. __u8 secure_boot;
  90. __u8 key_from_hdr;
  91. __u8 key_type;
  92. __u8 otp_lock;
  93. __u8 api_lock;
  94. __u8 debug_lock;
  95. bdaddr_t otp_bdaddr;
  96. __u8 min_fw_build_nn;
  97. __u8 min_fw_build_cw;
  98. __u8 min_fw_build_yy;
  99. __u8 limited_cce;
  100. __u8 unlocked_state;
  101. } __packed;
  102. struct intel_bootup {
  103. __u8 zero;
  104. __u8 num_cmds;
  105. __u8 source;
  106. __u8 reset_type;
  107. __u8 reset_reason;
  108. __u8 ddc_status;
  109. } __packed;
  110. struct intel_secure_send_result {
  111. __u8 result;
  112. __le16 opcode;
  113. __u8 status;
  114. } __packed;
  115. struct intel_reset {
  116. __u8 reset_type;
  117. __u8 patch_enable;
  118. __u8 ddc_reload;
  119. __u8 boot_option;
  120. __le32 boot_param;
  121. } __packed;
  122. struct intel_debug_features {
  123. __u8 page1[16];
  124. } __packed;
  125. #if IS_ENABLED(CONFIG_BT_INTEL)
  126. int btintel_check_bdaddr(struct hci_dev *hdev);
  127. int btintel_enter_mfg(struct hci_dev *hdev);
  128. int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched);
  129. int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
  130. int btintel_set_diag(struct hci_dev *hdev, bool enable);
  131. int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable);
  132. void btintel_hw_error(struct hci_dev *hdev, u8 code);
  133. void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
  134. void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *version);
  135. int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
  136. const void *param);
  137. int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
  138. int btintel_set_event_mask(struct hci_dev *hdev, bool debug);
  139. int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
  140. int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
  141. int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver);
  142. struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
  143. u16 opcode_write);
  144. int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
  145. int btintel_read_boot_params(struct hci_dev *hdev,
  146. struct intel_boot_params *params);
  147. int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
  148. u32 *boot_param);
  149. int btintel_download_firmware_newgen(struct hci_dev *hdev,
  150. const struct firmware *fw,
  151. u32 *boot_param, u8 hw_variant,
  152. u8 sbe_type);
  153. void btintel_reset_to_bootloader(struct hci_dev *hdev);
  154. int btintel_read_debug_features(struct hci_dev *hdev,
  155. struct intel_debug_features *features);
  156. int btintel_set_debug_features(struct hci_dev *hdev,
  157. const struct intel_debug_features *features);
  158. #else
  159. static inline int btintel_check_bdaddr(struct hci_dev *hdev)
  160. {
  161. return -EOPNOTSUPP;
  162. }
  163. static inline int btintel_enter_mfg(struct hci_dev *hdev)
  164. {
  165. return -EOPNOTSUPP;
  166. }
  167. static inline int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
  168. {
  169. return -EOPNOTSUPP;
  170. }
  171. static inline int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
  172. {
  173. return -EOPNOTSUPP;
  174. }
  175. static inline int btintel_set_diag(struct hci_dev *hdev, bool enable)
  176. {
  177. return -EOPNOTSUPP;
  178. }
  179. static inline int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable)
  180. {
  181. return -EOPNOTSUPP;
  182. }
  183. static inline void btintel_hw_error(struct hci_dev *hdev, u8 code)
  184. {
  185. }
  186. static inline void btintel_version_info(struct hci_dev *hdev,
  187. struct intel_version *ver)
  188. {
  189. }
  190. static inline void btintel_version_info_tlv(struct hci_dev *hdev,
  191. struct intel_version_tlv *version)
  192. {
  193. }
  194. static inline int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type,
  195. u32 plen, const void *param)
  196. {
  197. return -EOPNOTSUPP;
  198. }
  199. static inline int btintel_load_ddc_config(struct hci_dev *hdev,
  200. const char *ddc_name)
  201. {
  202. return -EOPNOTSUPP;
  203. }
  204. static inline int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
  205. {
  206. return -EOPNOTSUPP;
  207. }
  208. static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
  209. {
  210. return -EOPNOTSUPP;
  211. }
  212. static inline int btintel_read_version(struct hci_dev *hdev,
  213. struct intel_version *ver)
  214. {
  215. return -EOPNOTSUPP;
  216. }
  217. static inline int btintel_read_version_tlv(struct hci_dev *hdev,
  218. struct intel_version_tlv *ver)
  219. {
  220. return -EOPNOTSUPP;
  221. }
  222. static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
  223. u16 opcode_read,
  224. u16 opcode_write)
  225. {
  226. return ERR_PTR(-EINVAL);
  227. }
  228. static inline int btintel_send_intel_reset(struct hci_dev *hdev,
  229. u32 reset_param)
  230. {
  231. return -EOPNOTSUPP;
  232. }
  233. static inline int btintel_read_boot_params(struct hci_dev *hdev,
  234. struct intel_boot_params *params)
  235. {
  236. return -EOPNOTSUPP;
  237. }
  238. static inline int btintel_download_firmware(struct hci_dev *dev,
  239. const struct firmware *fw,
  240. u32 *boot_param)
  241. {
  242. return -EOPNOTSUPP;
  243. }
  244. static inline int btintel_download_firmware_newgen(struct hci_dev *hdev,
  245. const struct firmware *fw,
  246. u32 *boot_param,
  247. u8 hw_variant, u8 sbe_type)
  248. {
  249. return -EOPNOTSUPP;
  250. }
  251. static inline void btintel_reset_to_bootloader(struct hci_dev *hdev)
  252. {
  253. }
  254. static inline int btintel_read_debug_features(struct hci_dev *hdev,
  255. struct intel_debug_features *features)
  256. {
  257. return -EOPNOTSUPP;
  258. }
  259. static inline int btintel_set_debug_features(struct hci_dev *hdev,
  260. const struct intel_debug_features *features)
  261. {
  262. return -EOPNOTSUPP;
  263. }
  264. #endif