From patchwork Thu Oct 19 11:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13428712 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37534C41513 for ; Thu, 19 Oct 2023 11:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345488AbjJSL7W (ORCPT ); Thu, 19 Oct 2023 07:59:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345485AbjJSL7U (ORCPT ); Thu, 19 Oct 2023 07:59:20 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2058.outbound.protection.outlook.com [40.92.98.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C808B13E for ; Thu, 19 Oct 2023 04:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=As+qEO0GFsciQmMTaXDok+YuXTUJGu6W7z3yfgEm7zuEt9lsapt2PFiUKANNEpF42d9qIx5QAHEQf9/SFlM3zk3JvF2pI0BjVjRmSNJGPZ1qieOdZ1SgB0I6BDyo0DmakFLzvw6saQ79geTty2/q2oKUiW+lkAYtubYilTi7JmgYep8EKXfJtV/xEAlVkjfnRwfpd7VkhGoyL9HAg815YR+wWhnIWhklBnPm+OUac1LppgGvdPqfbyjcm4U93HxezXyjR8P02qwkcP1/e4b34rAuUld9ZKPMg7i2bLzilqxl3i0zfZMy31oc5+u6F5VN9h5vcpbwy40AVoKRryrrIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4PYELlLRj/GVS7zUmN1Ca4BFDWB26dSlU0wtnSPSaKs=; b=McyCCvWKeRUPnGj+3Ij82HLKdRtummpncDAsXTaw+tZBTx80a73ao5eik7deexhLtE79dlULSuuEFWPFM6HirYr3gx2SKMD9yG9MBZIzudNqrCqAM2wB/jpizC6xdEJH64k3sgY4jOMok1QVlSscFBq1XApaF3jbpDcrKqlAUVzydCO/nCCRrxh2oYsAwZAl4iqHNZojA8wk+nqwKUReku1SFupiU2EYuliBIZvS0DEpWLfN2qXT80I67pvhJKJQuH5CgJED7dLXdp4suaFZFmqCv5OKF08QMDCwwaGdqEBz6y1FC+4kW+wj5AlYyxSB51jFTchPPUl2ICAfdigMWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4PYELlLRj/GVS7zUmN1Ca4BFDWB26dSlU0wtnSPSaKs=; b=Xum7TdtH33wYTO+8l+sv33vq7nJelyzEfVprgElAHl9DW0kyGUqTV4UXvMiAGoKsf8jdRsQsbLLZpLFQjpPWKny3+t0sDI12q+lMO0p2eE4F4tI3itEMHB9dMwIpyHXmof6yMrP12D6c5MbO5r07QVYRy9pS0kt9264CGoluPNIkPf9lTCk3eayg6mazQdP6aCvCRmhFx4NLhjOt/IcYbfrBpLwJ0vatRoyfnMWg7DeuviuVZqsylj/5NBn8cYfD+9oBqwbauKsdkuktTmAJZPJWDEVW5xneZZJHucP0zOXnQlljzfC6zEjFDHsd/5ly0AnvN7oW01ibtpymoifSPQ== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYWP286MB2729.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:24c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Thu, 19 Oct 2023 11:59:15 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b%6]) with mapi id 15.20.6907.022; Thu, 19 Oct 2023 11:59:15 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH V2 1/3] wifi: rt2x00: improve MT7620 register initialization Date: Thu, 19 Oct 2023 19:58:56 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019115859.2791-1-yangshiji66@outlook.com> References: <20231019115859.2791-1-yangshiji66@outlook.com> X-TMN: [LusD4yKUbCMe3Iu74XrVn5segyZkGUhi] X-ClientProxiedBy: TYCPR01CA0196.jpnprd01.prod.outlook.com (2603:1096:405:7a::20) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231019115859.2791-2-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYWP286MB2729:EE_ X-MS-Office365-Filtering-Correlation-Id: 75f82d3f-bf13-4c48-3be7-08dbd09ad0d2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YAJLQwSB/6rn9vaz7Cq3Lz/SUECBZQ1Em5nor7REHw3go0iaa1ZOpW0NESLUtDMTTuHfcH4RMx3EksADC6+AfMqjrxbCKf/4ferOz0Y+14WQGIZBitrGNNeYSJE3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JhV+IY2bGSJ3nLCRJ7D+Lqrfka1TixRrtzcPtmDvngeF4k+yeXUcJIzE6cvJuw+X64H77+xuzY9jNFpB+xH3zY9BQL4yltV7g79NuelMeN9iuuuRGizUyYQtaO/Oa6fXKZs4SYYgO2uw3KqB1m3WyrvOA7eQAzx7EEZHUff8RLLGTrEDw0XsGAHP2zFpw24VLPTMLCL8ldp/jjKV7SC6S7dh960Jd5qWxHlTMk5B/ZfugeLjO0mlPJyx5WkXzHwEwDzBvFockhCIUdQw97XPweqDNBPEDtCqD9REKS4YF+VmPzcDA9dgzuKA6iEGVpMGG4S3+SN6l5+aCwZwxOV6+aO1tDsBx4DLVtc7wNWeRakueQl0qXv4lgAugNU9StUqKs+xenZt+xrK3mcItX7LNavYyhzq5YRz6WnOhTJI+UbvaRGa0qR3rNpW9NQlSURF2GDh+OIz2bK+O2IaUX/IHumy62NUWOeXGD7gUkGPzxlaXUg0tEWD/5JgIDP0vbUkRk3toZqS21OkA2/HE/mrG2cerweuracuSeChnCjiim0q59M6Inv4nQBvUYQW7hgQv1tvw0KNY7PR8+T9mX99w9ZK8DBIGTHhTfGKkC2wNG3n1pSwITDL0aNZ6yzgs2FbXgJ4Xe4XvRU3+hvUKV+HaOertw5CZutmJz3vj4OEWhavSiUZcqioVQyEG47/Ke6JjRGS9up/m+u6n01a9axfSrudr+PlElv4TeRfy7YwPGb2DSaEVT6lMU1TO2Nw= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75f82d3f-bf13-4c48-3be7-08dbd09ad0d2 X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 11:59:15.7683 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB2729 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 1. Do not hard reset the BBP. We can use soft reset instead. This change has some help to the calibration failure issue. 2. Enable falling back to legacy rate from the HT/RTS rate by setting the HT_FBK_TO_LEGACY register. 3. Implement MCS rate specific maximum PSDU size. It can improve the transmission quality under the low RSSI condition. 4. Set BBP_84 register value to 0x19. This is used for extension channel overlapping IOT. Signed-off-by: Shiji Yang Acked-by: Stanislaw Gruszka --- drivers/net/wireless/ralink/rt2x00/rt2800.h | 18 ++++++++++++++ .../net/wireless/ralink/rt2x00/rt2800lib.c | 24 +++++++++++++++++++ .../net/wireless/ralink/rt2x00/rt2800mmio.c | 3 +++ 3 files changed, 45 insertions(+) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h index de2ee5ffc..48521e455 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h @@ -870,6 +870,18 @@ #define LED_CFG_Y_LED_MODE FIELD32(0x30000000) #define LED_CFG_LED_POLAR FIELD32(0x40000000) +/* + * AMPDU_MAX_LEN_20M1S: Per MCS max A-MPDU length, 20 MHz, MCS 0-7 + * AMPDU_MAX_LEN_20M2S: Per MCS max A-MPDU length, 20 MHz, MCS 8-15 + * AMPDU_MAX_LEN_40M1S: Per MCS max A-MPDU length, 40 MHz, MCS 0-7 + * AMPDU_MAX_LEN_40M2S: Per MCS max A-MPDU length, 40 MHz, MCS 8-15 + * Maximum A-MPDU length = 2^(AMPDU_MAX - 5) kilobytes + */ +#define AMPDU_MAX_LEN_20M1S 0x1030 +#define AMPDU_MAX_LEN_20M2S 0x1034 +#define AMPDU_MAX_LEN_40M1S 0x1038 +#define AMPDU_MAX_LEN_40M2S 0x103C + /* * AMPDU_BA_WINSIZE: Force BlockAck window size * FORCE_WINSIZE_ENABLE: @@ -1545,6 +1557,12 @@ */ #define EXP_ACK_TIME 0x1380 +/* + * HT_FBK_TO_LEGACY: Enable/Disable HT/RTS fallback to OFDM/CCK rate + * Not available for legacy SoCs + */ +#define HT_FBK_TO_LEGACY 0x1384 + /* TX_PWR_CFG_5 */ #define TX_PWR_CFG_5 0x1384 #define TX_PWR_CFG_5_MCS16_CH0 FIELD32(0x0000000f) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index 7fb9bc83b..08d979f69 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -5903,6 +5903,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u32 reg; u16 eeprom; + u8 bbp; unsigned int i; int ret; @@ -5912,6 +5913,19 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) if (ret) return ret; + if (rt2x00_rt(rt2x00dev, RT6352)) { + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x01); + + bbp = rt2800_bbp_read(rt2x00dev, 21); + bbp |= 0x01; + rt2800_bbp_write(rt2x00dev, 21, bbp); + bbp = rt2800_bbp_read(rt2x00dev, 21); + bbp &= (~0x01); + rt2800_bbp_write(rt2x00dev, 21, bbp); + + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00); + } + rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f); rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003); @@ -6065,6 +6079,14 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) reg = rt2800_register_read(rt2x00dev, TX_ALC_CFG_1); rt2x00_set_field32(®, TX_ALC_CFG_1_ROS_BUSY_EN, 0); rt2800_register_write(rt2x00dev, TX_ALC_CFG_1, reg); + + rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_20M1S, 0x77754433); + rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_20M2S, 0x77765543); + rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_40M1S, 0x77765544); + rt2800_register_write(rt2x00dev, AMPDU_MAX_LEN_40M2S, 0x77765544); + + rt2800_register_write(rt2x00dev, HT_FBK_TO_LEGACY, 0x1010); + } else { rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000); rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); @@ -7283,6 +7305,8 @@ static void rt2800_init_bbp_6352(struct rt2x00_dev *rt2x00dev) rt2800_bbp_dcoc_write(rt2x00dev, 159, 0x64); rt2800_bbp4_mac_if_ctrl(rt2x00dev); + + rt2800_bbp_write(rt2x00dev, 84, 0x19); } static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c index 862098f75..5323acff9 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c @@ -760,6 +760,9 @@ int rt2800mmio_init_registers(struct rt2x00_dev *rt2x00dev) rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); + if (rt2x00_rt(rt2x00dev, RT6352)) + return 0; + reg = 0; rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); From patchwork Thu Oct 19 11:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13428713 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23F85CDB484 for ; Thu, 19 Oct 2023 11:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345512AbjJSL7X (ORCPT ); Thu, 19 Oct 2023 07:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345477AbjJSL7V (ORCPT ); Thu, 19 Oct 2023 07:59:21 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2058.outbound.protection.outlook.com [40.92.98.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D489F183 for ; Thu, 19 Oct 2023 04:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NtTAxwA2+NVojwbnYq78SmBU1Oat2G4jierVdg6TqHqINleHAG9RmZgHoX65hbumdHUrNEF2yRFAak5vEhlF6f8DRt9VH4CE5sBuq4X6zPVz61s9txZgAWNsxvEk+1HabtR/bmYjeCJQySvWOXzcnn8CS5B31Xtat7fOZaETcclMTVSvDcRdsy2/wEj0eOzhPX6eQvlwBiVGo6Xrn1QhZc3CUSVgCwZlv8EhtJaJ1jHwXoKwVfv7N65QyC0ugSpdkY2wmiKZlgz8rrm4kO/RuHcVMCdJfMB2DnNFjoGa2wZJpTDSvKUTiAtMAus4spVFrs6exk90UnVCKi76T+UEnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YO4duBB9v3ePuxDiJ+DMqt+mufiWbRvk3TlCGAbF5hE=; b=M2S6m0agKTXvIUpOfqmqI+oQR2Ahv3IS35U0IMv21w3B3xAZ0utyt/VB8pLavGZt+j3+gUdMtkhyjzdFARFXJGExUlbWREGvELUGqyCNrdRgJ9wrsq5SBY+Z9p9NewwL/G43Iz7mP/uXar41cyqgQRAqwBCArKfVZi+BKotRSU/GEYEZjnABmHVH1BCvmj9cfonBAfbJpihR5ch14ACPsl6TznztGafNpxb130PtF2r6L5fgfMvgiMJni1Gn6v3Epajl5qoFUQmaacKAv2eDZRipg8JHBXwgLBmk2EKAxtRiC346c7V3hvSBaAqHDZ6G8N+Ia+laCeN/2nlHZe2lYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YO4duBB9v3ePuxDiJ+DMqt+mufiWbRvk3TlCGAbF5hE=; b=f1nILYjxzXbkIc3wFchacucJYUdLDwP2dtPhESk+T1BOALb/Jv9iTH0HLGH2dyURucGnb4gDp3Wa6K5foO487GcCSfqoe4RMZhovtMFAanna5hSEyWKwHc5Yg0NdoZZ+QNpLPt4S/yAeSaeoZHbN9KTC849HvWTobslr6HVASrJj/qQwvNwFYEvy76++FVxj1ZQuBkwKBkuGXdBCd9PIpJS4j3APDxFOTw0QyfShjLUZ2tn+dUP4vRzPw8cuoV/aguyL1JDxGhgCL6Q9diWAFdVsqRofr6Dkxg3NwMJraAl2gErS204WicL5fRcVmfbb7n1YVZCNXuihhSTK3iiOEQ== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYWP286MB2729.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:24c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Thu, 19 Oct 2023 11:59:17 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b%6]) with mapi id 15.20.6907.022; Thu, 19 Oct 2023 11:59:17 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH V2 2/3] wifi: rt2x00: rework MT7620 channel config function Date: Thu, 19 Oct 2023 19:58:57 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019115859.2791-1-yangshiji66@outlook.com> References: <20231019115859.2791-1-yangshiji66@outlook.com> X-TMN: [ytzwQs3hrZpEtWKw1jONlmdpbsKQsQAM] X-ClientProxiedBy: TYCPR01CA0196.jpnprd01.prod.outlook.com (2603:1096:405:7a::20) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231019115859.2791-3-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYWP286MB2729:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c166a8a-e748-4f83-0be1-08dbd09ad201 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9cgpoRPfOV1wYJSKz0euzhH2UBSzkldpjHq7JiQIGNDCNM6I57GUVJhRiByKHQ/nTnmlborawokAAlVWF/7vBcH3uX9KZzxzkqkAjzofMut9evLXZ8IslsszRhLNPvPRMzAveYiZicjJXkgWIw8DBdvTyfE9+BcaIH3rezi3hyOgYdGT7vSFuGt9VFoxrbOVCH0cpa0p+zaEPVdCcput6TeGxINGIhmm1UdElqvZRVJ88cLOW+UdAw2U5JgIhn0pw8l2xSRPT+KPSWorbs+IPl9oBz7X8AAeNgl+pp9r9e20mCeQP7omNXs747zDduQzdDrgwUqlgclb2xGLIbdU9F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0X6cBwmWQR2jmu/5/m06ypR9ukOjN5Ucp/batWzbEVISYPpeahZnrM2s00J4V7Z+LNNow+rgrjNLZBGm73smfRvIapXeTzPTm2P+gpNYcv8guEHZ9s+MYIbKp6pYUcGI4Xe7j/JiRW6OJ7SQlRhIuOl8JwLWo9vr6k4Wx5vkSpRufVpDB+j/uCV0FeV3GyaZMYH1lfHaJN1X7laXZGwXz6wFxQ80l2wsVRw1QErWgvAgXLv1JlboKYJqfTH7oBH1Y4ALeK8v3+gLQDMbOTyeKJhTQdsqfSWpjDQ5Y2Kq1H5C5lyxdKjomsgZS6LapTkxleqtCjBDk41W2WcUbjg/ImhkSHixXQIRDQj1l0kpM20+sAyj6MVbNj9/VhTKTei+Mmp2YNubdVeaYdgBq8hmfaCSKTavY3CNjQU7AjL2cnRL2NqAYMLWo/OEXIDHFIofJAjuM5aKljLd4KnwrkCW+bOqlNs4tmhA0iSuOxQUfkm6Q5ZZcWeCn/V7i1y0nODKNf8i6fB6X1nM= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c166a8a-e748-4f83-0be1-08dbd09ad201 X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 11:59:17.6605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB2729 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 1. Move the channel configuration code from rt2800_vco_calibration() to the rt2800_config_channel(). 2. Use MT7620 SoC specific AGC initial LNA value instead of the RT5592's value. 3. BBP{195,196} pairing write has been replaced with rt2800_bbp_glrt_write() to reduce redundant code. Signed-off-by: Shiji Yang Acked-by: Stanislaw Gruszka --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 91 +++++++------------ 1 file changed, 35 insertions(+), 56 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index 08d979f69..66ee50320 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -3913,14 +3913,6 @@ static void rt2800_config_channel_rf7620(struct rt2x00_dev *rt2x00dev, rfcsr |= tx_agc_fc; rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); } - - if (conf_is_ht40(conf)) { - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10); - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f); - } else { - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a); - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40); - } } static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev, @@ -4489,32 +4481,46 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, usleep_range(1000, 1500); } - if (rt2x00_rt(rt2x00dev, RT5592) || rt2x00_rt(rt2x00dev, RT6352)) { - reg = 0x10; - if (!conf_is_ht40(conf)) { - if (rt2x00_rt(rt2x00dev, RT6352) && - rt2x00_has_cap_external_lna_bg(rt2x00dev)) { - reg |= 0x5; - } else { - reg |= 0xa; - } - } - rt2800_bbp_write(rt2x00dev, 195, 141); - rt2800_bbp_write(rt2x00dev, 196, reg); + if (rt2x00_rt(rt2x00dev, RT5592)) { + bbp = conf_is_ht40(conf) ? 0x10 : 0x1a; + rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); - /* AGC init. - * Despite the vendor driver using different values here for - * RT6352 chip, we use 0x1c for now. This may have to be changed - * once TSSI got implemented. - */ - reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + bbp = (rf->channel <= 14 ? 0x1c : 0x24) + 2 * rt2x00dev->lna_gain; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); - if (rt2x00_rt(rt2x00dev, RT5592)) - rt2800_iq_calibrate(rt2x00dev, rf->channel); + rt2800_iq_calibrate(rt2x00dev, rf->channel); } if (rt2x00_rt(rt2x00dev, RT6352)) { + /* BBP for GLRT BW */ + bbp = conf_is_ht40(conf) ? + 0x10 : rt2x00_has_cap_external_lna_bg(rt2x00dev) ? + 0x15 : 0x1a; + rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); + + bbp = conf_is_ht40(conf) ? 0x2f : 0x40; + rt2800_bbp_glrt_write(rt2x00dev, 157, bbp); + + if (rt2x00dev->default_ant.rx_chain_num == 1) { + rt2800_bbp_write(rt2x00dev, 91, 0x07); + rt2800_bbp_write(rt2x00dev, 95, 0x1a); + rt2800_bbp_glrt_write(rt2x00dev, 128, 0xa0); + rt2800_bbp_glrt_write(rt2x00dev, 170, 0x12); + rt2800_bbp_glrt_write(rt2x00dev, 171, 0x10); + } else { + rt2800_bbp_write(rt2x00dev, 91, 0x06); + rt2800_bbp_write(rt2x00dev, 95, 0x9a); + rt2800_bbp_glrt_write(rt2x00dev, 128, 0xe0); + rt2800_bbp_glrt_write(rt2x00dev, 170, 0x30); + rt2800_bbp_glrt_write(rt2x00dev, 171, 0x30); + } + + /* AGC init */ + bbp = rf->channel <= 14 ? 0x04 + 2 * rt2x00dev->lna_gain : 0; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); + + usleep_range(1000, 1500); + if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); @@ -5660,26 +5666,6 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); if (rt2x00_rt(rt2x00dev, RT6352)) { - if (rt2x00dev->default_ant.rx_chain_num == 1) { - rt2800_bbp_write(rt2x00dev, 91, 0x07); - rt2800_bbp_write(rt2x00dev, 95, 0x1A); - rt2800_bbp_write(rt2x00dev, 195, 128); - rt2800_bbp_write(rt2x00dev, 196, 0xA0); - rt2800_bbp_write(rt2x00dev, 195, 170); - rt2800_bbp_write(rt2x00dev, 196, 0x12); - rt2800_bbp_write(rt2x00dev, 195, 171); - rt2800_bbp_write(rt2x00dev, 196, 0x10); - } else { - rt2800_bbp_write(rt2x00dev, 91, 0x06); - rt2800_bbp_write(rt2x00dev, 95, 0x9A); - rt2800_bbp_write(rt2x00dev, 195, 128); - rt2800_bbp_write(rt2x00dev, 196, 0xE0); - rt2800_bbp_write(rt2x00dev, 195, 170); - rt2800_bbp_write(rt2x00dev, 196, 0x30); - rt2800_bbp_write(rt2x00dev, 195, 171); - rt2800_bbp_write(rt2x00dev, 196, 0x30); - } - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { rt2800_bbp_write(rt2x00dev, 75, 0x68); rt2800_bbp_write(rt2x00dev, 76, 0x4C); @@ -5687,13 +5673,6 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) rt2800_bbp_write(rt2x00dev, 80, 0x0C); rt2800_bbp_write(rt2x00dev, 82, 0xB6); } - - /* On 11A, We should delay and wait RF/BBP to be stable - * and the appropriate time should be 1000 micro seconds - * 2005/06/05 - On 11G, we also need this delay time. - * Otherwise it's difficult to pass the WHQL. - */ - usleep_range(1000, 1500); } } EXPORT_SYMBOL_GPL(rt2800_vco_calibration); From patchwork Thu Oct 19 11:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13428714 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A20DFCDB465 for ; Thu, 19 Oct 2023 11:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345477AbjJSL7Z (ORCPT ); Thu, 19 Oct 2023 07:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345510AbjJSL7X (ORCPT ); Thu, 19 Oct 2023 07:59:23 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2058.outbound.protection.outlook.com [40.92.98.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B8FFBE for ; Thu, 19 Oct 2023 04:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jl2kzNCJgHvTMM5FPYZ/ji1Qt2/TSAPSonaVU6EWaCKLr1izWOb7Vqqx7YhM4W0i+qGVa7qxvidghn8zJhV5w/opUPQ9C2ebSd/R5JGb+DydL2xWHNOiFiSd6wDIP99fqHofRSrZbtRB+miGIgjQSkggWC09uIq+h9zLyQ5hREKG5JaGSv/svdXsRw7v+hPzu9nBH9Cs0+fOTmhFLjrrclg2NXKnzgIBPoCKfU715O3xKM+5+iwGuHzQ1heVJ76xeFSD4OHMd4XjQcU6ctmh4/uYPGwv1cmkBsBKvYIBU1JMj8ZyhvXTumjiyXp4ocDjN4wektUeIhKBA0yiox0Taw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pc0bAkvhUhiRJF8uj1mMFNtaNi7yZe7xthGQaMlogsA=; b=NSCXlEtEwLy2KFsdrWvTsTWHNIUC5O8V46j//w+ni1Zru60HkiT0Gkx6EyzalALlYkbnvyODZr0jkGdEODePT+IFrewScmLzMu1Whlk4ymVYWQDTHyywhNFwdwxmT6x8y4ycL1M81ElTn9Uube3L0jkhC5G5ZLQnSQydaozaZ3yLYsXrQry2KducLiyBPDKD059Rcqt3npytGFFaXiOeqxxe9k7jvXy2BkciJiC04CoxfuYt3giteGG5gWrjFM53wjrxCkpNkOG+bnTIqnlTlPw8CuW9WYx7bqC5/VqhDshRF/gXklYXtbcR9WWimleiETtSaB8CzDsWw7NCy6RT3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pc0bAkvhUhiRJF8uj1mMFNtaNi7yZe7xthGQaMlogsA=; b=oDAxKcelJbxHM66khOG9T3BnDL5p1gYvK/rR76KJUxKdajTw5MovPESAtdSn7QJWAg5d7oU3Y0prf7T3oogHRN0PWpiJEQgkStyh/gDlz066EI9SYMmkgNMYLfRF5Iub2IK+8CNJ1ipIXDCTsMnHuQ1DfbsA+2wloA9yB1FXx+CRezdMbdPaB6YL+kpMLlX6fMoNRARKM9GPZMyEX9dNDZKcMsMDDE74zuK2xIgfA1nDhweGlmfJMvbMO7t8ZGmaaODHctouPncTh8Y1hlj5bEEc0Q3XrsAySBuyVe8hF/GSBQjg97kdlVfh7wAVVaIjnDmalCiUD0QZF1+9IkBWaQ== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYWP286MB2729.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:24c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Thu, 19 Oct 2023 11:59:19 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::465a:2534:4d99:a25b%6]) with mapi id 15.20.6907.022; Thu, 19 Oct 2023 11:59:19 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH V2 3/3] wifi: rt2x00: rework MT7620 PA/LNA RF calibration Date: Thu, 19 Oct 2023 19:58:58 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019115859.2791-1-yangshiji66@outlook.com> References: <20231019115859.2791-1-yangshiji66@outlook.com> X-TMN: [p80y12FRyRhwvt2Yq82Wzeujl79BdPaX] X-ClientProxiedBy: TYCPR01CA0196.jpnprd01.prod.outlook.com (2603:1096:405:7a::20) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231019115859.2791-4-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYWP286MB2729:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f8995bf-77a9-46c1-17c9-08dbd09ad30c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EY4vBYM7jRh3zaj4J3Y8RSnHHuMIzHomBxWzTl+rxtiNsRgpGrQqVas2ch6MUd3FBUs8ppbgCWXY523Hm9tsZLH/8XI6WSAOGc02Ufx8CNRuJMYuHylhWYq/CqkTiCX5Kd9PRh/kbikaUwbLMszskAirjXpSAlZaNFRz7UTuV7edSwep4ARMBNatpumo/0Pm9JPLZn4WNTlr/hy7RLdlYjodYN0+Ga42SD+rdW7r7uo0gwlbVZQkAIxKR636egNQUj1eQodPo37I2JOWxZqW14SBNWs4FH5hfNJz+Z0CVh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VzwbczuCrF9JYRXtRKGBG2SpaDud947bM8quY0zJQOtxCZwhKnTDTXnk204dySA1Ds8yDzKM2AA44YkEZFo+6JkctT6oO1QSGU9DKyZY0T1xCe7Db97e7GcxuKhL6vdHtZqlGuEDYfd0bHFBDy2xEU0oU0atv8b+U9xIq4PChvnQAHIWo2osEqWj5Vgs68h0EtkgR1WfhGGVekND/0XQm7IvGo9MYmH4TKOfD5RSjMIGHEeQZM84TtOLx4inhHz2jXardhdZAZ9e6ll/vHPuRN9sgRIFKepGvywUYHBtzcwQu/LtuMA4J38bVURY59BIWsuAglmc0F5rvgqd7Ecj02lTDY+kUn88eL9jp2Af9gSFNRP5lok8sWkHSOVd0016v0bLrHzo4NzfNw9a9ZytOhUl2Ifsy4lyXRwl+IWoFdoIqZBpVbCAo9s/mMvL7KgVeH3fMygLW4oB9UFzvO+eACofQY7sQfJxn5IKvMbzZWpZG0RJ4WHMo2d4T/O7wZ0ATITDzVVO39Mt/fAKo/N0sWSTw6yRunrSkuKF/syZq0z+HI59B+0nCS7DyDu59alI= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f8995bf-77a9-46c1-17c9-08dbd09ad30c X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 11:59:19.3255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB2729 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 1. Move MT7620 PA/LNA calibration code to dedicated functions. 2. For external PA/LNA devices, restore RF and BBP registers before R-Calibration. 3. Do Rx DCOC calibration again before RXIQ calibration. 4. Add some missing LNA related registers' initialization. Signed-off-by: Shiji Yang Acked-by: Stanislaw Gruszka --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 176 ++++++++++++------ drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 + 2 files changed, 130 insertions(+), 52 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index 66ee50320..8d40f52da 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c @@ -4520,41 +4520,6 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); usleep_range(1000, 1500); - - if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, - &rt2x00dev->cap_flags)) { - reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); - reg |= 0x00000101; - rt2800_register_write(rt2x00dev, RF_CONTROL3, reg); - - reg = rt2800_register_read(rt2x00dev, RF_BYPASS3); - reg |= 0x00000101; - rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); - - rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73); - rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73); - rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73); - rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27); - rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0xC8); - rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xA4); - rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x05); - rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); - rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xC8); - rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xA4); - rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x05); - rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x27); - rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0xC8); - rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xA4); - rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x05); - rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00); - - rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, - 0x36303636); - rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, - 0x6C6C6B6C); - rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, - 0x6C6C6B6C); - } } bbp = rt2800_bbp_read(rt2x00dev, 4); @@ -5664,16 +5629,6 @@ void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev) } } rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); - - if (rt2x00_rt(rt2x00dev, RT6352)) { - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { - rt2800_bbp_write(rt2x00dev, 75, 0x68); - rt2800_bbp_write(rt2x00dev, 76, 0x4C); - rt2800_bbp_write(rt2x00dev, 79, 0x1C); - rt2800_bbp_write(rt2x00dev, 80, 0x0C); - rt2800_bbp_write(rt2x00dev, 82, 0xB6); - } - } } EXPORT_SYMBOL_GPL(rt2800_vco_calibration); @@ -10400,6 +10355,128 @@ static void rt2800_bw_filter_calibration(struct rt2x00_dev *rt2x00dev, rt2800_register_write(rt2x00dev, RF_BYPASS0, MAC_RF_BYPASS0); } +static void rt2800_restore_rf_bbp_rt6352(struct rt2x00_dev *rt2x00dev) +{ + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0); + rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0); + } + + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16); + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23); + rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02); + } + + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xd3); + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xb3); + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xd5); + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27); + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6c); + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xfc); + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1f); + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66); + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xff); + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x1c); + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x20); + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6b); + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xf7); + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09); + } + + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_bbp_write(rt2x00dev, 75, 0x60); + rt2800_bbp_write(rt2x00dev, 76, 0x44); + rt2800_bbp_write(rt2x00dev, 79, 0x1c); + rt2800_bbp_write(rt2x00dev, 80, 0x0c); + rt2800_bbp_write(rt2x00dev, 82, 0xB6); + } + + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x3630363a); + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6c6c666c); + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6c6c666c); + } +} + +static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev) +{ + u32 reg; + + if (rt2x00_has_cap_external_pa(rt2x00dev) || + rt2x00_has_cap_external_lna_bg(rt2x00dev)) + rt2800_restore_rf_bbp_rt6352(rt2x00dev); + + rt2800_r_calibration(rt2x00dev); + rt2800_rf_self_txdc_cal(rt2x00dev); + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_bw_filter_calibration(rt2x00dev, true); + rt2800_bw_filter_calibration(rt2x00dev, false); + rt2800_loft_iq_calibration(rt2x00dev); + + /* missing DPD calibration for internal PA devices */ + + rt2800_rxdcoc_calibration(rt2x00dev); + rt2800_rxiq_calibration(rt2x00dev); + + if (!rt2x00_has_cap_external_pa(rt2x00dev) && + !rt2x00_has_cap_external_lna_bg(rt2x00dev)) + return; + + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); + reg |= 0x00000101; + rt2800_register_write(rt2x00dev, RF_CONTROL3, reg); + + reg = rt2800_register_read(rt2x00dev, RF_BYPASS3); + reg |= 0x00000101; + rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); + } + + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66); + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20); + rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42); + } + + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73); + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73); + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73); + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27); + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0xc8); + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xa4); + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x05); + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27); + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xc8); + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xa4); + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x05); + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x27); + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0xc8); + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xa4); + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x05); + } + + if (rt2x00_has_cap_external_pa(rt2x00dev)) + rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00); + + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_bbp_write(rt2x00dev, 75, 0x68); + rt2800_bbp_write(rt2x00dev, 76, 0x4c); + rt2800_bbp_write(rt2x00dev, 79, 0x1c); + rt2800_bbp_write(rt2x00dev, 80, 0x0c); + rt2800_bbp_write(rt2x00dev, 82, 0xb6); + } + + if (rt2x00_has_cap_external_pa(rt2x00dev)) { + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x36303636); + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6c6c6b6c); + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6c6c6b6c); + } +} + static void rt2800_init_rfcsr_6352(struct rt2x00_dev *rt2x00dev) { /* Initialize RF central register to default value */ @@ -10664,13 +10741,8 @@ static void rt2800_init_rfcsr_6352(struct rt2x00_dev *rt2x00dev) rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); - rt2800_r_calibration(rt2x00dev); - rt2800_rf_self_txdc_cal(rt2x00dev); - rt2800_rxdcoc_calibration(rt2x00dev); - rt2800_bw_filter_calibration(rt2x00dev, true); - rt2800_bw_filter_calibration(rt2x00dev, false); - rt2800_loft_iq_calibration(rt2x00dev); - rt2800_rxiq_calibration(rt2x00dev); + /* Do calibration and init PA/LNA */ + rt2800_calibration_rt6352(rt2x00dev); } static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h index b8338a422..0f6252ea6 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h @@ -1267,6 +1267,12 @@ rt2x00_has_cap_external_lna_bg(struct rt2x00_dev *rt2x00dev) return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_LNA_BG); } +static inline bool +rt2x00_has_cap_external_pa(struct rt2x00_dev *rt2x00dev) +{ + return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_PA_TX0); +} + static inline bool rt2x00_has_cap_double_antenna(struct rt2x00_dev *rt2x00dev) {