Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2297243ybt; Tue, 16 Jun 2020 02:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbwJ00qYFsFyfG8npk3Bg+U5aRNK7HNJj6tuy8bf3qqUPdgnlm7DStB0+JkvIMQeJRD38U X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr1743543edy.362.1592299035107; Tue, 16 Jun 2020 02:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592299035; cv=none; d=google.com; s=arc-20160816; b=Uc6wy3JdDfaoovOUceRO/nZuSOclreRK8AJDEBRfmPB9Apj8EvBg/g2elOYUhjEDNi VHaZZ/5YWxTI7Gzzz1T9EhdBMznssYCmtzoFnm8YSq+UctMu/BMNuOV39w1esbv2e3XD U5byZHHq5I5wltWz1nSknrvEbR1aUyzuQKJjxI+jpCrLSJkEWu8pfVgLdR7HyAYsaHTN m4aeX49eBOOrWtvxEGBrETSuHrb60maAjA9FwYpXe0D7NJy05hIzuJVebuD1bzF3uDzc pZKCvw3F8v6f3S88mlqIu+FnBCBw8gBvPMuHWVYRpy6vmWoDEMg/vclbjoxEHLz4kdRT q8oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:authenticated-by; bh=OmXDpu/NXd+AZyafGsQAi1BOnP+rm/DAX6OTpSUcuwU=; b=Gp5fueDLvfG3cJxemOKQGI+K8jPZ6eSiEi0EPGZuEtoOfNm8/po59Olwbbx3508axM rWIU/5h2gpCMx43nn/ffBHgN3lYYdNZB6u063y/p1KyH/H+UXs8pfxmR/5GGNXL+dyqG cbqwcpCGJebKOQC6RbDGS1i0BUdxc2tN/Q7a75zIld5IypXr3V28uBb6/QcbGPuRPkJu VMTUo8LGH7h31s3Fjfq14vayKK9dd1wJVbpc4FLF1GAAuPXvHT3EBWh7++GRX74ATyKe 9estoQmisvW0dsLVUHsIFESpZkelaMsLMBY3ZIPQxOWTm+VzRHgZmuraMfj8TeWzDuMM QcEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si10978169ejz.132.2020.06.16.02.16.51; Tue, 16 Jun 2020 02:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgFPJQs (ORCPT + 99 others); Tue, 16 Jun 2020 05:16:48 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:46535 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgFPJQq (ORCPT ); Tue, 16 Jun 2020 05:16:46 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 05G9GWB10021728, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 05G9GWB10021728 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 16 Jun 2020 17:16:32 +0800 Received: from RTEXMB04.realtek.com.tw (172.21.6.97) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 16 Jun 2020 17:16:32 +0800 Received: from localhost.localdomain (172.21.68.128) by RTEXMB04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 16 Jun 2020 17:16:32 +0800 From: To: CC: , , Subject: [PATCH v4 2/7] rtw88: 8821c: add set tx power index Date: Tue, 16 Jun 2020 17:16:20 +0800 Message-ID: <20200616091625.26489-3-yhchuang@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616091625.26489-1-yhchuang@realtek.com> References: <20200616091625.26489-1-yhchuang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.68.128] X-ClientProxiedBy: RTEXMB02.realtek.com.tw (172.21.6.95) To RTEXMB04.realtek.com.tw (172.21.6.97) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Tzu-En Huang To configure the transmit power of 8821c implement trasmit power index setting callback function for 8821c. This is very similar to the callback function of 8822b. Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Tzu-En Huang Signed-off-by: Yan-Hsuan Chuang --- drivers/net/wireless/realtek/rtw88/rtw8821c.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 9989eab95256..d5ce4ce568dd 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -169,6 +169,44 @@ static void rtw8821c_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr); } +static void +rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs) +{ + struct rtw_hal *hal = &rtwdev->hal; + static const u32 offset_txagc[2] = {0x1d00, 0x1d80}; + static u32 phy_pwr_idx; + u8 rate, rate_idx, pwr_index, shift; + int j; + + for (j = 0; j < rtw_rate_size[rs]; j++) { + rate = rtw_rate_section[rs][j]; + pwr_index = hal->tx_pwr_tbl[path][rate]; + shift = rate & 0x3; + phy_pwr_idx |= ((u32)pwr_index << (shift * 8)); + if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) { + rate_idx = rate & 0xfc; + rtw_write32(rtwdev, offset_txagc[path] + rate_idx, + phy_pwr_idx); + phy_pwr_idx = 0; + } + } +} + +static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev) +{ + struct rtw_hal *hal = &rtwdev->hal; + int rs, path; + + for (path = 0; path < hal->rf_path_num; path++) { + for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) { + if (rs == RTW_RATE_SECTION_HT_2S || + rs == RTW_RATE_SECTION_VHT_2S) + continue; + rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs); + } + } +} + static struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8821c[] = { {0x0086, RTW_PWR_CUT_ALL_MSK, @@ -598,6 +636,7 @@ static struct rtw_chip_ops rtw8821c_ops = { .read_rf = rtw_phy_read_rf, .write_rf = rtw_phy_write_rf_reg_sipi, .set_antenna = NULL, + .set_tx_power_index = rtw8821c_set_tx_power_index, .cfg_ldo25 = rtw8821c_cfg_ldo25, }; -- 2.17.1