@@ -12,6 +12,7 @@ mt76-y := \
mt76-$(CONFIG_PCI) += pci.o
mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o
+mt76-$(CONFIG_ACPI_WBRF) += acpi_wbrf.o
mt76-usb-y := usb.o usb_trace.o
mt76-sdio-y := sdio.o sdio_txrx.o
new file mode 100644
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: ISC
+/* Copyright (C) 2023 Advanced Micro Devices */
+
+#include <linux/wbrf.h>
+#include "mt76.h"
+
+#if defined(CONFIG_ACPI_WBRF)
+void mt76_init_acpi_wbrf(struct mt76_dev *dev)
+{
+ struct acpi_device *acpi_dev = ACPI_COMPANION(dev->dev);
+
+ if (!acpi_dev) {
+ dev_dbg(dev->dev, "ACPI companion not found\n");
+ return;
+ }
+
+ dev->phy.wbrf = wbrf_supported_producer(acpi_dev);
+ dev_dbg(dev->dev, "WBRF is %s supported\n",
+ dev->phy.wbrf ? "" : "not");
+}
+EXPORT_SYMBOL_GPL(mt76_init_acpi_wbrf);
+int mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef)
+{
+ if (!dev->phy.wbrf)
+ return 0;
+ return wbrf_add_exclusion_wlan(ACPI_COMPANION(dev->dev), chandef);
+}
+EXPORT_SYMBOL_GPL(mt76_add_wbrf);
+int mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef)
+{
+ if (!dev->phy.wbrf)
+ return 0;
+ return wbrf_remove_exclusion_wlan(ACPI_COMPANION(dev->dev), chandef);
+}
+EXPORT_SYMBOL_GPL(mt76_remove_wbrf);
+#endif
@@ -733,6 +733,7 @@ struct mt76_phy {
int txpower_cur;
u8 antenna_mask;
u16 chainmask;
+ bool wbrf;
#ifdef CONFIG_NL80211_TESTMODE
struct mt76_testmode_data test;
@@ -1511,4 +1512,22 @@ mt76_packet_id_flush(struct mt76_dev *dev, struct mt76_wcid *wcid)
idr_destroy(&wcid->pktid);
}
+#ifdef CONFIG_ACPI_WBRF
+void mt76_init_acpi_wbrf(struct mt76_dev *dev);
+int mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef);
+int mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef);
+#else
+static inline void mt76_init_acpi_wbrf(struct mt76_dev *dev) { };
+static inline int
+mt76_add_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef)
+{
+ return 0;
+}
+static inline int
+mt76_remove_wbrf(struct mt76_dev *dev, struct cfg80211_chan_def *chandef)
+{
+ return 0;
+}
+#endif /* CONFIG_ACPI_WBRF */
+
#endif
@@ -420,6 +420,8 @@ int mt7921_register_device(struct mt7921_dev *dev)
mt7921_init_acpi_sar(dev);
+ mt76_init_acpi_wbrf(&dev->mt76);
+
ret = mt7921_init_wcid(dev);
if (ret)
return ret;
@@ -480,6 +480,8 @@ static int mt7921_set_channel(struct mt7921_phy *phy)
mt7921_mutex_acquire(dev);
set_bit(MT76_RESET, &phy->mt76->state);
+ mt76_remove_wbrf(phy->mt76->dev, &phy->mt76->chandef);
+
mt76_set_channel(phy->mt76);
ret = mt7921_mcu_set_chan_info(phy, MCU_EXT_CMD(CHANNEL_SWITCH));
@@ -493,6 +495,7 @@ static int mt7921_set_channel(struct mt7921_phy *phy)
out:
clear_bit(MT76_RESET, &phy->mt76->state);
+ mt76_add_wbrf(phy->mt76->dev, &phy->mt76->chandef);
mt7921_mutex_release(dev);
mt76_worker_schedule(&dev->mt76.tx_worker);