From nobody Wed Dec 18 19:32:39 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YD3jg1rybz5gnSm; Wed, 18 Dec 2024 19:32:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YD3jg1J8Kz4wBQ; Wed, 18 Dec 2024 19:32:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734550359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oehJwsDeYLvhru6eoRLbqsITpPMsWNGVnwmbiwcYB5g=; b=ltLyzqY4DYx1eo7jN+HXfgJh0GQlDrz+JCAewrgBVVMNhA99KvKez7C2pMZUDQeuxJvAvV gjY2IUrmKHxwf0Nc1KLYkEjfep2GLgOohNXx/8nupCiCVQD//Tf8j2Oqi5NiHjZk6x6t7c nQy5FxqcdM9Q2l8aoYDlLpkULyKpTvW/WyLsjrFMUPIGK6WnFXMY2bdMwunPkIAqc/+J4r V383R8bIHeXgZEwlnx35FLQ6srUbrqYUtsaW/xbD74bw6Q1KLwQ9Xqt7pLS4aJlE1YSXC5 nYB7C5spMARHHiru3OGmdTaHBQPGMgNxTTS7xWnqPP0NdtRpCf7AsdcVIDldzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734550359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oehJwsDeYLvhru6eoRLbqsITpPMsWNGVnwmbiwcYB5g=; b=sMmOjpni5qtkzI7MJGUaTnPx2/1kjslEQYtyd3euIbCnPkd5Oyx6gM7r3Ccia3Jk82Nih5 s1vgPMZ9RXuLUwPyERaRdkCJUWBFtGls94xoMXI+GnoxFqbfKKdpuhhK8FaHCsOxoYdHlS 45ZibZoLqckzVBnqvyxn5IjzMxT/ew7S+n3Ajlot7UZvTiIlnGe4680isnjT9c42cNOxHb w7VVUDf4J2bPUbOTeNARWfuD/AH6K94+SOR+mnUs7bXKB5qPNzo3Zr+GnDJ4tBsSQkoTmZ OdXv3nxx4pMXfNmH6YoVtciwP4IJQsbf5egKXipMYrleiJoGwqoEjy7AdY6tPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734550359; a=rsa-sha256; cv=none; b=qu2+fIs+eeDvrSyK0GESClnjCLhNrmY+n2QM0F+1TMxJGhK7bpRJVkLW81pg0Ds9xWMv1H bhyK5ceYTZ7EJ+gfm0DdUmKZMHeMlO+QaqLnDO66GORg7dJbKqNs/dgYhI6/MIFx9lI2CC j9CnnacT7BmvG6sEwfLMlW03U9XjpLW7SP2U2n/WD/LwJTcoN7i8RPFwNYvHHwSBRpN3bG cHR7PIdEr7lj2cPmnuYfRfBVBOCgt6UXAct00VHA4kKz1mcfOB0wbDNBqf1ANNTujJ41fU 7Ha1vQ7QrGtjU+ROJELHeXhTG5u/siNW3z9vWJM2CrO6D6zxnjX3dQDtM/gm6w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YD3jg0vp4zM5N; Wed, 18 Dec 2024 19:32:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BIJWdU4070804; Wed, 18 Dec 2024 19:32:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BIJWd8v070801; Wed, 18 Dec 2024 19:32:39 GMT (envelope-from git) Date: Wed, 18 Dec 2024 19:32:39 GMT Message-Id: <202412181932.4BIJWd8v070801@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: cf6b389f7c48 - main - rtwn: add tx power training for RTL8812/RTL8821 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf6b389f7c485f735c3d84a7e3fe6833e91321e4 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=cf6b389f7c485f735c3d84a7e3fe6833e91321e4 commit cf6b389f7c485f735c3d84a7e3fe6833e91321e4 Author: Adrian Chadd AuthorDate: 2024-12-07 15:47:45 +0000 Commit: Adrian Chadd CommitDate: 2024-12-18 19:31:18 +0000 rtwn: add tx power training for RTL8812/RTL8821 This apparently kicks off TX power level self-calibration, which can't hurt. Locally tested: * RTL8812AU, STA * RTL8821AU, STA Obtained from: Linux rtw88 Differential Revision: https://reviews.freebsd.org/D47978 Reviewed by: bz, imp --- sys/dev/rtwn/rtl8812a/r12a_chan.c | 32 ++++++++++++++++++++++++++++++++ sys/dev/rtwn/rtl8812a/r12a_reg.h | 1 + 2 files changed, 33 insertions(+) diff --git a/sys/dev/rtwn/rtl8812a/r12a_chan.c b/sys/dev/rtwn/rtl8812a/r12a_chan.c index 749f0e09e831..d71e0a8177fd 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_chan.c +++ b/sys/dev/rtwn/rtl8812a/r12a_chan.c @@ -180,6 +180,36 @@ r12a_write_txpower_ofdm(struct rtwn_softc *sc, int chain, SM(R12A_TXAGC_OFDM54, power[RTWN_RIDX_OFDM54])); } +static void +r12a_tx_power_training(struct rtwn_softc *sc, int chain, + const struct ieee80211_channel *c, uint8_t power[RTWN_RIDX_COUNT]) +{ + uint32_t write_data; + int32_t power_level; + int i; + + write_data = 0; + + power_level = (int32_t) power[RTWN_RIDX_HT_MCS(7)]; + for (i = 0; i < 3; i++) { + if (i == 0) + power_level -= 10; + else if (i == 1) + power_level -= 8; + else + power_level -= 6; + + /* Handle underflow and the minimum value (2) */ + if (power_level < 2) + power_level = 2; + + write_data |= ((power_level & 0xff) << (i * 8)); + } + + rtwn_bb_setbits(sc, R12A_TX_PWR_TRAINING(chain), + 0x00ffffff, write_data); +} + static void r12a_write_txpower(struct rtwn_softc *sc, int chain, struct ieee80211_channel *c, uint8_t power[RTWN_RIDX_COUNT]) @@ -189,6 +219,8 @@ r12a_write_txpower(struct rtwn_softc *sc, int chain, r12a_write_txpower_ofdm(sc, chain, c, power); r12a_write_txpower_ht(sc, chain, c, power); r12a_write_txpower_vht(sc, chain, c, power); + + r12a_tx_power_training(sc, chain, c, power); } static int diff --git a/sys/dev/rtwn/rtl8812a/r12a_reg.h b/sys/dev/rtwn/rtl8812a/r12a_reg.h index 13867fb76973..f1fc4ee2f302 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_reg.h +++ b/sys/dev/rtwn/rtl8812a/r12a_reg.h @@ -124,6 +124,7 @@ #define R12A_TXAGC_NSS2IX5_2IX2(chain) (0xc48 + (chain) * 0x200) #define R12A_TXAGC_NSS2IX9_2IX6(chain) (0xc4c + (chain) * 0x200) #define R12A_INITIAL_GAIN(chain) (0xc50 + (chain) * 0x200) +#define R12A_TX_PWR_TRAINING(chain) (0xc54 + (chain) * 0x200) #define R12A_AFE_POWER_1(chain) (0xc60 + (chain) * 0x200) #define R12A_AFE_POWER_2(chain) (0xc64 + (chain) * 0x200) #define R12A_SLEEP_NAV(chain) (0xc80 + (chain) * 0x200)