From patchwork Wed Jun 12 01:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1946599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzSkB2Tk9z20Z4 for ; Wed, 12 Jun 2024 11:33:53 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sHCru-0000aD-N8; Wed, 12 Jun 2024 01:33:42 +0000 Received: from mail-pj1-f53.google.com ([209.85.216.53]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sHCrs-0000Zh-3g for kernel-team@lists.ubuntu.com; Wed, 12 Jun 2024 01:33:40 +0000 Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2c2c74d9be0so1488664a91.1 for ; Tue, 11 Jun 2024 18:33:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718156018; x=1718760818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=zopNxwxquwyrhmi5DNbRI0Yt+L6DKLWB5XRrZ7gJAGY=; b=tWacBWtqRD0Ncro4/mtT1DNkMWlh7ZBag8AJJsaEmHduEehMd6RNeLPFAl3LAzDXjf QOyM46Srnl05jeOdLRpv05ZLlkfw6pQ6AW1pEqzNHI1Z2VeJ9fyTFhBSLzh4Be7YwfQT zDtDsOynsUBr0aJPKgnIppzt3bsbdw3Mam8+Zm8NoWAbFuYV8LPUdhKRlfJcXc+D2F0m cz0RF5Jz2aO1g1gW4l0c5rk8vS2Jcyn355zquZkU5cjxDYvdjXKKaCE/9bkFtcCMukjS U+6tonBK0hPk1JVLq1vTNtux60QdLJavuUqqI0QasZ8AThWSE7zHRGtmVsxAhhIodSQN 6t8A== X-Gm-Message-State: AOJu0Yy1DivHPeXjqOxd0dpiWX0ZgMIRTeWtn7tJF8gbd/jSh/jVbmm0 8fJa0plbuCCGChzq7HK3qM7ZdfMHT2ipV6aC8msyXx9wu93APi7EaMs+cw== X-Google-Smtp-Source: AGHT+IF9nw7xy3t09d5JpxncgdBl/3Ce/0vNXv7zMRmv7qLPkAfLULnbdZkNHUl7lq1WdPmU+mjdkg== X-Received: by 2002:a17:90a:dc09:b0:2c2:ce7e:458e with SMTP id 98e67ed59e1d1-2c4a7601f0dmr546652a91.10.1718156017635; Tue, 11 Jun 2024 18:33:37 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4a75eeef1sm302083a91.22.2024.06.11.18.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 18:33:37 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2][SRU][N] wifi: rtw89: reset AFEDIG register in power off sequence Date: Wed, 12 Jun 2024 09:33:32 +0800 Message-Id: <20240612013333.1608029-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240612013333.1608029-1-acelan.kao@canonical.com> References: <20240612013333.1608029-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.53; envelope-from=acelan@gmail.com; helo=mail-pj1-f53.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Chin-Yen Lee BugLink: https://bugs.launchpad.net/bugs/2065128 Some Wi-Fi chips meet card lost issue due to unstable hardware signal of GPIO pins during power off. Reset AFEDIG register before BB reset in power off sequence could avoid unstable signal and fix the issue. Signed-off-by: Chin-Yen Lee Signed-off-by: Ping-Ke Shih Link: https://msgid.link/20240426061200.44262-1-pkshih@realtek.com (cherry picked from commit 535c045da60fec1afb31919a9df3e06574d4dc52) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/rtw8851b.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852b.c | 2 ++ drivers/net/wireless/realtek/rtw89/rtw8852c.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851b.c b/drivers/net/wireless/realtek/rtw89/rtw8851b.c index 5c167a9278ce..6ebbe48ca50b 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8851b.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8851b.c @@ -2274,6 +2274,7 @@ static int rtw8851b_mac_disable_bb_rf(struct rtw89_dev *rtwdev) u8 wl_rfc_s1; int ret; + rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG); rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BBRSTB | B_AX_FEN_BB_GLB_RSTN); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b.c b/drivers/net/wireless/realtek/rtw89/rtw8852b.c index de887a35f3fb..491527e3c7a3 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852b.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852b.c @@ -550,6 +550,7 @@ static int rtw8852b_pwr_off_func(struct rtw89_dev *rtwdev) return ret; rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_EN_WLON); + rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG); rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BB_GLB_RSTN | B_AX_FEN_BBRSTB); rtw89_write32_clr(rtwdev, R_AX_SYS_ADIE_PAD_PWR_CTRL, B_AX_SYM_PADPDN_WL_RFC_1P3); @@ -2443,6 +2444,7 @@ static int rtw8852b_mac_disable_bb_rf(struct rtw89_dev *rtwdev) u8 wl_rfc_s1; int ret; + rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG); rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BBRSTB | B_AX_FEN_BB_GLB_RSTN); diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852c.c b/drivers/net/wireless/realtek/rtw89/rtw8852c.c index 8618d0204f66..4f2cd9082e9f 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852c.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852c.c @@ -338,6 +338,7 @@ static int rtw8852c_pwr_off_func(struct rtw89_dev *rtwdev) return ret; rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_EN_WLON); + rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG); rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BB_GLB_RSTN | B_AX_FEN_BBRSTB); rtw89_write32_clr(rtwdev, R_AX_SYS_ISO_CTRL_EXTEND, B_AX_R_SYM_FEN_WLBBGLB_1 | B_AX_R_SYM_FEN_WLBBFUN_1); @@ -2790,6 +2791,7 @@ static int rtw8852c_mac_enable_bb_rf(struct rtw89_dev *rtwdev) static int rtw8852c_mac_disable_bb_rf(struct rtw89_dev *rtwdev) { + rtw89_write32_clr(rtwdev, R_AX_WLRF_CTRL, B_AX_AFC_AFEDIG); rtw89_write8_clr(rtwdev, R_AX_SYS_FUNC_EN, B_AX_FEN_BBRSTB | B_AX_FEN_BB_GLB_RSTN); From patchwork Wed Jun 12 01:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1946597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzSkB2SQRz20Wq for ; Wed, 12 Jun 2024 11:33:53 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sHCru-0000aS-Th; Wed, 12 Jun 2024 01:33:42 +0000 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sHCrt-0000Zu-GF for kernel-team@lists.ubuntu.com; Wed, 12 Jun 2024 01:33:41 +0000 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1f65a3abd01so14872205ad.3 for ; Tue, 11 Jun 2024 18:33:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718156020; x=1718760820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=cToDlQYGdvAAqb8AQKS+lD72Adlt5fqWWPv1d/VDas0=; b=FzjX1MaYO/uUaeGC1cUtpLk90XCHQD8cNEd4NvUUGcC/POzHhB6mJYWaEEw8J8VrV3 yf+DkRAXmh4j0bIVg1b9NA0EDWwjE848Y7yLoINWWime+BBQMwsu9/Xk93uxGeQnJbV1 RWpcEqPeb61tg8ZuDRyZZDAtc5wlYG8QwueELeicu7uXHb2b26FOgSnikFtjMtpRK0RW 3fwcCF6hOBY+VXMv2IGNnGm7iqGBr+AS8IYrLXqXZ7zLTstJTiLD7Iu4aEv4wY6veMlc dLdW/g2nXNWgrqKdub5gzV62zMwu4i27f4oKz2bHSHPcEETi91APphnS/D222JUjoFZn yIMg== X-Gm-Message-State: AOJu0Yw7VQMKfUsK2QhpiBjcNemjYUyrYgQNsZS9ATC7fD70S1V2wOyD GSBRYn2Yb94TfMoz/lK81OvKtvkrqOKhb1NKSxjGQ09KboHDFTw04IDx2A== X-Google-Smtp-Source: AGHT+IEkACv0H8KQnca3jWpNHaux+YDClPydil3csMrCtuFIELuvRYbBTEbd6f5XWkvrget9dNEM2g== X-Received: by 2002:a17:902:d504:b0:1f7:195d:8e7d with SMTP id d9443c01a7336-1f83b719c9dmr6854435ad.54.1718156019525; Tue, 11 Jun 2024 18:33:39 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6bd7eeb6esm109828105ad.256.2024.06.11.18.33.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 18:33:39 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][SRU][N] wifi: rtw89: 8852c: refine power sequence to imporve power consumption Date: Wed, 12 Jun 2024 09:33:33 +0800 Message-Id: <20240612013333.1608029-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240612013333.1608029-1-acelan.kao@canonical.com> References: <20240612013333.1608029-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.172; envelope-from=acelan@gmail.com; helo=mail-pl1-f172.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Chia-Yuan Li BugLink: https://bugs.launchpad.net/bugs/2065128 Power sequence is a flow to enable/disable WiFi card with hardware parameters. Adjust power and clock parameters according to results of internal simulation and verification, so apply them to have better power consumption. Signed-off-by: Chia-Yuan Li Signed-off-by: Ping-Ke Shih Link: https://msgid.link/20240426061200.44262-2-pkshih@realtek.com (cherry picked from commit 4e5957101d421627ed9e7ef8ce43a7e50e6d5822) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852c.c b/drivers/net/wireless/realtek/rtw89/rtw8852c.c index 4f2cd9082e9f..619de4e420a3 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852c.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852c.c @@ -203,6 +203,9 @@ static int rtw8852c_pwr_on_func(struct rtw89_dev *rtwdev) rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APDM_HPDN); rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFM_SWLPS); + rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, + B_AX_OCP_L1_MASK, 0x7); + ret = read_poll_timeout(rtw89_read32, val32, val32 & B_AX_RDY_SYSPWR, 1000, 20000, false, rtwdev, R_AX_SYS_PW_CTRL); if (ret) @@ -266,7 +269,7 @@ static int rtw8852c_pwr_on_func(struct rtw89_dev *rtwdev) ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_ANAPAR_WL, 0, XTAL_SI_SRAM2RFC); if (ret) return ret; - ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_XMD_2, 0, XTAL_SI_LDO_LPS); + ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_XMD_2, 0x10, XTAL_SI_LDO_LPS); if (ret) return ret; ret = rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_XMD_4, 0, XTAL_SI_LPS_CAP); @@ -361,8 +364,11 @@ static int rtw8852c_pwr_off_func(struct rtw89_dev *rtwdev) if (ret) return ret; - rtw89_write32(rtwdev, R_AX_WLLPS_CTRL, 0x0001A0B0); + rtw89_write32(rtwdev, R_AX_WLLPS_CTRL, SW_LPS_OPTION); rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_XTAL_OFF_A_DIE); + rtw89_write32_set(rtwdev, R_AX_SYS_SWR_CTRL1, B_AX_SYM_CTRL_SPS_PWMFREQ); + rtw89_write32_mask(rtwdev, R_AX_SPS_DIG_ON_CTRL0, + B_AX_REG_ZCDC_H_MASK, 0x3); rtw89_write32_set(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFM_SWLPS); return 0;