Skip to content

Commit 0ae2015

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kern
el/git/bluetooth/bluetooth-next Johan Hedberg says: ==================== pull request: bluetooth-next 2021-02-11 Here's the main bluetooth-next pull request for 5.12: - Add support for advertising monitor offliading using Microsoft vendor extensions - Add firmware download support for MediaTek MT7921U USB devices - Suspend-related fixes for Qualcomm devices - Add support for Intel GarfieldPeak controller - Various other smaller fixes & cleanups Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1d13115 + 55c0bd7 commit 0ae2015

File tree

29 files changed

+1694
-343
lines changed

29 files changed

+1694
-343
lines changed

Documentation/devicetree/bindings/net/btusb.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt:
3838
compatible = "usb1286,204e";
3939
reg = <1>;
4040
interrupt-parent = <&gpio0>;
41-
interrupt-name = "wakeup";
41+
interrupt-names = "wakeup";
4242
interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
4343
};
4444
};

drivers/bluetooth/btintel.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,38 +437,31 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver
437437
tlv = (struct intel_tlv *)skb->data;
438438
switch (tlv->type) {
439439
case INTEL_TLV_CNVI_TOP:
440-
version->cnvi_top =
441-
__le32_to_cpu(get_unaligned_le32(tlv->val));
440+
version->cnvi_top = get_unaligned_le32(tlv->val);
442441
break;
443442
case INTEL_TLV_CNVR_TOP:
444-
version->cnvr_top =
445-
__le32_to_cpu(get_unaligned_le32(tlv->val));
443+
version->cnvr_top = get_unaligned_le32(tlv->val);
446444
break;
447445
case INTEL_TLV_CNVI_BT:
448-
version->cnvi_bt =
449-
__le32_to_cpu(get_unaligned_le32(tlv->val));
446+
version->cnvi_bt = get_unaligned_le32(tlv->val);
450447
break;
451448
case INTEL_TLV_CNVR_BT:
452-
version->cnvr_bt =
453-
__le32_to_cpu(get_unaligned_le32(tlv->val));
449+
version->cnvr_bt = get_unaligned_le32(tlv->val);
454450
break;
455451
case INTEL_TLV_DEV_REV_ID:
456-
version->dev_rev_id =
457-
__le16_to_cpu(get_unaligned_le16(tlv->val));
452+
version->dev_rev_id = get_unaligned_le16(tlv->val);
458453
break;
459454
case INTEL_TLV_IMAGE_TYPE:
460455
version->img_type = tlv->val[0];
461456
break;
462457
case INTEL_TLV_TIME_STAMP:
463-
version->timestamp =
464-
__le16_to_cpu(get_unaligned_le16(tlv->val));
458+
version->timestamp = get_unaligned_le16(tlv->val);
465459
break;
466460
case INTEL_TLV_BUILD_TYPE:
467461
version->build_type = tlv->val[0];
468462
break;
469463
case INTEL_TLV_BUILD_NUM:
470-
version->build_num =
471-
__le32_to_cpu(get_unaligned_le32(tlv->val));
464+
version->build_num = get_unaligned_le32(tlv->val);
472465
break;
473466
case INTEL_TLV_SECURE_BOOT:
474467
version->secure_boot = tlv->val[0];

drivers/bluetooth/btmtksdio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,15 @@ static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size)
442442
}
443443

444444
switch ((&pkts[i])->lsize) {
445-
case 1:
446-
dlen = skb->data[(&pkts[i])->loff];
447-
break;
448-
case 2:
449-
dlen = get_unaligned_le16(skb->data +
445+
case 1:
446+
dlen = skb->data[(&pkts[i])->loff];
447+
break;
448+
case 2:
449+
dlen = get_unaligned_le16(skb->data +
450450
(&pkts[i])->loff);
451-
break;
452-
default:
453-
goto err_kfree_skb;
451+
break;
452+
default:
453+
goto err_kfree_skb;
454454
}
455455

456456
pad_size = skb->len - (&pkts[i])->hlen - dlen;

drivers/bluetooth/btqca.c

Lines changed: 67 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;
@@ -517,13 +564,33 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
517564
return err;
518565
}
519566

567+
/* WCN399x supports the Microsoft vendor extension with 0xFD70 as the
568+
* VsMsftOpCode.
569+
*/
570+
switch (soc_type) {
571+
case QCA_WCN3990:
572+
case QCA_WCN3991:
573+
case QCA_WCN3998:
574+
hci_set_msft_opcode(hdev, 0xFD70);
575+
break;
576+
default:
577+
break;
578+
}
579+
520580
/* Perform HCI reset */
521581
err = qca_send_reset(hdev);
522582
if (err < 0) {
523583
bt_dev_err(hdev, "QCA Failed to run HCI_RESET (%d)", err);
524584
return err;
525585
}
526586

587+
if (soc_type == QCA_WCN3991) {
588+
/* get fw build info */
589+
err = qca_read_fw_build_info(hdev);
590+
if (err < 0)
591+
return err;
592+
}
593+
527594
bt_dev_info(hdev, "QCA setup on UART is completed");
528595

529596
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)

drivers/bluetooth/btqcomsmd.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ static int btqcomsmd_probe(struct platform_device *pdev)
142142

143143
btq->cmd_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_CMD",
144144
btqcomsmd_cmd_callback, btq);
145-
if (IS_ERR(btq->cmd_channel))
146-
return PTR_ERR(btq->cmd_channel);
145+
if (IS_ERR(btq->cmd_channel)) {
146+
ret = PTR_ERR(btq->cmd_channel);
147+
goto destroy_acl_channel;
148+
}
147149

148150
hdev = hci_alloc_dev();
149-
if (!hdev)
150-
return -ENOMEM;
151+
if (!hdev) {
152+
ret = -ENOMEM;
153+
goto destroy_cmd_channel;
154+
}
151155

152156
hci_set_drvdata(hdev, btq);
153157
btq->hdev = hdev;
@@ -161,14 +165,21 @@ static int btqcomsmd_probe(struct platform_device *pdev)
161165
hdev->set_bdaddr = qca_set_bdaddr_rome;
162166

163167
ret = hci_register_dev(hdev);
164-
if (ret < 0) {
165-
hci_free_dev(hdev);
166-
return ret;
167-
}
168+
if (ret < 0)
169+
goto hci_free_dev;
168170

169171
platform_set_drvdata(pdev, btq);
170172

171173
return 0;
174+
175+
hci_free_dev:
176+
hci_free_dev(hdev);
177+
destroy_cmd_channel:
178+
rpmsg_destroy_ept(btq->cmd_channel);
179+
destroy_acl_channel:
180+
rpmsg_destroy_ept(btq->acl_channel);
181+
182+
return ret;
172183
}
173184

174185
static int btqcomsmd_remove(struct platform_device *pdev)

drivers/bluetooth/btrtl.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@
3838
.hci_ver = (hciv), \
3939
.hci_bus = (bus)
4040

41+
enum btrtl_chip_id {
42+
CHIP_ID_8723A,
43+
CHIP_ID_8723B,
44+
CHIP_ID_8821A,
45+
CHIP_ID_8761A,
46+
CHIP_ID_8822B = 8,
47+
CHIP_ID_8723D,
48+
CHIP_ID_8821C,
49+
CHIP_ID_8822C = 13,
50+
CHIP_ID_8761B,
51+
CHIP_ID_8852A = 18,
52+
};
53+
4154
struct id_table {
4255
__u16 match_flags;
4356
__u16 lmp_subver;
@@ -58,6 +71,7 @@ struct btrtl_device_info {
5871
u8 *cfg_data;
5972
int cfg_len;
6073
bool drop_fw;
74+
int project_id;
6175
};
6276

6377
static const struct id_table ic_id_table[] = {
@@ -307,8 +321,10 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
307321

308322
/* Find project_id in table */
309323
for (i = 0; i < ARRAY_SIZE(project_id_to_lmp_subver); i++) {
310-
if (project_id == project_id_to_lmp_subver[i].id)
324+
if (project_id == project_id_to_lmp_subver[i].id) {
325+
btrtl_dev->project_id = project_id;
311326
break;
327+
}
312328
}
313329

314330
if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
@@ -658,6 +674,12 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
658674
}
659675
}
660676

677+
/* RTL8822CE supports the Microsoft vendor extension and uses 0xFCF0
678+
* for VsMsftOpCode.
679+
*/
680+
if (lmp_subver == RTL_ROM_LMP_8822B)
681+
hci_set_msft_opcode(hdev, 0xFCF0);
682+
661683
return btrtl_dev;
662684

663685
err_free:
@@ -708,13 +730,28 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
708730

709731
ret = btrtl_download_firmware(hdev, btrtl_dev);
710732

711-
btrtl_free(btrtl_dev);
712-
713733
/* Enable controller to do both LE scan and BR/EDR inquiry
714734
* simultaneously.
715735
*/
716736
set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
717737

738+
/* Enable central-peripheral role (able to create new connections with
739+
* an existing connection in slave role).
740+
*/
741+
/* Enable WBS supported for the specific Realtek devices. */
742+
switch (btrtl_dev->project_id) {
743+
case CHIP_ID_8822C:
744+
case CHIP_ID_8852A:
745+
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
746+
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
747+
break;
748+
default:
749+
rtl_dev_dbg(hdev, "Central-peripheral role not enabled.");
750+
rtl_dev_dbg(hdev, "WBS supported not enabled.");
751+
break;
752+
}
753+
754+
btrtl_free(btrtl_dev);
718755
return ret;
719756
}
720757
EXPORT_SYMBOL_GPL(btrtl_setup_realtek);

0 commit comments

Comments
 (0)