diff --git a/patches/linux-imx/0016-Revert-net-rfkill-gpio-add-device-tree-support.patch b/patches/linux-imx/0016-Revert-net-rfkill-gpio-add-device-tree-support.patch new file mode 100644 index 0000000..4419888 --- /dev/null +++ b/patches/linux-imx/0016-Revert-net-rfkill-gpio-add-device-tree-support.patch @@ -0,0 +1,110 @@ +From 2d00a064025e8a0f45897cc90362a811e1b5081c Mon Sep 17 00:00:00 2001 +From: Josua Mayer +Date: Sun, 28 Apr 2024 14:54:56 +0200 +Subject: [PATCH 16/19] Revert "net: rfkill: gpio: add device tree support" + +This reverts commit 484b7645c68380fc606947620f3fbd39288b717a. +--- + .../bindings/rfkill/rfkill-gpio.txt | 25 ------------------ + net/rfkill/rfkill-gpio.c | 26 ------------------- + 2 files changed, 51 deletions(-) + delete mode 100644 Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt + +diff --git a/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt b/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt +deleted file mode 100644 +index 44e82a91ce0c..000000000000 +--- a/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt ++++ /dev/null +@@ -1,25 +0,0 @@ +-GPIO controlled RFKILL devices +- +-Required properties: +-- compatible : Must be "rfkill-gpio". +-- rfkill-name : Name of RFKILL device +-- rfkill-type : Type of RFKILL device: 1 for WiFi, 2 for BlueTooth, etc. +- See include/uapi/linux/rfkill.h for all valid values +-- reset-gpio : reset-gpio to use +-- shutdown-gpio : Shutdown gpio to use +- +-At least one gpio needs to be provided. If both are provided, the "reset" GPIO is toggled first. +- +-Optional properties: +-- clocks : phandle to clock to enable/disable +- +-Example: +- +- rfkill_bt { +- compatible = "rfkill-gpio"; +- rfkill-name = "bluetooth"; +- rfkill-type = <2>; +- reset-gpio = <&gpio7 8 GPIO_ACTIVE_HIGH>; +- shutdown-gpio = <&gpio7 9 GPIO_ACTIVE_HIGH>; +- clocks = <&clk_out_a>; +- }; +diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c +index 67c299e7b916..f5afc9bcdee6 100644 +--- a/net/rfkill/rfkill-gpio.c ++++ b/net/rfkill/rfkill-gpio.c +@@ -13,7 +13,6 @@ + #include + #include + #include +-#include + + struct rfkill_gpio_data { + const char *name; +@@ -72,18 +71,6 @@ static int rfkill_gpio_acpi_probe(struct device *dev, + return devm_acpi_dev_add_driver_gpios(dev, acpi_rfkill_default_gpios); + } + +-static int rfkill_gpio_dt_probe(struct device *dev, +- struct rfkill_gpio_data *rfkill) +-{ +- struct device_node * np = dev->of_node; +- +- rfkill->name = np->name; +- of_property_read_string(np, "rfkill-name", &rfkill->name); +- of_property_read_u32(np, "rfkill-type", &rfkill->type); +- +- return 0; +-} +- + static int rfkill_gpio_probe(struct platform_device *pdev) + { + struct rfkill_gpio_data *rfkill; +@@ -107,10 +94,6 @@ static int rfkill_gpio_probe(struct platform_device *pdev) + ret = rfkill_gpio_acpi_probe(&pdev->dev, rfkill); + if (ret) + return ret; +- } else if (&pdev->dev.of_node) { +- ret = rfkill_gpio_dt_probe(&pdev->dev, rfkill); +- if (ret) +- return ret; + } + + rfkill->clk = devm_clk_get(&pdev->dev, NULL); +@@ -174,21 +157,12 @@ static const struct acpi_device_id rfkill_acpi_match[] = { + MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match); + #endif + +-#ifdef CONFIG_OF +-static const struct of_device_id rfkill_of_match[] = { +- { .compatible = "rfkill-gpio", }, +- {}, +-}; +-MODULE_DEVICE_TABLE(of, rfkill_of_match); +-#endif +- + static struct platform_driver rfkill_gpio_driver = { + .probe = rfkill_gpio_probe, + .remove = rfkill_gpio_remove, + .driver = { + .name = "rfkill_gpio", + .acpi_match_table = ACPI_PTR(rfkill_acpi_match), +- .of_match_table = of_match_ptr(rfkill_of_match), + }, + }; + +-- +2.35.3 + diff --git a/patches/linux-imx/0017-net-rfkill-gpio-add-DT-support.patch b/patches/linux-imx/0017-net-rfkill-gpio-add-DT-support.patch new file mode 100644 index 0000000..da78b35 --- /dev/null +++ b/patches/linux-imx/0017-net-rfkill-gpio-add-DT-support.patch @@ -0,0 +1,72 @@ +From 508e2f1097ae105d7a56d4fe4bb858964c45fe9f Mon Sep 17 00:00:00 2001 +From: Philipp Zabel +Date: Mon, 2 Jan 2023 18:29:34 +0100 +Subject: [PATCH 17/19] net: rfkill: gpio: add DT support + +Allow probing rfkill-gpio via device tree. This hooks up the already +existing support that was started in commit 262c91ee5e52 ("net: +rfkill: gpio: prepare for DT and ACPI support") via the "rfkill-gpio" +compatible, with the "name" and "type" properties renamed to "label" +and "radio-type", respectively, in the device tree case. + +Signed-off-by: Philipp Zabel +Link: https://lore.kernel.org/r/20230102-rfkill-gpio-dt-v2-2-d1b83758c16d@pengutronix.de +Signed-off-by: Johannes Berg +--- + net/rfkill/rfkill-gpio.c | 20 ++++++++++++++++++-- + 1 file changed, 18 insertions(+), 2 deletions(-) + +diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c +index f5afc9bcdee6..786dbfdad772 100644 +--- a/net/rfkill/rfkill-gpio.c ++++ b/net/rfkill/rfkill-gpio.c +@@ -75,6 +75,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) + { + struct rfkill_gpio_data *rfkill; + struct gpio_desc *gpio; ++ const char *name_property; ++ const char *type_property; + const char *type_name; + int ret; + +@@ -82,8 +84,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev) + if (!rfkill) + return -ENOMEM; + +- device_property_read_string(&pdev->dev, "name", &rfkill->name); +- device_property_read_string(&pdev->dev, "type", &type_name); ++ if (dev_of_node(&pdev->dev)) { ++ name_property = "label"; ++ type_property = "radio-type"; ++ } else { ++ name_property = "name"; ++ type_property = "type"; ++ } ++ device_property_read_string(&pdev->dev, name_property, &rfkill->name); ++ device_property_read_string(&pdev->dev, type_property, &type_name); + + if (!rfkill->name) + rfkill->name = dev_name(&pdev->dev); +@@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = { + MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match); + #endif + ++static const struct of_device_id rfkill_of_match[] __maybe_unused = { ++ { .compatible = "rfkill-gpio", }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(of, rfkill_of_match); ++ + static struct platform_driver rfkill_gpio_driver = { + .probe = rfkill_gpio_probe, + .remove = rfkill_gpio_remove, + .driver = { + .name = "rfkill_gpio", + .acpi_match_table = ACPI_PTR(rfkill_acpi_match), ++ .of_match_table = of_match_ptr(rfkill_of_match), + }, + }; + +-- +2.35.3 + diff --git a/patches/linux-imx/0018-net-rfkill-gpio-prevent-value-glitch-during-probe.patch b/patches/linux-imx/0018-net-rfkill-gpio-prevent-value-glitch-during-probe.patch new file mode 100644 index 0000000..f9ec52f --- /dev/null +++ b/patches/linux-imx/0018-net-rfkill-gpio-prevent-value-glitch-during-probe.patch @@ -0,0 +1,56 @@ +From bc389ffe9d31c99c42007ab4c180fbb16ec38f91 Mon Sep 17 00:00:00 2001 +From: Josua Mayer +Date: Wed, 4 Oct 2023 18:39:28 +0200 +Subject: [PATCH 18/19] net: rfkill: gpio: prevent value glitch during probe + +When either reset- or shutdown-gpio have are initially deasserted, +e.g. after a reboot - or when the hardware does not include pull-down, +there will be a short toggle of both IOs to logical 0 and back to 1. + +It seems that the rfkill default is unblocked, so the driver should not +glitch to output low during probe. +It can lead e.g. to unexpected lte modem reconnect: + +[1] root@localhost:~# dmesg | grep "usb 2-1" +[ 2.136124] usb 2-1: new SuperSpeed USB device number 2 using xhci-hcd +[ 21.215278] usb 2-1: USB disconnect, device number 2 +[ 28.833977] usb 2-1: new SuperSpeed USB device number 3 using xhci-hcd + +The glitch has been discovered on an arm64 board, now that device-tree +support for the rfkill-gpio driver has finally appeared :). + +Change the flags for devm_gpiod_get_optional from GPIOD_OUT_LOW to +GPIOD_ASIS to avoid any glitches. +The rfkill driver will set the intended value during rfkill_sync_work. + +Fixes: 7176ba23f8b5 ("net: rfkill: add generic gpio rfkill driver") +Signed-off-by: Josua Mayer +Link: https://lore.kernel.org/r/20231004163928.14609-1-josua@solid-run.com +Signed-off-by: Johannes Berg +--- + net/rfkill/rfkill-gpio.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c +index 786dbfdad772..db2f7dba5bab 100644 +--- a/net/rfkill/rfkill-gpio.c ++++ b/net/rfkill/rfkill-gpio.c +@@ -107,13 +107,13 @@ static int rfkill_gpio_probe(struct platform_device *pdev) + + rfkill->clk = devm_clk_get(&pdev->dev, NULL); + +- gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); ++ gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_ASIS); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + + rfkill->reset_gpio = gpio; + +- gpio = devm_gpiod_get_optional(&pdev->dev, "shutdown", GPIOD_OUT_LOW); ++ gpio = devm_gpiod_get_optional(&pdev->dev, "shutdown", GPIOD_ASIS); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + +-- +2.35.3 + diff --git a/patches/linux-imx/0019-net-rfkill-gpio-set-GPIO-direction.patch b/patches/linux-imx/0019-net-rfkill-gpio-set-GPIO-direction.patch new file mode 100644 index 0000000..aae18ba --- /dev/null +++ b/patches/linux-imx/0019-net-rfkill-gpio-set-GPIO-direction.patch @@ -0,0 +1,45 @@ +From c6559f9a8c60f0dad6097853f3b4eca6c05ad657 Mon Sep 17 00:00:00 2001 +From: Rouven Czerwinski +Date: Thu, 7 Dec 2023 08:58:36 +0100 +Subject: [PATCH 19/19] net: rfkill: gpio: set GPIO direction + +Fix the undefined usage of the GPIO consumer API after retrieving the +GPIO description with GPIO_ASIS. The API documentation mentions that +GPIO_ASIS won't set a GPIO direction and requires the user to set a +direction before using the GPIO. + +This can be confirmed on i.MX6 hardware, where rfkill-gpio is no longer +able to enabled/disable a device, presumably because the GPIO controller +was never configured for the output direction. + +Fixes: b2f750c3a80b ("net: rfkill: gpio: prevent value glitch during probe") +Cc: stable@vger.kernel.org +Signed-off-by: Rouven Czerwinski +Link: https://msgid.link/20231207075835.3091694-1-r.czerwinski@pengutronix.de +Signed-off-by: Johannes Berg +--- + net/rfkill/rfkill-gpio.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c +index db2f7dba5bab..97cddab14961 100644 +--- a/net/rfkill/rfkill-gpio.c ++++ b/net/rfkill/rfkill-gpio.c +@@ -125,6 +125,14 @@ static int rfkill_gpio_probe(struct platform_device *pdev) + return -EINVAL; + } + ++ ret = gpiod_direction_output(rfkill->reset_gpio, true); ++ if (ret) ++ return ret; ++ ++ ret = gpiod_direction_output(rfkill->shutdown_gpio, true); ++ if (ret) ++ return ret; ++ + rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, + rfkill->type, &rfkill_gpio_ops, + rfkill); +-- +2.35.3 + diff --git a/patches/linux-imx/0020-arm64-dts-imx8mp-hummingboard-pulse-use-upstream-rfk.patch b/patches/linux-imx/0020-arm64-dts-imx8mp-hummingboard-pulse-use-upstream-rfk.patch new file mode 100644 index 0000000..a33bb39 --- /dev/null +++ b/patches/linux-imx/0020-arm64-dts-imx8mp-hummingboard-pulse-use-upstream-rfk.patch @@ -0,0 +1,54 @@ +From 76ce3a836b822aca8188264ca7811c6a25d4ffbc Mon Sep 17 00:00:00 2001 +From: Josua Mayer +Date: Sun, 28 Apr 2024 15:13:39 +0200 +Subject: [PATCH] arm64: dts: imx8mp-hummingboard-pulse: use upstream rfkill + properties + +Upstream finally has accepted rfkill-gpio driver for use in device-tree. +Modify the properties to match current upstream choices. + +Signed-off-by: Josua Mayer +--- + .../dts/freescale/imx8mp-hummingboard-pulse.dtsi | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/arch/arm64/boot/dts/freescale/imx8mp-hummingboard-pulse.dtsi b/arch/arm64/boot/dts/freescale/imx8mp-hummingboard-pulse.dtsi +index 9a9ab1437..2339f8166 100644 +--- a/arch/arm64/boot/dts/freescale/imx8mp-hummingboard-pulse.dtsi ++++ b/arch/arm64/boot/dts/freescale/imx8mp-hummingboard-pulse.dtsi +@@ -104,8 +104,8 @@ rfkill_m2_wdis { + compatible = "rfkill-gpio"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_m2_rfkill>; +- rfkill-name = "m2_wdis"; +- rfkill-type = <5>; ++ label = "m2_wdis"; ++ radio-type = "wwan"; + shutdown-gpio = <&gpio1 13 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; +@@ -114,8 +114,8 @@ rfkill_m2_gps { + compatible = "rfkill-gpio"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_m2_gps_rfkill>; +- rfkill-name = "m2_gps"; +- rfkill-type = <6>; ++ label = "m2_gps"; ++ radio-type = "gps"; + shutdown-gpio = <&gpio1 7 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; +@@ -124,8 +124,8 @@ rfkill_mpcie_wdis { + compatible = "rfkill-gpio"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_mpcie_rfkill>; +- rfkill-name = "mpcie_wdis"; +- rfkill-type = <5>; ++ label = "mpcie_wdis"; ++ radio-type = "wwan"; + reset-gpio = <&gpio1 1 GPIO_ACTIVE_HIGH>; + shutdown-gpio = <&gpio1 5 GPIO_ACTIVE_HIGH>; + status = "okay"; +-- +2.35.3 +