Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btusb: QCA: Support downloading custom-made firmwares

There are custom-made firmwares based on board ID for a given QCA BT
chip sometimes, and they are different with existing firmwares and put
in a separate subdirectory to avoid conflict, for example:
QCA2066, as a variant of WCN6855, has firmwares under 'qca/QCA2066/'
of linux-firmware repository.

Support downloading custom-made firmwares based on a table newly added.

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Zijun Hu and committed by
Luiz Augusto von Dentz
a3f9f6dd 085ee7cf

+49 -5
+49 -5
drivers/bluetooth/btusb.c
··· 3190 3190 u8 ver_offset; /* offset of version structure in rampatch */ 3191 3191 }; 3192 3192 3193 + struct qca_custom_firmware { 3194 + u32 rom_version; 3195 + u16 board_id; 3196 + const char *subdirectory; 3197 + }; 3198 + 3193 3199 static const struct qca_device_info qca_devices_table[] = { 3194 3200 { 0x00000100, 20, 4, 8 }, /* Rome 1.0 */ 3195 3201 { 0x00000101, 20, 4, 8 }, /* Rome 1.1 */ ··· 3207 3201 { 0x00130200, 40, 4, 16 }, /* WCN6855 2.0 */ 3208 3202 { 0x00130201, 40, 4, 16 }, /* WCN6855 2.1 */ 3209 3203 { 0x00190200, 40, 4, 16 }, /* WCN785x 2.0 */ 3204 + }; 3205 + 3206 + static const struct qca_custom_firmware qca_custom_btfws[] = { 3207 + { 0x00130201, 0x030A, "QCA2066" }, 3208 + { }, 3210 3209 }; 3211 3210 3212 3211 static u16 qca_extract_board_id(const struct qca_version *ver) ··· 3238 3227 board_id = 0; 3239 3228 3240 3229 return board_id; 3230 + } 3231 + 3232 + static const char *qca_get_fw_subdirectory(const struct qca_version *ver) 3233 + { 3234 + const struct qca_custom_firmware *ptr; 3235 + u32 rom_ver; 3236 + u16 board_id; 3237 + 3238 + rom_ver = le32_to_cpu(ver->rom_version); 3239 + board_id = qca_extract_board_id(ver); 3240 + if (!board_id) 3241 + return NULL; 3242 + 3243 + for (ptr = qca_custom_btfws; ptr->rom_version; ptr++) { 3244 + if (ptr->rom_version == rom_ver && 3245 + ptr->board_id == board_id) 3246 + return ptr->subdirectory; 3247 + } 3248 + 3249 + return NULL; 3241 3250 } 3242 3251 3243 3252 static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, ··· 3364 3333 { 3365 3334 struct qca_rampatch_version *rver; 3366 3335 const struct firmware *fw; 3336 + const char *fw_subdir; 3367 3337 u32 ver_rom, ver_patch, rver_rom; 3368 3338 u16 rver_rom_low, rver_rom_high, rver_patch; 3369 - char fwname[64]; 3339 + char fwname[80]; 3370 3340 int err; 3371 3341 3372 3342 ver_rom = le32_to_cpu(ver->rom_version); 3373 3343 ver_patch = le32_to_cpu(ver->patch_version); 3374 3344 3375 - snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", ver_rom); 3345 + fw_subdir = qca_get_fw_subdirectory(ver); 3346 + if (fw_subdir) 3347 + snprintf(fwname, sizeof(fwname), "qca/%s/rampatch_usb_%08x.bin", 3348 + fw_subdir, ver_rom); 3349 + else 3350 + snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", 3351 + ver_rom); 3376 3352 3377 3353 err = request_firmware(&fw, fwname, &hdev->dev); 3378 3354 if (err) { ··· 3423 3385 const struct qca_version *ver) 3424 3386 { 3425 3387 u32 rom_version = le32_to_cpu(ver->rom_version); 3426 - const char *variant; 3388 + const char *variant, *fw_subdir; 3427 3389 int len; 3428 3390 u16 board_id; 3429 3391 3392 + fw_subdir = qca_get_fw_subdirectory(ver); 3430 3393 board_id = qca_extract_board_id(ver); 3431 3394 3432 3395 switch (le32_to_cpu(ver->ram_version)) { ··· 3440 3401 break; 3441 3402 } 3442 3403 3443 - len = snprintf(fwname, max_size, "qca/nvm_usb_%08x", rom_version); 3404 + if (fw_subdir) 3405 + len = snprintf(fwname, max_size, "qca/%s/nvm_usb_%08x", 3406 + fw_subdir, rom_version); 3407 + else 3408 + len = snprintf(fwname, max_size, "qca/nvm_usb_%08x", 3409 + rom_version); 3444 3410 if (variant) 3445 3411 len += snprintf(fwname + len, max_size - len, "%s", variant); 3446 3412 if (board_id) ··· 3458 3414 const struct qca_device_info *info) 3459 3415 { 3460 3416 const struct firmware *fw; 3461 - char fwname[64]; 3417 + char fwname[80]; 3462 3418 int err; 3463 3419 3464 3420 btusb_generate_qca_nvm_name(fwname, sizeof(fwname), ver);