Skip to content

Commit ce9db46

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: linux-bluetooth 2019-11-11 Here's one more bluetooth-next pull request for the 5.5 kernel release. - Several fixes for LE advertising - Added PM support to hci_qca driver - Added support for WCN3991 SoC in hci_qca driver - Added DT bindings for BCM43540 module - A few other small cleanups/fixes ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e0580b5 + 7d250a0 commit ce9db46

File tree

9 files changed

+242
-52
lines changed

9 files changed

+242
-52
lines changed

Documentation/devicetree/bindings/net/broadcom-bluetooth.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Required properties:
1414
* "brcm,bcm4330-bt"
1515
* "brcm,bcm43438-bt"
1616
* "brcm,bcm4345c5"
17+
* "brcm,bcm43540-bt"
1718

1819
Optional properties:
1920

drivers/bluetooth/btmtksdio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static const struct sdio_device_id btmtksdio_table[] = {
5757
.driver_data = (kernel_ulong_t)&mt7668_data },
5858
{ } /* Terminating entry */
5959
};
60+
MODULE_DEVICE_TABLE(sdio, btmtksdio_table);
6061

6162
#define MTK_REG_CHLPCR 0x4 /* W1S */
6263
#define C_INT_EN_SET BIT(0)

drivers/bluetooth/btqca.c

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,41 @@
1414

1515
#define VERSION "0.1"
1616

17-
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
17+
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
18+
enum qca_btsoc_type soc_type)
1819
{
1920
struct sk_buff *skb;
2021
struct edl_event_hdr *edl;
21-
struct rome_version *ver;
22+
struct qca_btsoc_version *ver;
2223
char cmd;
2324
int err = 0;
25+
u8 event_type = HCI_EV_VENDOR;
26+
u8 rlen = sizeof(*edl) + sizeof(*ver);
27+
u8 rtype = EDL_APP_VER_RES_EVT;
2428

2529
bt_dev_dbg(hdev, "QCA Version Request");
2630

31+
/* Unlike other SoC's sending version command response as payload to
32+
* VSE event. WCN3991 sends version command response as a payload to
33+
* command complete event.
34+
*/
35+
if (soc_type == QCA_WCN3991) {
36+
event_type = 0;
37+
rlen += 1;
38+
rtype = EDL_PATCH_VER_REQ_CMD;
39+
}
40+
2741
cmd = EDL_PATCH_VER_REQ_CMD;
2842
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
29-
&cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
43+
&cmd, event_type, HCI_INIT_TIMEOUT);
3044
if (IS_ERR(skb)) {
3145
err = PTR_ERR(skb);
3246
bt_dev_err(hdev, "Reading QCA version information failed (%d)",
3347
err);
3448
return err;
3549
}
3650

37-
if (skb->len != sizeof(*edl) + sizeof(*ver)) {
51+
if (skb->len != rlen) {
3852
bt_dev_err(hdev, "QCA Version size mismatch len %d", skb->len);
3953
err = -EILSEQ;
4054
goto out;
@@ -48,26 +62,29 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
4862
}
4963

5064
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
51-
edl->rtype != EDL_APP_VER_RES_EVT) {
65+
edl->rtype != rtype) {
5266
bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
5367
edl->rtype);
5468
err = -EIO;
5569
goto out;
5670
}
5771

58-
ver = (struct rome_version *)(edl->data);
72+
if (soc_type == QCA_WCN3991)
73+
memmove(&edl->data, &edl->data[1], sizeof(*ver));
74+
75+
ver = (struct qca_btsoc_version *)(edl->data);
5976

6077
BT_DBG("%s: Product:0x%08x", hdev->name, le32_to_cpu(ver->product_id));
6178
BT_DBG("%s: Patch :0x%08x", hdev->name, le16_to_cpu(ver->patch_ver));
62-
BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rome_ver));
79+
BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rom_ver));
6380
BT_DBG("%s: SOC :0x%08x", hdev->name, le32_to_cpu(ver->soc_id));
6481

6582
/* QCA chipset version can be decided by patch and SoC
6683
* version, combination with upper 2 bytes from SoC
6784
* and lower 2 bytes from patch will be used.
6885
*/
6986
*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
70-
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
87+
(le16_to_cpu(ver->rom_ver) & 0x0000ffff);
7188
if (*soc_version == 0)
7289
err = -EILSEQ;
7390

@@ -121,7 +138,7 @@ int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
121138
}
122139
EXPORT_SYMBOL_GPL(qca_send_pre_shutdown_cmd);
123140

124-
static void qca_tlv_check_data(struct rome_config *config,
141+
static void qca_tlv_check_data(struct qca_fw_config *config,
125142
const struct firmware *fw)
126143
{
127144
const u8 *data;
@@ -140,8 +157,8 @@ static void qca_tlv_check_data(struct rome_config *config,
140157
BT_DBG("TLV Type\t\t : 0x%x", type_len & 0x000000ff);
141158
BT_DBG("Length\t\t : %d bytes", length);
142159

143-
config->dnld_mode = ROME_SKIP_EVT_NONE;
144-
config->dnld_type = ROME_SKIP_EVT_NONE;
160+
config->dnld_mode = QCA_SKIP_EVT_NONE;
161+
config->dnld_type = QCA_SKIP_EVT_NONE;
145162

146163
switch (config->type) {
147164
case TLV_TYPE_PATCH:
@@ -223,31 +240,45 @@ static void qca_tlv_check_data(struct rome_config *config,
223240
}
224241

225242
static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size,
226-
const u8 *data, enum rome_tlv_dnld_mode mode)
243+
const u8 *data, enum qca_tlv_dnld_mode mode,
244+
enum qca_btsoc_type soc_type)
227245
{
228246
struct sk_buff *skb;
229247
struct edl_event_hdr *edl;
230248
struct tlv_seg_resp *tlv_resp;
231249
u8 cmd[MAX_SIZE_PER_TLV_SEGMENT + 2];
232250
int err = 0;
251+
u8 event_type = HCI_EV_VENDOR;
252+
u8 rlen = (sizeof(*edl) + sizeof(*tlv_resp));
253+
u8 rtype = EDL_TVL_DNLD_RES_EVT;
233254

234255
cmd[0] = EDL_PATCH_TLV_REQ_CMD;
235256
cmd[1] = seg_size;
236257
memcpy(cmd + 2, data, seg_size);
237258

238-
if (mode == ROME_SKIP_EVT_VSE_CC || mode == ROME_SKIP_EVT_VSE)
259+
if (mode == QCA_SKIP_EVT_VSE_CC || mode == QCA_SKIP_EVT_VSE)
239260
return __hci_cmd_send(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2,
240261
cmd);
241262

263+
/* Unlike other SoC's sending version command response as payload to
264+
* VSE event. WCN3991 sends version command response as a payload to
265+
* command complete event.
266+
*/
267+
if (soc_type == QCA_WCN3991) {
268+
event_type = 0;
269+
rlen = sizeof(*edl);
270+
rtype = EDL_PATCH_TLV_REQ_CMD;
271+
}
272+
242273
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, cmd,
243-
HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
274+
event_type, HCI_INIT_TIMEOUT);
244275
if (IS_ERR(skb)) {
245276
err = PTR_ERR(skb);
246277
bt_dev_err(hdev, "QCA Failed to send TLV segment (%d)", err);
247278
return err;
248279
}
249280

250-
if (skb->len != sizeof(*edl) + sizeof(*tlv_resp)) {
281+
if (skb->len != rlen) {
251282
bt_dev_err(hdev, "QCA TLV response size mismatch");
252283
err = -EILSEQ;
253284
goto out;
@@ -260,13 +291,19 @@ static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size,
260291
goto out;
261292
}
262293

263-
tlv_resp = (struct tlv_seg_resp *)(edl->data);
294+
if (edl->cresp != EDL_CMD_REQ_RES_EVT || edl->rtype != rtype) {
295+
bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x",
296+
edl->cresp, edl->rtype);
297+
err = -EIO;
298+
}
264299

265-
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
266-
edl->rtype != EDL_TVL_DNLD_RES_EVT || tlv_resp->result != 0x00) {
300+
if (soc_type == QCA_WCN3991)
301+
goto out;
302+
303+
tlv_resp = (struct tlv_seg_resp *)(edl->data);
304+
if (tlv_resp->result) {
267305
bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x (0x%x)",
268306
edl->cresp, edl->rtype, tlv_resp->result);
269-
err = -EIO;
270307
}
271308

272309
out:
@@ -301,7 +338,8 @@ static int qca_inject_cmd_complete_event(struct hci_dev *hdev)
301338
}
302339

303340
static int qca_download_firmware(struct hci_dev *hdev,
304-
struct rome_config *config)
341+
struct qca_fw_config *config,
342+
enum qca_btsoc_type soc_type)
305343
{
306344
const struct firmware *fw;
307345
const u8 *segment;
@@ -328,10 +366,10 @@ static int qca_download_firmware(struct hci_dev *hdev,
328366
remain -= segsize;
329367
/* The last segment is always acked regardless download mode */
330368
if (!remain || segsize < MAX_SIZE_PER_TLV_SEGMENT)
331-
config->dnld_mode = ROME_SKIP_EVT_NONE;
369+
config->dnld_mode = QCA_SKIP_EVT_NONE;
332370

333371
ret = qca_tlv_send_segment(hdev, segsize, segment,
334-
config->dnld_mode);
372+
config->dnld_mode, soc_type);
335373
if (ret)
336374
goto out;
337375

@@ -344,8 +382,8 @@ static int qca_download_firmware(struct hci_dev *hdev,
344382
* decrease the BT in initialization time. Here we will inject a command
345383
* complete event to avoid a command timeout error message.
346384
*/
347-
if (config->dnld_type == ROME_SKIP_EVT_VSE_CC ||
348-
config->dnld_type == ROME_SKIP_EVT_VSE)
385+
if (config->dnld_type == QCA_SKIP_EVT_VSE_CC ||
386+
config->dnld_type == QCA_SKIP_EVT_VSE)
349387
ret = qca_inject_cmd_complete_event(hdev);
350388

351389
out:
@@ -382,7 +420,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
382420
enum qca_btsoc_type soc_type, u32 soc_ver,
383421
const char *firmware_name)
384422
{
385-
struct rome_config config;
423+
struct qca_fw_config config;
386424
int err;
387425
u8 rom_ver = 0;
388426

@@ -405,7 +443,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
405443
"qca/rampatch_%08x.bin", soc_ver);
406444
}
407445

408-
err = qca_download_firmware(hdev, &config);
446+
err = qca_download_firmware(hdev, &config, soc_type);
409447
if (err < 0) {
410448
bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
411449
return err;
@@ -426,7 +464,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
426464
snprintf(config.fwname, sizeof(config.fwname),
427465
"qca/nvm_%08x.bin", soc_ver);
428466

429-
err = qca_download_firmware(hdev, &config);
467+
err = qca_download_firmware(hdev, &config, soc_type);
430468
if (err < 0) {
431469
bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
432470
return err;

drivers/bluetooth/btqca.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ enum qca_baudrate {
5656
QCA_BAUDRATE_RESERVED
5757
};
5858

59-
enum rome_tlv_dnld_mode {
60-
ROME_SKIP_EVT_NONE,
61-
ROME_SKIP_EVT_VSE,
62-
ROME_SKIP_EVT_CC,
63-
ROME_SKIP_EVT_VSE_CC
59+
enum qca_tlv_dnld_mode {
60+
QCA_SKIP_EVT_NONE,
61+
QCA_SKIP_EVT_VSE,
62+
QCA_SKIP_EVT_CC,
63+
QCA_SKIP_EVT_VSE_CC
6464
};
6565

66-
enum rome_tlv_type {
66+
enum qca_tlv_type {
6767
TLV_TYPE_PATCH = 1,
6868
TLV_TYPE_NVM
6969
};
7070

71-
struct rome_config {
71+
struct qca_fw_config {
7272
u8 type;
7373
char fwname[64];
7474
uint8_t user_baud_rate;
75-
enum rome_tlv_dnld_mode dnld_mode;
76-
enum rome_tlv_dnld_mode dnld_type;
75+
enum qca_tlv_dnld_mode dnld_mode;
76+
enum qca_tlv_dnld_mode dnld_type;
7777
};
7878

7979
struct edl_event_hdr {
@@ -82,10 +82,10 @@ struct edl_event_hdr {
8282
__u8 data[0];
8383
} __packed;
8484

85-
struct rome_version {
85+
struct qca_btsoc_version {
8686
__le32 product_id;
8787
__le16 patch_ver;
88-
__le16 rome_ver;
88+
__le16 rom_ver;
8989
__le32 soc_id;
9090
} __packed;
9191

@@ -125,6 +125,7 @@ enum qca_btsoc_type {
125125
QCA_AR3002,
126126
QCA_ROME,
127127
QCA_WCN3990,
128+
QCA_WCN3991,
128129
QCA_WCN3998,
129130
};
130131

@@ -134,12 +135,14 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
134135
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
135136
enum qca_btsoc_type soc_type, u32 soc_ver,
136137
const char *firmware_name);
137-
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
138+
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
139+
enum qca_btsoc_type);
138140
int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
139141
int qca_send_pre_shutdown_cmd(struct hci_dev *hdev);
140142
static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
141143
{
142-
return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3998;
144+
return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 ||
145+
soc_type == QCA_WCN3998;
143146
}
144147
#else
145148

@@ -155,7 +158,8 @@ static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
155158
return -EOPNOTSUPP;
156159
}
157160

158-
static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
161+
static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version,
162+
enum qca_btsoc_type)
159163
{
160164
return -EOPNOTSUPP;
161165
}

drivers/bluetooth/btrtl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ int btrtl_get_uart_settings(struct hci_dev *hdev,
778778
rtl_dev_dbg(hdev, "skipping config entry 0x%x (len %u)",
779779
le16_to_cpu(entry->offset), entry->len);
780780
break;
781-
};
781+
}
782782

783783
i += sizeof(*entry) + entry->len;
784784
}

drivers/bluetooth/hci_bcm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,7 @@ static const struct of_device_id bcm_bluetooth_of_match[] = {
14241424
{ .compatible = "brcm,bcm4345c5" },
14251425
{ .compatible = "brcm,bcm4330-bt" },
14261426
{ .compatible = "brcm,bcm43438-bt" },
1427+
{ .compatible = "brcm,bcm43540-bt" },
14271428
{ },
14281429
};
14291430
MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);

drivers/bluetooth/hci_bcsp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
591591
if (*ptr == 0xc0) {
592592
BT_ERR("Short BCSP packet");
593593
kfree_skb(bcsp->rx_skb);
594+
bcsp->rx_skb = NULL;
594595
bcsp->rx_state = BCSP_W4_PKT_START;
595596
bcsp->rx_count = 0;
596597
} else
@@ -606,6 +607,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
606607
bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {
607608
BT_ERR("Error in BCSP hdr checksum");
608609
kfree_skb(bcsp->rx_skb);
610+
bcsp->rx_skb = NULL;
609611
bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
610612
bcsp->rx_count = 0;
611613
continue;
@@ -630,6 +632,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
630632
bscp_get_crc(bcsp));
631633

632634
kfree_skb(bcsp->rx_skb);
635+
bcsp->rx_skb = NULL;
633636
bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
634637
bcsp->rx_count = 0;
635638
continue;

0 commit comments

Comments
 (0)