From patchwork Fri Oct 13 23:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13421870 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 CFBA9CDB483 for ; Fri, 13 Oct 2023 23:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjJMXW1 (ORCPT ); Fri, 13 Oct 2023 19:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjJMXW0 (ORCPT ); Fri, 13 Oct 2023 19:22:26 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2072.outbound.protection.outlook.com [40.92.99.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C775BE for ; Fri, 13 Oct 2023 16:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ksaxAFYyv1hdyD2gO2FdreW4mt5FN6u+MSghEe6oj4rlc6iQQ5ufaszUq4HK24tjk04YA2Tjy64cvs8bUBtjr0GQgm/Paw9U+fal+TARY766aiIzcbkmLXFpZ8rwqMFCJsyHyt0hZEet0uiyXV95CyED8jR0U+yH5ESX9h86YKGCdU1kHWmX7iPTL21NuIHFcWbLqudKEvgchI/52VZKLE+Noei64bRr58W00lNUNeK6nZ9lz2iecpQ2YPGFshrZ9kqGQ1Umvnut4wlQv1wqq2Ia08dbesS4n0+036ZUCm/8aysfy5Pcgvf+qd+a3SyEJGGUlUYfDzfx/TT5z9+SRA== 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=wi0KsgjoU4BgJtfmSpQQNmdlzzYYiBArj7G/m6I4f/U=; b=U57nrog2jQgiNZn0i//nAXcltjlTQ8mBHtypCmYYcUygXs1AjQZktJBh0uMQf04nP6kAew/VUzRZ8wZBaVSE8X3pTDMOQED3Kcrlew/CWJ0L3JEhGTi9xoKzHtKal7BerLowo6YMiCkyhem77nclFr+agYtkFr0f4IWQSyTH7jnJ+GK025VdCv7nSntDM1s5oopji8mtbpIMOI98ftEys+IhARTkYe6T1LyAcGSjaaL+Jk9mtGFCtC/Jw5vyw+XbrQXSnHXNHmewfQioUiZTkk6w2t+86z5oWoMxvwipNAKn6nlvDNd+HZVA87oyEHWqQEs7QdMwqcyAdkwI9CItjQ== 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=wi0KsgjoU4BgJtfmSpQQNmdlzzYYiBArj7G/m6I4f/U=; b=LBQtDF9rctDe4yWV1ovCnhl8i4v3ZB4KW1KOVrXqNmrFGr/u5HozHfNfQ9LstSXiKpLICecvfs+Fs//84gg17BbGPt4cYlCy2HP9L2x147irp3jK7d6MZLDXfYQjV1KhRc42pGfLXgQz7OSWsWPqGRMdzV8Tj0Z+Lywva7wjDuxPOB7CGe+p7j27hDAvBGh8EJSrYueJpceeAqoenehhP8xhn8hJKQHwcST3i7MavolDIzQ4Q6tvGaQDrR3VTc8OQWlOLPf0zlPENX94AY3UVWIaRVFQZjodB/dimae/H/hK4X7o/fEllxF1sc8jFooLXziA6Ui7PpnjR7Ose7/ZCw== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYYP286MB1691.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:fd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.31; Fri, 13 Oct 2023 23:22:22 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a%4]) with mapi id 15.20.6886.030; Fri, 13 Oct 2023 23:22:22 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH 1/3] wifi: rt2x00: improve MT7620 register initialization Date: Sat, 14 Oct 2023 07:21:28 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013232130.416-1-yangshiji66@outlook.com> References: <20231013232130.416-1-yangshiji66@outlook.com> X-TMN: [kU/wz1r+Ckz00b9ycYszlzh3ac0F6UfXA1ANgFwKcgk=] X-ClientProxiedBy: TYBP286CA0031.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::19) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231013232130.416-2-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYYP286MB1691:EE_ X-MS-Office365-Filtering-Correlation-Id: bb11cee8-5930-495a-ae21-08dbcc434045 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jA42NYVSgM1czEbL7IXSgTnic0+EgDGRJuj0ipspQ5OzZZdhy8zAQFGe/qbrzoYPOeUPIb1xxAuV+KlJxxIL4k3Rz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2Zv+917O2+S7/IGBJINChfZsCSMrG0hrZwJbK0nxg7F3lmZcts95v8GD6SRXrf6IUvvDQhXWnw+J+afh4kv9UPfqQ0ia9gA2cZRuus1tjYC2CQ/A/2uCedLK26vgHxpqbVLAzQwk3d7qLIQu7K8wbSIGNK4DD17IJYPIFQyqwFEgRop6CO0MPslotpFkYPueCOZ8cyPswum/ad7ev/G5uYlLzFxlHJk80KUFqqN3t1dOYiSA4+li9pv/ESpkMi2vRCETmISwLrVAflKsPY0lK2wTkowsEX4qgz0KO514nX75YiADsFHaypA5dRmEdYYDDKpThRq5kzYTFF+X8BkXZ8wRjOUBA+o64fL9wZ5pyF8tIDK1s9YFa4NF0Mbaj6Vr4KQ5LKvyCChsfv/XmyrD50+geJMqpoQtq7a82NaAIQDnn8/aINTXmw1gnO8nOzRuE9RbaobTkIZUuracaHBC+ahhxUJKYo3u3axn+QUrLpkOWhfZe1zH+rM0sNskQ7lp5oN69APByZTW9Wn7GU9zTVjRq2/RdOXS41EM5GsV/81piv3ezsCNfgBXMLQp6AsLpoeKSnXXG8bw/+O70c8g39h03+hAYAgC8m3VeVb6JOIzelmgzedjcaLlR7vm8rBAduql9B2G4ig7habfXKzdx8dFPEAj9lpeUMA4jttsLIuetGfXBWe38JQn32YW+3ptVMn04HqzJyxLYf0oU1MPYi1uPjMgtvn/ZB/PTJbMNmUN7Aft8bf0l3l0+r7PvtO4gHwzteP8AF296bN1fyu9wrcdmbG0= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb11cee8-5930-495a-ae21-08dbcc434045 X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 23:22:22.0133 (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: TYYP286MB1691 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 --- 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 7b2bf23ac..acc720ef4 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 Fri Oct 13 23:21:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13421871 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 B92A2CDB47E for ; Fri, 13 Oct 2023 23:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbjJMXW2 (ORCPT ); Fri, 13 Oct 2023 19:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232383AbjJMXW1 (ORCPT ); Fri, 13 Oct 2023 19:22:27 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2072.outbound.protection.outlook.com [40.92.99.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B068BC2 for ; Fri, 13 Oct 2023 16:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A7xUhQ6i0sBLkyhPdw9VnUWOzw+vSLEYLIRp3UZ/Rh/faE8vMciyiLKVKiY0krbo27UFwIRBykxehIj4HXVXoEdds7N9N3plztlDzO98hTNLPmVJYor7K1PNp6y3tD6qlWaN5dY5m3Rd4DiTqnz1Hdpmsvv9rhd4fPOmbvGsbyppnEP8A+Tl3WmbAfK5IEv4Bsj/KFkFuJ9paodNEEyuC8o/R/qibKOm++kMd1GalIcoxXh9wqOXKx/fiiYvlFyMZVyu2mphOg7HFzaj68z0onBm/A08qlL1CvIS0f0s9XfpgCl7l3oOvIRHklWLDo2uBvgyVmf6Kd7SS6MeOvGtoA== 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=s1C+OECrPgyku3ySESsbfvKbG450xbOMf5+1/jaaWHw=; b=bevwldPniCW2hkL5SiDyT6861fvr1yGueeTRswHi2Ri/U+dBGa9OiaXhsyS6zOysXztMCkiCBHQYoPKIP6qKfamBzFoKUjtVlbh1Pz0iUskxpIGshSkHOIehZ4FoRU87O6abVGolFCrx+DVdsKogLCb7FkITzbgY3i3B62ZyDtskKn6MBwMe8wdTFOmepnbB/4M0/m/nVRw7bg7YAn7UeIqT7DU1qJjvVRJ54uRsbpU0MMCIRyAkfaYY0OD2MzisAYQmLXIsnnXG3x+ZWqO1LFYQTvCWJVULuJPq4cIeVeRoG3Mjk3REs8MGPCP4xXboG+Sw91L9K2+nEzciKIpLjg== 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=s1C+OECrPgyku3ySESsbfvKbG450xbOMf5+1/jaaWHw=; b=J7rdCJWGrG7Xl53tMYXUeimI6Se7vJcG3wHDh1/A1tBszwOwwCC1AonRaSX8t6MS6+DseH/E8SibiNuinuVOvdGuxR/FaG07XVdHPk4P57cp2c0SLiHAncwkGrdSFX7p6VNPeTg8TjpKw4Io3z0dFZLmYItlTjNY0DlyVIcCBn2liiGEsLWO1XMvt1gdXlmVTzq5/yMQZV3JItdvIfHNzzQspS5nc8/tyv/s5J19G2bCIE9NAok8HlGNcRUajX5N2gGWmkCoDiuMG6CW/eWRKTpfqbVjx29oL7Fv9cdZCXPYflwywqSOb9vgVQPOzEDkdaYmMcO6oe4Ij4YMuleMcA== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYYP286MB1691.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:fd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.31; Fri, 13 Oct 2023 23:22:23 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a%4]) with mapi id 15.20.6886.030; Fri, 13 Oct 2023 23:22:23 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH 2/3] wifi: rt2x00: rework MT7620 channel config function Date: Sat, 14 Oct 2023 07:21:29 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013232130.416-1-yangshiji66@outlook.com> References: <20231013232130.416-1-yangshiji66@outlook.com> X-TMN: [RbpzqHzuEBnShHC64BHf21TB/oW+hMvhOgb7votRxEU=] X-ClientProxiedBy: TYBP286CA0031.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::19) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231013232130.416-3-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYYP286MB1691:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d88d417-2217-4fbf-9301-08dbcc43412a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DW2eeFaXczsjbSjRInib3aZLEvzyatC+FpZjHS0SbmdTZgYSuL1m1W2N63k30N1XTloYZhwNRMbo/AIYZJgEqBJeNX+47vSKjytJutn1Sr0GdGkETNpUVJybA1wqqtKq51tgfX1Fs7oHLQpOvnaGxqV2PCimuWf3l1z3Yuh6jlQA+qnz0uywQMBMUPtU6ENP5A8POfYpd5rEH7XE54LqaUNl8wIsE9zLTN0QJT4dkpFfpE0AMQhnYgVtjMJCd7h74q1g2bnln8gZzjqST26lBSeQjTfJZ2pOxt8VR/6i+1aDJEGgsnXILckiU4VvULcs6RXR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7hmqYaggnaazNbHkgnFnGkY2waf5/4BWSpXBY1UEoPzetbqWJ/HRHTk0oqLy0gWjYaeN1fgkKkmnmspVrp3Dms+P+x5pIRCY3IqxEvyvI/4xEJR4X4aYnqcOgjJj1a4qHjHvAtpXYsjTorSpZpbeCLOgNhWarHcOll3EUwhnMQ8RDZv7vOYjIcX9IDlubArAZ7dPzJSKfiuDrHFrgFsr28hKVB5P1k2IOnjZfia+Uh+PmtVW5hRRXzYqEVJlhjGYqQ6QqYXKo4RgIKUqZEIB8FQoc6+fDf06RQLllyAe2U69MNukmMnOSAgtQI0uUpY+/a4lxri487VzMqcpHJJHrA8WJcXtWjHkUtLjt0ZjSrMsTENycOcFyQ5Ot0tx1tVrffEwyfbdV2BXj8now/oEcfxCMDrLfiANEsWLJAfmsvstGmdzKChoW6emPZwa9VEixiQCPf5X9lHuijlTGrU80G5MuGEYLzLcE8Db4JkWugI1LJFm9DxaRGxVYZ6vfU//5RX5EBJd9B62HMgVqT7PNXEaGsttjqqJtuI= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d88d417-2217-4fbf-9301-08dbcc43412a X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 23:22:23.4554 (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: TYYP286MB1691 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 --- .../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 acc720ef4..ae969ec20 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 Fri Oct 13 23:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 13421872 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 72240CDB482 for ; Fri, 13 Oct 2023 23:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232493AbjJMXWa (ORCPT ); Fri, 13 Oct 2023 19:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbjJMXW2 (ORCPT ); Fri, 13 Oct 2023 19:22:28 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2072.outbound.protection.outlook.com [40.92.99.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09996BB for ; Fri, 13 Oct 2023 16:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D7+8CVhxGCRStBIyPqeV8VnntumzVyeoPMTXGbi0pxU80HTAqmvBZ4wiuunJVGv9e1r8CTq+gH/0ZVcOy27K0exX6LsfcYOLDyP1IsIY/eIqgcykXtWc7bzRXgwjYeBk3oGOfZokZHyV1qM28LmVWQqhOJV8xrOCTiBW192B7swquq179Q3u4yeqhA0LTU8Jw1ramgsWbDbGlMgShhdEiU/N7cB+l30ijSeUkPHgbNBECZ+cjpXZlba0j0saNLShortWoN29tsdykWUPa8m+NQ0rjYzejsqtsvevV9Anx2SJX3Rtl5a2kmdJbjb4WjG7IFT9ndGcQELKAveVDt4fSw== 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=VvY1UXZmJVpx06oc5WN2TTCInIhhuYRfsxLv+dtf2rM=; b=RQYBtJOlo2K0DfVJQIK1YDwYsyxHJH++L1sbyjEt6VF/fN3r6lStwrR9qP/z/0m/5PEsjJCz1UxwIihaAG9CJ8nvkcq2or7CIM+rm9AbsgZhvAbeBrhB5JxtOPXyIPDl37DHwK5CrUDDm+lZI6dudQY9t50V3Tt1bqLfQzoC5HfCY+HzeVACgAJ+qnEXMYTAc+YOk6FZXhuQQ5KjR2z6wz+5nLjCk2y+kPl5mmuL7wftwOFSV3J9WraGY8DfjC3kpgLhQITFZQ2OuyBn7QTEonJWfr+OEQ41YrY/5IVUL2jemeUCVRODNmcKJRP1g1TOQBQgf65jCDdXK/FJiqf/LQ== 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=VvY1UXZmJVpx06oc5WN2TTCInIhhuYRfsxLv+dtf2rM=; b=sa23bupshmVURIwZo/2YR4hrV4H/7112T6j40Ifo4/6FgsJE//uJOiLWitEvikgpniaaEga0y/fAS2j3t6C5yTpbwX7jd6TzRojGe0nURRnLjHvOCwp8GuVgBekfVDgfAw0IgEfGP3E1julKmHH1/sqmLBvcNZlke+TznlmJrrj5NRwWMAxqJSUGEqZvmCz1JKLEdtLVe+nc0SJ161elwfha2z1um3WWN3JpyzLzbDJb+JaUUTdub/TYspGQYPNYBLCf5ZDkdJmOCLOHRxUM5dOt70YnGp+NXmo16u+FqybmiBTyn6GkB+C0FGykYGmoEK1stMZhOAtgfhugpwvjCQ== Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) by TYYP286MB1691.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:fd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.31; Fri, 13 Oct 2023 23:22:25 +0000 Received: from TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a]) by TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM ([fe80::bbb1:a301:f7b6:744a%4]) with mapi id 15.20.6886.030; Fri, 13 Oct 2023 23:22:24 +0000 From: Shiji Yang To: linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Helmut Schaa , Kalle Valo , Shiji Yang Subject: [PATCH 3/3] wifi: rt2x00: rework MT7620 PA/LNA RF calibration Date: Sat, 14 Oct 2023 07:21:30 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013232130.416-1-yangshiji66@outlook.com> References: <20231013232130.416-1-yangshiji66@outlook.com> X-TMN: [lBGTfHv+G5FlaqKCitlau+NIALSeTE5LvntsXrvZ94M=] X-ClientProxiedBy: TYBP286CA0031.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::19) To TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:8041::8) X-Microsoft-Original-Message-ID: <20231013232130.416-4-yangshiji66@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0315:EE_|TYYP286MB1691:EE_ X-MS-Office365-Filtering-Correlation-Id: 1856485a-fd59-4cc6-1791-08dbcc43420d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Do7QUnWsb1or38uKPAHrYtf3SvSxAaLycV4OzdI+YSRoJwdVyvV/JdQb2Fv3PM4WAvtzCccOU4hLHxeTIvB21TnY2sxsxyBy1QtyfkIOf/E0rmlFpGkW+eI/RPkpyLtzHggRyNYJIXhG0Y29UpkIelH1pF1FgROC1eB6VsCKJlA56S19ou+SNAmCFXGeIZ57I00gtsNtUHYwiM3j1jnJt7kegUM2TFsXuLHdJNjlnS3A9EThMHGLXwbzfbuaWgVdM7HRVEIMc70btFQEvWdwoBqSc51OTHeitxw19ldg2u1SOBNFh+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WFZ0DX/KSzZZ1oypYNrHGx/fELLnMlgFy5zeLQtOI4xINr7zuVcXJhjcnqcXe5iZDw/422wXzD/aFj/BEHbo1ftWB88SufGfaffqm1SL+jjxKDFyv4XJmmrP14jhfScw9thcJziA1JUL+XaDjWj76uPbF8tEiX1GEaXMFG8wZFe3NOT+m1CbK5bjejeJVaTiLt0FSMqTveYsnjxo9AzCNS1jwXtKRpCQmyY4C09lPnedEcckn/lSLuxminPDRu19CCuAxUtEPQVlQK4/8O1jvtZ/cattth2EBQgeRHqH3DnBlxOpWDm2P41rnbVA673qcIkPIwdThoflqX2xWBINhS0s/PEXoVf3gu602ydW00ob4udDo072oxdY8T8PNRTFUDI2/3X0sI0ajQcsXG84A7ZN3ODF+4GnDKsVM+b+OmeV7jOxVCNDj6LEWdcMYt1Co+LJaFa2M2lNol39rXe59zCA3ZHZgi+h80owx0sfvaZBq+Xxs61Rb+rhiubNOTi33BBzOOdaMq/GiMLw3rkiz+SNsH2GT+7YjCjQ7Y6g= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1856485a-fd59-4cc6-1791-08dbcc43420d X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 23:22:24.9241 (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: TYYP286MB1691 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 --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 179 ++++++++++++------ drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 + 2 files changed, 132 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index ae969ec20..6e483eba2 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); @@ -10663,14 +10618,6 @@ 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); } static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) @@ -10722,6 +10669,128 @@ static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) } } +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); + } +} + int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev) { u32 reg; @@ -10762,6 +10831,10 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev) rt2800_init_bbp(rt2x00dev); rt2800_init_rfcsr(rt2x00dev); + /* Do calibration and init PA/LNA for RT6352 */ + if (rt2x00_rt(rt2x00dev, RT6352)) + rt2800_calibration_rt6352(rt2x00dev); + if (rt2x00_is_usb(rt2x00dev) && (rt2x00_rt(rt2x00dev, RT3070) || rt2x00_rt(rt2x00dev, RT3071) || 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) {