Skip to contentSkip to conversation

Bluetooth: btqca: Add support to read FW build version for WCN3991 BTSoC

PATCH Superseded Venkata Lakshmi Narayana Gubba 4 participants 5 messages Nov 18, 2020 – Nov 24, 2020

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Bluetooth: btqca: Add support to read FW build version for WCN3991 BTSoC

Add support to read FW build version for WCN3991 BTSoC

---
 drivers/bluetooth/btqca.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btqca.h |  3 +++
 2 files changed, 60 insertions(+)
drivers/bluetooth/btqca.c +57 -0
index ce9dcff..dfd7ff7 100644
@@ -101,6 +101,56 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
 }
 EXPORT_SYMBOL_GPL(qca_read_soc_version);
 
+static int qca_read_fw_build_info(struct hci_dev *hdev)
+{
+	struct sk_buff *skb;
+	struct edl_event_hdr *edl;
+	char cmd;
+	int err = 0;
+	char build_label[QCA_FW_BUILD_VER_LEN];
+	int build_lbl_len;
+
+	bt_dev_dbg(hdev, "QCA read fw build info");
+
+	cmd = EDL_GET_BUILD_INFO_CMD;
+	skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
+				&cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		err = PTR_ERR(skb);
+		bt_dev_err(hdev, "Reading QCA fw build info failed (%d)",
+			   err);
+		return err;
+	}
+
+	edl = (struct edl_event_hdr *)(skb->data);
+	if (!edl) {
+		bt_dev_err(hdev, "QCA read fw build info with no header");
+		err = -EILSEQ;
+		goto out;
+	}
+
+	if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
+	    edl->rtype != EDL_GET_BUILD_INFO_CMD) {
+		bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
+			   edl->rtype);
+		err = -EIO;
+		goto out;
+	}
+
+	build_lbl_len = edl->data[0];
+	memcpy(build_label, &edl->data[1], build_lbl_len);
+	*(build_label + build_lbl_len) = '\0';
+
+	bt_dev_info(hdev, "BT SoC FW Build info: %s", build_label);
+
+out:
+	kfree_skb(skb);
+	if (err)
+		bt_dev_err(hdev, "QCA read fw build info failed (%d)", err);
+
+	return err;
+}
+
 static int qca_send_reset(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -520,6 +570,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 		return err;
 	}
 
+	if (soc_type == QCA_WCN3991) {
+		/* get fw build info */
+		err = qca_read_fw_build_info(hdev);
+		if (err < 0)
+			return err;
+	}
+
 	bt_dev_info(hdev, "QCA setup on UART is completed");
 
 	return 0;
drivers/bluetooth/btqca.h +3 -0
index d81b74c..375c7fc 100644
@@ -11,6 +11,7 @@
 #define EDL_PATCH_CMD_LEN		(1)
 #define EDL_PATCH_VER_REQ_CMD		(0x19)
 #define EDL_PATCH_TLV_REQ_CMD		(0x1E)
+#define EDL_GET_BUILD_INFO_CMD		(0x20)
 #define EDL_NVM_ACCESS_SET_REQ_CMD	(0x01)
 #define MAX_SIZE_PER_TLV_SEGMENT	(243)
 #define QCA_PRE_SHUTDOWN_CMD		(0xFC08)
@@ -34,6 +35,8 @@
 #define QCA_HCI_CC_OPCODE		0xFC00
 #define QCA_HCI_CC_SUCCESS		0x00
 
+#define QCA_FW_BUILD_VER_LEN		255
+
 enum qca_baudrate {
 	QCA_BAUDRATE_115200 	= 0,
 	QCA_BAUDRATE_57600,
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw
Quoted 1 line · Venkata Lakshmi Narayana Gubba

Add support to read FW build version for WCN3991 BTSoC

Your commit message doesn't describe why you need/want this? Is it somehow required for BT to come up or is it simply 57 lines of code to print a line of build info in the kernel log?

Note that most people reading the kernel log won't care about what firmware version their BT chip is running, so if it's only for your own debugging purpose I would prefer if you make this available in sysfs or debugfs.

Regards,
Bjorn

Quoted 107 lines
---
 drivers/bluetooth/btqca.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btqca.h |  3 +++
 2 files changed, 60 insertions(+)
drivers/bluetooth/btqca.c +57 -0
index ce9dcff..dfd7ff7 100644
@@ -101,6 +101,56 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
 }
 EXPORT_SYMBOL_GPL(qca_read_soc_version);
 
+static int qca_read_fw_build_info(struct hci_dev *hdev)
+{
+	struct sk_buff *skb;
+	struct edl_event_hdr *edl;
+	char cmd;
+	int err = 0;
+	char build_label[QCA_FW_BUILD_VER_LEN];
+	int build_lbl_len;
+
+	bt_dev_dbg(hdev, "QCA read fw build info");
+
+	cmd = EDL_GET_BUILD_INFO_CMD;
+	skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
+				&cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		err = PTR_ERR(skb);
+		bt_dev_err(hdev, "Reading QCA fw build info failed (%d)",
+			   err);
+		return err;
+	}
+
+	edl = (struct edl_event_hdr *)(skb->data);
+	if (!edl) {
+		bt_dev_err(hdev, "QCA read fw build info with no header");
+		err = -EILSEQ;
+		goto out;
+	}
+
+	if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
+	    edl->rtype != EDL_GET_BUILD_INFO_CMD) {
+		bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
+			   edl->rtype);
+		err = -EIO;
+		goto out;
+	}
+
+	build_lbl_len = edl->data[0];
+	memcpy(build_label, &edl->data[1], build_lbl_len);
+	*(build_label + build_lbl_len) = '\0';
+
+	bt_dev_info(hdev, "BT SoC FW Build info: %s", build_label);
+
+out:
+	kfree_skb(skb);
+	if (err)
+		bt_dev_err(hdev, "QCA read fw build info failed (%d)", err);
+
+	return err;
+}
+
 static int qca_send_reset(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -520,6 +570,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
 		return err;
 	}
 
+	if (soc_type == QCA_WCN3991) {
+		/* get fw build info */
+		err = qca_read_fw_build_info(hdev);
+		if (err < 0)
+			return err;
+	}
+
 	bt_dev_info(hdev, "QCA setup on UART is completed");
 
 	return 0;
drivers/bluetooth/btqca.h +3 -0
index d81b74c..375c7fc 100644
@@ -11,6 +11,7 @@
 #define EDL_PATCH_CMD_LEN		(1)
 #define EDL_PATCH_VER_REQ_CMD		(0x19)
 #define EDL_PATCH_TLV_REQ_CMD		(0x1E)
+#define EDL_GET_BUILD_INFO_CMD		(0x20)
 #define EDL_NVM_ACCESS_SET_REQ_CMD	(0x01)
 #define MAX_SIZE_PER_TLV_SEGMENT	(243)
 #define QCA_PRE_SHUTDOWN_CMD		(0xFC08)
@@ -34,6 +35,8 @@
 #define QCA_HCI_CC_OPCODE		0xFC00
 #define QCA_HCI_CC_SUCCESS		0x00
 
+#define QCA_FW_BUILD_VER_LEN		255
+
 enum qca_baudrate {
 	QCA_BAUDRATE_115200 	= 0,
 	QCA_BAUDRATE_57600,
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

Hi Bjorn,

Quoted 10 lines · Bjorn Andersson
Quoted 1 line · Venkata Lakshmi Narayana Gubba

Add support to read FW build version for WCN3991 BTSoC

Your commit message doesn't describe why you need/want this? Is it somehow required for BT to come up or is it simply 57 lines of code to print a line of build info in the kernel log?

Quoted 8 lines

Note that most people reading the kernel log won't care about what firmware version their BT chip is running, so if it's only for your own debugging purpose I would prefer if you make this available in sysfs or debugfs.

Regards,
Bjorn

[Venkata] :
Yes, this code is to print build info in kernel log for debugging purpose. I will add this in debugfs and will post the updated patch.

Quoted 102 lines
Quoted 102 lines
---
 drivers/bluetooth/btqca.c | 57 
+++++++++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btqca.h |  3 +++
 2 files changed, 60 insertions(+)
drivers/bluetooth/btqca.c +50 -0
index ce9dcff..dfd7ff7 100644
@@ -101,6 +101,56 @@ int qca_read_soc_version(struct hci_dev *hdev, 
 u32 *soc_version,
 }
 EXPORT_SYMBOL_GPL(qca_read_soc_version);
 
+static int qca_read_fw_build_info(struct hci_dev *hdev)
+{
+	struct sk_buff *skb;
+	struct edl_event_hdr *edl;
+	char cmd;
+	int err = 0;
+	char build_label[QCA_FW_BUILD_VER_LEN];
+	int build_lbl_len;
+
+	bt_dev_dbg(hdev, "QCA read fw build info");
+
+	cmd = EDL_GET_BUILD_INFO_CMD;
+	skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, 
 EDL_PATCH_CMD_LEN,
+				&cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		err = PTR_ERR(skb);
+		bt_dev_err(hdev, "Reading QCA fw build info failed (%d)",
+			   err);
+		return err;
+	}
+
+	edl = (struct edl_event_hdr *)(skb->data);
+	if (!edl) {
+		bt_dev_err(hdev, "QCA read fw build info with no header");
+		err = -EILSEQ;
+		goto out;
+	}
+
+	if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
+	    edl->rtype != EDL_GET_BUILD_INFO_CMD) {
+		bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
+			   edl->rtype);
+		err = -EIO;
+		goto out;
+	}
+
+	build_lbl_len = edl->data[0];
+	memcpy(build_label, &edl->data[1], build_lbl_len);
+	*(build_label + build_lbl_len) = '\0';
+
+	bt_dev_info(hdev, "BT SoC FW Build info: %s", build_label);
+
+out:
+	kfree_skb(skb);
+	if (err)
+		bt_dev_err(hdev, "QCA read fw build info failed (%d)", err);
+
+	return err;
+}
+
 static int qca_send_reset(struct hci_dev *hdev)

{

drivers/bluetooth/btqca.c +7 -0
 	struct sk_buff *skb;
@@ -520,6 +570,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t 
 baudrate,
 		return err;
 	}
 
+	if (soc_type == QCA_WCN3991) {
+		/* get fw build info */
+		err = qca_read_fw_build_info(hdev);
+		if (err < 0)
+			return err;
+	}
+
 	bt_dev_info(hdev, "QCA setup on UART is completed");
 
drivers/bluetooth/btqca.c +0 -0
 	return 0;
drivers/bluetooth/btqca.h +1 -0
index d81b74c..375c7fc 100644
@@ -11,6 +11,7 @@
 #define EDL_PATCH_CMD_LEN		(1)
 #define EDL_PATCH_VER_REQ_CMD		(0x19)
 #define EDL_PATCH_TLV_REQ_CMD		(0x1E)
+#define EDL_GET_BUILD_INFO_CMD		(0x20)
 #define EDL_NVM_ACCESS_SET_REQ_CMD	(0x01)
 #define MAX_SIZE_PER_TLV_SEGMENT	(243)
 #define QCA_PRE_SHUTDOWN_CMD		(0xFC08)
@@ -34,6 +35,8 @@
 #define QCA_HCI_CC_OPCODE		0xFC00
 #define QCA_HCI_CC_SUCCESS		0x00
 
Quoted 9 lines
Quoted 9 lines
drivers/bluetooth/btqca.h +2 -1
+#define QCA_FW_BUILD_VER_LEN		255
+
 enum qca_baudrate {
 	QCA_BAUDRATE_115200 	= 0,
 	QCA_BAUDRATE_57600,
--

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

Regards,
Lakshmi Narayana.

#3 lore raw
In reply to Venkata Lakshmi Narayana Gubba

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=386807

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuildK - PASS

---
Regards,
Linux Bluetooth