File Index
Files and directories
Sign in
FILE

btintel.h

File preview with syntax highlighting.

linux-6.19.14/drivers/bluetooth/btintel.h OBJECTIVE-C
  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
  9/* List of tlv type */
 10enum {
 11	INTEL_TLV_CNVI_TOP = 0x10,
 12	INTEL_TLV_CNVR_TOP,
 13	INTEL_TLV_CNVI_BT,
 14	INTEL_TLV_CNVR_BT,
 15	INTEL_TLV_CNVI_OTP,
 16	INTEL_TLV_CNVR_OTP,
 17	INTEL_TLV_DEV_REV_ID,
 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,
 23	INTEL_TLV_IMAGE_TYPE,
 24	INTEL_TLV_TIME_STAMP,
 25	INTEL_TLV_BUILD_TYPE,
 26	INTEL_TLV_BUILD_NUM,
 27	INTEL_TLV_FW_BUILD_PRODUCT,
 28	INTEL_TLV_FW_BUILD_HW,
 29	INTEL_TLV_FW_STEP,
 30	INTEL_TLV_BT_SPEC,
 31	INTEL_TLV_MFG_NAME,
 32	INTEL_TLV_HCI_REV,
 33	INTEL_TLV_LMP_SUBVER,
 34	INTEL_TLV_OTP_PATCH_VER,
 35	INTEL_TLV_SECURE_BOOT,
 36	INTEL_TLV_KEY_FROM_HDR,
 37	INTEL_TLV_OTP_LOCK,
 38	INTEL_TLV_API_LOCK,
 39	INTEL_TLV_DEBUG_LOCK,
 40	INTEL_TLV_MIN_FW,
 41	INTEL_TLV_LIMITED_CCE,
 42	INTEL_TLV_SBE_TYPE,
 43	INTEL_TLV_OTP_BDADDR,
 44	INTEL_TLV_UNLOCKED_STATE,
 45	INTEL_TLV_GIT_SHA1,
 46	INTEL_TLV_FW_ID = 0x50
 47};
 48
 49struct intel_tlv {
 50	u8 type;
 51	u8 len;
 52	u8 val[];
 53} __packed;
 54
 55#define BTINTEL_HCI_OP_RESET	0xfc01
 56
 57#define BTINTEL_CNVI_BLAZARI		0x900
 58#define BTINTEL_CNVI_BLAZARIW		0x901
 59#define BTINTEL_CNVI_GAP		0x910
 60#define BTINTEL_CNVI_BLAZARU		0x930
 61#define BTINTEL_CNVI_SCP		0xA00
 62
 63/* CNVR */
 64#define BTINTEL_CNVR_FMP2		0x910
 65
 66#define BTINTEL_IMG_BOOTLOADER		0x01	/* Bootloader image */
 67#define BTINTEL_IMG_IML			0x02	/* Intermediate image */
 68#define BTINTEL_IMG_OP			0x03	/* Operational image */
 69
 70#define BTINTEL_FWID_MAXLEN 64
 71
 72struct intel_version_tlv {
 73	u32	cnvi_top;
 74	u32	cnvr_top;
 75	u32	cnvi_bt;
 76	u32	cnvr_bt;
 77	u16	dev_rev_id;
 78	u8	img_type;
 79	u16	timestamp;
 80	u8	build_type;
 81	u32	build_num;
 82	u8	secure_boot;
 83	u8	otp_lock;
 84	u8	api_lock;
 85	u8	debug_lock;
 86	u8	min_fw_build_nn;
 87	u8	min_fw_build_cw;
 88	u8	min_fw_build_yy;
 89	u8	limited_cce;
 90	u8	sbe_type;
 91	u32	git_sha1;
 92	u8	fw_id[BTINTEL_FWID_MAXLEN];
 93	bdaddr_t otp_bd_addr;
 94};
 95
 96struct intel_version {
 97	u8 status;
 98	u8 hw_platform;
 99	u8 hw_variant;
100	u8 hw_revision;
101	u8 fw_variant;
102	u8 fw_revision;
103	u8 fw_build_num;
104	u8 fw_build_ww;
105	u8 fw_build_yy;
106	u8 fw_patch_num;
107} __packed;
108
109struct intel_boot_params {
110	__u8     status;
111	__u8     otp_format;
112	__u8     otp_content;
113	__u8     otp_patch;
114	__le16   dev_revid;
115	__u8     secure_boot;
116	__u8     key_from_hdr;
117	__u8     key_type;
118	__u8     otp_lock;
119	__u8     api_lock;
120	__u8     debug_lock;
121	bdaddr_t otp_bdaddr;
122	__u8     min_fw_build_nn;
123	__u8     min_fw_build_cw;
124	__u8     min_fw_build_yy;
125	__u8     limited_cce;
126	__u8     unlocked_state;
127} __packed;
128
129struct intel_bootup {
130	__u8     zero;
131	__u8     num_cmds;
132	__u8     source;
133	__u8     reset_type;
134	__u8     reset_reason;
135	__u8     ddc_status;
136} __packed;
137
138struct intel_secure_send_result {
139	__u8     result;
140	__le16   opcode;
141	__u8     status;
142} __packed;
143
144struct intel_reset {
145	__u8     reset_type;
146	__u8     patch_enable;
147	__u8     ddc_reload;
148	__u8     boot_option;
149	__le32   boot_param;
150} __packed;
151
152struct intel_debug_features {
153	__u8    page1[16];
154} __packed;
155
156struct intel_offload_use_cases {
157	__u8	status;
158	__u8	preset[8];
159} __packed;
160
161#define INTEL_OP_PPAG_CMD		0xFE0B
162struct hci_ppag_enable_cmd {
163	__le32	ppag_enable_flags;
164} __packed;
165
166#define INTEL_TLV_TYPE_ID		0x01
167
168#define INTEL_TLV_SYSTEM_EXCEPTION	0x00
169#define INTEL_TLV_FATAL_EXCEPTION	0x01
170#define INTEL_TLV_DEBUG_EXCEPTION	0x02
171#define INTEL_TLV_TEST_EXCEPTION	0xDE
172
173struct btintel_cp_ddc_write {
174	u8	len;
175	__le16	id;
176	u8	data[];
177} __packed;
178
179/* Bluetooth SAR feature (BRDS), Revision 1 */
180struct btintel_sar_inc_pwr {
181	u8	revision;
182	u32	bt_sar_bios; /* Mode of SAR control to be used, 1:enabled in bios */
183	u32	inc_power_mode;  /* Increased power mode */
184	u8	sar_2400_chain_a; /* Sar power restriction LB */
185	u8	br;
186	u8	edr2;
187	u8	edr3;
188	u8	le;
189	u8	le_2mhz;
190	u8	le_lr;
191};
192
193#define INTEL_HW_PLATFORM(cnvx_bt)	((u8)(((cnvx_bt) & 0x0000ff00) >> 8))
194#define INTEL_HW_VARIANT(cnvx_bt)	((u8)(((cnvx_bt) & 0x003f0000) >> 16))
195#define INTEL_CNVX_TOP_TYPE(cnvx_top)	((cnvx_top) & 0x00000fff)
196#define INTEL_CNVX_TOP_STEP(cnvx_top)	(((cnvx_top) & 0x0f000000) >> 24)
197#define INTEL_CNVX_TOP_PACK_SWAB(t, s)	__swab16(((__u16)(((t) << 4) | (s))))
198
199enum {
200	INTEL_BOOTLOADER,
201	INTEL_DOWNLOADING,
202	INTEL_FIRMWARE_LOADED,
203	INTEL_FIRMWARE_FAILED,
204	INTEL_BOOTING,
205	INTEL_BROKEN_INITIAL_NCMD,
206	INTEL_BROKEN_SHUTDOWN_LED,
207	INTEL_ROM_LEGACY,
208	INTEL_ROM_LEGACY_NO_WBS_SUPPORT,
209	INTEL_ACPI_RESET_ACTIVE,
210	INTEL_WAIT_FOR_D0,
211
212	__INTEL_NUM_FLAGS,
213};
214
215struct btintel_data {
216	DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS);
217	int (*acpi_reset_method)(struct hci_dev *hdev);
218};
219
220#define btintel_set_flag(hdev, nr)					\
221	do {								\
222		struct btintel_data *intel = hci_get_priv((hdev));	\
223		set_bit((nr), intel->flags);				\
224	} while (0)
225
226#define btintel_clear_flag(hdev, nr)					\
227	do {								\
228		struct btintel_data *intel = hci_get_priv((hdev));	\
229		clear_bit((nr), intel->flags);				\
230	} while (0)
231
232#define btintel_wake_up_flag(hdev, nr)					\
233	do {								\
234		struct btintel_data *intel = hci_get_priv((hdev));	\
235		wake_up_bit(intel->flags, (nr));			\
236	} while (0)
237
238#define btintel_get_flag(hdev)						\
239	(((struct btintel_data *)hci_get_priv(hdev))->flags)
240
241#define btintel_test_flag(hdev, nr)	test_bit((nr), btintel_get_flag(hdev))
242#define btintel_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), btintel_get_flag(hdev))
243#define btintel_wait_on_flag_timeout(hdev, nr, m, to)			\
244		wait_on_bit_timeout(btintel_get_flag(hdev), (nr), m, to)
245
246#if IS_ENABLED(CONFIG_BT_INTEL) || IS_ENABLED(CONFIG_BT_INTEL_PCIE)
247
248int btintel_check_bdaddr(struct hci_dev *hdev);
249int btintel_enter_mfg(struct hci_dev *hdev);
250int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched);
251int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
252int btintel_set_diag(struct hci_dev *hdev, bool enable);
253
254int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
255int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
256int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
257int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
258struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
259				   u16 opcode_write);
260int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
261int btintel_read_boot_params(struct hci_dev *hdev,
262			     struct intel_boot_params *params);
263int btintel_download_firmware(struct hci_dev *dev, struct intel_version *ver,
264			      const struct firmware *fw, u32 *boot_param);
265int btintel_configure_setup(struct hci_dev *hdev, const char *driver_name);
266int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb);
267void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len);
268void btintel_secure_send_result(struct hci_dev *hdev,
269				const void *ptr, unsigned int len);
270int btintel_set_quality_report(struct hci_dev *hdev, bool enable);
271int btintel_version_info_tlv(struct hci_dev *hdev,
272			     struct intel_version_tlv *version);
273int btintel_parse_version_tlv(struct hci_dev *hdev,
274			      struct intel_version_tlv *version,
275			      struct sk_buff *skb);
276void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant);
277int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
278				 struct intel_version_tlv *ver);
279int btintel_shutdown_combined(struct hci_dev *hdev);
280void btintel_hw_error(struct hci_dev *hdev, u8 code);
281void btintel_print_fseq_info(struct hci_dev *hdev);
282#else
283
284static inline int btintel_check_bdaddr(struct hci_dev *hdev)
285{
286	return -EOPNOTSUPP;
287}
288
289static inline int btintel_enter_mfg(struct hci_dev *hdev)
290{
291	return -EOPNOTSUPP;
292}
293
294static inline int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
295{
296	return -EOPNOTSUPP;
297}
298
299static inline int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
300{
301	return -EOPNOTSUPP;
302}
303
304static inline int btintel_set_diag(struct hci_dev *hdev, bool enable)
305{
306	return -EOPNOTSUPP;
307}
308
309static inline int btintel_version_info(struct hci_dev *hdev,
310				       struct intel_version *ver)
311{
312	return -EOPNOTSUPP;
313}
314
315static inline int btintel_load_ddc_config(struct hci_dev *hdev,
316					  const char *ddc_name)
317{
318	return -EOPNOTSUPP;
319}
320
321static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
322{
323	return -EOPNOTSUPP;
324}
325
326static inline int btintel_read_version(struct hci_dev *hdev,
327				       struct intel_version *ver)
328{
329	return -EOPNOTSUPP;
330}
331
332static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
333						 u16 opcode_read,
334						 u16 opcode_write)
335{
336	return ERR_PTR(-EINVAL);
337}
338
339static inline int btintel_send_intel_reset(struct hci_dev *hdev,
340					   u32 reset_param)
341{
342	return -EOPNOTSUPP;
343}
344
345static inline int btintel_read_boot_params(struct hci_dev *hdev,
346					   struct intel_boot_params *params)
347{
348	return -EOPNOTSUPP;
349}
350
351static inline int btintel_download_firmware(struct hci_dev *dev,
352					    const struct firmware *fw,
353					    u32 *boot_param)
354{
355	return -EOPNOTSUPP;
356}
357
358static inline int btintel_configure_setup(struct hci_dev *hdev,
359					  const char *driver_name)
360{
361	return -ENODEV;
362}
363
364static inline void btintel_bootup(struct hci_dev *hdev,
365				  const void *ptr, unsigned int len)
366{
367}
368
369static inline void btintel_secure_send_result(struct hci_dev *hdev,
370				const void *ptr, unsigned int len)
371{
372}
373
374static inline int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
375{
376	return -ENODEV;
377}
378
379static inline int btintel_version_info_tlv(struct hci_dev *hdev,
380					   struct intel_version_tlv *version)
381{
382	return -EOPNOTSUPP;
383}
384
385static inline int btintel_parse_version_tlv(struct hci_dev *hdev,
386					    struct intel_version_tlv *version,
387					    struct sk_buff *skb)
388{
389	return -EOPNOTSUPP;
390}
391
392static inline void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant)
393
394{
395}
396
397static inline int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
398					       struct intel_version_tlv *ver)
399{
400	return -ENODEV;
401}
402
403static inline int btintel_shutdown_combined(struct hci_dev *hdev)
404{
405	return -ENODEV;
406}
407
408static inline void btintel_hw_error(struct hci_dev *hdev, u8 code)
409{
410}
411
412static inline void btintel_print_fseq_info(struct hci_dev *hdev)
413{
414}
415#endif
~/ Read-only file preview.