Skip to content

Commit c0187b0

Browse files
Venkata Lakshmi Narayana Gubbaholtmann
authored andcommitted
Bluetooth: btqca: Add support to read FW build version for WCN3991 BTSoC
Add support to read FW build version from debugfs node. This info can be read from /sys/kernel/debug/bluetooth/hci0/firmware_info Signed-off-by: Venkata Lakshmi Narayana Gubba <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 517b693 commit c0187b0

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

drivers/bluetooth/btqca.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,53 @@ int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver,
9494
}
9595
EXPORT_SYMBOL_GPL(qca_read_soc_version);
9696

97+
static int qca_read_fw_build_info(struct hci_dev *hdev)
98+
{
99+
struct sk_buff *skb;
100+
struct edl_event_hdr *edl;
101+
char cmd, build_label[QCA_FW_BUILD_VER_LEN];
102+
int build_lbl_len, err = 0;
103+
104+
bt_dev_dbg(hdev, "QCA read fw build info");
105+
106+
cmd = EDL_GET_BUILD_INFO_CMD;
107+
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
108+
&cmd, 0, HCI_INIT_TIMEOUT);
109+
if (IS_ERR(skb)) {
110+
err = PTR_ERR(skb);
111+
bt_dev_err(hdev, "Reading QCA fw build info failed (%d)",
112+
err);
113+
return err;
114+
}
115+
116+
edl = (struct edl_event_hdr *)(skb->data);
117+
if (!edl) {
118+
bt_dev_err(hdev, "QCA read fw build info with no header");
119+
err = -EILSEQ;
120+
goto out;
121+
}
122+
123+
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
124+
edl->rtype != EDL_GET_BUILD_INFO_CMD) {
125+
bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
126+
edl->rtype);
127+
err = -EIO;
128+
goto out;
129+
}
130+
131+
build_lbl_len = edl->data[0];
132+
if (build_lbl_len <= QCA_FW_BUILD_VER_LEN - 1) {
133+
memcpy(build_label, edl->data + 1, build_lbl_len);
134+
*(build_label + build_lbl_len) = '\0';
135+
}
136+
137+
hci_set_fw_info(hdev, "%s", build_label);
138+
139+
out:
140+
kfree_skb(skb);
141+
return err;
142+
}
143+
97144
static int qca_send_reset(struct hci_dev *hdev)
98145
{
99146
struct sk_buff *skb;
@@ -524,6 +571,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
524571
return err;
525572
}
526573

574+
if (soc_type == QCA_WCN3991) {
575+
/* get fw build info */
576+
err = qca_read_fw_build_info(hdev);
577+
if (err < 0)
578+
return err;
579+
}
580+
527581
bt_dev_info(hdev, "QCA setup on UART is completed");
528582

529583
return 0;

drivers/bluetooth/btqca.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define EDL_PATCH_CMD_LEN (1)
1212
#define EDL_PATCH_VER_REQ_CMD (0x19)
1313
#define EDL_PATCH_TLV_REQ_CMD (0x1E)
14+
#define EDL_GET_BUILD_INFO_CMD (0x20)
1415
#define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
1516
#define MAX_SIZE_PER_TLV_SEGMENT (243)
1617
#define QCA_PRE_SHUTDOWN_CMD (0xFC08)

0 commit comments

Comments
 (0)