Allow to use leds-ns2 with n090401 boards
Subsystems (2)
v2 cover Allow to use leds-ns2 with n090401 boards
Hello,
This patch series allows to use the leds-ns2 driver with the n090401 boards (Seagate NAS 4-Bay), based on an Armada-370 SoC.
Here is the list changes:
- Allow to configure the LED mode mapping.
- Handle can_sleep GPIOs. On n090401, the LEDs are connected to an I2C GPIO expander.
- Make leds-ns2 depends on MACH_ARMADA_370.
Changes for v2:
- Fix gpio_{get,set}_*_cansleep() usage while holding a spinlock:
Holding a spinlock at this places was not needed.
- Add Acked-by from Jacek Anaszewski for patch 4.
Simon
Simon Guinot (2):
leds: leds-ns2: handle can_sleep GPIOs
leds: leds-ns2: depends on MACH_ARMADA_370
Vincent Donnefort (2):
leds: leds-ns2: move LED modes mapping outside of the driver
ARM: Kirkwood: add modes-map property to ns2-leds nodes
.../devicetree/bindings/leds/leds-ns2.txt | 9 ++ arch/arm/boot/dts/kirkwood-d2net.dts | 5 + arch/arm/boot/dts/kirkwood-is2.dts | 5 + arch/arm/boot/dts/kirkwood-ns2.dts | 5 + arch/arm/boot/dts/kirkwood-ns2max.dts | 5 + arch/arm/boot/dts/kirkwood-ns2mini.dts | 5 + drivers/leds/Kconfig | 12 +- drivers/leds/leds-ns2.c | 169 ++++++++++++--------- include/dt-bindings/leds/leds-ns2.h | 8 + include/linux/platform_data/leds-kirkwood-ns2.h | 14 ++ 10 files changed, 165 insertions(+), 72 deletions(-) create mode 100644 include/dt-bindings/leds/leds-ns2.h
Signature · 1 line
2.1.4
PATCH v2 1/4 leds: leds-ns2: move LED modes mapping outside of the driver
From: Vincent Donnefort <[email protected]>
On the board n090401 (Seagate NAS 4-Bay), the LED mode mapping (GPIO values to LED mode) is different from the one used on other boards supported by the leds-ns2 driver.
With this patch the hardcoded mapping is removed from leds-ns2. Now, it must be defined either in the platform data (if an old-fashion board setup file is used) or in the DT node. In order to allow the later, this patch also introduces a modes-map property for the leds-ns2 DT binding.
--- .../devicetree/bindings/leds/leds-ns2.txt | 9 ++ drivers/leds/leds-ns2.c | 102 +++++++++++---------- include/dt-bindings/leds/leds-ns2.h | 8 ++ include/linux/platform_data/leds-kirkwood-ns2.h | 14 +++ 4 files changed, 85 insertions(+), 48 deletions(-) create mode 100644 include/dt-bindings/leds/leds-ns2.h
Documentation/devicetree/bindings/leds/leds-ns2.txt +9 -0
@@ -8,6 +8,9 @@ Each LED is represented as a sub-node of the ns2-leds device. Required sub-node properties: - cmd-gpio: Command LED GPIO. See OF device-tree GPIO specification. - slow-gpio: Slow LED GPIO. See OF device-tree GPIO specification. +- modes-map: A mapping between LED modes (off, on or SATA activity blinking) and + the corresponding cmd-gpio/slow-gpio values. All the GPIO values combinations + should be given in order to avoid having an unknown mode at driver probe time. Optional sub-node properties: - label: Name for this LED. If omitted, the label is taken from the node name.
@@ -15,6 +18,8 @@ Optional sub-node properties: Example: +#include <dt-bindings/leds/leds-ns2.h> + ns2-leds { compatible = "lacie,ns2-leds";
@@ -22,5 +27,9 @@ ns2-leds { label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 0 1 + NS_V2_LED_ON 1 0 + NS_V2_LED_ON 0 0 + NS_V2_LED_SATA 1 1>; }; };
drivers/leds/leds-ns2.c +54 -48
163 lines not on this page · raw message
include/dt-bindings/leds/leds-ns2.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _DT_BINDINGS_LEDS_NS2_H +#define _DT_BINDINGS_LEDS_NS2_H + +#define NS_V2_LED_OFF 0 +#define NS_V2_LED_ON 1 +#define NS_V2_LED_SATA 2 + +#endif
include/linux/platform_data/leds-kirkwood-ns2.h +14 -0
@@ -9,11 +9,25 @@#ifndef __LEDS_KIRKWOOD_NS2_H#define __LEDS_KIRKWOOD_NS2_H +enum ns2_led_modes { +NS_V2_LED_OFF , +NS_V2_LED_ON , +NS_V2_LED_SATA , +}; + +struct ns2_led_modval { +enum ns2_led_modes mode; +int cmd_level; +int slow_level; +}; +struct ns2_led {const char *name;const char *default_trigger;unsigned cmd;unsigned slow; +int num_modes; +struct ns2_led_modval *modval; }; struct ns2_led_platform_data {
Signature · 1 line
2.1.4
PATCH v2 2/4 ARM: Kirkwood: add modes-map property to ns2-leds nodes
In reply to Simon GuinotFrom: Vincent Donnefort <[email protected]>
Since the LED modes mapping is no longer hardcoded inside the leds-ns2 driver, then it must be provided through the modes-map property in the ns2-leds nodes.
--- arch/arm/boot/dts/kirkwood-d2net.dts | 5 +++++ arch/arm/boot/dts/kirkwood-is2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2max.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2mini.dts | 5 +++++ 5 files changed, 25 insertions(+)
arch/arm/boot/dts/kirkwood-d2net.dts +5 -0
@@ -10,6 +10,7 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-netxbig.dtsi" / {
@@ -28,6 +29,10 @@ label = "d2net_v2:blue:sata"; slow-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>; cmd-gpio = <&gpio0 30 GPIO_ACTIVE_HIGH>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; };
arch/arm/boot/dts/kirkwood-is2.dts +5 -0
@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {
@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
arch/arm/boot/dts/kirkwood-ns2.dts +5 -0
@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {
@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
arch/arm/boot/dts/kirkwood-ns2max.dts +5 -0
@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {
@@ -46,6 +47,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
arch/arm/boot/dts/kirkwood-ns2mini.dts +5 -0
@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {
@@ -47,6 +48,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
Signature · 1 line
2.1.4
PATCH v2 2/4 ARM: Kirkwood: add modes-map property to ns2-leds nodes
Hi Simon, Jacek, Bryan, Richard,
Quoted 7 lines · Simon Guinot
From: Vincent Donnefort <[email protected]>
Since the LED modes mapping is no longer hardcoded inside the leds-ns2 driver, then it must be provided through the modes-map property in the ns2-leds nodes.
Signed-off-by Vincent Donnefort <[email protected]>
As the other patch of the series seem to be merged in the led branch, then I can apply this patch on mvebu/dt.
It is OK for being in linux-next, however this patch depend on "leds:
leds-ns2: move LED modes mapping outside of the driver", so I will need to find a way to express this dependency when I will do the pull request to arm-soc.
Thanks,
Gregory
Quoted 120 lines
--- arch/arm/boot/dts/kirkwood-d2net.dts | 5 +++++ arch/arm/boot/dts/kirkwood-is2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2max.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2mini.dts | 5 +++++ 5 files changed, 25 insertions(+)arch/arm/boot/dts/kirkwood-d2net.dts +5
-0@@ -10,6 +10,7 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-netxbig.dtsi" / {@@ -28,6 +29,10 @@ label = "d2net_v2:blue:sata"; slow-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>; cmd-gpio = <&gpio0 30 GPIO_ACTIVE_HIGH>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; };arch/arm/boot/dts/kirkwood-is2.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2max.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -46,6 +47,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2mini.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -47,6 +48,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v2 2/4 ARM: Kirkwood: add modes-map property to ns2-leds nodes
Hi Simon, Jacek,
Quoted 11 lines · Gregory CLEMENT
Hi Simon, Jacek, Bryan, Richard,
Quoted 7 lines · Simon Guinot
From: Vincent Donnefort <[email protected]>
Since the LED modes mapping is no longer hardcoded inside the leds-ns2 driver, then it must be provided through the modes-map property in the ns2-leds nodes.
Signed-off-by Vincent Donnefort <[email protected]>
Quoted 8 lines
As the other patch of the series seem to be merged in the led branch, then I can apply this patch on mvebu/dt.
It is OK for being in linux-next, however this patch depend on "leds:
leds-ns2: move LED modes mapping outside of the driver", so I will need to find a way to express this dependency when I will do the pull request to arm-soc.
Eventually I removed this patch from my branch. Jacek, you can take it with my
Thanks,
Gregory
Quoted 128 lines
Thanks,
Gregory
Quoted 120 lines
--- arch/arm/boot/dts/kirkwood-d2net.dts | 5 +++++ arch/arm/boot/dts/kirkwood-is2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2max.dts | 5 +++++ arch/arm/boot/dts/kirkwood-ns2mini.dts | 5 +++++ 5 files changed, 25 insertions(+)arch/arm/boot/dts/kirkwood-d2net.dts +5
-0@@ -10,6 +10,7 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-netxbig.dtsi" / {@@ -28,6 +29,10 @@ label = "d2net_v2:blue:sata"; slow-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>; cmd-gpio = <&gpio0 30 GPIO_ACTIVE_HIGH>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; };arch/arm/boot/dts/kirkwood-is2.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2max.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -46,6 +47,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };arch/arm/boot/dts/kirkwood-ns2mini.dts +5
-0@@ -1,5 +1,6 @@ /dts-v1/; +#include <dt-bindings/leds/leds-ns2.h> #include "kirkwood-ns2-common.dtsi" / {@@ -47,6 +48,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = <NS_V2_LED_OFF 1 0 + NS_V2_LED_ON 0 1 + NS_V2_LED_ON 1 1 + NS_V2_LED_SATA 0 0>; }; }; };
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v2 2/4 ARM: Kirkwood: add modes-map property to ns2-leds nodes
Quoted 23 lines · Gregory CLEMENT
Hi Simon, Jacek,
Quoted 11 lines · Gregory CLEMENT
Hi Simon, Jacek, Bryan, Richard,
Quoted 7 lines · Simon Guinot
From: Vincent Donnefort <[email protected]>
Since the LED modes mapping is no longer hardcoded inside the leds-ns2 driver, then it must be provided through the modes-map property in the ns2-leds nodes.
Signed-off-by Vincent Donnefort <[email protected]>Quoted 8 lines
As the other patch of the series seem to be merged in the led branch, then I can apply this patch on mvebu/dt.
It is OK for being in linux-next, however this patch depend on "leds:
leds-ns2: move LED modes mapping outside of the driver", so I will need to find a way to express this dependency when I will do the pull request to arm-soc.
Quoted 5 lines
Eventually I removed this patch from my branch.
Jacek, you can take it with myAcked-by Gregory CLEMENT <[email protected]>
OK, I'll take it with your ack.
Signature · 2 lines
Best Regards, Jacek Anaszewski
PATCH v2 3/4 leds: leds-ns2: handle can_sleep GPIOs
In reply to Simon GuinotOn the board n090401 (Seagate NAS 4-Bay), some of the LEDs are handled by the leds-ns2 driver. This LEDs are connected to an I2C GPIO expander (PCA95554PW) which means that GPIO access may sleep. This patch makes leds-ns2 compatible with such GPIOs by using the *_cansleep() variant of the GPIO functions. As a drawback this functions can't be used safely in a timer context (with the timer LED trigger for example). To fix this issue, a workqueue mechanism (copied from the leds-gpio driver) is used.
Note that this patch also updates slightly the ns2_led_sata_store function. The LED state is now retrieved from cached values instead of reading the GPIOs previously. This prevents ns2_led_sata_store from working with a stale LED state (which may happen when a delayed work is pending).
--- drivers/leds/leds-ns2.c | 75 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 24 deletions(-)
Changes for v2:
- Fix gpio_{get,set}_*_cansleep() usage while holding a spinlock:
Holding a spinlock at this places was not needed.
drivers/leds/leds-ns2.c +51 -24
@@ -31,6 +31,7 @@#include <linux/platform_data/leds-kirkwood-ns2.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include "leds.h" /* * The Network Space v2 dual-GPIO LED is wired to a CPLD. Three different LED
@@ -43,12 +44,25 @@ struct ns2_led_data {struct led_classdev cdev;unsigned cmd;unsigned slow; +bool can_sleep; +int mode_index;unsigned char sata;/* True when SATA mode active. */ rwlock_t rw_lock;/* Lock GPIOs. */ +struct work_struct work;int num_modes;struct ns2_led_modval *modval; }; +static void ns2_led_work (struct work_struct *work) +{ +struct ns2_led_data *led_dat = + container_of(work, struct ns2_led_data, work); +int i = led_dat->mode_index; + +gpio_set_value_cansleep (led_dat->cmd, led_dat->modval[i].cmd_level); +gpio_set_value_cansleep (led_dat->slow, led_dat->modval[i].slow_level); +} +static int ns2_led_get_mode (struct ns2_led_data *led_dat,enum ns2_led_modes *mode) {
@@ -57,10 +71,8 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat,int cmd_level;int slow_level; -read_lock_irq (&led_dat->rw_lock); - - cmd_level =gpio_get_value (led_dat->cmd); - slow_level =gpio_get_value (led_dat->slow); + cmd_level =gpio_get_value_cansleep (led_dat->cmd); + slow_level =gpio_get_value_cansleep (led_dat->slow);for (i =0 ; i < led_dat->num_modes; i++) { if (cmd_level == led_dat->modval[i].cmd_level &&
@@ -71,8 +83,6 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, } } -read_unlock_irq (&led_dat->rw_lock); -return ret; }
@@ -80,19 +90,32 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, enum ns2_led_modes mode) {int i; +bool found = false;unsigned long flags; -write_lock_irqsave (&led_dat->rw_lock, flags); - -for (i =0 ; i < led_dat->num_modes; i++) { +for (i =0 ; i < led_dat->num_modes; i++)if (mode == led_dat->modval[i].mode) { -gpio_set_value (led_dat->cmd, - led_dat->modval[i].cmd_level); -gpio_set_value (led_dat->slow, - led_dat->modval[i].slow_level); + found = true; +break ; } + +if (!found) +return ; + +write_lock_irqsave (&led_dat->rw_lock, flags); + +if (!led_dat->can_sleep) { +gpio_set_value (led_dat->cmd, + led_dat->modval[i].cmd_level); +gpio_set_value (led_dat->slow, + led_dat->modval[i].slow_level); + goto exit_unlock; } + led_dat->mode_index = i; +schedule_work (&led_dat->work); + +exit_unlock:write_unlock_irqrestore (&led_dat->rw_lock, flags); }
@@ -122,7 +145,6 @@ static ssize_t ns2_led_sata_store(struct device *dev, container_of(led_cdev, struct ns2_led_data, cdev);int ret;unsigned long enable; -enum ns2_led_modes mode; ret =kstrtoul (buff,10 , &enable);if (ret <0 )
@@ -131,19 +153,19 @@ static ssize_t ns2_led_sata_store(struct device *dev, enable = !!enable;if (led_dat->sata == enable) -return count; + goto exit; - ret =ns2_led_get_mode (led_dat, &mode); -if (ret <0 ) -return ret; + led_dat->sata = enable; + +if (!led_get_brightness (led_cdev)) + goto exit; -if (enable && mode ==NS_V2_LED_ON ) +if (enable)ns2_led_set_mode (led_dat,NS_V2_LED_SATA ); -if (!enable && mode ==NS_V2_LED_SATA ) +else ns2_led_set_mode (led_dat,NS_V2_LED_ON ); - led_dat->sata = enable; - +exit:return count; }
@@ -173,7 +195,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,enum ns2_led_modes mode; ret =devm_gpio_request_one (&pdev->dev, template->cmd, -gpio_get_value (template->cmd) ? +gpio_get_value_cansleep (template->cmd) ?GPIOF_OUT_INIT_HIGH :GPIOF_OUT_INIT_LOW , template->name);if (ret) {
@@ -183,7 +205,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, } ret =devm_gpio_request_one (&pdev->dev, template->slow, -gpio_get_value (template->slow) ? +gpio_get_value_cansleep (template->slow) ?GPIOF_OUT_INIT_HIGH :GPIOF_OUT_INIT_LOW , template->name);if (ret) {
@@ -202,6 +224,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.groups = ns2_led_groups; led_dat->cmd = template->cmd; led_dat->slow = template->slow; + led_dat->can_sleep =gpio_cansleep (led_dat->cmd) | +gpio_cansleep (led_dat->slow); led_dat->modval = template->modval; led_dat->num_modes = template->num_modes;
@@ -214,6 +238,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.brightness = (mode ==NS_V2_LED_OFF ) ?LED_OFF :LED_FULL ; +INIT_WORK (&led_dat->work, ns2_led_work); + ret =led_classdev_register (&pdev->dev, &led_dat->cdev);if (ret <0 )return ret;
@@ -224,6 +250,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,static void delete_ns2_led (struct ns2_led_data *led_dat) {led_classdev_unregister (&led_dat->cdev); +cancel_work_sync (&led_dat->work); }#ifdef CONFIG_OF_GPIO
Signature · 1 line
2.1.4
PATCH v2 4/4 leds: leds-ns2: depends on MACH_ARMADA_370
In reply to Simon GuinotThe leds-ns2 driver is also used by the n090401 board (Seagate NAS 4-Bay), which is based on the Marvell Armada-370 SoC.
Then this patch allows to select the leds-ns2 driver if MACH_ARMADA_370 is enabled. Additionally, this also updates the Kconfig help message.
--- drivers/leds/Kconfig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/leds/Kconfig +8 -4
@@ -431,12 +431,16 @@ config LEDS_MC13783 config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs" depends on LEDS_CLASS - depends on MACH_KIRKWOOD + depends on MACH_KIRKWOOD || MACH_ARMADA_370 default y help - This option enable support for the dual-GPIO LED found on the - Network Space v2 board (and parents). This include Internet Space v2, - Network Space (Max) v2 and d2 Network v2 boards. + This option enables support for the dual-GPIO LEDs found on the + following LaCie/Seagate boards: + + Network Space v2 (and parents: Max, Mini) + Internet Space v2 + d2 Network v2 + n090401 (Seagate NAS 4-Bay) config LEDS_NETXBIG tristate "LED support for Big Network series LEDs"
Signature · 1 line
2.1.4
v2 cover Allow to use leds-ns2 with n090401 boards
In reply to Simon GuinotHi Simon,
Quoted 38 lines · Simon Guinot
Hello,
This patch series allows to use the leds-ns2 driver with the n090401 boards (Seagate NAS 4-Bay), based on an Armada-370 SoC.
Here is the list changes:
- Allow to configure the LED mode mapping.
- Handlecan_sleepGPIOs. On n090401, the LEDs are connected to an I2C GPIO expander.
- Make leds-ns2 depends onMACH_ARMADA_370.Changes for v2:
- Fix gpio_{get,set}_*_cansleep() usage while holding a spinlock:
Holding a spinlock at this places was not needed.
- Add Acked-by from Jacek Anaszewski for patch 4.Simon
Simon Guinot (2):
leds: leds-ns2: handlecan_sleepGPIOs
leds: leds-ns2: depends onMACH_ARMADA_370Vincent Donnefort (2):
leds: leds-ns2: move LED modes mapping outside of the driver
ARM: Kirkwood: add modes-map property to ns2-leds nodes.../devicetree/bindings/leds/leds-ns2.txt | 9 ++ arch/arm/boot/dts/kirkwood-d2net.dts | 5 + arch/arm/boot/dts/kirkwood-is2.dts | 5 + arch/arm/boot/dts/kirkwood-ns2.dts | 5 + arch/arm/boot/dts/kirkwood-ns2max.dts | 5 + arch/arm/boot/dts/kirkwood-ns2mini.dts | 5 + drivers/leds/Kconfig | 12 +- drivers/leds/leds-ns2.c | 169 ++++++++++++--------- include/dt-bindings/leds/leds-ns2.h | 8 + include/linux/platform_data/leds-kirkwood-ns2.h | 14 ++ 10 files changed, 165 insertions(+), 72 deletions(-)
Quoted 2 lines
create mode 100644
include/dt-bindings/leds/leds-ns2.h
For the whole patch set:
Signature · 2 lines
Best Regards, Jacek Anaszewski