ath9k: OF: qca,disable-(2|5)ghz => ieee80211-freq-limit
authorChristian Lamparter <chunkeey@gmail.com>
Sat, 9 Oct 2021 18:51:21 +0000 (20:51 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sat, 30 Oct 2021 14:32:59 +0000 (16:32 +0200)
OpenWrt maintains two special out-of-tree DT properties:
"qca,disable-5ghz" and "qca,disable-2ghz". These are implemented
in a mac80211 ath9k patch "550-ath9k-disable-bands-via-dt.patch".

With the things being what they are, now might be a good
point to switch the devices to the generic and upstream
"ieee80211-freq-limit" property. This property is much
broader and works differently. Instead of disabling the
drivers logic which would add the affected band and
channels. It now disables all channels which are not
within the specified frequency range.

Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # HH5A
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
package/kernel/mac80211/patches/ath9k/040-ath9k-support-DT-ieee80211-freq-limit-property-to-li.patch [new file with mode: 0644]
package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch [deleted file]
package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch
target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
target/linux/ath79/dts/ar9344_atheros_db120.dts
target/linux/ath79/dts/ar9344_engenius_exx600.dtsi
target/linux/ath79/dts/ar9344_pcs_cap324.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi

diff --git a/package/kernel/mac80211/patches/ath9k/040-ath9k-support-DT-ieee80211-freq-limit-property-to-li.patch b/package/kernel/mac80211/patches/ath9k/040-ath9k-support-DT-ieee80211-freq-limit-property-to-li.patch
new file mode 100644 (file)
index 0000000..4142cb6
--- /dev/null
@@ -0,0 +1,29 @@
+From 03469e79fee9e8e908dae3bd1a80bcd9a66f2a88 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Mon, 11 Oct 2021 18:18:00 +0300
+Subject: ath9k: support DT ieee80211-freq-limit property to limit channels
+
+The common DT property can be used to limit the available channels
+but ath9k has to manually call wiphy_read_of_freq_limits().
+
+I would have put this into ath9k_of_init(). But it didn't work there.
+The reason is that in ath9k_of_init() the channels and bands are not yet
+registered in the wiphy struct. So there isn't any channel to flag as
+disabled.
+
+Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Link: https://lore.kernel.org/r/20211009212847.1781986-1-chunkeey@gmail.com
+---
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -1094,6 +1094,8 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
+               ARRAY_SIZE(ath9k_tpt_blink));
+ #endif
++      wiphy_read_of_freq_limits(hw->wiphy);
++
+       /* Register with mac80211 */
+       error = ieee80211_register_hw(hw);
+       if (error)
+
diff --git a/package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch b/package/kernel/mac80211/patches/ath9k/550-ath9k-disable-bands-via-dt.patch
deleted file mode 100644 (file)
index d159333..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -625,6 +625,12 @@ static int ath9k_of_init(struct ath_soft
-       ath_dbg(common, CONFIG, "parsing configuration from OF node\n");
-+      if (of_property_read_bool(np, "qca,disable-2ghz"))
-+              ah->disable_2ghz = true;
-+
-+      if (of_property_read_bool(np, "qca,disable-5ghz"))
-+              ah->disable_5ghz = true;
-+
-       if (of_property_read_bool(np, "qca,no-eeprom")) {
-               /* ath9k-eeprom-<bus>-<id>.bin */
-               scnprintf(eeprom_name, sizeof(eeprom_name),
index 2552bbc7a143b80041d183224553b3ffee79f0b8..fce6db21672e48c99683313c66ab262bc3b423db 100644 (file)
@@ -16,7 +16,7 @@
  
  static const struct platform_device_id ath9k_platform_id_table[] = {
        {
-@@ -69,6 +77,242 @@ static const struct ath_bus_ops ath_ahb_
+@@ -69,6 +77,236 @@ static const struct ath_bus_ops ath_ahb_
        .eeprom_read = ath_ahb_eeprom_read,
  };
  
 +      else
 +              pdata->led_pin = -1;
 +
-+      if (of_property_read_bool(pdev->dev.of_node, "qca,disable-2ghz"))
-+              pdata->disable_2ghz = true;
-+
-+      if (of_property_read_bool(pdev->dev.of_node, "qca,disable-5ghz"))
-+              pdata->disable_5ghz = true;
-+
 +      if (of_property_read_bool(pdev->dev.of_node, "qca,tx-gain-buffalo"))
 +              pdata->tx_gain_buffalo = true;
 +
index 549daace7e4597c30d96d4d6ca728755fec70241..ba0f7ad23e52940b1bc4ec2971a8d8e8c73062a6 100644 (file)
@@ -78,7 +78,7 @@
 &wmac {
        status = "okay";
 
-       qca,disable-5ghz;
+       ieee80211-freq-limit = <2402000 2482000>;
        mtd-cal-data = <&art 0x1000>;
 };
 
index f96e31caca8883554e6d689529ee5521664e9a54..625a8e4fa23c8155245d508d075d32aca083dece 100644 (file)
                compatible = "pci168c,0030";
                reg = <0x0000 0 0 0 0>;
                qca,no-eeprom;
-               qca,disable-2ghz;
+               ieee80211-freq-limit = <4900000 5990000>;
                #gpio-cells = <2>;
                gpio-controller;
        };
index 1c318f20837a281b1d343c243ce5f25c43b987c5..09dc5806d7a5116fc351d36a082861e481695524 100644 (file)
@@ -69,7 +69,7 @@
        ath9k: wifi@0,0,0 {
                compatible = "pci168c,0030";
                reg = <0x0 0 0 0 0>;
-               qca,disable-5ghz;
+               ieee80211-freq-limit = <2402000 2482000>;
                qca,no-eeprom;
                #gpio-cells = <2>;
                gpio-controller;
@@ -79,7 +79,7 @@
 &wmac {
        status = "okay";
 
-       qca,disable-2ghz;
+       ieee80211-freq-limit = <4900000 5990000>;
 
        mtd-cal-data = <&art 0x1000>;
 };
index 1f15a2e8b82a81744223286b5e4890ef11f0c0b1..6ebd6a43bb10e60868603e31d6d803f3d68ba1a6 100644 (file)
                mac-address-increment = <(-2)>;
                mtd-cal-data = <&art 0x5000>;
                qca,no-eeprom;
-               qca,disable-5ghz;
+               ieee80211-freq-limit = <2402000 2482000>;
                #gpio-cells = <2>;
                gpio-controller;
        };
 &wmac {
        status = "okay";
 
-       qca,disable-2ghz;
+       ieee80211-freq-limit = <4900000 5990000>;
        mtd-cal-data = <&art 0x1000>;
        nvmem-cells = <&macaddr_art_0>;
        nvmem-cell-names = "mac-address";
index 76cf69335b917ba79af34e1968e1c98bf098e64e..1cd0f2c6b6cea4b685e283124b2320084707dda2 100644 (file)
                compatible = "pci168c,002d";
                reg = <0x7000 0 0 0 0>;
                qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:00:0e.0.bin */
-               qca,disable-5ghz;
+               ieee80211-freq-limit = <2402000 2482000>;
        };
 };
 
index bdf98fe98e4849cc853165adc51a1b185c44061e..5b7c10bb9dd49b5a3959a8818015bee06ea93da4 100644 (file)
                        #gpio-cells = <2>;
                        gpio-controller;
                        qca,no-eeprom;
-                       qca,disable-5ghz;
+                       ieee80211-freq-limit = <2402000 2482000>;
                        nvmem-cells = <&macaddr_ath9k_cal_f100>;
                        nvmem-cell-names = "mac-address";
                        mac-address-increment = <2>;