Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1247464pxb; Wed, 4 Nov 2020 04:05:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3vgesMjNdwSkHkzf4D8Cc05YvwUt0/Z7CJnH9Sx8Gqdu/N0u0FgQjqKhWDWbtJS21hfc/ X-Received: by 2002:a17:906:cd0f:: with SMTP id oz15mr24822872ejb.200.1604491528275; Wed, 04 Nov 2020 04:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604491528; cv=none; d=google.com; s=arc-20160816; b=GIzQ56jk1Sv9obk9IBnyCbpyrovf74KrEw9XlXkse4O+jV1Pqz7tyh13nrhY5k2ujD lK66JdOIEyLoW/9MQ6ICtt1u5gQ4PDRlm/y7ZRKGlaZuuPS5liPynUEpiJ6YSei2HKjE vS9TbY9Pb9/KhzHoyQxuDnTqD6olPExGtnF/m1pThCjEWGnWOMV70czH5EQuD7eoYPxG 7kks0zEXbN3qHBUlZ0/TZs/HRDSVX1U39EaTw9kPuV9HHvQOzQa09G+FKhG5ZtGhdVzg sL216+1bAuV6ltwUQNEQa/COWrksCiq8tFoj9C2nZo2CZNLwuPtG58YM18kZpmvGcC5e 0K8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :authenticated-by; bh=n/rz4k5dCEAs/JxVkRuX6W29OFTS40QKoxlxj8Rpqb0=; b=x7Jc2sMWUpvDsBm+yomR9X0V698zymNGwyQVaqf+5welcgooxrqu0kDKwqrDfxbwX4 oiqJqnV7WrolZep3CjNUYfKI6Y+ny2XCeYMrft6U754i1yosw98nDt6cI/u953uSe1sn V6JpspZAdhtWNRZwGmHs5LFak3pOrnFZDa/FrVtIk6+BRjMhNHYiw8yOU8Dj0IgaLYOx jEflS7fIbIhgBG0Bt4RX4MlVO8NKiLm3CNbHYIyEVD/IhA6n3Lb7OGWmxraSmyJPjTSW SxDI9IkSf9ELLLMutd64QbC6UYV/PKptbnM40zI9pYpFEkadkO2UwoKDm7oRrndRsHDB 1zdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si1478628eji.143.2020.11.04.04.04.45; Wed, 04 Nov 2020 04:05:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728523AbgKDME3 (ORCPT + 99 others); Wed, 4 Nov 2020 07:04:29 -0500 Received: from rtits2.realtek.com ([211.75.126.72]:39303 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbgKDME2 (ORCPT ); Wed, 4 Nov 2020 07:04:28 -0500 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 0A4C4IES0003516, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb01.realtek.com.tw[172.21.6.94]) by rtits2.realtek.com.tw (8.15.2/2.70/5.88) with ESMTPS id 0A4C4IES0003516 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 4 Nov 2020 20:04:18 +0800 Received: from RTEXMBS03.realtek.com.tw (172.21.6.34) by RTEXMB01.realtek.com.tw (172.21.6.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Wed, 4 Nov 2020 20:04:18 +0800 Received: from localhost.localdomain (172.21.132.186) by RTEXMBS03.realtek.com.tw (172.21.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 4 Nov 2020 20:04:18 +0800 From: To: , , , , , CC: , Subject: [PATCH] Bluetooth: btrtl: Refine the ic_id_table for clearer and more regular Date: Wed, 4 Nov 2020 20:04:14 +0800 Message-ID: <20201104120414.12772-1-max.chou@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.132.186] X-ClientProxiedBy: RTEXMB03.realtek.com.tw (172.21.6.96) To RTEXMBS03.realtek.com.tw (172.21.6.34) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Max Chou Enhance the ic_id_table that it's able to maintain regularly. To judge which chip should be initialized by LMP subversion, HCI revision, HCI version and HCI bus which were given in the ic_id_table. Also, refine the incorrect LMP subversion of ROM for RTL8723D and RTL8723A. Suggested-by: Alex Lu Signed-off-by: Max Chou --- drivers/bluetooth/btrtl.c | 65 ++++++++++++--------------------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 3a9afc905f24..1ab9f27e4fa7 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -18,10 +18,8 @@ #define VERSION "0.1" #define RTL_EPATCH_SIGNATURE "Realtech" -#define RTL_ROM_LMP_3499 0x3499 #define RTL_ROM_LMP_8723A 0x1200 #define RTL_ROM_LMP_8723B 0x8723 -#define RTL_ROM_LMP_8723D 0x8873 #define RTL_ROM_LMP_8821A 0x8821 #define RTL_ROM_LMP_8761A 0x8761 #define RTL_ROM_LMP_8822B 0x8822 @@ -31,10 +29,13 @@ #define IC_MATCH_FL_HCIREV (1 << 1) #define IC_MATCH_FL_HCIVER (1 << 2) #define IC_MATCH_FL_HCIBUS (1 << 3) -#define IC_INFO(lmps, hcir) \ - .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV, \ +#define IC_INFO(lmps, hcir, hciv, bus) \ + .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV | \ + IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS, \ .lmp_subver = (lmps), \ - .hci_rev = (hcir) + .hci_rev = (hcir), \ + .hci_ver = (hciv), \ + .hci_bus = (bus) struct id_table { __u16 match_flags; @@ -58,112 +59,85 @@ struct btrtl_device_info { }; static const struct id_table ic_id_table[] = { - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_8723A, 0x0, - .config_needed = false, - .has_rom_version = false, - .fw_name = "rtl_bt/rtl8723a_fw.bin", - .cfg_name = NULL }, - - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_3499, 0x0, + /* 8723A */ + { IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB), .config_needed = false, .has_rom_version = false, .fw_name = "rtl_bt/rtl8723a_fw.bin", .cfg_name = NULL }, /* 8723BS */ - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV | - IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS, - .lmp_subver = RTL_ROM_LMP_8723B, - .hci_rev = 0xb, - .hci_ver = 6, - .hci_bus = HCI_UART, + { IC_INFO(RTL_ROM_LMP_8723B, 0xb, 0x6, HCI_UART), .config_needed = true, .has_rom_version = true, .fw_name = "rtl_bt/rtl8723bs_fw.bin", .cfg_name = "rtl_bt/rtl8723bs_config" }, /* 8723B */ - { IC_INFO(RTL_ROM_LMP_8723B, 0xb), + { IC_INFO(RTL_ROM_LMP_8723B, 0xb, 0x6, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8723b_fw.bin", .cfg_name = "rtl_bt/rtl8723b_config" }, /* 8723D */ - { IC_INFO(RTL_ROM_LMP_8723B, 0xd), + { IC_INFO(RTL_ROM_LMP_8723B, 0xd, 0x8, HCI_USB), .config_needed = true, .has_rom_version = true, .fw_name = "rtl_bt/rtl8723d_fw.bin", .cfg_name = "rtl_bt/rtl8723d_config" }, /* 8723DS */ - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV | - IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS, - .lmp_subver = RTL_ROM_LMP_8723B, - .hci_rev = 0xd, - .hci_ver = 8, - .hci_bus = HCI_UART, + { IC_INFO(RTL_ROM_LMP_8723B, 0xd, 0x8, HCI_UART), .config_needed = true, .has_rom_version = true, .fw_name = "rtl_bt/rtl8723ds_fw.bin", .cfg_name = "rtl_bt/rtl8723ds_config" }, - /* 8723DU */ - { IC_INFO(RTL_ROM_LMP_8723D, 0x826C), - .config_needed = true, - .has_rom_version = true, - .fw_name = "rtl_bt/rtl8723d_fw.bin", - .cfg_name = "rtl_bt/rtl8723d_config" }, - /* 8821A */ - { IC_INFO(RTL_ROM_LMP_8821A, 0xa), + { IC_INFO(RTL_ROM_LMP_8821A, 0xa, 0x6, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8821a_fw.bin", .cfg_name = "rtl_bt/rtl8821a_config" }, /* 8821C */ - { IC_INFO(RTL_ROM_LMP_8821A, 0xc), + { IC_INFO(RTL_ROM_LMP_8821A, 0xc, 0x8, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8821c_fw.bin", .cfg_name = "rtl_bt/rtl8821c_config" }, /* 8761A */ - { IC_INFO(RTL_ROM_LMP_8761A, 0xa), + { IC_INFO(RTL_ROM_LMP_8761A, 0xa, 0x6, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8761a_fw.bin", .cfg_name = "rtl_bt/rtl8761a_config" }, /* 8761B */ - { IC_INFO(RTL_ROM_LMP_8761A, 0xb), + { IC_INFO(RTL_ROM_LMP_8761A, 0xb, 0xa, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8761b_fw.bin", .cfg_name = "rtl_bt/rtl8761b_config" }, /* 8822C with UART interface */ - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV | - IC_MATCH_FL_HCIBUS, - .lmp_subver = RTL_ROM_LMP_8822B, - .hci_rev = 0x000c, - .hci_ver = 0x0a, - .hci_bus = HCI_UART, + { IC_INFO(RTL_ROM_LMP_8822B, 0xc, 0xa, HCI_UART), .config_needed = true, .has_rom_version = true, .fw_name = "rtl_bt/rtl8822cs_fw.bin", .cfg_name = "rtl_bt/rtl8822cs_config" }, /* 8822C with USB interface */ - { IC_INFO(RTL_ROM_LMP_8822B, 0xc), + { IC_INFO(RTL_ROM_LMP_8822B, 0xc, 0xa, HCI_USB), .config_needed = false, .has_rom_version = true, .fw_name = "rtl_bt/rtl8822cu_fw.bin", .cfg_name = "rtl_bt/rtl8822cu_config" }, /* 8822B */ - { IC_INFO(RTL_ROM_LMP_8822B, 0xb), + { IC_INFO(RTL_ROM_LMP_8822B, 0xb, 0x7, HCI_USB), .config_needed = true, .has_rom_version = true, .fw_name = "rtl_bt/rtl8822b_fw.bin", @@ -654,7 +628,6 @@ int btrtl_download_firmware(struct hci_dev *hdev, switch (btrtl_dev->ic_info->lmp_subver) { case RTL_ROM_LMP_8723A: - case RTL_ROM_LMP_3499: return btrtl_setup_rtl8723a(hdev, btrtl_dev); case RTL_ROM_LMP_8723B: case RTL_ROM_LMP_8821A: -- 2.17.1