1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Bluetooth support for Intel devices
6 * Copyright (C) 2015 Intel Corporation
11 INTEL_TLV_CNVI_TOP
= 0x10,
18 INTEL_TLV_USB_VENDOR_ID
,
19 INTEL_TLV_USB_PRODUCT_ID
,
20 INTEL_TLV_PCIE_VENDOR_ID
,
21 INTEL_TLV_PCIE_DEVICE_ID
,
22 INTEL_TLV_PCIE_SUBSYSTEM_ID
,
27 INTEL_TLV_FW_BUILD_PRODUCT
,
28 INTEL_TLV_FW_BUILD_HW
,
34 INTEL_TLV_OTP_PATCH_VER
,
35 INTEL_TLV_SECURE_BOOT
,
36 INTEL_TLV_KEY_FROM_HDR
,
41 INTEL_TLV_LIMITED_CCE
,
44 INTEL_TLV_UNLOCKED_STATE
,
46 INTEL_TLV_FW_ID
= 0x50
55 #define BTINTEL_CNVI_BLAZARI 0x900
56 #define BTINTEL_CNVI_BLAZARIW 0x901
57 #define BTINTEL_CNVI_GAP 0x910
58 #define BTINTEL_CNVI_BLAZARU 0x930
60 #define BTINTEL_IMG_BOOTLOADER 0x01 /* Bootloader image */
61 #define BTINTEL_IMG_IML 0x02 /* Intermediate image */
62 #define BTINTEL_IMG_OP 0x03 /* Operational image */
64 #define BTINTEL_FWID_MAXLEN 64
66 struct intel_version_tlv
{
86 u8 fw_id
[BTINTEL_FWID_MAXLEN
];
90 struct intel_version
{
103 struct intel_boot_params
{
116 __u8 min_fw_build_nn
;
117 __u8 min_fw_build_cw
;
118 __u8 min_fw_build_yy
;
123 struct intel_bootup
{
132 struct intel_secure_send_result
{
146 struct intel_debug_features
{
150 struct intel_offload_use_cases
{
155 #define INTEL_OP_PPAG_CMD 0xFE0B
156 struct hci_ppag_enable_cmd
{
157 __le32 ppag_enable_flags
;
160 #define INTEL_TLV_TYPE_ID 0x01
162 #define INTEL_TLV_SYSTEM_EXCEPTION 0x00
163 #define INTEL_TLV_FATAL_EXCEPTION 0x01
164 #define INTEL_TLV_DEBUG_EXCEPTION 0x02
165 #define INTEL_TLV_TEST_EXCEPTION 0xDE
167 #define INTEL_HW_PLATFORM(cnvx_bt) ((u8)(((cnvx_bt) & 0x0000ff00) >> 8))
168 #define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16))
169 #define INTEL_CNVX_TOP_TYPE(cnvx_top) ((cnvx_top) & 0x00000fff)
170 #define INTEL_CNVX_TOP_STEP(cnvx_top) (((cnvx_top) & 0x0f000000) >> 24)
171 #define INTEL_CNVX_TOP_PACK_SWAB(t, s) __swab16(((__u16)(((t) << 4) | (s))))
176 INTEL_FIRMWARE_LOADED
,
177 INTEL_FIRMWARE_FAILED
,
179 INTEL_BROKEN_INITIAL_NCMD
,
180 INTEL_BROKEN_SHUTDOWN_LED
,
182 INTEL_ROM_LEGACY_NO_WBS_SUPPORT
,
183 INTEL_ACPI_RESET_ACTIVE
,
189 struct btintel_data
{
190 DECLARE_BITMAP(flags
, __INTEL_NUM_FLAGS
);
191 int (*acpi_reset_method
)(struct hci_dev
*hdev
);
194 #define btintel_set_flag(hdev, nr) \
196 struct btintel_data *intel = hci_get_priv((hdev)); \
197 set_bit((nr), intel->flags); \
200 #define btintel_clear_flag(hdev, nr) \
202 struct btintel_data *intel = hci_get_priv((hdev)); \
203 clear_bit((nr), intel->flags); \
206 #define btintel_wake_up_flag(hdev, nr) \
208 struct btintel_data *intel = hci_get_priv((hdev)); \
209 wake_up_bit(intel->flags, (nr)); \
212 #define btintel_get_flag(hdev) \
213 (((struct btintel_data *)hci_get_priv(hdev))->flags)
215 #define btintel_test_flag(hdev, nr) test_bit((nr), btintel_get_flag(hdev))
216 #define btintel_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), btintel_get_flag(hdev))
217 #define btintel_wait_on_flag_timeout(hdev, nr, m, to) \
218 wait_on_bit_timeout(btintel_get_flag(hdev), (nr), m, to)
220 #if IS_ENABLED(CONFIG_BT_INTEL) || IS_ENABLED(CONFIG_BT_INTEL_PCIE)
222 int btintel_check_bdaddr(struct hci_dev
*hdev
);
223 int btintel_enter_mfg(struct hci_dev
*hdev
);
224 int btintel_exit_mfg(struct hci_dev
*hdev
, bool reset
, bool patched
);
225 int btintel_set_bdaddr(struct hci_dev
*hdev
, const bdaddr_t
*bdaddr
);
226 int btintel_set_diag(struct hci_dev
*hdev
, bool enable
);
228 int btintel_version_info(struct hci_dev
*hdev
, struct intel_version
*ver
);
229 int btintel_load_ddc_config(struct hci_dev
*hdev
, const char *ddc_name
);
230 int btintel_set_event_mask_mfg(struct hci_dev
*hdev
, bool debug
);
231 int btintel_read_version(struct hci_dev
*hdev
, struct intel_version
*ver
);
232 struct regmap
*btintel_regmap_init(struct hci_dev
*hdev
, u16 opcode_read
,
234 int btintel_send_intel_reset(struct hci_dev
*hdev
, u32 boot_param
);
235 int btintel_read_boot_params(struct hci_dev
*hdev
,
236 struct intel_boot_params
*params
);
237 int btintel_download_firmware(struct hci_dev
*dev
, struct intel_version
*ver
,
238 const struct firmware
*fw
, u32
*boot_param
);
239 int btintel_configure_setup(struct hci_dev
*hdev
, const char *driver_name
);
240 int btintel_recv_event(struct hci_dev
*hdev
, struct sk_buff
*skb
);
241 void btintel_bootup(struct hci_dev
*hdev
, const void *ptr
, unsigned int len
);
242 void btintel_secure_send_result(struct hci_dev
*hdev
,
243 const void *ptr
, unsigned int len
);
244 int btintel_set_quality_report(struct hci_dev
*hdev
, bool enable
);
245 int btintel_version_info_tlv(struct hci_dev
*hdev
,
246 struct intel_version_tlv
*version
);
247 int btintel_parse_version_tlv(struct hci_dev
*hdev
,
248 struct intel_version_tlv
*version
,
249 struct sk_buff
*skb
);
250 void btintel_set_msft_opcode(struct hci_dev
*hdev
, u8 hw_variant
);
251 int btintel_bootloader_setup_tlv(struct hci_dev
*hdev
,
252 struct intel_version_tlv
*ver
);
253 int btintel_shutdown_combined(struct hci_dev
*hdev
);
254 void btintel_hw_error(struct hci_dev
*hdev
, u8 code
);
255 void btintel_print_fseq_info(struct hci_dev
*hdev
);
256 int btintel_diagnostics(struct hci_dev
*hdev
, struct sk_buff
*skb
);
259 static inline int btintel_check_bdaddr(struct hci_dev
*hdev
)
264 static inline int btintel_enter_mfg(struct hci_dev
*hdev
)
269 static inline int btintel_exit_mfg(struct hci_dev
*hdev
, bool reset
, bool patched
)
274 static inline int btintel_set_bdaddr(struct hci_dev
*hdev
, const bdaddr_t
*bdaddr
)
279 static inline int btintel_set_diag(struct hci_dev
*hdev
, bool enable
)
284 static inline int btintel_version_info(struct hci_dev
*hdev
,
285 struct intel_version
*ver
)
290 static inline int btintel_load_ddc_config(struct hci_dev
*hdev
,
291 const char *ddc_name
)
296 static inline int btintel_set_event_mask_mfg(struct hci_dev
*hdev
, bool debug
)
301 static inline int btintel_read_version(struct hci_dev
*hdev
,
302 struct intel_version
*ver
)
307 static inline struct regmap
*btintel_regmap_init(struct hci_dev
*hdev
,
311 return ERR_PTR(-EINVAL
);
314 static inline int btintel_send_intel_reset(struct hci_dev
*hdev
,
320 static inline int btintel_read_boot_params(struct hci_dev
*hdev
,
321 struct intel_boot_params
*params
)
326 static inline int btintel_download_firmware(struct hci_dev
*dev
,
327 const struct firmware
*fw
,
333 static inline int btintel_configure_setup(struct hci_dev
*hdev
,
334 const char *driver_name
)
339 static inline void btintel_bootup(struct hci_dev
*hdev
,
340 const void *ptr
, unsigned int len
)
344 static inline void btintel_secure_send_result(struct hci_dev
*hdev
,
345 const void *ptr
, unsigned int len
)
349 static inline int btintel_set_quality_report(struct hci_dev
*hdev
, bool enable
)
354 static inline int btintel_version_info_tlv(struct hci_dev
*hdev
,
355 struct intel_version_tlv
*version
)
360 static inline int btintel_parse_version_tlv(struct hci_dev
*hdev
,
361 struct intel_version_tlv
*version
,
367 static inline void btintel_set_msft_opcode(struct hci_dev
*hdev
, u8 hw_variant
)
372 static inline int btintel_bootloader_setup_tlv(struct hci_dev
*hdev
,
373 struct intel_version_tlv
*ver
)
378 static inline int btintel_shutdown_combined(struct hci_dev
*hdev
)
383 static inline void btintel_hw_error(struct hci_dev
*hdev
, u8 code
)
387 static inline void btintel_print_fseq_info(struct hci_dev
*hdev
)
391 static inline int btintel_diagnostics(struct hci_dev
*hdev
, struct sk_buff
*skb
)