summaryrefslogtreecommitdiff
path: root/target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch')
-rw-r--r--target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch271
1 files changed, 271 insertions, 0 deletions
diff --git a/target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch b/target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch
new file mode 100644
index 0000000..ca71a91
--- /dev/null
+++ b/target/linux/sunxi/patches-3.14/230-net-rfkill-changes.patch
@@ -0,0 +1,271 @@
+From 5f6f6af41e39677c9b722376a4088d10732cdd44 Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Fri, 17 Jan 2014 14:47:26 +0800
+Subject: [PATCH] net: rfkill: gpio: fix gpio name buffer size off by 1
+
+snprintf should be passed the complete size of the buffer, including
+the space for '\0'. The previous code resulted in the *_reset and
+*_shutdown strings being truncated.
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ 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 bd2a5b9..97ec12a 100644
+--- a/net/rfkill/rfkill-gpio.c
++++ b/net/rfkill/rfkill-gpio.c
+@@ -117,8 +117,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
+ if (!rfkill->shutdown_name)
+ return -ENOMEM;
+
+- snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name);
+- snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name);
++ snprintf(rfkill->reset_name, len + 7 , "%s_reset", rfkill->name);
++ snprintf(rfkill->shutdown_name, len + 10, "%s_shutdown", rfkill->name);
+
+ rfkill->clk = devm_clk_get(&pdev->dev, clk_name);
+
+--
+2.0.3
+
+From d91c313c08167978c3fb20b327b6a7abb7b00ffd Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Fri, 17 Jan 2014 14:47:27 +0800
+Subject: [PATCH] net: rfkill: gpio: use
+ clk_prepare_enable/clk_disable_unprepare
+
+rfkill-gpio calls clk_enable() without first calling clk_prepare(),
+resulting in a warning and no effect. Switch to clk_prepare_enable()
+and clk_disable_unprepare.
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ 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 97ec12a..c7081b7 100644
+--- a/net/rfkill/rfkill-gpio.c
++++ b/net/rfkill/rfkill-gpio.c
+@@ -51,10 +51,10 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
+ gpiod_set_value(rfkill->shutdown_gpio, 0);
+ gpiod_set_value(rfkill->reset_gpio, 0);
+ if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled)
+- clk_disable(rfkill->clk);
++ clk_disable_unprepare(rfkill->clk);
+ } else {
+ if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
+- clk_enable(rfkill->clk);
++ clk_prepare_enable(rfkill->clk);
+ gpiod_set_value(rfkill->reset_gpio, 1);
+ gpiod_set_value(rfkill->shutdown_gpio, 1);
+ }
+--
+2.0.3
+
+From f6dc85e22d3215a26f509fb5b34ca34c56a0d8b4 Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Fri, 17 Jan 2014 14:47:28 +0800
+Subject: [PATCH] net: rfkill: gpio: fix reversed clock enable state
+
+rfkill-gpio has clk_enabled = blocked, which is true when rfkill
+blocks the device. This results in calling clock enable/disable at
+the wrong time. Reversing the value fixes this.
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ net/rfkill/rfkill-gpio.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
+index c7081b7..3084fa3 100644
+--- a/net/rfkill/rfkill-gpio.c
++++ b/net/rfkill/rfkill-gpio.c
+@@ -59,7 +59,7 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
+ gpiod_set_value(rfkill->shutdown_gpio, 1);
+ }
+
+- rfkill->clk_enabled = blocked;
++ rfkill->clk_enabled = !blocked;
+
+ return 0;
+ }
+--
+2.0.3
+
+From 57301a41d4a82902e967f6bd9f09ba6ca31fcbed Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Fri, 17 Jan 2014 14:47:29 +0800
+Subject: [PATCH] net: rfkill: gpio: add device tree support
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ .../devicetree/bindings/rfkill/rfkill-gpio.txt | 26 ++++++++++++++++++++++
+ net/rfkill/rfkill-gpio.c | 23 +++++++++++++++++++
+ 2 files changed, 49 insertions(+)
+ create 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
+new file mode 100644
+index 0000000..8a07ea4
+--- /dev/null
++++ b/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt
+@@ -0,0 +1,26 @@
++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
++- NAME_shutdown-gpios : GPIO phandle to shutdown control
++ (phandle must be the second)
++- NAME_reset-gpios : GPIO phandle to reset control
++
++NAME must match the rfkill-name property. NAME_shutdown-gpios or
++NAME_reset-gpios, or both, must be defined.
++
++Optional properties:
++- clocks : phandle to clock to enable/disable
++
++Example:
++
++ rfkill_bt: rfkill@0 {
++ compatible = "rfkill-gpio";
++ rfkill-name = "bluetooth";
++ rfkill-type = <2>;
++ bluetooth_shutdown-gpios = <0>, <&pio 7 18 0>;
++ bluetooth_reset-gpios = <&pio 7 24 0>;
++ clocks = <&clk_out_a>;
++ };
+diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
+index 3084fa3..48381a8 100644
+--- a/net/rfkill/rfkill-gpio.c
++++ b/net/rfkill/rfkill-gpio.c
+@@ -26,6 +26,7 @@
+ #include <linux/slab.h>
+ #include <linux/acpi.h>
+ #include <linux/gpio/consumer.h>
++#include <linux/of_gpio.h>
+
+ #include <linux/rfkill-gpio.h>
+
+@@ -83,6 +84,18 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
+ return 0;
+ }
+
++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_platform_data *pdata = pdev->dev.platform_data;
+@@ -100,6 +113,10 @@ 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;
+ } else if (pdata) {
+ clk_name = pdata->power_clk_name;
+ rfkill->name = pdata->name;
+@@ -189,6 +206,11 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
+ { },
+ };
+
++static const struct of_device_id rfkill_of_match[] = {
++ { .compatible = "rfkill-gpio", },
++ {},
++};
++
+ static struct platform_driver rfkill_gpio_driver = {
+ .probe = rfkill_gpio_probe,
+ .remove = rfkill_gpio_remove,
+@@ -196,6 +218,7 @@ static struct platform_driver rfkill_gpio_driver = {
+ .name = "rfkill_gpio",
+ .owner = THIS_MODULE,
+ .acpi_match_table = ACPI_PTR(rfkill_acpi_match),
++ .of_match_table = of_match_ptr(rfkill_of_match),
+ },
+ };
+
+--
+2.0.3
+
+From 83c43937ee8c5fcb38241a8e89c2b93e5b0f9526 Mon Sep 17 00:00:00 2001
+From: Chen-Yu Tsai <wens@csie.org>
+Date: Fri, 17 Jan 2014 14:47:30 +0800
+Subject: [PATCH] net: rfkill: gpio: add clock-frequency device tree property
+
+Some devices, such as Broadcom Bluetooth devices, require a specific
+clock rate for the clock tied to the rfkill device. Add clock-frequency
+property so we can specify this from the device tree.
+
+Signed-off-by: Chen-Yu Tsai <wens@csie.org>
+---
+ Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt | 2 ++
+ net/rfkill/rfkill-gpio.c | 4 ++++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt b/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt
+index 8a07ea4..8b8db0a 100644
+--- a/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt
++++ b/Documentation/devicetree/bindings/rfkill/rfkill-gpio.txt
+@@ -13,6 +13,7 @@ NAME_reset-gpios, or both, must be defined.
+
+ Optional properties:
+ - clocks : phandle to clock to enable/disable
++- clock-frequency : clock rate to set for the given clock
+
+ Example:
+
+@@ -23,4 +24,5 @@ Example:
+ bluetooth_shutdown-gpios = <0>, <&pio 7 18 0>;
+ bluetooth_reset-gpios = <&pio 7 24 0>;
+ clocks = <&clk_out_a>;
++ clock-frequency = <32678>;
+ };
+diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
+index 48381a8..3092681 100644
+--- a/net/rfkill/rfkill-gpio.c
++++ b/net/rfkill/rfkill-gpio.c
+@@ -40,6 +40,7 @@ struct rfkill_gpio_data {
+ char *reset_name;
+ char *shutdown_name;
+ struct clk *clk;
++ int clk_frequency;
+
+ bool clk_enabled;
+ };
+@@ -92,6 +93,7 @@ static int rfkill_gpio_dt_probe(struct device *dev,
+ rfkill->name = np->name;
+ of_property_read_string(np, "rfkill-name", &rfkill->name);
+ of_property_read_u32(np, "rfkill-type", &rfkill->type);
++ of_property_read_u32(np, "clock-frequency", &rfkill->clk_frequency);
+
+ return 0;
+ }
+@@ -138,6 +140,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
+ snprintf(rfkill->shutdown_name, len + 10, "%s_shutdown", rfkill->name);
+
+ rfkill->clk = devm_clk_get(&pdev->dev, clk_name);
++ if (!IS_ERR(rfkill->clk) && rfkill->clk_frequency > 0)
++ clk_set_rate(rfkill->clk, rfkill->clk_frequency);
+
+ gpio = devm_gpiod_get_index(&pdev->dev, rfkill->reset_name, 0);
+ if (!IS_ERR(gpio)) {
+--
+2.0.3
+