leds: add LED driver for Big Network series LEDs
Subsystems (3)
PATCH 1/2 leds: add LED driver for Big Network series LEDs
From: Simon Guinot <[email protected]>
This patch add a LED class driver for LEDs found on the LaCie 2Big and 5Big Network v2 boards. The LEDs are wired to a CPLD and are controlled through a GPIO extension bus.
Signed-off-by Simon Guinot <[email protected]>
--- arch/arm/mach-kirkwood/include/mach/leds-netxbig.h | 55 +++ drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-netxbig.c | 449 ++++++++++++++++++++ 4 files changed, 514 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-kirkwood/include/mach/leds-netxbig.h create mode 100644 drivers/leds/leds-netxbig.c
arch/arm/mach-kirkwood/include/mach/leds-netxbig.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* arch/arm/mach-kirkwood/include/mach/leds-netxbig.h +* +* Platform data structure for netxbig LED driver +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __MACH_LEDS_NETXBIG_H +#define __MACH_LEDS_NETXBIG_H + +struct netxbig_gpio_ext { +unsigned *addr; +int num_addr; +unsigned *data; +int num_data; +unsigned enable; +}; + +enum netxbig_led_mode { +NETXBIG_LED_OFF , +NETXBIG_LED_ON , +NETXBIG_LED_SATA , +NETXBIG_LED_TIMER1 , +NETXBIG_LED_TIMER2 , +NETXBIG_LED_MODE_NUM , +}; + +#define NETXBIG_LED_INVALID_MODE NETXBIG_LED_MODE_NUM + +struct netxbig_led_timer { +unsigned long delay_on; +unsigned long delay_off; +enum netxbig_led_mode mode; +}; + +struct netxbig_led { +const char *name; +const char *default_trigger; +int mode_addr; +int *mode_val; +int bright_addr; +}; + +struct netxbig_led_platform_data { +struct netxbig_gpio_ext *gpio_ext; +struct netxbig_led_timer *timer; +int num_timer; +struct netxbig_led *leds; +int num_leds; +}; + +#endif /* __MACH_LEDS_NETXBIG_H */
drivers/leds/Kconfig +9 -0
@@ -311,6 +311,15 @@ config LEDS_NS2 Network Space v2 board (and parents). This include Internet Space v2, Network Space (Max) v2 and d2 Network v2 boards. +config LEDS_NETXBIG + tristate "LED support for Big Network series LEDs" + depends on MACH_NET2BIG_V2 || MACH_NET5BIG_V2 + default y + help + This option enable support for LEDs found on the LaCie 2Big + and 5Big Network v2 boards. The LEDs are wired to a CPLD and are + controlled through a GPIO extension bus. + config LEDS_TRIGGERS bool "LED Trigger support" help
drivers/leds/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_NS2) += leds-ns2.o +obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-netxbig.c new file +449 -0
449 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 2/2 Kirkwood: add LED support for netxbig_v2 boards
From: Simon Guinot <[email protected]>
Signed-off-by Simon Guinot <[email protected]>
--- arch/arm/mach-kirkwood/netxbig_v2-setup.c | 158 ++++++++++++++++++++++++----- 1 files changed, 133 insertions(+), 25 deletions(-)
arch/arm/mach-kirkwood/netxbig_v2-setup.c +133 -25
@@ -32,6 +32,7 @@#include <asm/mach-types.h> #include <asm/mach/arch.h> #include <mach/kirkwood.h> +#include <mach/leds-netxbig.h> #include "common.h" #include "mpp.h" #include "lacie_v2-common.h"
@@ -104,7 +105,7 @@ static struct platform_device netxbig_v2_gpio_buttons = { };/***************************************************************************** -* GPIO LEDs +* GPIO extension LEDs ****************************************************************************/ /*
@@ -114,19 +115,32 @@ static struct platform_device netxbig_v2_gpio_buttons = {* - address register : bit [0-2] -> GPIO [47-49] * - data register : bit [0-2] -> GPIO [44-46] * - enable register : GPIO 29 -* +*/ + +static int netxbig_v2_gpio_ext_addr[] = {47 ,48 ,49 }; +static int netxbig_v2_gpio_ext_data[] = {44 ,45 ,46 }; + +static struct netxbig_gpio_ext netxbig_v2_gpio_ext = { + .addr = netxbig_v2_gpio_ext_addr, + .num_addr =ARRAY_SIZE (netxbig_v2_gpio_ext_addr), + .data = netxbig_v2_gpio_ext_data, + .num_data =ARRAY_SIZE (netxbig_v2_gpio_ext_data), + .enable =29 , +}; + +/* * Address register selection: * * addr | register * ---------------------------- * 0 | front LED * 1 | front LED brightness -* 2 | HDD LED brightness -* 3 | HDD1 LED -* 4 | HDD2 LED -* 5 | HDD3 LED -* 6 | HDD4 LED -* 7 | HDD5 LED +* 2 | SATA LED brightness +* 3 | SATA0 LED +* 4 | SATA1 LED +* 5 | SATA2 LED +* 6 | SATA3 LED +* 7 | SATA4 LED * * Data register configuration: *
@@ -147,18 +161,109 @@ static struct platform_device netxbig_v2_gpio_buttons = {* 6 | blink blue on=1 sec and red on=1 sec * 7 | blink blue on=0.5 sec and blue off=2.5 sec * -* data | HDD LED mode +* data | SATA LED mode * ------------------------------------------------- -* 0 | fix blue on +* 0 | fix off * 1 | SATA activity blink * 2 | fix red on * 3 | blink blue on=1 sec and blue off=1 sec * 4 | blink red on=1 sec and red off=1 sec * 5 | blink blue on=2.5 sec and red on=0.5 sec * 6 | blink blue on=1 sec and red on=1 sec -* 7 | blink blue on=0.5 sec and blue off=2.5 sec +* 7 | fix blue on */ +static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM ] = { + [NETXBIG_LED_OFF ] =0 , + [NETXBIG_LED_ON ] =2 , + [NETXBIG_LED_SATA ] =NETXBIG_LED_INVALID_MODE , + [NETXBIG_LED_TIMER1 ] =4 , + [NETXBIG_LED_TIMER2 ] =NETXBIG_LED_INVALID_MODE , +}; + +static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM ] = { + [NETXBIG_LED_OFF ] =0 , + [NETXBIG_LED_ON ] =1 , + [NETXBIG_LED_SATA ] =NETXBIG_LED_INVALID_MODE , + [NETXBIG_LED_TIMER1 ] =3 , + [NETXBIG_LED_TIMER2 ] =7 , +}; + +static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM ] = { + [NETXBIG_LED_OFF ] =0 , + [NETXBIG_LED_ON ] =7 , + [NETXBIG_LED_SATA ] =1 , + [NETXBIG_LED_TIMER1 ] =3 , + [NETXBIG_LED_TIMER2 ] =NETXBIG_LED_INVALID_MODE , +}; + +static struct netxbig_led_timer netxbig_v2_led_timer[] = { + [0 ] = { + .delay_on =500 , + .delay_off =500 , + .mode =NETXBIG_LED_TIMER1 , + }, + [1 ] = { + .delay_on =500 , + .delay_off =1000 , + .mode =NETXBIG_LED_TIMER2 , + }, +}; + +#define NETXBIG_LED (_name, maddr, mval, baddr) \ + { .name = _name, \ + .mode_addr = maddr, \ + .mode_val = mval, \ + .bright_addr = baddr } + +static struct netxbig_led net2big_v2_leds_ctrl[] = { +NETXBIG_LED ("net2big-v2:blue:power" ,0 , netxbig_v2_blue_pwr_mled,1 ), +NETXBIG_LED ("net2big-v2:red:power" ,0 , netxbig_v2_red_mled,1 ), +NETXBIG_LED ("net2big-v2:blue:sata0" ,3 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net2big-v2:red:sata0" ,3 , netxbig_v2_red_mled,2 ), +NETXBIG_LED ("net2big-v2:blue:sata1" ,4 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net2big-v2:red:sata1" ,4 , netxbig_v2_red_mled,2 ), +}; + +static struct netxbig_led_platform_data net2big_v2_leds_data = { + .gpio_ext = &netxbig_v2_gpio_ext, + .timer = netxbig_v2_led_timer, + .num_timer =ARRAY_SIZE (netxbig_v2_led_timer), + .leds = net2big_v2_leds_ctrl, + .num_leds =ARRAY_SIZE (net2big_v2_leds_ctrl), +}; + +static struct netxbig_led net5big_v2_leds_ctrl[] = { +NETXBIG_LED ("net5big-v2:blue:power" ,0 , netxbig_v2_blue_pwr_mled,1 ), +NETXBIG_LED ("net5big-v2:red:power" ,0 , netxbig_v2_red_mled,1 ), +NETXBIG_LED ("net5big-v2:blue:sata0" ,3 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net5big-v2:red:sata0" ,3 , netxbig_v2_red_mled,2 ), +NETXBIG_LED ("net5big-v2:blue:sata1" ,4 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net5big-v2:red:sata1" ,4 , netxbig_v2_red_mled,2 ), +NETXBIG_LED ("net5big-v2:blue:sata2" ,5 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net5big-v2:red:sata2" ,5 , netxbig_v2_red_mled,2 ), +NETXBIG_LED ("net5big-v2:blue:sata3" ,6 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net5big-v2:red:sata3" ,6 , netxbig_v2_red_mled,2 ), +NETXBIG_LED ("net5big-v2:blue:sata4" ,7 , netxbig_v2_blue_sata_mled,2 ), +NETXBIG_LED ("net5big-v2:red:sata5" ,7 , netxbig_v2_red_mled,2 ), +}; + +static struct netxbig_led_platform_data net5big_v2_leds_data = { + .gpio_ext = &netxbig_v2_gpio_ext, + .timer = netxbig_v2_led_timer, + .num_timer =ARRAY_SIZE (netxbig_v2_led_timer), + .leds = net5big_v2_leds_ctrl, + .num_leds =ARRAY_SIZE (net5big_v2_leds_ctrl), +}; + +static struct platform_device netxbig_v2_leds = { + .name ="leds-netxbig" , + .id =-1 , + .dev = { + .platform_data = &net2big_v2_leds_data, + }, +}; +/***************************************************************************** * General Setup ****************************************************************************/
@@ -184,18 +289,18 @@ static unsigned int net2big_v2_mpp_config[] __initdata = {MPP24_GPIO ,/* USB mode select */ MPP26_GPIO ,/* USB device vbus */ MPP28_GPIO ,/* USB enable host vbus */ -MPP29_GPIO ,/* CPLD extension ALE */ +MPP29_GPIO ,/* GPIO extension ALE */ MPP34_GPIO ,/* Rear Push button */ MPP35_GPIO ,/* Inhibit switch power-off */ MPP36_GPIO ,/* SATA HDD1 presence */ MPP37_GPIO ,/* SATA HDD2 presence */ MPP40_GPIO ,/* eSATA presence */ -MPP44_GPIO ,/* CPLD extension (data 0) */ -MPP45_GPIO ,/* CPLD extension (data 1) */ -MPP46_GPIO ,/* CPLD extension (data 2) */ -MPP47_GPIO ,/* CPLD extension (addr 0) */ -MPP48_GPIO ,/* CPLD extension (addr 1) */ -MPP49_GPIO ,/* CPLD extension (addr 2) */ +MPP44_GPIO ,/* GPIO extension (data 0) */ +MPP45_GPIO ,/* GPIO extension (data 1) */ +MPP46_GPIO ,/* GPIO extension (data 2) */ +MPP47_GPIO ,/* GPIO extension (addr 0) */ +MPP48_GPIO ,/* GPIO extension (addr 1) */ +MPP49_GPIO ,/* GPIO extension (addr 2) */ 0 };
@@ -224,7 +329,7 @@ static unsigned int net5big_v2_mpp_config[] __initdata = {MPP26_GE1_RXD2 ,MPP27_GE1_RXD3 ,MPP28_GPIO ,/* USB enable host vbus */ -MPP29_GPIO ,/* CPLD extension ALE */ +MPP29_GPIO ,/* GPIO extension ALE */ MPP30_GE1_RXCTL ,MPP31_GE1_RXCLK , MPP32_GE1_TCLKOUT,
@@ -239,12 +344,12 @@ static unsigned int net5big_v2_mpp_config[] __initdata = {MPP41_GPIO ,/* SATA HDD3 power */ MPP42_GPIO ,/* SATA HDD4 power */ MPP43_GPIO ,/* SATA HDD5 power */ -MPP44_GPIO ,/* CPLD extension (data 0) */ -MPP45_GPIO ,/* CPLD extension (data 1) */ -MPP46_GPIO ,/* CPLD extension (data 2) */ -MPP47_GPIO ,/* CPLD extension (addr 0) */ -MPP48_GPIO ,/* CPLD extension (addr 1) */ -MPP49_GPIO ,/* CPLD extension (addr 2) */ +MPP44_GPIO ,/* GPIO extension (data 0) */ +MPP45_GPIO ,/* GPIO extension (data 1) */ +MPP46_GPIO ,/* GPIO extension (data 2) */ +MPP47_GPIO ,/* GPIO extension (addr 0) */ +MPP48_GPIO ,/* GPIO extension (addr 1) */ +MPP49_GPIO ,/* GPIO extension (addr 2) */ 0 };
@@ -280,6 +385,9 @@ static void __init netxbig_v2_init(void)lacie_v2_register_flash ();lacie_v2_register_i2c_devices (); +if (machine_is_net5big_v2 ()) + netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data; +platform_device_register (&netxbig_v2_leds);platform_device_register (&netxbig_v2_gpio_buttons); if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
Signature · 1 line
1.6.3.1