[openwrt/openwrt] mac80211: fix led-pin usage
LEDE Commits
lede-commits at lists.infradead.org
Wed Apr 9 03:43:39 PDT 2025
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/8534844847d47d1f883012c0297422d5611c7e83
commit 8534844847d47d1f883012c0297422d5611c7e83
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Wed Jan 1 11:26:16 2025 -0800
mac80211: fix led-pin usage
ath9k uses a deprecated GPIO API that assumes a starting base of 0. This
is no longer the case and so must be fixed.
Upstream pending patch.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17445
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../ath9k/341-wifi-ath9k-obtain-system-gpios.patch | 273 +++++++++++++++++++++
...k-interpret-requested-txpower-in-EIRP-dom.patch | 4 +-
...t-tx-power-reduction-for-US-regulatory-do.patch | 2 +-
.../patches/ath9k/513-ath9k_add_pci_ids.patch | 2 +-
.../patches/ath9k/542-ath9k_debugfs_diag.patch | 4 +-
5 files changed, 279 insertions(+), 6 deletions(-)
diff --git a/package/kernel/mac80211/patches/ath9k/341-wifi-ath9k-obtain-system-gpios.patch b/package/kernel/mac80211/patches/ath9k/341-wifi-ath9k-obtain-system-gpios.patch
new file mode 100644
index 0000000000..4feb748229
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath9k/341-wifi-ath9k-obtain-system-gpios.patch
@@ -0,0 +1,273 @@
+From patchwork Tue Apr 23 12:12:33 2024
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Linus Walleij <linus.walleij at linaro.org>
+X-Patchwork-Id: 1926515
+Return-Path:
+ <linux-gpio+bounces-5755-incoming=patchwork.ozlabs.org at vger.kernel.org>
+X-Original-To: incoming at patchwork.ozlabs.org
+Delivered-To: patchwork-incoming at legolas.ozlabs.org
+Authentication-Results: legolas.ozlabs.org;
+ dkim=pass (2048-bit key;
+ unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256
+ header.s=google header.b=qX99TQMM;
+ dkim-atps=neutral
+Authentication-Results: legolas.ozlabs.org;
+ spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org
+ (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org;
+ envelope-from=linux-gpio+bounces-5755-incoming=patchwork.ozlabs.org at vger.kernel.org;
+ receiver=patchwork.ozlabs.org)
+Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org
+ [IPv6:2604:1380:45e3:2400::1])
+ (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
+ key-exchange X25519 server-signature ECDSA (secp384r1))
+ (No client certificate requested)
+ by legolas.ozlabs.org (Postfix) with ESMTPS id 4VP1Gc6RZKz1yZP
+ for <incoming at patchwork.ozlabs.org>; Tue, 23 Apr 2024 22:12:56 +1000 (AEST)
+Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org
+ [52.25.139.140])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5BB9C28522A
+ for <incoming at patchwork.ozlabs.org>; Tue, 23 Apr 2024 12:12:55 +0000 (UTC)
+Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
+ by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F83B8563D;
+ Tue, 23 Apr 2024 12:12:41 +0000 (UTC)
+Authentication-Results: smtp.subspace.kernel.org;
+ dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org
+ header.b="qX99TQMM"
+X-Original-To: linux-gpio at vger.kernel.org
+Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com
+ [209.85.208.179])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
+ (No client certificate requested)
+ by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8F3C82865
+ for <linux-gpio at vger.kernel.org>; Tue, 23 Apr 2024 12:12:37 +0000 (UTC)
+Authentication-Results: smtp.subspace.kernel.org;
+ arc=none smtp.client-ip=209.85.208.179
+ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
+ t=1713874361; cv=none;
+ b=d6RcvcAu8hBYAK8Io489ZHQpJVXPwuokP6iMcAkbvElCerbXD6jAdqdi+RjDlo5C49GHGO4FQ19UwQn/VE//qSwiK1ulTSBp3OkvAmyb7yYAFnDs9AVNWRw+5/NxeFNn3fj5PyvqVymIbaJKabfrOVNwkz/5JMHxEIJtr6Crmog=
+ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
+ s=arc-20240116; t=1713874361; c=relaxed/simple;
+ bh=0eXJ5AIjzz1TBGZ8SlshIPrEHZaZwZfYEdof+dSpu4Y=;
+ h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc;
+ b=EfFtruUxRIGy+jylEiJ2rPEyPCjGCc8ptT9FVxe6s0O/kW38Y6196xVQeiSV2tSKVCEOIO+9HoqmpgdKsJE7gU9++EcrasP96MYpsklYpc2zsWW3b8QEhfxfZ9Ai/idyYihE2u9dQ7a143P/Ij/twDrZTt24wO/mtHDrE5XcCFI=
+ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
+ dmarc=pass (p=none dis=none) header.from=linaro.org;
+ spf=pass smtp.mailfrom=linaro.org;
+ dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org
+ header.b=qX99TQMM; arc=none smtp.client-ip=209.85.208.179
+Authentication-Results: smtp.subspace.kernel.org;
+ dmarc=pass (p=none dis=none) header.from=linaro.org
+Authentication-Results: smtp.subspace.kernel.org;
+ spf=pass smtp.mailfrom=linaro.org
+Received: by mail-lj1-f179.google.com with SMTP id
+ 38308e7fff4ca-2dd041acff1so40839131fa.1
+ for <linux-gpio at vger.kernel.org>;
+ Tue, 23 Apr 2024 05:12:37 -0700 (PDT)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=linaro.org; s=google; t=1713874356; x=1714479156;
+ darn=vger.kernel.org;
+ h=cc:to:message-id:content-transfer-encoding:mime-version:subject
+ :date:from:from:to:cc:subject:date:message-id:reply-to;
+ bh=vysJsMiH5IVqdTs4yMwZxZ7nUmt2aG7eBhkn8qm8hvI=;
+ b=qX99TQMMdHbskFYUaw8c93sIJsUhKmj/WPdyahHcupUhwn5wol4aVoPczkOKYwJZhE
+ eoInxzjAHIl3UNKyvPPrD4MrbLcSoFT6mTFMsgRQYUghsLattmGcqIebu9XT556dBhsf
+ DydmpqGgnTOIa+IEknFxg24mo8Xn2LVmDC7LSGEYykUy1xLHd1NSq56YEaYXC7641xeZ
+ 9TOL0rZszeGld5cCS3013EmEeXQGCC3lAP83Eb48vbFXjPojkN0s40rZ2s8YpVsGT0iP
+ LeLVtP/E8XJqi4YipKryKSgbgOvQ1Bclle5+s+2qcJQNnSEjekMwR59BIRs3OZH2SRfN
+ gQdQ==
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=1e100.net; s=20230601; t=1713874356; x=1714479156;
+ h=cc:to:message-id:content-transfer-encoding:mime-version:subject
+ :date:from:x-gm-message-state:from:to:cc:subject:date:message-id
+ :reply-to;
+ bh=vysJsMiH5IVqdTs4yMwZxZ7nUmt2aG7eBhkn8qm8hvI=;
+ b=jEBH4NQ7SzFi2tnb1lgL06IchnBJoscNgKesjlorvou6X/9wDE/VbgxNFKR0zWwdTk
+ BEjG/ifFJxLmM9jdaCKu5cJc4yiDNXp7yZd48D71V34zJ4aINAGAx4hcOKqf95neFknx
+ nsFPpBFnTYFEpCLF0TebVoL6h6ehPzSojmkArzsrMppNvW2cwJ5gDlkqy2y4SezLanmM
+ 6iU0ksnwE0bb2iLkahhgo00Ejt33yqxwa+3xBfhOe9oYKSSZYnY7qVq055SSwt9IAq+H
+ REGyJN+GrvupTHagiioYe3LPXDPdOui9ZixXXDllw1t1yGUy+TkJu8xSqtvHEfg81FHP
+ AxtA==
+X-Forwarded-Encrypted: i=1;
+ AJvYcCUbxzPklfPYrLgyY1I0ycuj7Dh04dcGVonYocA2mzxzlAEV107o0ELlFqr3O9Td+tV/t0eV9ly9YAbTY6n1XPnFXS5dsYYAZw6RHw==
+X-Gm-Message-State: AOJu0YxsC7zdakTzntbiRFnN2A7yTrR0x+IpR6ce6eGn5kHeqIBi1km+
+ zTVpRulbch3JsmzVDbCbbAAYoBkNgEA568YL6zdjVARnvFwNz1cqatOrR1AXUm0=
+X-Google-Smtp-Source:
+ AGHT+IHBRMGvaJM98f86Z6m/RfVhK2XejjNGF3EvcRq/4x3oGM0DKpd2PbeCJdgmzHjLPVVbdsNzJg==
+X-Received: by 2002:a2e:9852:0:b0:2d8:a98d:18e with SMTP id
+ e18-20020a2e9852000000b002d8a98d018emr7955886ljj.8.1713874355700;
+ Tue, 23 Apr 2024 05:12:35 -0700 (PDT)
+Received: from [192.168.1.140] ([85.235.12.238])
+ by smtp.gmail.com with ESMTPSA id
+ x6-20020a2e7c06000000b002da179d8d25sm1628982ljc.64.2024.04.23.05.12.33
+ (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
+ Tue, 23 Apr 2024 05:12:35 -0700 (PDT)
+From: Linus Walleij <linus.walleij at linaro.org>
+Date: Tue, 23 Apr 2024 14:12:33 +0200
+Subject: [PATCH v2] wifi: ath9k: Obtain system GPIOS from descriptors
+Precedence: bulk
+X-Mailing-List: linux-gpio at vger.kernel.org
+List-Id: <linux-gpio.vger.kernel.org>
+List-Subscribe: <mailto:linux-gpio+subscribe at vger.kernel.org>
+List-Unsubscribe: <mailto:linux-gpio+unsubscribe at vger.kernel.org>
+MIME-Version: 1.0
+Message-Id: <20240423-descriptors-wireless-v2-1-6d1d03b30bfa at linaro.org>
+X-B4-Tracking: v=1; b=H4sIALClJ2YC/22Nyw6CMBBFf4XM2hpanrLyPwyL0o4wCaFkxqCG9
+ N+txKXLc5Nz7g6CTCjQZTswbiQUlgTmlIGb7DKiIp8YTG7KXBujPIpjWh+BRT2JcUYRNbTeXir
+ v7FBUkNSV8U6vI3vrE08kSXgfL5v+rr9gof8HN61yhdo1rvJ125T1dabFcjgHHqGPMX4Ao4iiN
+ LkAAAA=
+To: Kalle Valo <kvalo at kernel.org>,
+ Andy Shevchenko <andriy.shevchenko at linux.intel.com>,
+ Arnd Bergmann <arnd at arndb.de>, Alban Bedel <albeu at free.fr>,
+ Bartosz Golaszewski <brgl at bgdev.pl>, =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rg?=
+ =?utf-8?q?ensen?= <toke at toke.dk>
+Cc: linux-wireless at vger.kernel.org, brcm80211-dev-list.pdl at broadcom.com,
+ linux-gpio at vger.kernel.org, Linus Walleij <linus.walleij at linaro.org>
+X-Mailer: b4 0.13.0
+
+The ath9k has an odd use of system-wide GPIOs: if the chip
+does not have internal GPIO capability, it will try to obtain a
+GPIO line from the system GPIO controller:
+
+ if (BIT(gpio) & ah->caps.gpio_mask)
+ ath9k_hw_gpio_cfg_wmac(...);
+ else if (AR_SREV_SOC(ah))
+ ath9k_hw_gpio_cfg_soc(ah, gpio, out, label);
+
+Where ath9k_hw_gpio_cfg_soc() will attempt to issue
+gpio_request_one() passing the local GPIO number of the controller
+(0..31) to gpio_request_one().
+
+This is somewhat peculiar and possibly even dangerous: there is
+nowadays no guarantee of the numbering of these system-wide
+GPIOs, and assuming that GPIO 0..31 as used by ath9k would
+correspond to GPIOs 0..31 on the system as a whole seems a bit
+wild.
+
+Register all 32 GPIOs at index 0..31 directly in the ATH79K
+GPIO driver and associate with WIFI if and only if we are probing
+ATH79K wifi from the AHB bus (used for SoCs).
+
+Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
+---
+Changes in v2:
+- Define all the descriptors directly in the ATH79K
+ GPIO driver in case the driver want to request them directly.
+- Link to v1: https://lore.kernel.org/r/20240131-descriptors-wireless-v1-0-e1c7c5d68746@linaro.org
+---
+ drivers/net/wireless/ath/ath9k/hw.c | 29 ++++++++++++-----------
+ drivers/net/wireless/ath/ath9k/hw.h | 3 ++-
+ 2 files changed, 32 insertions(+), 15 deletions(-)
+
+
+---
+base-commit: 4cece764965020c22cff7665b18a012006359095
+change-id: 20240122-descriptors-wireless-b8da95dcab35
+
+Best regards,
+
+--- a/drivers/net/wireless/ath/ath9k/hw.c
++++ b/drivers/net/wireless/ath/ath9k/hw.c
+@@ -20,7 +20,7 @@
+ #include <linux/time.h>
+ #include <linux/bitops.h>
+ #include <linux/etherdevice.h>
+-#include <linux/gpio.h>
++#include <linux/gpio/consumer.h>
+ #include <linux/unaligned.h>
+
+ #include "hw.h"
+@@ -2727,19 +2727,25 @@ static void ath9k_hw_gpio_cfg_output_mux
+ static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
+ const char *label)
+ {
++ enum gpiod_flags flags = out ? GPIOD_OUT_LOW : GPIOD_IN;
++ struct gpio_desc *gpiod;
+ int err;
+
+- if (ah->caps.gpio_requested & BIT(gpio))
++ if (ah->gpiods[gpio])
+ return;
+
+- err = devm_gpio_request_one(ah->dev, gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label);
+- if (err) {
++ /* Obtains a system specific GPIO descriptor from another GPIO controller */
++ gpiod = gpiod_get_index(NULL, "ath9k", gpio, flags);
++
++ if (IS_ERR(gpiod)) {
++ err = PTR_ERR(gpiod);
+ ath_err(ath9k_hw_common(ah), "request GPIO%d failed:%d\n",
+ gpio, err);
+ return;
+ }
+
+- ah->caps.gpio_requested |= BIT(gpio);
++ gpiod_set_consumer_name(gpiod, label);
++ ah->gpiods[gpio] = gpiod;
+ }
+
+ static void ath9k_hw_gpio_cfg_wmac(struct ath_hw *ah, u32 gpio, bool out,
+@@ -2801,8 +2807,10 @@ void ath9k_hw_gpio_free(struct ath_hw *a
+
+ WARN_ON(gpio >= ah->caps.num_gpio_pins);
+
+- if (ah->caps.gpio_requested & BIT(gpio))
+- ah->caps.gpio_requested &= ~BIT(gpio);
++ if (ah->gpiods[gpio]) {
++ gpiod_put(ah->gpiods[gpio]);
++ ah->gpiods[gpio] = NULL;
++ }
+ }
+ EXPORT_SYMBOL(ath9k_hw_gpio_free);
+
+@@ -2830,8 +2838,8 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah,
+ val = REG_READ(ah, AR_GPIO_IN(ah)) & BIT(gpio);
+ else
+ val = MS_REG_READ(AR, gpio);
+- } else if (BIT(gpio) & ah->caps.gpio_requested) {
+- val = gpio_get_value(gpio) & BIT(gpio);
++ } else if (ah->gpiods[gpio]) {
++ val = gpiod_get_value(ah->gpiods[gpio]);
+ } else {
+ WARN_ON(1);
+ }
+@@ -2854,8 +2862,8 @@ void ath9k_hw_set_gpio(struct ath_hw *ah
+ AR7010_GPIO_OUT : AR_GPIO_IN_OUT(ah);
+
+ REG_RMW(ah, out_addr, val << gpio, BIT(gpio));
+- } else if (BIT(gpio) & ah->caps.gpio_requested) {
+- gpio_set_value(gpio, val);
++ } else if (ah->gpiods[gpio]) {
++ gpiod_set_value(ah->gpiods[gpio], val);
+ } else {
+ WARN_ON(1);
+ }
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -19,6 +19,7 @@
+
+ #include <linux/if_ether.h>
+ #include <linux/delay.h>
++#include <linux/gpio/consumer.h>
+ #include <linux/io.h>
+ #include <linux/firmware.h>
+
+@@ -302,7 +303,6 @@ struct ath9k_hw_capabilities {
+ u8 max_rxchains;
+ u8 num_gpio_pins;
+ u32 gpio_mask;
+- u32 gpio_requested;
+ u8 rx_hp_qdepth;
+ u8 rx_lp_qdepth;
+ u8 rx_status_len;
+@@ -783,6 +783,7 @@ struct ath_hw {
+ struct ath9k_hw_capabilities caps;
+ struct ath9k_channel channels[ATH9K_NUM_CHANNELS];
+ struct ath9k_channel *curchan;
++ struct gpio_desc *gpiods[32];
+
+ union {
+ struct ar5416_eeprom_def def;
diff --git a/package/kernel/mac80211/patches/ath9k/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch b/package/kernel/mac80211/patches/ath9k/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
index 9016da963b..78ad7623b2 100644
--- a/package/kernel/mac80211/patches/ath9k/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
+++ b/package/kernel/mac80211/patches/ath9k/356-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
@@ -8,7 +8,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2975,7 +2975,8 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2983,7 +2983,8 @@ void ath9k_hw_apply_txpower(struct ath_h
{
struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
struct ieee80211_channel *channel;
@@ -18,7 +18,7 @@ This reverts commit 71f5137bf010c6faffab50c0ec15374c59c4a411.
u16 ctl = NO_CTL;
if (!chan)
-@@ -2987,9 +2988,14 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2995,9 +2996,14 @@ void ath9k_hw_apply_txpower(struct ath_h
channel = chan->chan;
chan_pwr = min_t(int, channel->max_power * 2, MAX_COMBINED_POWER);
new_pwr = min_t(int, chan_pwr, reg->power_limit);
diff --git a/package/kernel/mac80211/patches/ath9k/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch b/package/kernel/mac80211/patches/ath9k/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch
index 5e5f3e4f10..21563bdaf5 100644
--- a/package/kernel/mac80211/patches/ath9k/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch
+++ b/package/kernel/mac80211/patches/ath9k/365-ath9k-adjust-tx-power-reduction-for-US-regulatory-do.patch
@@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2994,6 +2994,10 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -3002,6 +3002,10 @@ void ath9k_hw_apply_txpower(struct ath_h
if (ant_gain > max_gain)
ant_reduction = ant_gain - max_gain;
diff --git a/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch b/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch
index 6b60d3c089..9e3f867344 100644
--- a/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch
+++ b/package/kernel/mac80211/patches/ath9k/513-ath9k_add_pci_ids.patch
@@ -10,7 +10,7 @@
case AR5416_AR9100_DEVID:
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
-@@ -36,6 +36,7 @@
+@@ -37,6 +37,7 @@
#define ATHEROS_VENDOR_ID 0x168c
diff --git a/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch b/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch
index f08301c7f4..35d39a05c7 100644
--- a/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch
+++ b/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch
@@ -75,7 +75,7 @@
struct ath9k_hw_version {
u32 magic;
u16 devid;
-@@ -810,6 +816,8 @@ struct ath_hw {
+@@ -811,6 +817,8 @@ struct ath_hw {
u32 ah_flags;
s16 nf_override;
@@ -84,7 +84,7 @@
bool reset_power_on;
bool htc_reset_init;
-@@ -1079,6 +1087,7 @@ void ath9k_hw_check_nav(struct ath_hw *a
+@@ -1080,6 +1088,7 @@ void ath9k_hw_check_nav(struct ath_hw *a
bool ath9k_hw_check_alive(struct ath_hw *ah);
bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode);
More information about the lede-commits
mailing list