2019-05-27 14:55:05 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-04-06 15:52:11 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Bluetooth support for Intel devices
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
2020-09-14 21:25:05 +08:00
|
|
|
/* List of tlv type */
|
|
|
|
enum {
|
|
|
|
INTEL_TLV_CNVI_TOP = 0x10,
|
|
|
|
INTEL_TLV_CNVR_TOP,
|
|
|
|
INTEL_TLV_CNVI_BT,
|
|
|
|
INTEL_TLV_CNVR_BT,
|
|
|
|
INTEL_TLV_CNVI_OTP,
|
|
|
|
INTEL_TLV_CNVR_OTP,
|
|
|
|
INTEL_TLV_DEV_REV_ID,
|
|
|
|
INTEL_TLV_USB_VENDOR_ID,
|
|
|
|
INTEL_TLV_USB_PRODUCT_ID,
|
|
|
|
INTEL_TLV_PCIE_VENDOR_ID,
|
|
|
|
INTEL_TLV_PCIE_DEVICE_ID,
|
|
|
|
INTEL_TLV_PCIE_SUBSYSTEM_ID,
|
|
|
|
INTEL_TLV_IMAGE_TYPE,
|
|
|
|
INTEL_TLV_TIME_STAMP,
|
|
|
|
INTEL_TLV_BUILD_TYPE,
|
|
|
|
INTEL_TLV_BUILD_NUM,
|
|
|
|
INTEL_TLV_FW_BUILD_PRODUCT,
|
|
|
|
INTEL_TLV_FW_BUILD_HW,
|
|
|
|
INTEL_TLV_FW_STEP,
|
|
|
|
INTEL_TLV_BT_SPEC,
|
|
|
|
INTEL_TLV_MFG_NAME,
|
|
|
|
INTEL_TLV_HCI_REV,
|
|
|
|
INTEL_TLV_LMP_SUBVER,
|
|
|
|
INTEL_TLV_OTP_PATCH_VER,
|
|
|
|
INTEL_TLV_SECURE_BOOT,
|
|
|
|
INTEL_TLV_KEY_FROM_HDR,
|
|
|
|
INTEL_TLV_OTP_LOCK,
|
|
|
|
INTEL_TLV_API_LOCK,
|
|
|
|
INTEL_TLV_DEBUG_LOCK,
|
|
|
|
INTEL_TLV_MIN_FW,
|
|
|
|
INTEL_TLV_LIMITED_CCE,
|
|
|
|
INTEL_TLV_SBE_TYPE,
|
|
|
|
INTEL_TLV_OTP_BDADDR,
|
|
|
|
INTEL_TLV_UNLOCKED_STATE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct intel_tlv {
|
|
|
|
u8 type;
|
|
|
|
u8 len;
|
2020-10-27 13:54:08 +08:00
|
|
|
u8 val[];
|
2020-09-14 21:25:05 +08:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct intel_version_tlv {
|
|
|
|
u32 cnvi_top;
|
|
|
|
u32 cnvr_top;
|
|
|
|
u32 cnvi_bt;
|
|
|
|
u32 cnvr_bt;
|
|
|
|
u16 dev_rev_id;
|
|
|
|
u8 img_type;
|
|
|
|
u16 timestamp;
|
|
|
|
u8 build_type;
|
|
|
|
u32 build_num;
|
|
|
|
u8 secure_boot;
|
|
|
|
u8 otp_lock;
|
|
|
|
u8 api_lock;
|
|
|
|
u8 debug_lock;
|
|
|
|
u8 min_fw_build_nn;
|
|
|
|
u8 min_fw_build_cw;
|
|
|
|
u8 min_fw_build_yy;
|
|
|
|
u8 limited_cce;
|
|
|
|
u8 sbe_type;
|
|
|
|
bdaddr_t otp_bd_addr;
|
|
|
|
};
|
|
|
|
|
2015-04-06 15:52:13 +08:00
|
|
|
struct intel_version {
|
|
|
|
u8 status;
|
|
|
|
u8 hw_platform;
|
|
|
|
u8 hw_variant;
|
|
|
|
u8 hw_revision;
|
|
|
|
u8 fw_variant;
|
|
|
|
u8 fw_revision;
|
|
|
|
u8 fw_build_num;
|
|
|
|
u8 fw_build_ww;
|
|
|
|
u8 fw_build_yy;
|
|
|
|
u8 fw_patch_num;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct intel_boot_params {
|
|
|
|
__u8 status;
|
|
|
|
__u8 otp_format;
|
|
|
|
__u8 otp_content;
|
|
|
|
__u8 otp_patch;
|
|
|
|
__le16 dev_revid;
|
|
|
|
__u8 secure_boot;
|
|
|
|
__u8 key_from_hdr;
|
|
|
|
__u8 key_type;
|
|
|
|
__u8 otp_lock;
|
|
|
|
__u8 api_lock;
|
|
|
|
__u8 debug_lock;
|
|
|
|
bdaddr_t otp_bdaddr;
|
|
|
|
__u8 min_fw_build_nn;
|
|
|
|
__u8 min_fw_build_cw;
|
|
|
|
__u8 min_fw_build_yy;
|
|
|
|
__u8 limited_cce;
|
|
|
|
__u8 unlocked_state;
|
|
|
|
} __packed;
|
|
|
|
|
2015-04-09 15:35:19 +08:00
|
|
|
struct intel_bootup {
|
|
|
|
__u8 zero;
|
|
|
|
__u8 num_cmds;
|
|
|
|
__u8 source;
|
|
|
|
__u8 reset_type;
|
|
|
|
__u8 reset_reason;
|
|
|
|
__u8 ddc_status;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct intel_secure_send_result {
|
|
|
|
__u8 result;
|
|
|
|
__le16 opcode;
|
|
|
|
__u8 status;
|
|
|
|
} __packed;
|
|
|
|
|
2018-01-25 01:19:18 +08:00
|
|
|
struct intel_reset {
|
|
|
|
__u8 reset_type;
|
|
|
|
__u8 patch_enable;
|
|
|
|
__u8 ddc_reload;
|
|
|
|
__u8 boot_option;
|
|
|
|
__le32 boot_param;
|
|
|
|
} __packed;
|
|
|
|
|
2020-06-08 20:27:46 +08:00
|
|
|
struct intel_debug_features {
|
|
|
|
__u8 page1[16];
|
|
|
|
} __packed;
|
|
|
|
|
2021-09-07 18:12:39 +08:00
|
|
|
struct intel_offload_use_cases {
|
|
|
|
__u8 status;
|
|
|
|
__u8 preset[8];
|
|
|
|
} __packed;
|
|
|
|
|
2020-11-19 19:39:41 +08:00
|
|
|
#define INTEL_HW_PLATFORM(cnvx_bt) ((u8)(((cnvx_bt) & 0x0000ff00) >> 8))
|
|
|
|
#define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16))
|
|
|
|
#define INTEL_CNVX_TOP_TYPE(cnvx_top) ((cnvx_top) & 0x00000fff)
|
|
|
|
#define INTEL_CNVX_TOP_STEP(cnvx_top) (((cnvx_top) & 0x0f000000) >> 24)
|
|
|
|
#define INTEL_CNVX_TOP_PACK_SWAB(t, s) __swab16(((__u16)(((t) << 4) | (s))))
|
|
|
|
|
2021-08-05 08:32:11 +08:00
|
|
|
enum {
|
|
|
|
INTEL_BOOTLOADER,
|
|
|
|
INTEL_DOWNLOADING,
|
|
|
|
INTEL_FIRMWARE_LOADED,
|
|
|
|
INTEL_FIRMWARE_FAILED,
|
|
|
|
INTEL_BOOTING,
|
2021-08-05 08:32:12 +08:00
|
|
|
INTEL_BROKEN_INITIAL_NCMD,
|
2022-01-07 08:34:54 +08:00
|
|
|
INTEL_BROKEN_SHUTDOWN_LED,
|
2021-08-05 08:32:14 +08:00
|
|
|
INTEL_ROM_LEGACY,
|
2022-01-21 03:44:18 +08:00
|
|
|
INTEL_ROM_LEGACY_NO_WBS_SUPPORT,
|
2021-08-05 08:32:11 +08:00
|
|
|
|
|
|
|
__INTEL_NUM_FLAGS,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btintel_data {
|
|
|
|
DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define btintel_set_flag(hdev, nr) \
|
|
|
|
do { \
|
|
|
|
struct btintel_data *intel = hci_get_priv((hdev)); \
|
|
|
|
set_bit((nr), intel->flags); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define btintel_clear_flag(hdev, nr) \
|
|
|
|
do { \
|
|
|
|
struct btintel_data *intel = hci_get_priv((hdev)); \
|
|
|
|
clear_bit((nr), intel->flags); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define btintel_wake_up_flag(hdev, nr) \
|
|
|
|
do { \
|
|
|
|
struct btintel_data *intel = hci_get_priv((hdev)); \
|
|
|
|
wake_up_bit(intel->flags, (nr)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define btintel_get_flag(hdev) \
|
|
|
|
(((struct btintel_data *)hci_get_priv(hdev))->flags)
|
|
|
|
|
|
|
|
#define btintel_test_flag(hdev, nr) test_bit((nr), btintel_get_flag(hdev))
|
|
|
|
#define btintel_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), btintel_get_flag(hdev))
|
|
|
|
#define btintel_wait_on_flag_timeout(hdev, nr, m, to) \
|
|
|
|
wait_on_bit_timeout(btintel_get_flag(hdev), (nr), m, to)
|
|
|
|
|
2015-04-06 15:52:11 +08:00
|
|
|
#if IS_ENABLED(CONFIG_BT_INTEL)
|
|
|
|
|
|
|
|
int btintel_check_bdaddr(struct hci_dev *hdev);
|
2015-12-03 23:10:22 +08:00
|
|
|
int btintel_enter_mfg(struct hci_dev *hdev);
|
|
|
|
int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched);
|
2015-04-06 15:52:11 +08:00
|
|
|
int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
|
2015-10-09 20:42:08 +08:00
|
|
|
int btintel_set_diag(struct hci_dev *hdev, bool enable);
|
2015-04-06 15:52:11 +08:00
|
|
|
|
2021-03-24 02:58:59 +08:00
|
|
|
int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver);
|
2015-09-04 23:54:34 +08:00
|
|
|
int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name);
|
2015-10-21 08:45:19 +08:00
|
|
|
int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug);
|
2015-12-06 23:18:34 +08:00
|
|
|
int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
|
2015-10-02 00:16:21 +08:00
|
|
|
struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
|
|
|
|
u16 opcode_write);
|
2018-01-25 01:19:18 +08:00
|
|
|
int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
|
2018-01-25 01:19:20 +08:00
|
|
|
int btintel_read_boot_params(struct hci_dev *hdev,
|
|
|
|
struct intel_boot_params *params);
|
2021-03-24 02:58:56 +08:00
|
|
|
int btintel_download_firmware(struct hci_dev *dev, struct intel_version *ver,
|
|
|
|
const struct firmware *fw, u32 *boot_param);
|
2021-08-05 08:32:09 +08:00
|
|
|
int btintel_configure_setup(struct hci_dev *hdev);
|
2021-08-05 08:32:15 +08:00
|
|
|
void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len);
|
|
|
|
void btintel_secure_send_result(struct hci_dev *hdev,
|
|
|
|
const void *ptr, unsigned int len);
|
2021-08-15 20:17:17 +08:00
|
|
|
int btintel_set_quality_report(struct hci_dev *hdev, bool enable);
|
2015-04-06 15:52:11 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
static inline int btintel_check_bdaddr(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-12-03 23:10:22 +08:00
|
|
|
static inline int btintel_enter_mfg(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-04-06 15:52:11 +08:00
|
|
|
static inline int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-10-09 20:42:08 +08:00
|
|
|
static inline int btintel_set_diag(struct hci_dev *hdev, bool enable)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2021-03-24 02:58:59 +08:00
|
|
|
static inline int btintel_version_info(struct hci_dev *hdev,
|
|
|
|
struct intel_version *ver)
|
2015-07-05 21:02:07 +08:00
|
|
|
{
|
2021-03-24 02:58:59 +08:00
|
|
|
return -EOPNOTSUPP;
|
2015-07-05 21:02:07 +08:00
|
|
|
}
|
|
|
|
|
2015-09-04 23:54:34 +08:00
|
|
|
static inline int btintel_load_ddc_config(struct hci_dev *hdev,
|
|
|
|
const char *ddc_name)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-10-21 08:45:19 +08:00
|
|
|
static inline int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-12-06 23:18:34 +08:00
|
|
|
static inline int btintel_read_version(struct hci_dev *hdev,
|
|
|
|
struct intel_version *ver)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-10-02 00:16:21 +08:00
|
|
|
static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
|
|
|
|
u16 opcode_read,
|
|
|
|
u16 opcode_write)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
2018-01-25 01:19:18 +08:00
|
|
|
|
|
|
|
static inline int btintel_send_intel_reset(struct hci_dev *hdev,
|
|
|
|
u32 reset_param)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2018-01-25 01:19:20 +08:00
|
|
|
|
|
|
|
static inline int btintel_read_boot_params(struct hci_dev *hdev,
|
|
|
|
struct intel_boot_params *params)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2018-01-25 01:19:21 +08:00
|
|
|
|
|
|
|
static inline int btintel_download_firmware(struct hci_dev *dev,
|
|
|
|
const struct firmware *fw,
|
|
|
|
u32 *boot_param)
|
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2019-10-17 16:22:29 +08:00
|
|
|
|
2021-08-05 08:32:09 +08:00
|
|
|
static inline int btintel_configure_setup(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2021-08-05 08:32:15 +08:00
|
|
|
static inline void btintel_bootup(struct hci_dev *hdev,
|
|
|
|
const void *ptr, unsigned int len)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void btintel_secure_send_result(struct hci_dev *hdev,
|
|
|
|
const void *ptr, unsigned int len)
|
|
|
|
{
|
|
|
|
}
|
2021-08-15 20:17:17 +08:00
|
|
|
|
|
|
|
static inline int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2015-04-06 15:52:11 +08:00
|
|
|
#endif
|