btintel.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. *
  3. * Bluetooth support for Intel devices
  4. *
  5. * Copyright (C) 2015 Intel Corporation
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. struct intel_version {
  24. u8 status;
  25. u8 hw_platform;
  26. u8 hw_variant;
  27. u8 hw_revision;
  28. u8 fw_variant;
  29. u8 fw_revision;
  30. u8 fw_build_num;
  31. u8 fw_build_ww;
  32. u8 fw_build_yy;
  33. u8 fw_patch_num;
  34. } __packed;
  35. struct intel_boot_params {
  36. __u8 status;
  37. __u8 otp_format;
  38. __u8 otp_content;
  39. __u8 otp_patch;
  40. __le16 dev_revid;
  41. __u8 secure_boot;
  42. __u8 key_from_hdr;
  43. __u8 key_type;
  44. __u8 otp_lock;
  45. __u8 api_lock;
  46. __u8 debug_lock;
  47. bdaddr_t otp_bdaddr;
  48. __u8 min_fw_build_nn;
  49. __u8 min_fw_build_cw;
  50. __u8 min_fw_build_yy;
  51. __u8 limited_cce;
  52. __u8 unlocked_state;
  53. } __packed;
  54. struct intel_bootup {
  55. __u8 zero;
  56. __u8 num_cmds;
  57. __u8 source;
  58. __u8 reset_type;
  59. __u8 reset_reason;
  60. __u8 ddc_status;
  61. } __packed;
  62. struct intel_secure_send_result {
  63. __u8 result;
  64. __le16 opcode;
  65. __u8 status;
  66. } __packed;
  67. struct intel_reset {
  68. __u8 reset_type;
  69. __u8 patch_enable;
  70. __u8 ddc_reload;
  71. __u8 boot_option;
  72. __le32 boot_param;
  73. } __packed;
  74. #if IS_ENABLED(CONFIG_BT_INTEL)
  75. int btintel_check_bdaddr(struct hci_dev *hdev);
  76. int btintel_enter_mfg(struct hci_dev *hdev);
  77. int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched);
  78. int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
  79. int btintel_set_diag(struct hci_dev *hdev, bool enable);
  80. int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable);
  81. void btintel_hw_error(struct hci_dev *hdev, u8 code);
  82. void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
  83. int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
  84. const void *param);
  85. int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
  86. int btintel_set_event_mask(struct hci_dev *hdev, bool debug);
  87. int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
  88. int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
  89. struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
  90. u16 opcode_write);
  91. int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
  92. int btintel_read_boot_params(struct hci_dev *hdev,
  93. struct intel_boot_params *params);
  94. int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
  95. u32 *boot_param);
  96. #else
  97. static inline int btintel_check_bdaddr(struct hci_dev *hdev)
  98. {
  99. return -EOPNOTSUPP;
  100. }
  101. static inline int btintel_enter_mfg(struct hci_dev *hdev)
  102. {
  103. return -EOPNOTSUPP;
  104. }
  105. static inline int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
  106. {
  107. return -EOPNOTSUPP;
  108. }
  109. static inline int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
  110. {
  111. return -EOPNOTSUPP;
  112. }
  113. static inline int btintel_set_diag(struct hci_dev *hdev, bool enable)
  114. {
  115. return -EOPNOTSUPP;
  116. }
  117. static inline int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable)
  118. {
  119. return -EOPNOTSUPP;
  120. }
  121. static inline void btintel_hw_error(struct hci_dev *hdev, u8 code)
  122. {
  123. }
  124. static inline void btintel_version_info(struct hci_dev *hdev,
  125. struct intel_version *ver)
  126. {
  127. }
  128. static inline int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type,
  129. u32 plen, const void *param)
  130. {
  131. return -EOPNOTSUPP;
  132. }
  133. static inline int btintel_load_ddc_config(struct hci_dev *hdev,
  134. const char *ddc_name)
  135. {
  136. return -EOPNOTSUPP;
  137. }
  138. static inline int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
  139. {
  140. return -EOPNOTSUPP;
  141. }
  142. static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
  143. {
  144. return -EOPNOTSUPP;
  145. }
  146. static inline int btintel_read_version(struct hci_dev *hdev,
  147. struct intel_version *ver)
  148. {
  149. return -EOPNOTSUPP;
  150. }
  151. static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
  152. u16 opcode_read,
  153. u16 opcode_write)
  154. {
  155. return ERR_PTR(-EINVAL);
  156. }
  157. static inline int btintel_send_intel_reset(struct hci_dev *hdev,
  158. u32 reset_param)
  159. {
  160. return -EOPNOTSUPP;
  161. }
  162. static inline int btintel_read_boot_params(struct hci_dev *hdev,
  163. struct intel_boot_params *params)
  164. {
  165. return -EOPNOTSUPP;
  166. }
  167. static inline int btintel_download_firmware(struct hci_dev *dev,
  168. const struct firmware *fw,
  169. u32 *boot_param)
  170. {
  171. return -EOPNOTSUPP;
  172. }
  173. #endif