Skip to content

Commit 4301595

Browse files
zijun-huVudentz
authored andcommitted
Bluetooth: btusb: QCA: Fix downloading wrong NVM for WCN6855 GF variant without board ID
For GF variant of WCN6855 without board ID programmed btusb_generate_qca_nvm_name() will chose wrong NVM 'qca/nvm_usb_00130201.bin' to download. Fix by choosing right NVM 'qca/nvm_usb_00130201_gf.bin'. Also simplify NVM choice logic of btusb_generate_qca_nvm_name(). Fixes: d6cba4e ("Bluetooth: btusb: Add support using different nvm for variant WCN6855 controller") Signed-off-by: Zijun Hu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 6851a0c commit 4301595

File tree

1 file changed

+44
-34
lines changed

1 file changed

+44
-34
lines changed

drivers/bluetooth/btusb.c

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,6 +3192,32 @@ static const struct qca_device_info qca_devices_table[] = {
31923192
{ 0x00190200, 40, 4, 16 }, /* WCN785x 2.0 */
31933193
};
31943194

3195+
static u16 qca_extract_board_id(const struct qca_version *ver)
3196+
{
3197+
u16 flag = le16_to_cpu(ver->flag);
3198+
u16 board_id = 0;
3199+
3200+
if (((flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
3201+
/* The board_id should be split into two bytes
3202+
* The 1st byte is chip ID, and the 2nd byte is platform ID
3203+
* For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID
3204+
* we have several platforms, and platform IDs are continuously added
3205+
* Platform ID:
3206+
* 0x00 is for Mobile
3207+
* 0x01 is for X86
3208+
* 0x02 is for Automotive
3209+
* 0x03 is for Consumer electronic
3210+
*/
3211+
board_id = (ver->chip_id << 8) + ver->platform_id;
3212+
}
3213+
3214+
/* Take 0xffff as invalid board ID */
3215+
if (board_id == 0xffff)
3216+
board_id = 0;
3217+
3218+
return board_id;
3219+
}
3220+
31953221
static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request,
31963222
void *data, u16 size)
31973223
{
@@ -3348,44 +3374,28 @@ static void btusb_generate_qca_nvm_name(char *fwname, size_t max_size,
33483374
const struct qca_version *ver)
33493375
{
33503376
u32 rom_version = le32_to_cpu(ver->rom_version);
3351-
u16 flag = le16_to_cpu(ver->flag);
3377+
const char *variant;
3378+
int len;
3379+
u16 board_id;
33523380

3353-
if (((flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
3354-
/* The board_id should be split into two bytes
3355-
* The 1st byte is chip ID, and the 2nd byte is platform ID
3356-
* For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID
3357-
* we have several platforms, and platform IDs are continuously added
3358-
* Platform ID:
3359-
* 0x00 is for Mobile
3360-
* 0x01 is for X86
3361-
* 0x02 is for Automotive
3362-
* 0x03 is for Consumer electronic
3363-
*/
3364-
u16 board_id = (ver->chip_id << 8) + ver->platform_id;
3365-
const char *variant;
3381+
board_id = qca_extract_board_id(ver);
33663382

3367-
switch (le32_to_cpu(ver->ram_version)) {
3368-
case WCN6855_2_0_RAM_VERSION_GF:
3369-
case WCN6855_2_1_RAM_VERSION_GF:
3370-
variant = "_gf";
3371-
break;
3372-
default:
3373-
variant = "";
3374-
break;
3375-
}
3376-
3377-
if (board_id == 0) {
3378-
snprintf(fwname, max_size, "qca/nvm_usb_%08x%s.bin",
3379-
rom_version, variant);
3380-
} else {
3381-
snprintf(fwname, max_size, "qca/nvm_usb_%08x%s_%04x.bin",
3382-
rom_version, variant, board_id);
3383-
}
3384-
} else {
3385-
snprintf(fwname, max_size, "qca/nvm_usb_%08x.bin",
3386-
rom_version);
3383+
switch (le32_to_cpu(ver->ram_version)) {
3384+
case WCN6855_2_0_RAM_VERSION_GF:
3385+
case WCN6855_2_1_RAM_VERSION_GF:
3386+
variant = "_gf";
3387+
break;
3388+
default:
3389+
variant = NULL;
3390+
break;
33873391
}
33883392

3393+
len = snprintf(fwname, max_size, "qca/nvm_usb_%08x", rom_version);
3394+
if (variant)
3395+
len += snprintf(fwname + len, max_size - len, "%s", variant);
3396+
if (board_id)
3397+
len += snprintf(fwname + len, max_size - len, "_%04x", board_id);
3398+
len += snprintf(fwname + len, max_size - len, ".bin");
33893399
}
33903400

33913401
static int btusb_setup_qca_load_nvm(struct hci_dev *hdev,

0 commit comments

Comments
 (0)