From: Sathish Narasimman <nsathish41@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com,
kiran.k@intel.com,
Sathish Narasimman <sathish.narasimman@intel.com>
Subject: [PATCH 3/3] Bluetooth: btusb: Use the new btintel read version
Date: Thu, 22 Oct 2020 13:54:35 +0530 [thread overview]
Message-ID: <20201022082435.31831-4-sathish.narasimman@intel.com> (raw)
In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com>
Replace the legacy btintel_read_version to btintel_read_verison_new.
The new intel firmware has the support to parse TLV structure during
operational mode. The patch takes care of both legacy and tlv structure.
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
---
drivers/bluetooth/btintel.h | 1 +
drivers/bluetooth/btusb.c | 41 +++++++++++++++++++++++++++++--------
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index 08406ef935a3..e3025b90eda5 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -140,6 +140,7 @@ struct btintel_version {
};
};
+#define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16))
#if IS_ENABLED(CONFIG_BT_INTEL)
int btintel_check_bdaddr(struct hci_dev *hdev);
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 1005b6e8ff74..c63bc8a0c84f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2554,7 +2554,8 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
static int btusb_setup_intel_new(struct hci_dev *hdev)
{
struct btusb_data *data = hci_get_drvdata(hdev);
- struct intel_version ver;
+ struct btintel_version bt_ver;
+ u8 hw_variant;
struct intel_boot_params params;
u32 boot_param;
char ddcname[64];
@@ -2577,19 +2578,33 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
* is in bootloader mode or if it already has operational firmware
* loaded.
*/
- err = btintel_read_version(hdev, &ver);
+ err = btintel_read_version_new(hdev, &bt_ver);
if (err) {
bt_dev_err(hdev, "Intel Read version failed (%d)", err);
btintel_reset_to_bootloader(hdev);
return err;
}
- err = btusb_intel_download_firmware(hdev, &ver, ¶ms, &boot_param);
+ /* If TLV format is supported then it is in Operational Firmware. TLV
+ * structure is supported only in operational mode in latest Firmware.
+ */
+ if (bt_ver.tlv_format && bt_ver.ver_tlv.img_type == 0x03) {
+ btintel_version_info_tlv(hdev, &bt_ver.ver_tlv);
+ clear_bit(BTUSB_BOOTLOADER, &data->flags);
+ goto finish;
+ }
+
+ err = btusb_intel_download_firmware(hdev, &bt_ver.ver, ¶ms,
+ &boot_param);
if (err)
return err;
- /* controller is already having an operational firmware */
- if (ver.fw_variant == 0x23)
+ /* In case if old firmware is used, it should be backward compatible
+ * to check for operational firmware. only on latest firmware the
+ * support for TLV structure is added. so check for tlv is not
+ * required here.
+ */
+ if (bt_ver.ver.fw_variant == 0x23)
goto finish;
rettime = ktime_get();
@@ -2641,7 +2656,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
clear_bit(BTUSB_BOOTLOADER, &data->flags);
- err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, ddcname,
+ err = btusb_setup_intel_new_get_fw_name(&bt_ver.ver, ¶ms, ddcname,
sizeof(ddcname), "ddc");
if (!err) {
@@ -2665,17 +2680,25 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
btintel_set_debug_features(hdev, &features);
/* Read the Intel version information after loading the FW */
- err = btintel_read_version(hdev, &ver);
+ err = btintel_read_version_new(hdev, &bt_ver);
if (err)
return err;
- btintel_version_info(hdev, &ver);
+ if (bt_ver.tlv_format)
+ btintel_version_info_tlv(hdev, &bt_ver.ver_tlv);
+ else
+ btintel_version_info(hdev, &bt_ver.ver);
finish:
/* All Intel controllers that support the Microsoft vendor
* extension are using 0xFC1E for VsMsftOpCode.
*/
- switch (ver.hw_variant) {
+ if (!bt_ver.tlv_format)
+ hw_variant = bt_ver.ver.hw_variant;
+ else
+ hw_variant = INTEL_HW_VARIANT(bt_ver.ver_tlv.cnvi_bt);
+
+ switch (hw_variant) {
case 0x12: /* ThP */
hci_set_msft_opcode(hdev, 0xFC1E);
break;
--
2.17.1
next prev parent reply other threads:[~2020-10-22 8:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 8:24 [PATCH 0/3] Bluetooth:btintel parse TLV structure Sathish Narasimman
2020-10-22 8:24 ` [PATCH 1/3] Bluetooth: btintel: seperated TLV parsing as new function Sathish Narasimman
2020-10-22 8:24 ` [PATCH 2/3] Bluetooth: btintel: Introducing new btintel read version Sathish Narasimman
2020-10-29 5:28 ` Tedd Ho-Jeong An
2020-10-29 6:07 ` Narasimman, Sathish
2020-10-22 8:24 ` Sathish Narasimman [this message]
2020-10-28 5:26 ` [PATCH 0/3] Bluetooth:btintel parse TLV structure Sathish Narasimman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201022082435.31831-4-sathish.narasimman@intel.com \
--to=nsathish41@gmail.com \
--cc=chethan.tumkur.narayan@intel.com \
--cc=kiran.k@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=ravishankar.srivatsa@intel.com \
--cc=sathish.narasimman@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox