Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp883817rdb; Tue, 23 Jan 2024 19:47:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMth59GVDfDG0qQUvK0WzaaK5CXQThhvat5LZPUC6Wwd9gm1ICa4LVNgO3PbuKh+kfcD4Y X-Received: by 2002:a17:90b:46c4:b0:290:d2fd:552c with SMTP id jx4-20020a17090b46c400b00290d2fd552cmr1430945pjb.38.1706068061375; Tue, 23 Jan 2024 19:47:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706068061; cv=pass; d=google.com; s=arc-20160816; b=wMyn/BdxSTbuL4VnO3z3ZSHkOzJc9oMVaJ1sJWqjOHMA6IFbRHqhjISfXlay71Gh/I V+anvWtE4tVNyTIdv/5/ArO4eqPwpEkeNQzo2MYZpV+nM/n/9GfEKadhsGxsTqxB/bwT 5tVPxTkXoYobS5YgKzhG1Tqnmm2VH7LvOs6AHAgdN0bCbNZQFya84kAk2tsHKQ14Rq74 NzJ9iLRIxlGVqSIGL8xAcLaOR1RQFLWsl4mKgoclPvmMTW49w+5d4ogds+oPTYvGdVtx px0fpgwOY43VjB2O9If9NxOR+dObFRxNNbCsTWBQZuB2W1Od5gI+0nTtLsGJ7eU1JLj9 MIZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=K2IiosL1bN/ci3hKGajJm0l17qgv6Ej5k7LzVMUi/xI=; fh=119R0DZRwIns1LRpqAK2A6izyPVjL4TEe6VydCwW0T8=; b=JgC+TLVTltXfIffLGPMtptoyd+DnrcucAsNxFzTt28yDLs14UYvC9f08trY1tG6+3c EHDlFxcyzU61kk37eQaHWDu1EEF7ZOVl3XNTcEpgvPj+C3vsrbCWrY3ZCOAayCR9z5PE 5PfP8vH/8mmyNm3BvKcGWyvpYKzZHLyGRcX7cjaR62WhhDV3OWgw7TDMfGpi9qgk1SET yW5X2H8g/+Y3UIPBLmYXarG6Ld+BSj2ApxK6+zq04Xz4lGO2jNrsNOdm3cik2XqUTgYT YK48ZLmpqRg0zu/rwTJrOU2YIq5v8gRiQBu61DE6yKt5um4zuoG+6bUEItLe+CtxfH1+ V0gA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-2432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2432-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p10-20020a17090a930a00b0028e0e6bf078si10807322pjo.96.2024.01.23.19.47.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 19:47:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-2432-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2432-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DAD5229511D for ; Wed, 24 Jan 2024 03:38:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F3611381; Wed, 24 Jan 2024 03:38:28 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7B70C150 for ; Wed, 24 Jan 2024 03:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706067508; cv=none; b=HCQrZfXN2+oQqW1ZFsp4LECRVckaStkGM5oY9f50WDDdUgzXXy5zPP2cZdfSz7bbYzyYfbEdLuAKBPewckNf39coSpbgsA3KzbeLFRY1QU9jpLlCu/46+GK/Tz+d+LHpjrZ2FgkRAMhgHzGiXy/HeqS7lzIDBwmmbry5+E+EWYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706067508; c=relaxed/simple; bh=Hu9g7LFvFK17Pn1xaH1uXNjhZhlX51I/4akHjWvBDgc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TZXJ8K8VPZFLhMPTsTjRDbEOt9uyoB4rXDLGhrDX8pr5MqhplE2gqPazrbb5PkXkRGvTExAV6t+XDrjcPRIxo0UdASMlq7ZNqMAQT/Wo34E85GI3OvU5VfFJqmkKm6QslZCZyX8NGtAyceG5+aJ30RAsWyLHAc2hh7qovRe7+6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 40O3cLHd9724205, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 40O3cLHd9724205 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 11:38:21 +0800 Received: from RTEXDAG02.realtek.com.tw (172.21.6.101) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; Wed, 24 Jan 2024 11:38:21 +0800 Received: from [127.0.1.1] (172.21.69.94) by RTEXDAG02.realtek.com.tw (172.21.6.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 24 Jan 2024 11:38:21 +0800 From: Ping-Ke Shih To: CC: Subject: [PATCH 5/6] wifi: rtw89: 8922a: add chip_ops to get thermal value Date: Wed, 24 Jan 2024 11:38:02 +0800 Message-ID: <20240124033802.12508-1-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240124033637.12330-1-pkshih@realtek.com> References: <20240124033637.12330-1-pkshih@realtek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXDAG02.realtek.com.tw (172.21.6.101) X-KSE-ServerInfo: RTEXDAG02.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback Get thermal value as a clue to do RF calibration if the delta is larger than a threshold, but 8922A doesn't need this, so we only read out the value when debugging to reduce IO. Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/reg.h | 1 + drivers/net/wireless/realtek/rtw89/rtw8922a.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/reg.h b/drivers/net/wireless/realtek/rtw89/reg.h index 6b15fa431b22..53061801fa4c 100644 --- a/drivers/net/wireless/realtek/rtw89/reg.h +++ b/drivers/net/wireless/realtek/rtw89/reg.h @@ -7465,6 +7465,7 @@ #define RR_LUTWD0_LB GENMASK(5, 0) #define RR_TM 0x42 #define RR_TM_TRI BIT(19) +#define RR_TM_VAL_V1 GENMASK(7, 0) #define RR_TM_VAL GENMASK(6, 1) #define RR_TM2 0x43 #define RR_TM2_OFF GENMASK(19, 16) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922a.c b/drivers/net/wireless/realtek/rtw89/rtw8922a.c index 1c5ceb5564c3..6de3c0f8d83a 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8922a.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8922a.c @@ -1528,6 +1528,27 @@ static void rtw8922a_bb_cfg_txrx_path(struct rtw89_dev *rtwdev) &tx_en0, false); } +static u8 rtw8922a_get_thermal(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path) +{ + struct rtw89_power_trim_info *info = &rtwdev->pwr_trim; + int th; + + /* read thermal only if debugging */ + if (!rtw89_debug_is_enabled(rtwdev, RTW89_DBG_CFO | RTW89_DBG_RFK_TRACK)) + return 80; + + rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1); + rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x0); + rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1); + + fsleep(200); + + th = rtw89_read_rf(rtwdev, rf_path, RR_TM, RR_TM_VAL_V1); + th += (s8)info->thermal_trim[rf_path]; + + return clamp_t(int, th, 0, U8_MAX); +} + static void rtw8922a_fill_freq_with_ppdu(struct rtw89_dev *rtwdev, struct rtw89_rx_phy_ppdu *phy_ppdu, struct ieee80211_rx_status *status) @@ -1603,6 +1624,7 @@ static const struct rtw89_chip_ops rtw8922a_chip_ops = { .set_txpwr = rtw8922a_set_txpwr, .set_txpwr_ctrl = rtw8922a_set_txpwr_ctrl, .init_txpwr_unit = NULL, + .get_thermal = rtw8922a_get_thermal, .ctrl_btg_bt_rx = rtw8922a_ctrl_btg_bt_rx, .query_ppdu = rtw8922a_query_ppdu, .ctrl_nbtg_bt_tx = rtw8922a_ctrl_nbtg_bt_tx, -- 2.25.1