0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 enum {
0011 INTEL_TLV_CNVI_TOP = 0x10,
0012 INTEL_TLV_CNVR_TOP,
0013 INTEL_TLV_CNVI_BT,
0014 INTEL_TLV_CNVR_BT,
0015 INTEL_TLV_CNVI_OTP,
0016 INTEL_TLV_CNVR_OTP,
0017 INTEL_TLV_DEV_REV_ID,
0018 INTEL_TLV_USB_VENDOR_ID,
0019 INTEL_TLV_USB_PRODUCT_ID,
0020 INTEL_TLV_PCIE_VENDOR_ID,
0021 INTEL_TLV_PCIE_DEVICE_ID,
0022 INTEL_TLV_PCIE_SUBSYSTEM_ID,
0023 INTEL_TLV_IMAGE_TYPE,
0024 INTEL_TLV_TIME_STAMP,
0025 INTEL_TLV_BUILD_TYPE,
0026 INTEL_TLV_BUILD_NUM,
0027 INTEL_TLV_FW_BUILD_PRODUCT,
0028 INTEL_TLV_FW_BUILD_HW,
0029 INTEL_TLV_FW_STEP,
0030 INTEL_TLV_BT_SPEC,
0031 INTEL_TLV_MFG_NAME,
0032 INTEL_TLV_HCI_REV,
0033 INTEL_TLV_LMP_SUBVER,
0034 INTEL_TLV_OTP_PATCH_VER,
0035 INTEL_TLV_SECURE_BOOT,
0036 INTEL_TLV_KEY_FROM_HDR,
0037 INTEL_TLV_OTP_LOCK,
0038 INTEL_TLV_API_LOCK,
0039 INTEL_TLV_DEBUG_LOCK,
0040 INTEL_TLV_MIN_FW,
0041 INTEL_TLV_LIMITED_CCE,
0042 INTEL_TLV_SBE_TYPE,
0043 INTEL_TLV_OTP_BDADDR,
0044 INTEL_TLV_UNLOCKED_STATE
0045 };
0046
0047 struct intel_tlv {
0048 u8 type;
0049 u8 len;
0050 u8 val[];
0051 } __packed;
0052
0053 struct intel_version_tlv {
0054 u32 cnvi_top;
0055 u32 cnvr_top;
0056 u32 cnvi_bt;
0057 u32 cnvr_bt;
0058 u16 dev_rev_id;
0059 u8 img_type;
0060 u16 timestamp;
0061 u8 build_type;
0062 u32 build_num;
0063 u8 secure_boot;
0064 u8 otp_lock;
0065 u8 api_lock;
0066 u8 debug_lock;
0067 u8 min_fw_build_nn;
0068 u8 min_fw_build_cw;
0069 u8 min_fw_build_yy;
0070 u8 limited_cce;
0071 u8 sbe_type;
0072 bdaddr_t otp_bd_addr;
0073 };
0074
0075 struct intel_version {
0076 u8 status;
0077 u8 hw_platform;
0078 u8 hw_variant;
0079 u8 hw_revision;
0080 u8 fw_variant;
0081 u8 fw_revision;
0082 u8 fw_build_num;
0083 u8 fw_build_ww;
0084 u8 fw_build_yy;
0085 u8 fw_patch_num;
0086 } __packed;
0087
0088 struct intel_boot_params {
0089 __u8 status;
0090 __u8 otp_format;
0091 __u8 otp_content;
0092 __u8 otp_patch;
0093 __le16 dev_revid;
0094 __u8 secure_boot;
0095 __u8 key_from_hdr;
0096 __u8 key_type;
0097 __u8 otp_lock;
0098 __u8 api_lock;
0099 __u8 debug_lock;
0100 bdaddr_t otp_bdaddr;
0101 __u8 min_fw_build_nn;
0102 __u8 min_fw_build_cw;
0103 __u8 min_fw_build_yy;
0104 __u8 limited_cce;
0105 __u8 unlocked_state;
0106 } __packed;
0107
0108 struct intel_bootup {
0109 __u8 zero;
0110 __u8 num_cmds;
0111 __u8 source;
0112 __u8 reset_type;
0113 __u8 reset_reason;
0114 __u8 ddc_status;
0115 } __packed;
0116
0117 struct intel_secure_send_result {
0118 __u8 result;
0119 __le16 opcode;
0120 __u8 status;
0121 } __packed;
0122
0123 struct intel_reset {
0124 __u8 reset_type;
0125 __u8 patch_enable;
0126 __u8 ddc_reload;
0127 __u8 boot_option;
0128 __le32 boot_param;
0129 } __packed;
0130
0131 struct intel_debug_features {
0132 __u8 page1[16];
0133 } __packed;
0134
0135 struct intel_offload_use_cases {
0136 __u8 status;
0137 __u8 preset[8];
0138 } __packed;
0139
0140 #define INTEL_HW_PLATFORM(cnvx_bt) ((u8)(((cnvx_bt) & 0x0000ff00) >> 8))
0141 #define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16))
0142 #define INTEL_CNVX_TOP_TYPE(cnvx_top) ((cnvx_top) & 0x00000fff)
0143 #define INTEL_CNVX_TOP_STEP(cnvx_top) (((cnvx_top) & 0x0f000000) >> 24)
0144 #define INTEL_CNVX_TOP_PACK_SWAB(t, s) __swab16(((__u16)(((t) << 4) | (s))))
0145
0146 enum {
0147 INTEL_BOOTLOADER,
0148 INTEL_DOWNLOADING,
0149 INTEL_FIRMWARE_LOADED,
0150 INTEL_FIRMWARE_FAILED,
0151 INTEL_BOOTING,
0152 INTEL_BROKEN_INITIAL_NCMD,
0153 INTEL_BROKEN_SHUTDOWN_LED,
0154 INTEL_ROM_LEGACY,
0155 INTEL_ROM_LEGACY_NO_WBS_SUPPORT,
0156
0157 __INTEL_NUM_FLAGS,
0158 };
0159
0160 struct btintel_data {
0161 DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS);
0162 };
0163
0164 #define btintel_set_flag(hdev, nr) \
0165 do { \
0166 struct btintel_data *intel = hci_get_priv((hdev)); \
0167 set_bit((nr), intel->flags); \
0168 } while (0)
0169
0170 #define btintel_clear_flag(hdev, nr) \
0171 do { \
0172 struct btintel_data *intel = hci_get_priv((hdev)); \
0173 clear_bit((nr), intel->flags); \
0174 } while (0)
0175
0176 #define btintel_wake_up_flag(hdev, nr) \
0177 do { \
0178 struct btintel_data *intel = hci_get_priv((hdev)); \
0179 wake_up_bit(intel->flags, (nr)); \
0180 } while (0)
0181
0182 #define btintel_get_flag(hdev) \
0183 (((struct btintel_data *)hci_get_priv(hdev))->flags)
0184
0185 #define btintel_test_flag(hdev, nr) test_bit((nr), btintel_get_flag(hdev))
0186 #define btintel_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), btintel_get_flag(hdev))
0187 #define btintel_wait_on_flag_timeout(hdev, nr, m, to) \
0188 wait_on_bit_timeout(btintel_get_flag(hdev), (nr), m, to)
0189
0190 #if IS_ENABLED(CONFIG_BT_INTEL)
0191
0192 int btintel_check_bdaddr(struct hci_dev *hdev);
0193 int btintel_enter_mfg(struct hci_dev *hdev);
0194 int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched);
0195 int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
0196 int btintel_set_diag(struct hci_dev *hdev, bool enable);
0197
0198 int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
0199 int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
0200 int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
0201 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
0202 struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
0203 u16 opcode_write);
0204 int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
0205 int btintel_read_boot_params(struct hci_dev *hdev,
0206 struct intel_boot_params *params);
0207 int btintel_download_firmware(struct hci_dev *dev, struct intel_version *ver,
0208 const struct firmware *fw, u32 *boot_param);
0209 int btintel_configure_setup(struct hci_dev *hdev);
0210 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len);
0211 void btintel_secure_send_result(struct hci_dev *hdev,
0212 const void *ptr, unsigned int len);
0213 int btintel_set_quality_report(struct hci_dev *hdev, bool enable);
0214 #else
0215
0216 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
0217 {
0218 return -EOPNOTSUPP;
0219 }
0220
0221 static inline int btintel_enter_mfg(struct hci_dev *hdev)
0222 {
0223 return -EOPNOTSUPP;
0224 }
0225
0226 static inline int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
0227 {
0228 return -EOPNOTSUPP;
0229 }
0230
0231 static inline int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
0232 {
0233 return -EOPNOTSUPP;
0234 }
0235
0236 static inline int btintel_set_diag(struct hci_dev *hdev, bool enable)
0237 {
0238 return -EOPNOTSUPP;
0239 }
0240
0241 static inline int btintel_version_info(struct hci_dev *hdev,
0242 struct intel_version *ver)
0243 {
0244 return -EOPNOTSUPP;
0245 }
0246
0247 static inline int btintel_load_ddc_config(struct hci_dev *hdev,
0248 const char *ddc_name)
0249 {
0250 return -EOPNOTSUPP;
0251 }
0252
0253 static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
0254 {
0255 return -EOPNOTSUPP;
0256 }
0257
0258 static inline int btintel_read_version(struct hci_dev *hdev,
0259 struct intel_version *ver)
0260 {
0261 return -EOPNOTSUPP;
0262 }
0263
0264 static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
0265 u16 opcode_read,
0266 u16 opcode_write)
0267 {
0268 return ERR_PTR(-EINVAL);
0269 }
0270
0271 static inline int btintel_send_intel_reset(struct hci_dev *hdev,
0272 u32 reset_param)
0273 {
0274 return -EOPNOTSUPP;
0275 }
0276
0277 static inline int btintel_read_boot_params(struct hci_dev *hdev,
0278 struct intel_boot_params *params)
0279 {
0280 return -EOPNOTSUPP;
0281 }
0282
0283 static inline int btintel_download_firmware(struct hci_dev *dev,
0284 const struct firmware *fw,
0285 u32 *boot_param)
0286 {
0287 return -EOPNOTSUPP;
0288 }
0289
0290 static inline int btintel_configure_setup(struct hci_dev *hdev)
0291 {
0292 return -ENODEV;
0293 }
0294
0295 static inline void btintel_bootup(struct hci_dev *hdev,
0296 const void *ptr, unsigned int len)
0297 {
0298 }
0299
0300 static inline void btintel_secure_send_result(struct hci_dev *hdev,
0301 const void *ptr, unsigned int len)
0302 {
0303 }
0304
0305 static inline int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
0306 {
0307 return -ENODEV;
0308 }
0309 #endif