From 72b59359565a1e58e62074faebe4111c0ea08140 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Wed, 1 Jan 2025 11:22:40 +0100 Subject: [PATCH] Revert "mac80211: remove ath9k_platform_data" This reverts commit fdc2c6ab9901ad3e64ec1f93d5ccdc38990243b4. Signed-off-by: Robert Marko --- package/kernel/mac80211/Makefile | 2 +- .../mac80211/patches/ath9k/100-gpio-of.patch | 16 --- .../ath9k/531-ath9k_extra_platform_leds.patch | 28 +++-- .../ath9k/542-ath9k_debugfs_diag.patch | 2 +- .../ath9k/547-ath9k_led_defstate_fix.patch | 2 +- .../ath9k/548-ath9k_enable_gpio_chip.patch | 23 ++-- .../ath9k/549-ath9k_enable_gpio_buttons.patch | 36 +++--- .../patches/ath9k/552-ath9k-ahb_of.patch | 106 +++++++++++++----- 8 files changed, 130 insertions(+), 85 deletions(-) delete mode 100644 package/kernel/mac80211/patches/ath9k/100-gpio-of.patch diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index c3ffb8dc06..b0de3950b9 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 PKG_VERSION:=6.12.6 -PKG_RELEASE:=2 +PKG_RELEASE:=1 PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING diff --git a/package/kernel/mac80211/patches/ath9k/100-gpio-of.patch b/package/kernel/mac80211/patches/ath9k/100-gpio-of.patch deleted file mode 100644 index 2cddb59fc5..0000000000 --- a/package/kernel/mac80211/patches/ath9k/100-gpio-of.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/hw.h -+++ b/drivers/net/wireless/ath/ath9k/hw.h -@@ -976,6 +976,13 @@ struct ath_hw { - bool disable_2ghz; - bool disable_5ghz; - -+ int num_leds; -+ const struct gpio_led *leds; -+ -+ unsigned num_btns; -+ const struct gpio_keys_button *btns; -+ unsigned btn_poll_interval; -+ - const struct firmware *eeprom_blob; - u16 *nvmem_blob; /* devres managed */ - size_t nvmem_blob_len; diff --git a/package/kernel/mac80211/patches/ath9k/531-ath9k_extra_platform_leds.patch b/package/kernel/mac80211/patches/ath9k/531-ath9k_extra_platform_leds.patch index 4f41cd9139..1055bd335c 100644 --- a/package/kernel/mac80211/patches/ath9k/531-ath9k_extra_platform_leds.patch +++ b/package/kernel/mac80211/patches/ath9k/531-ath9k_extra_platform_leds.patch @@ -1,6 +1,14 @@ --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c -@@ -108,6 +108,24 @@ int ath_create_gpio_led(struct ath_softc +@@ -15,6 +15,7 @@ + */ + + #include "ath9k.h" ++#include + + /********************************/ + /* LED functions */ +@@ -108,6 +109,24 @@ int ath_create_gpio_led(struct ath_softc return ret; } @@ -25,30 +33,30 @@ void ath_deinit_leds(struct ath_softc *sc) { struct ath_led *led; -@@ -124,8 +142,10 @@ void ath_deinit_leds(struct ath_softc *s +@@ -124,8 +143,10 @@ void ath_deinit_leds(struct ath_softc *s void ath_init_leds(struct ath_softc *sc) { -+ struct ath_hw *ah = sc->sc_ah; ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; char led_name[32]; const char *trigger; + int i; INIT_LIST_HEAD(&sc->leds); -@@ -134,6 +154,17 @@ void ath_init_leds(struct ath_softc *sc) +@@ -134,6 +155,17 @@ void ath_init_leds(struct ath_softc *sc) ath_fill_led_pin(sc); -+ if (ah->leds && ah->num_leds) -+ for (i = 0; i < ah->num_leds; i++) { -+ if (ah->leds[i].gpio == ah->led_pin) -+ ah->led_pin = -1; ++ if (pdata && pdata->leds && pdata->num_leds) ++ for (i = 0; i < pdata->num_leds; i++) { ++ if (pdata->leds[i].gpio == sc->sc_ah->led_pin) ++ sc->sc_ah->led_pin = -1; + -+ ath_create_platform_led(sc, &ah->leds[i]); ++ ath_create_platform_led(sc, &pdata->leds[i]); + } + -+ if (ah->led_pin < 0) ++ if (sc->sc_ah->led_pin < 0) + return; + snprintf(led_name, sizeof(led_name), "ath9k-%s", 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 9821716c6a..f08301c7f4 100644 --- a/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch +++ b/package/kernel/mac80211/patches/ath9k/542-ath9k_debugfs_diag.patch @@ -84,7 +84,7 @@ bool reset_power_on; bool htc_reset_init; -@@ -1086,6 +1094,7 @@ void ath9k_hw_check_nav(struct ath_hw *a +@@ -1079,6 +1087,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); diff --git a/package/kernel/mac80211/patches/ath9k/547-ath9k_led_defstate_fix.patch b/package/kernel/mac80211/patches/ath9k/547-ath9k_led_defstate_fix.patch index d633c051b0..5d84cf0c42 100644 --- a/package/kernel/mac80211/patches/ath9k/547-ath9k_led_defstate_fix.patch +++ b/package/kernel/mac80211/patches/ath9k/547-ath9k_led_defstate_fix.patch @@ -13,7 +13,7 @@ Signed-off-by: Michal Cieslakiewicz --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c -@@ -73,8 +73,11 @@ static int ath_add_led(struct ath_softc +@@ -74,8 +74,11 @@ static int ath_add_led(struct ath_softc ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name, AR_GPIO_OUTPUT_MUX_AS_OUTPUT); diff --git a/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch b/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch index 1c071c4621..9fb549cc19 100644 --- a/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch +++ b/package/kernel/mac80211/patches/ath9k/548-ath9k_enable_gpio_chip.patch @@ -45,10 +45,10 @@ Signed-off-by: Felix Fietkau #ifdef CPTCFG_ATH9K_DEBUGFS --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c -@@ -15,13 +15,131 @@ - */ +@@ -16,13 +16,135 @@ #include "ath9k.h" + #include +#include + +#ifdef CPTCFG_MAC80211_LEDS @@ -126,7 +126,9 @@ Signed-off-by: Felix Fietkau + gc->sc = sc; + snprintf(gc->label, sizeof(gc->label), "ath9k-%s", + wiphy_name(sc->hw->wiphy)); ++#ifdef CONFIG_OF + gc->gchip.parent = sc->dev; ++#endif + gc->gchip.label = gc->label; + gc->gchip.base = -1; /* determine base automatically */ + gc->gchip.ngpio = ah->caps.num_gpio_pins; @@ -141,7 +143,9 @@ Signed-off-by: Felix Fietkau + return; + } + ++#ifdef CONFIG_OF + gc->gchip.owner = NULL; ++#endif + sc->gpiochip = gc; +} + @@ -179,7 +183,7 @@ Signed-off-by: Felix Fietkau static void ath_fill_led_pin(struct ath_softc *sc) { struct ath_hw *ah = sc->sc_ah; -@@ -79,6 +197,12 @@ static int ath_add_led(struct ath_softc +@@ -80,6 +202,12 @@ static int ath_add_led(struct ath_softc else ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low); @@ -192,7 +196,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -135,17 +259,24 @@ void ath_deinit_leds(struct ath_softc *s +@@ -136,17 +264,24 @@ void ath_deinit_leds(struct ath_softc *s while (!list_empty(&sc->leds)) { led = list_first_entry(&sc->leds, struct ath_led, list); @@ -212,15 +216,18 @@ Signed-off-by: Felix Fietkau void ath_init_leds(struct ath_softc *sc) { - struct ath_hw *ah = sc->sc_ah; + struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct device_node *np = sc->dev->of_node; char led_name[32]; const char *trigger; int i; -@@ -155,6 +286,12 @@ void ath_init_leds(struct ath_softc *sc) +@@ -156,6 +291,15 @@ void ath_init_leds(struct ath_softc *sc) if (AR_SREV_9100(sc->sc_ah)) return; ++ if (!np) ++ ath9k_register_gpio_chip(sc); ++ + /* setup gpio controller only if requested and skip the led_pin setup */ + if (of_property_read_bool(np, "gpio-controller")) { + ath9k_register_gpio_chip(sc); @@ -229,8 +236,8 @@ Signed-off-by: Felix Fietkau + ath_fill_led_pin(sc); - if (ah->leds && ah->num_leds) -@@ -179,6 +316,7 @@ void ath_init_leds(struct ath_softc *sc) + if (pdata && pdata->leds && pdata->num_leds) +@@ -180,6 +324,7 @@ void ath_init_leds(struct ath_softc *sc) ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, !sc->sc_ah->config.led_active_high); } diff --git a/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch b/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch index 92f110b95c..d164d89031 100644 --- a/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch +++ b/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch @@ -20,16 +20,16 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/wireless/ath/ath9k/gpio.c +++ b/drivers/net/wireless/ath/ath9k/gpio.c -@@ -16,6 +16,8 @@ - +@@ -17,6 +17,8 @@ #include "ath9k.h" + #include #include +#include +#include #ifdef CPTCFG_MAC80211_LEDS -@@ -124,6 +126,67 @@ static void ath9k_unregister_gpio_chip(s +@@ -129,6 +131,67 @@ static void ath9k_unregister_gpio_chip(s sc->gpiochip = NULL; } @@ -40,7 +40,7 @@ Signed-off-by: Felix Fietkau +/* add GPIO buttons */ +static void ath9k_init_buttons(struct ath_softc *sc) +{ -+ struct ath_hw *ah = sc->sc_ah; ++ struct ath9k_platform_data *pdata = sc->dev->platform_data; + struct platform_device *pdev; + struct gpio_keys_platform_data gkpdata; + struct gpio_keys_button *bt; @@ -49,28 +49,28 @@ Signed-off-by: Felix Fietkau + if (!sc->gpiochip) + return; + -+ if (!ah->btns || !ah->num_btns) ++ if (!pdata || !pdata->btns || !pdata->num_btns) + return; + -+ bt = devm_kmemdup(sc->dev, ah->btns, -+ ah->num_btns * sizeof(struct gpio_keys_button), ++ bt = devm_kmemdup(sc->dev, pdata->btns, ++ pdata->num_btns * sizeof(struct gpio_keys_button), + GFP_KERNEL); + if (!bt) + return; + -+ for (i = 0; i < ah->num_btns; i++) { -+ if (ah->btns[i].gpio == sc->sc_ah->led_pin) ++ for (i = 0; i < pdata->num_btns; i++) { ++ if (pdata->btns[i].gpio == sc->sc_ah->led_pin) + sc->sc_ah->led_pin = -1; + -+ ath9k_hw_gpio_request_in(sc->sc_ah, ah->btns[i].gpio, ++ ath9k_hw_gpio_request_in(sc->sc_ah, pdata->btns[i].gpio, + "ath9k-gpio"); -+ bt[i].gpio = sc->gpiochip->gchip.base + ah->btns[i].gpio; ++ bt[i].gpio = sc->gpiochip->gchip.base + pdata->btns[i].gpio; + } + + memset(&gkpdata, 0, sizeof(struct gpio_keys_platform_data)); + gkpdata.buttons = bt; -+ gkpdata.nbuttons = ah->num_btns; -+ gkpdata.poll_interval = ah->btn_poll_interval; ++ gkpdata.nbuttons = pdata->num_btns; ++ gkpdata.poll_interval = pdata->btn_poll_interval; + + pdev = platform_device_register_data(sc->dev, "gpio-keys-polled", + PLATFORM_DEVID_AUTO, &gkpdata, @@ -97,7 +97,7 @@ Signed-off-by: Felix Fietkau #else /* CONFIG_GPIOLIB */ static inline void ath9k_register_gpio_chip(struct ath_softc *sc) -@@ -134,6 +197,14 @@ static inline void ath9k_unregister_gpio +@@ -139,6 +202,14 @@ static inline void ath9k_unregister_gpio { } @@ -112,7 +112,7 @@ Signed-off-by: Felix Fietkau #endif /* CONFIG_GPIOLIB */ /********************************/ -@@ -257,6 +328,7 @@ void ath_deinit_leds(struct ath_softc *s +@@ -262,6 +333,7 @@ void ath_deinit_leds(struct ath_softc *s { struct ath_led *led; @@ -120,11 +120,11 @@ Signed-off-by: Felix Fietkau while (!list_empty(&sc->leds)) { led = list_first_entry(&sc->leds, struct ath_led, list); #ifdef CONFIG_GPIOLIB -@@ -293,6 +365,7 @@ void ath_init_leds(struct ath_softc *sc) +@@ -301,6 +373,7 @@ void ath_init_leds(struct ath_softc *sc) } ath_fill_led_pin(sc); + ath9k_init_buttons(sc); - if (ah->leds && ah->num_leds) - for (i = 0; i < ah->num_leds; i++) { + if (pdata && pdata->leds && pdata->num_leds) + for (i = 0; i < pdata->num_leds; i++) { diff --git a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch index a5ad2bcffb..3adc8bb8d6 100644 --- a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch +++ b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch @@ -1,22 +1,27 @@ --- a/drivers/net/wireless/ath/ath9k/ahb.c +++ b/drivers/net/wireless/ath/ath9k/ahb.c -@@ -20,8 +20,12 @@ +@@ -20,7 +20,15 @@ #include #include #include +#include #include "ath9k.h" - ++#include ++ ++#ifdef CONFIG_OF +#include +#include -+ ++#include ++#endif + static const struct platform_device_id ath9k_platform_id_table[] = { { - .name = "ath9k", -@@ -69,22 +73,198 @@ static const struct ath_bus_ops ath_ahb_ +@@ -69,6 +77,192 @@ static const struct ath_bus_ops ath_ahb_ .eeprom_read = ath_ahb_eeprom_read, }; ++#ifdef CONFIG_OF ++ +#define QCA955X_DDR_CTL_CONFIG 0x108 +#define QCA955X_DDR_CTL_CONFIG_ACT_WMAC BIT(23) + @@ -157,7 +162,7 @@ + +static int of_ath_ahb_probe(struct platform_device *pdev) +{ -+ struct ath_hw *ah = platform_get_drvdata(pdev); ++ struct ath9k_platform_data *pdata; + const struct of_device_id *match; + const struct of_ath_ahb_data *data; + u8 led_pin; @@ -165,17 +170,19 @@ + match = of_match_device(of_ath_ahb_match, &pdev->dev); + data = (const struct of_ath_ahb_data *)match->data; + ++ pdata = dev_get_platdata(&pdev->dev); ++ + if (!of_property_read_u8(pdev->dev.of_node, "qca,led-pin", &led_pin)) -+ ah->led_pin = led_pin; ++ pdata->led_pin = led_pin; + else -+ ah->led_pin = -1; ++ pdata->led_pin = -1; + + if (of_property_read_bool(pdev->dev.of_node, "qca,tx-gain-buffalo")) -+ ah->config.tx_gain_buffalo = true; ++ pdata->tx_gain_buffalo = true; + + if (data->wmac_reset) { + data->wmac_reset(); -+ ah->external_reset = data->wmac_reset; ++ pdata->external_reset = data->wmac_reset; + } + + if (data->dev_id == AR9300_DEVID_AR953X) { @@ -184,55 +191,94 @@ + * Some vendors have an invalid bootstrap option + * set, which would break the WMAC here. + */ -+ ah->is_clk_25mhz = true; ++ pdata->is_clk_25mhz = true; + } else if (data->bootstrap_reg && data->bootstrap_ref) { + u32 t = ath79_reset_rr(data->bootstrap_reg); + if (t & data->bootstrap_ref) -+ ah->is_clk_25mhz = false; ++ pdata->is_clk_25mhz = false; + else -+ ah->is_clk_25mhz = true; ++ pdata->is_clk_25mhz = true; + } + -+ ah->get_mac_revision = data->soc_revision; ++ pdata->get_mac_revision = data->soc_revision; + + return data->dev_id; +} ++#endif + static int ath_ahb_probe(struct platform_device *pdev) { void __iomem *mem; - struct ath_softc *sc; - struct ieee80211_hw *hw; - struct resource *res; -- const struct platform_device_id *id = platform_get_device_id(pdev); - int irq; +@@ -80,6 +274,17 @@ static int ath_ahb_probe(struct platform int ret = 0; struct ath_hw *ah; char hw_name[64]; -- -- if (!dev_get_platdata(&pdev->dev)) { -- dev_err(&pdev->dev, "no platform data specified\n"); -- return -EINVAL; -- } -+ u32 dev_id; ++ u16 dev_id; ++ ++ if (id) ++ dev_id = id->driver_data; ++ ++#ifdef CONFIG_OF ++ if (pdev->dev.of_node) ++ pdev->dev.platform_data = devm_kzalloc(&pdev->dev, ++ sizeof(struct ath9k_platform_data), ++ GFP_KERNEL); ++#endif - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { -@@ -124,7 +304,8 @@ static int ath_ahb_probe(struct platform + if (!dev_get_platdata(&pdev->dev)) { + dev_err(&pdev->dev, "no platform data specified\n"); +@@ -118,17 +323,23 @@ static int ath_ahb_probe(struct platform + sc->mem = mem; + sc->irq = irq; + ++#ifdef CONFIG_OF ++ dev_id = of_ath_ahb_probe(pdev); ++#endif + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc); + if (ret) { + dev_err(&pdev->dev, "request_irq failed\n"); goto err_free_hw; } - ret = ath9k_init_device(id->driver_data, sc, &ath_ahb_bus_ops); -+ dev_id = of_ath_ahb_probe(pdev); + ret = ath9k_init_device(dev_id, sc, &ath_ahb_bus_ops); if (ret) { dev_err(&pdev->dev, "failed to initialize device\n"); goto err_irq; -@@ -162,6 +343,7 @@ static struct platform_driver ath_ahb_dr + } ++#ifdef CONFIG_OF ++ pdev->dev.platform_data = NULL; ++#endif + + ah = sc->sc_ah; + ath9k_hw_name(ah, hw_name, sizeof(hw_name)); +@@ -162,6 +373,9 @@ static struct platform_driver ath_ahb_dr .remove_new = ath_ahb_remove, .driver = { .name = "ath9k", ++#ifdef CONFIG_OF + .of_match_table = of_ath_ahb_match, ++#endif }, .id_table = ath9k_platform_id_table, }; +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + #include "common.h" + #include "debug.h" +@@ -1013,6 +1014,9 @@ struct ath_softc { + struct ath_hw *sc_ah; + void __iomem *mem; + int irq; ++#ifdef CONFIG_OF ++ struct reset_control *reset; ++#endif + spinlock_t sc_serial_rw; + spinlock_t sc_pm_lock; + spinlock_t sc_pcu_lock; -- 2.30.2