@@ -3251,6 +3251,32 @@ static const struct qca_device_info qca_devices_table[] = {
32513251 { 0x00190200 , 40 , 4 , 16 }, /* WCN785x 2.0 */
32523252};
32533253
3254+ static u16 qca_extract_board_id (const struct qca_version * ver )
3255+ {
3256+ u16 flag = le16_to_cpu (ver -> flag );
3257+ u16 board_id = 0 ;
3258+
3259+ if (((flag >> 8 ) & 0xff ) == QCA_FLAG_MULTI_NVM ) {
3260+ /* The board_id should be split into two bytes
3261+ * The 1st byte is chip ID, and the 2nd byte is platform ID
3262+ * For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID
3263+ * we have several platforms, and platform IDs are continuously added
3264+ * Platform ID:
3265+ * 0x00 is for Mobile
3266+ * 0x01 is for X86
3267+ * 0x02 is for Automotive
3268+ * 0x03 is for Consumer electronic
3269+ */
3270+ board_id = (ver -> chip_id << 8 ) + ver -> platform_id ;
3271+ }
3272+
3273+ /* Take 0xffff as invalid board ID */
3274+ if (board_id == 0xffff )
3275+ board_id = 0 ;
3276+
3277+ return board_id ;
3278+ }
3279+
32543280static int btusb_qca_send_vendor_req (struct usb_device * udev , u8 request ,
32553281 void * data , u16 size )
32563282{
@@ -3407,44 +3433,28 @@ static void btusb_generate_qca_nvm_name(char *fwname, size_t max_size,
34073433 const struct qca_version * ver )
34083434{
34093435 u32 rom_version = le32_to_cpu (ver -> rom_version );
3410- u16 flag = le16_to_cpu (ver -> flag );
3436+ const char * variant ;
3437+ int len ;
3438+ u16 board_id ;
34113439
3412- if (((flag >> 8 ) & 0xff ) == QCA_FLAG_MULTI_NVM ) {
3413- /* The board_id should be split into two bytes
3414- * The 1st byte is chip ID, and the 2nd byte is platform ID
3415- * For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID
3416- * we have several platforms, and platform IDs are continuously added
3417- * Platform ID:
3418- * 0x00 is for Mobile
3419- * 0x01 is for X86
3420- * 0x02 is for Automotive
3421- * 0x03 is for Consumer electronic
3422- */
3423- u16 board_id = (ver -> chip_id << 8 ) + ver -> platform_id ;
3424- const char * variant ;
3440+ board_id = qca_extract_board_id (ver );
34253441
3426- switch (le32_to_cpu (ver -> ram_version )) {
3427- case WCN6855_2_0_RAM_VERSION_GF :
3428- case WCN6855_2_1_RAM_VERSION_GF :
3429- variant = "_gf" ;
3430- break ;
3431- default :
3432- variant = "" ;
3433- break ;
3434- }
3435-
3436- if (board_id == 0 ) {
3437- snprintf (fwname , max_size , "qca/nvm_usb_%08x%s.bin" ,
3438- rom_version , variant );
3439- } else {
3440- snprintf (fwname , max_size , "qca/nvm_usb_%08x%s_%04x.bin" ,
3441- rom_version , variant , board_id );
3442- }
3443- } else {
3444- snprintf (fwname , max_size , "qca/nvm_usb_%08x.bin" ,
3445- rom_version );
3442+ switch (le32_to_cpu (ver -> ram_version )) {
3443+ case WCN6855_2_0_RAM_VERSION_GF :
3444+ case WCN6855_2_1_RAM_VERSION_GF :
3445+ variant = "_gf" ;
3446+ break ;
3447+ default :
3448+ variant = NULL ;
3449+ break ;
34463450 }
34473451
3452+ len = snprintf (fwname , max_size , "qca/nvm_usb_%08x" , rom_version );
3453+ if (variant )
3454+ len += snprintf (fwname + len , max_size - len , "%s" , variant );
3455+ if (board_id )
3456+ len += snprintf (fwname + len , max_size - len , "_%04x" , board_id );
3457+ len += snprintf (fwname + len , max_size - len , ".bin" );
34483458}
34493459
34503460static int btusb_setup_qca_load_nvm (struct hci_dev * hdev ,
0 commit comments