Skip to content

Commit 07f6ece

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Johan Hedberg says: ==================== pull request: bluetooth-next 2020-06-01 Here's one last bluetooth-next pull request for 5.8, which I hope can still be accepted. - Enabled Wide-Band Speech (WBS) support for Qualcomm wcn3991 - Multiple fixes/imprvovements to Qualcomm-based devices - Fix GAP/SEC/SEM/BI-10-C qualfication test case - Added support for Broadcom BCM4350C5 device - Several other smaller fixes & improvements Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1806c13 + e5aeebd commit 07f6ece

File tree

10 files changed

+154
-71
lines changed

10 files changed

+154
-71
lines changed

drivers/bluetooth/btbcm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,12 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
414414
{ 0x2118, "BCM20702A0" }, /* 001.001.024 */
415415
{ 0x2126, "BCM4335A0" }, /* 001.001.038 */
416416
{ 0x220e, "BCM20702A1" }, /* 001.002.014 */
417-
{ 0x230f, "BCM4354A2" }, /* 001.003.015 */
417+
{ 0x230f, "BCM4356A2" }, /* 001.003.015 */
418418
{ 0x4106, "BCM4335B0" }, /* 002.001.006 */
419419
{ 0x410e, "BCM20702B0" }, /* 002.001.014 */
420420
{ 0x6109, "BCM4335C0" }, /* 003.001.009 */
421421
{ 0x610c, "BCM4354" }, /* 003.001.012 */
422+
{ 0x6607, "BCM4350C5" }, /* 003.006.007 */
422423
{ }
423424
};
424425

drivers/bluetooth/btmtkuart.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ static int btmtkuart_change_baudrate(struct hci_dev *hdev)
695695

696696
/* Send a dummy byte 0xff to activate the new baudrate */
697697
param = 0xff;
698-
err = serdev_device_write(bdev->serdev, &param, sizeof(param),
699-
MAX_SCHEDULE_TIMEOUT);
698+
err = serdev_device_write_buf(bdev->serdev, &param, sizeof(param));
700699
if (err < 0 || err < sizeof(param))
701700
return err;
702701

@@ -1015,7 +1014,7 @@ static int btmtkuart_probe(struct serdev_device *serdev)
10151014
if (btmtkuart_is_standalone(bdev)) {
10161015
err = clk_prepare_enable(bdev->osc);
10171016
if (err < 0)
1018-
return err;
1017+
goto err_hci_free_dev;
10191018

10201019
if (bdev->boot) {
10211020
gpiod_set_value_cansleep(bdev->boot, 1);
@@ -1028,10 +1027,8 @@ static int btmtkuart_probe(struct serdev_device *serdev)
10281027

10291028
/* Power on */
10301029
err = regulator_enable(bdev->vcc);
1031-
if (err < 0) {
1032-
clk_disable_unprepare(bdev->osc);
1033-
return err;
1034-
}
1030+
if (err < 0)
1031+
goto err_clk_disable_unprepare;
10351032

10361033
/* Reset if the reset-gpios is available otherwise the board
10371034
* -level design should be guaranteed.
@@ -1063,7 +1060,6 @@ static int btmtkuart_probe(struct serdev_device *serdev)
10631060
err = hci_register_dev(hdev);
10641061
if (err < 0) {
10651062
dev_err(&serdev->dev, "Can't register HCI device\n");
1066-
hci_free_dev(hdev);
10671063
goto err_regulator_disable;
10681064
}
10691065

@@ -1072,6 +1068,11 @@ static int btmtkuart_probe(struct serdev_device *serdev)
10721068
err_regulator_disable:
10731069
if (btmtkuart_is_standalone(bdev))
10741070
regulator_disable(bdev->vcc);
1071+
err_clk_disable_unprepare:
1072+
if (btmtkuart_is_standalone(bdev))
1073+
clk_disable_unprepare(bdev->osc);
1074+
err_hci_free_dev:
1075+
hci_free_dev(hdev);
10751076

10761077
return err;
10771078
}

drivers/bluetooth/btqca.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
7474

7575
ver = (struct qca_btsoc_version *)(edl->data);
7676

77-
BT_DBG("%s: Product:0x%08x", hdev->name, le32_to_cpu(ver->product_id));
78-
BT_DBG("%s: Patch :0x%08x", hdev->name, le16_to_cpu(ver->patch_ver));
79-
BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rom_ver));
80-
BT_DBG("%s: SOC :0x%08x", hdev->name, le32_to_cpu(ver->soc_id));
77+
bt_dev_info(hdev, "QCA Product ID :0x%08x",
78+
le32_to_cpu(ver->product_id));
79+
bt_dev_info(hdev, "QCA SOC Version :0x%08x",
80+
le32_to_cpu(ver->soc_id));
81+
bt_dev_info(hdev, "QCA ROM Version :0x%08x",
82+
le16_to_cpu(ver->rom_ver));
83+
bt_dev_info(hdev, "QCA Patch Version:0x%08x",
84+
le16_to_cpu(ver->patch_ver));
8185

8286
/* QCA chipset version can be decided by patch and SoC
8387
* version, combination with upper 2 bytes from SoC
8488
* and lower 2 bytes from patch will be used.
8589
*/
8690
*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
87-
(le16_to_cpu(ver->rom_ver) & 0x0000ffff);
91+
(le16_to_cpu(ver->rom_ver) & 0x0000ffff);
8892
if (*soc_version == 0)
8993
err = -EILSEQ;
9094

drivers/bluetooth/hci_qca.c

Lines changed: 103 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ enum qca_flags {
7575
QCA_HW_ERROR_EVENT
7676
};
7777

78+
enum qca_capabilities {
79+
QCA_CAP_WIDEBAND_SPEECH = BIT(0),
80+
};
7881

7982
/* HCI_IBS transmit side sleep protocol states */
8083
enum tx_ibs_states {
@@ -111,6 +114,7 @@ struct qca_memdump_data {
111114
char *memdump_buf_tail;
112115
u32 current_seq_no;
113116
u32 received_dump;
117+
u32 ram_dump_size;
114118
};
115119

116120
struct qca_memdump_event_hdr {
@@ -187,10 +191,11 @@ struct qca_vreg {
187191
unsigned int load_uA;
188192
};
189193

190-
struct qca_vreg_data {
194+
struct qca_device_data {
191195
enum qca_btsoc_type soc_type;
192196
struct qca_vreg *vregs;
193197
size_t num_vregs;
198+
uint32_t capabilities;
194199
};
195200

196201
/*
@@ -972,6 +977,8 @@ static void qca_controller_memdump(struct work_struct *work)
972977
char nullBuff[QCA_DUMP_PACKET_SIZE] = { 0 };
973978
u16 seq_no;
974979
u32 dump_size;
980+
u32 rx_size;
981+
enum qca_btsoc_type soc_type = qca_soc_type(hu);
975982

976983
while ((skb = skb_dequeue(&qca->rx_memdump_q))) {
977984

@@ -1021,10 +1028,12 @@ static void qca_controller_memdump(struct work_struct *work)
10211028
dump_size);
10221029
queue_delayed_work(qca->workqueue,
10231030
&qca->ctrl_memdump_timeout,
1024-
msecs_to_jiffies(MEMDUMP_TIMEOUT_MS));
1031+
msecs_to_jiffies(MEMDUMP_TIMEOUT_MS)
1032+
);
10251033

10261034
skb_pull(skb, sizeof(dump_size));
10271035
memdump_buf = vmalloc(dump_size);
1036+
qca_memdump->ram_dump_size = dump_size;
10281037
qca_memdump->memdump_buf_head = memdump_buf;
10291038
qca_memdump->memdump_buf_tail = memdump_buf;
10301039
}
@@ -1047,26 +1056,57 @@ static void qca_controller_memdump(struct work_struct *work)
10471056
* the controller. In such cases let us store the dummy
10481057
* packets in the buffer.
10491058
*/
1059+
/* For QCA6390, controller does not lost packets but
1060+
* sequence number field of packat sometimes has error
1061+
* bits, so skip this checking for missing packet.
1062+
*/
10501063
while ((seq_no > qca_memdump->current_seq_no + 1) &&
1051-
seq_no != QCA_LAST_SEQUENCE_NUM) {
1064+
(soc_type != QCA_QCA6390) &&
1065+
seq_no != QCA_LAST_SEQUENCE_NUM) {
10521066
bt_dev_err(hu->hdev, "QCA controller missed packet:%d",
10531067
qca_memdump->current_seq_no);
1068+
rx_size = qca_memdump->received_dump;
1069+
rx_size += QCA_DUMP_PACKET_SIZE;
1070+
if (rx_size > qca_memdump->ram_dump_size) {
1071+
bt_dev_err(hu->hdev,
1072+
"QCA memdump received %d, no space for missed packet",
1073+
qca_memdump->received_dump);
1074+
break;
1075+
}
10541076
memcpy(memdump_buf, nullBuff, QCA_DUMP_PACKET_SIZE);
10551077
memdump_buf = memdump_buf + QCA_DUMP_PACKET_SIZE;
10561078
qca_memdump->received_dump += QCA_DUMP_PACKET_SIZE;
10571079
qca_memdump->current_seq_no++;
10581080
}
10591081

1060-
memcpy(memdump_buf, (unsigned char *) skb->data, skb->len);
1061-
memdump_buf = memdump_buf + skb->len;
1062-
qca_memdump->memdump_buf_tail = memdump_buf;
1063-
qca_memdump->current_seq_no = seq_no + 1;
1064-
qca_memdump->received_dump += skb->len;
1082+
rx_size = qca_memdump->received_dump + skb->len;
1083+
if (rx_size <= qca_memdump->ram_dump_size) {
1084+
if ((seq_no != QCA_LAST_SEQUENCE_NUM) &&
1085+
(seq_no != qca_memdump->current_seq_no))
1086+
bt_dev_err(hu->hdev,
1087+
"QCA memdump unexpected packet %d",
1088+
seq_no);
1089+
bt_dev_dbg(hu->hdev,
1090+
"QCA memdump packet %d with length %d",
1091+
seq_no, skb->len);
1092+
memcpy(memdump_buf, (unsigned char *)skb->data,
1093+
skb->len);
1094+
memdump_buf = memdump_buf + skb->len;
1095+
qca_memdump->memdump_buf_tail = memdump_buf;
1096+
qca_memdump->current_seq_no = seq_no + 1;
1097+
qca_memdump->received_dump += skb->len;
1098+
} else {
1099+
bt_dev_err(hu->hdev,
1100+
"QCA memdump received %d, no space for packet %d",
1101+
qca_memdump->received_dump, seq_no);
1102+
}
10651103
qca->qca_memdump = qca_memdump;
10661104
kfree_skb(skb);
10671105
if (seq_no == QCA_LAST_SEQUENCE_NUM) {
1068-
bt_dev_info(hu->hdev, "QCA writing crash dump of size %d bytes",
1069-
qca_memdump->received_dump);
1106+
bt_dev_info(hu->hdev,
1107+
"QCA memdump Done, received %d, total %d",
1108+
qca_memdump->received_dump,
1109+
qca_memdump->ram_dump_size);
10701110
memdump_buf = qca_memdump->memdump_buf_head;
10711111
dev_coredumpv(&hu->serdev->dev, memdump_buf,
10721112
qca_memdump->received_dump, GFP_KERNEL);
@@ -1691,7 +1731,7 @@ static const struct hci_uart_proto qca_proto = {
16911731
.dequeue = qca_dequeue,
16921732
};
16931733

1694-
static const struct qca_vreg_data qca_soc_data_wcn3990 = {
1734+
static const struct qca_device_data qca_soc_data_wcn3990 = {
16951735
.soc_type = QCA_WCN3990,
16961736
.vregs = (struct qca_vreg []) {
16971737
{ "vddio", 15000 },
@@ -1702,7 +1742,7 @@ static const struct qca_vreg_data qca_soc_data_wcn3990 = {
17021742
.num_vregs = 4,
17031743
};
17041744

1705-
static const struct qca_vreg_data qca_soc_data_wcn3991 = {
1745+
static const struct qca_device_data qca_soc_data_wcn3991 = {
17061746
.soc_type = QCA_WCN3991,
17071747
.vregs = (struct qca_vreg []) {
17081748
{ "vddio", 15000 },
@@ -1711,9 +1751,10 @@ static const struct qca_vreg_data qca_soc_data_wcn3991 = {
17111751
{ "vddch0", 450000 },
17121752
},
17131753
.num_vregs = 4,
1754+
.capabilities = QCA_CAP_WIDEBAND_SPEECH,
17141755
};
17151756

1716-
static const struct qca_vreg_data qca_soc_data_wcn3998 = {
1757+
static const struct qca_device_data qca_soc_data_wcn3998 = {
17171758
.soc_type = QCA_WCN3998,
17181759
.vregs = (struct qca_vreg []) {
17191760
{ "vddio", 10000 },
@@ -1724,7 +1765,7 @@ static const struct qca_vreg_data qca_soc_data_wcn3998 = {
17241765
.num_vregs = 4,
17251766
};
17261767

1727-
static const struct qca_vreg_data qca_soc_data_qca6390 = {
1768+
static const struct qca_device_data qca_soc_data_qca6390 = {
17281769
.soc_type = QCA_QCA6390,
17291770
.num_vregs = 0,
17301771
};
@@ -1860,7 +1901,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
18601901
{
18611902
struct qca_serdev *qcadev;
18621903
struct hci_dev *hdev;
1863-
const struct qca_vreg_data *data;
1904+
const struct qca_device_data *data;
18641905
int err;
18651906
bool power_ctrl_enabled = true;
18661907

@@ -1942,12 +1983,19 @@ static int qca_serdev_probe(struct serdev_device *serdev)
19421983
}
19431984
}
19441985

1986+
hdev = qcadev->serdev_hu.hdev;
1987+
19451988
if (power_ctrl_enabled) {
1946-
hdev = qcadev->serdev_hu.hdev;
19471989
set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
19481990
hdev->shutdown = qca_power_off;
19491991
}
19501992

1993+
/* Wideband speech support must be set per driver since it can't be
1994+
* queried via hci.
1995+
*/
1996+
if (data && (data->capabilities & QCA_CAP_WIDEBAND_SPEECH))
1997+
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
1998+
19511999
return 0;
19522000
}
19532001

@@ -1963,10 +2011,43 @@ static void qca_serdev_remove(struct serdev_device *serdev)
19632011
hci_uart_unregister_device(&qcadev->serdev_hu);
19642012
}
19652013

2014+
static void qca_serdev_shutdown(struct device *dev)
2015+
{
2016+
int ret;
2017+
int timeout = msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS);
2018+
struct serdev_device *serdev = to_serdev_device(dev);
2019+
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
2020+
const u8 ibs_wake_cmd[] = { 0xFD };
2021+
const u8 edl_reset_soc_cmd[] = { 0x01, 0x00, 0xFC, 0x01, 0x05 };
2022+
2023+
if (qcadev->btsoc_type == QCA_QCA6390) {
2024+
serdev_device_write_flush(serdev);
2025+
ret = serdev_device_write_buf(serdev, ibs_wake_cmd,
2026+
sizeof(ibs_wake_cmd));
2027+
if (ret < 0) {
2028+
BT_ERR("QCA send IBS_WAKE_IND error: %d", ret);
2029+
return;
2030+
}
2031+
serdev_device_wait_until_sent(serdev, timeout);
2032+
usleep_range(8000, 10000);
2033+
2034+
serdev_device_write_flush(serdev);
2035+
ret = serdev_device_write_buf(serdev, edl_reset_soc_cmd,
2036+
sizeof(edl_reset_soc_cmd));
2037+
if (ret < 0) {
2038+
BT_ERR("QCA send EDL_RESET_REQ error: %d", ret);
2039+
return;
2040+
}
2041+
serdev_device_wait_until_sent(serdev, timeout);
2042+
usleep_range(8000, 10000);
2043+
}
2044+
}
2045+
19662046
static int __maybe_unused qca_suspend(struct device *dev)
19672047
{
1968-
struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
1969-
struct hci_uart *hu = hci_get_drvdata(hdev);
2048+
struct serdev_device *serdev = to_serdev_device(dev);
2049+
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
2050+
struct hci_uart *hu = &qcadev->serdev_hu;
19702051
struct qca_data *qca = hu->priv;
19712052
unsigned long flags;
19722053
int ret = 0;
@@ -2045,8 +2126,9 @@ static int __maybe_unused qca_suspend(struct device *dev)
20452126

20462127
static int __maybe_unused qca_resume(struct device *dev)
20472128
{
2048-
struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
2049-
struct hci_uart *hu = hci_get_drvdata(hdev);
2129+
struct serdev_device *serdev = to_serdev_device(dev);
2130+
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
2131+
struct hci_uart *hu = &qcadev->serdev_hu;
20502132
struct qca_data *qca = hu->priv;
20512133

20522134
clear_bit(QCA_SUSPENDING, &qca->flags);
@@ -2088,6 +2170,7 @@ static struct serdev_device_driver qca_serdev_driver = {
20882170
.name = "hci_uart_qca",
20892171
.of_match_table = of_match_ptr(qca_bluetooth_of_match),
20902172
.acpi_match_table = ACPI_PTR(qca_bluetooth_acpi_match),
2173+
.shutdown = qca_serdev_shutdown,
20912174
.pm = &qca_pm_ops,
20922175
},
20932176
};

include/net/bluetooth/hci_core.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,10 +1381,26 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
13811381
conn->security_cfm_cb(conn, status);
13821382
}
13831383

1384-
static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
1385-
__u8 encrypt)
1384+
static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status)
13861385
{
13871386
struct hci_cb *cb;
1387+
__u8 encrypt;
1388+
1389+
if (conn->state == BT_CONFIG) {
1390+
if (status)
1391+
conn->state = BT_CONNECTED;
1392+
1393+
hci_connect_cfm(conn, status);
1394+
hci_conn_drop(conn);
1395+
return;
1396+
}
1397+
1398+
if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
1399+
encrypt = 0x00;
1400+
else if (test_bit(HCI_CONN_AES_CCM, &conn->flags))
1401+
encrypt = 0x02;
1402+
else
1403+
encrypt = 0x01;
13881404

13891405
if (conn->sec_level == BT_SECURITY_SDP)
13901406
conn->sec_level = BT_SECURITY_LOW;

0 commit comments

Comments
 (0)