linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <kvalo@kernel.org>
Cc: <kevin_yang@realtek.com>, <linux-wireless@vger.kernel.org>
Subject: [PATCH 2/8] wifi: rtw89: regd: judge 6 GHz according to chip and BIOS
Date: Fri, 2 Jun 2023 23:05:50 +0800	[thread overview]
Message-ID: <20230602150556.36777-3-pkshih@realtek.com> (raw)
In-Reply-To: <20230602150556.36777-1-pkshih@realtek.com>

From: Zong-Zhe Yang <kevin_yang@realtek.com>

We allow platform to disable 6 GHz on chips, which supports 6 GHz, through
BIOS. Driver will evaluate Realtek acpi DSM with RTW89_ACPI_DSM_FUNC_6G_DIS
(function 3) to get whether 6 GHz should be disabled.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/regd.c | 50 +++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c
index 377a7a1c560b7..43e589c023af8 100644
--- a/drivers/net/wireless/realtek/rtw89/regd.c
+++ b/drivers/net/wireless/realtek/rtw89/regd.c
@@ -330,6 +330,55 @@ static void rtw89_regd_setup_unii4(struct rtw89_dev *rtwdev,
 	sband->n_channels -= 3;
 }
 
+static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy)
+{
+	const struct rtw89_chip_info *chip = rtwdev->chip;
+	bool chip_support_6ghz = chip->support_bands & BIT(NL80211_BAND_6GHZ);
+	bool regd_allow_6ghz = chip_support_6ghz;
+	struct ieee80211_supported_band *sband;
+	int ret;
+	u8 val;
+
+	if (!chip_support_6ghz)
+		goto bottom;
+
+	ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_6G_DIS, &val);
+	if (ret) {
+		rtw89_debug(rtwdev, RTW89_DBG_REGD,
+			    "acpi: cannot eval 6ghz: %d\n", ret);
+		goto bottom;
+	}
+
+	rtw89_debug(rtwdev, RTW89_DBG_REGD,
+		    "acpi: eval if disallow 6ghz: %d\n", val);
+
+	switch (val) {
+	case 0:
+		regd_allow_6ghz = true;
+		break;
+	case 1:
+		regd_allow_6ghz = false;
+		break;
+	default:
+		break;
+	}
+
+bottom:
+	rtw89_debug(rtwdev, RTW89_DBG_REGD, "regd: allow 6ghz: %d\n",
+		    regd_allow_6ghz);
+
+	if (regd_allow_6ghz)
+		return;
+
+	sband = wiphy->bands[NL80211_BAND_6GHZ];
+	if (!sband)
+		return;
+
+	wiphy->bands[NL80211_BAND_6GHZ] = NULL;
+	kfree(sband->iftype_data);
+	kfree(sband);
+}
+
 int rtw89_regd_setup(struct rtw89_dev *rtwdev)
 {
 	struct wiphy *wiphy = rtwdev->hw->wiphy;
@@ -338,6 +387,7 @@ int rtw89_regd_setup(struct rtw89_dev *rtwdev)
 		return -EINVAL;
 
 	rtw89_regd_setup_unii4(rtwdev, wiphy);
+	rtw89_regd_setup_6ghz(rtwdev, wiphy);
 
 	wiphy->reg_notifier = rtw89_regd_notifier;
 	return 0;
-- 
2.25.1


  parent reply	other threads:[~2023-06-02 15:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 15:05 [PATCH 0/8] wifi: rtw89: support 6 GHz power types STD/LPI/VLP Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 1/8] wifi: rtw89: refine clearing supported bands to check 2/5 GHz first Ping-Ke Shih
2023-06-08 15:59   ` Kalle Valo
2023-06-02 15:05 ` Ping-Ke Shih [this message]
2023-06-02 15:05 ` [PATCH 3/8] wifi: rtw89: regd: update regulatory map to R64-R40 Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 4/8] wifi: rtw89: process regulatory for 6 GHz power type Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 5/8] wifi: rtw89: 8852c: update TX power tables to R63 with 6 GHz power type (1 of 3) Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 6/8] wifi: rtw89: 8852c: update TX power tables to R63 with 6 GHz power type (2 " Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 7/8] wifi: rtw89: 8852c: update TX power tables to R63 with 6 GHz power type (3 " Ping-Ke Shih
2023-06-02 15:05 ` [PATCH 8/8] wifi: rtw89: 8852c: update RF radio A/B parameters to R63 Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230602150556.36777-3-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=kevin_yang@realtek.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).