summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@freemail.hu>2018-01-18 13:50:31 +0100
committerJohn Crispin <john@phrozen.org>2018-01-22 10:53:32 +0100
commita4320b3332fb76e17b403c2df2f0f9ad77aafb33 (patch)
tree708749094a3d7fcb3a368a7fbc3eee0f41600cc7 /target/linux/ar71xx
parente379e60b17157d91ae51236f0a747772b0cc1662 (diff)
downloadmtk-20170518-a4320b3332fb76e17b403c2df2f0f9ad77aafb33.zip
mtk-20170518-a4320b3332fb76e17b403c2df2f0f9ad77aafb33.tar.gz
mtk-20170518-a4320b3332fb76e17b403c2df2f0f9ad77aafb33.tar.bz2
ar71xx: make leds-gpio usable with single-ended GPIOs
Add patches for the leds-gpio driver to make it usable with open-drain and open-source kind of GPIO lines. This type of functionality is required by various MikroTik boards. Signed-off-by: Gabor Juhos <juhosg@freemail.hu>
Diffstat (limited to 'target/linux/ar71xx')
-rw-r--r--target/linux/ar71xx/patches-4.4/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch45
-rw-r--r--target/linux/ar71xx/patches-4.9/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch45
2 files changed, 90 insertions, 0 deletions
diff --git a/target/linux/ar71xx/patches-4.4/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch b/target/linux/ar71xx/patches-4.4/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch
new file mode 100644
index 0000000..c17c8791
--- /dev/null
+++ b/target/linux/ar71xx/patches-4.4/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch
@@ -0,0 +1,45 @@
+From 183148e0789bee1cd5c46ba49afcb211f636f8a2 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@freemail.hu>
+Date: Mon, 15 Jan 2018 15:01:14 +0100
+Subject: [PATCH] leds: gpio: allow to use OPEN_{DRAIN,SOURCE} flags with
+ legacy GPIOs
+
+LEDs which are connected to open-source or open-drain type of GPIO lines
+can be used only, if those are defined via devicetree.
+Add two new fields to 'struct gpio_led' in order to make it possible to
+specify this type of GPIO lines to the leds-gpio driver via platform data.
+Also update the create_gpio_led() function to set the GPIOF_OPEN_DRAIN and
+GPIOF_OPEN_SOURCE flags for the given GPIO line.
+
+Signed-off-by: Gabor Juhos <juhosg@freemail.hu>
+---
+ drivers/leds/leds-gpio.c | 6 ++++++
+ include/linux/leds.h | 2 ++
+ 2 files changed, 8 insertions(+)
+
+--- a/drivers/leds/leds-gpio.c
++++ b/drivers/leds/leds-gpio.c
+@@ -110,6 +110,12 @@ static int create_gpio_led(const struct
+ if (template->active_low)
+ flags |= GPIOF_ACTIVE_LOW;
+
++ if (template->open_drain)
++ flags |= GPIOF_OPEN_DRAIN;
++
++ if (template->open_source)
++ flags |= GPIOF_OPEN_SOURCE;
++
+ ret = devm_gpio_request_one(parent, template->gpio, flags,
+ template->name);
+ if (ret < 0)
+--- a/include/linux/leds.h
++++ b/include/linux/leds.h
+@@ -350,6 +350,8 @@ struct gpio_led {
+ unsigned retain_state_suspended : 1;
+ unsigned default_state : 2;
+ /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
++ unsigned open_drain : 1;
++ unsigned open_source : 1;
+ struct gpio_desc *gpiod;
+ };
+ #define LEDS_GPIO_DEFSTATE_OFF 0
diff --git a/target/linux/ar71xx/patches-4.9/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch b/target/linux/ar71xx/patches-4.9/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch
new file mode 100644
index 0000000..26c8cb5
--- /dev/null
+++ b/target/linux/ar71xx/patches-4.9/442-leds-gpio-allow-to-use-OPEN_-DRAIN-SOURCE-flags-with.patch
@@ -0,0 +1,45 @@
+From 183148e0789bee1cd5c46ba49afcb211f636f8a2 Mon Sep 17 00:00:00 2001
+From: Gabor Juhos <juhosg@freemail.hu>
+Date: Mon, 15 Jan 2018 15:01:14 +0100
+Subject: [PATCH] leds: gpio: allow to use OPEN_{DRAIN,SOURCE} flags with
+ legacy GPIOs
+
+LEDs which are connected to open-source or open-drain type of GPIO lines
+can be used only, if those are defined via devicetree.
+Add two new fields to 'struct gpio_led' in order to make it possible to
+specify this type of GPIO lines to the leds-gpio driver via platform data.
+Also update the create_gpio_led() function to set the GPIOF_OPEN_DRAIN and
+GPIOF_OPEN_SOURCE flags for the given GPIO line.
+
+Signed-off-by: Gabor Juhos <juhosg@freemail.hu>
+---
+ drivers/leds/leds-gpio.c | 6 ++++++
+ include/linux/leds.h | 2 ++
+ 2 files changed, 8 insertions(+)
+
+--- a/drivers/leds/leds-gpio.c
++++ b/drivers/leds/leds-gpio.c
+@@ -100,6 +100,12 @@ static int create_gpio_led(const struct
+ if (template->active_low)
+ flags |= GPIOF_ACTIVE_LOW;
+
++ if (template->open_drain)
++ flags |= GPIOF_OPEN_DRAIN;
++
++ if (template->open_source)
++ flags |= GPIOF_OPEN_SOURCE;
++
+ ret = devm_gpio_request_one(parent, template->gpio, flags,
+ template->name);
+ if (ret < 0)
+--- a/include/linux/leds.h
++++ b/include/linux/leds.h
+@@ -380,6 +380,8 @@ struct gpio_led {
+ unsigned panic_indicator : 1;
+ unsigned default_state : 2;
+ /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
++ unsigned open_drain : 1;
++ unsigned open_source : 1;
+ struct gpio_desc *gpiod;
+ };
+ #define LEDS_GPIO_DEFSTATE_OFF 0