ARM: shmobile: lager: Add GPIO LEDs
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
--- arch/arm/mach-shmobile/board-lager.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.
arch/arm/mach-shmobile/board-lager.c +37 -0
@@ -21,13 +21,49 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> +#include <linux/leds.h> #include <linux/pinctrl/machine.h> +#include <linux/platform_data/gpio-rcar.h> #include <linux/platform_device.h> #include <mach/common.h> #include <mach/r8a7790.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> +/* LEDS */ +static struct gpio_led lager_leds[] = { + { + .name ="led8" , + .gpio =RCAR_GP_PIN (5 ,17 ), + .default_state =LEDS_GPIO_DEFSTATE_ON , + }, { + .name ="led7" , + .gpio =RCAR_GP_PIN (4 ,23 ), + .default_state =LEDS_GPIO_DEFSTATE_ON , + }, { + .name ="led6" , + .gpio =RCAR_GP_PIN (4 ,22 ), + .default_state =LEDS_GPIO_DEFSTATE_ON , + }, +}; + +static struct gpio_led_platform_data lager_leds_pdata = { + .leds = lager_leds, + .num_leds =ARRAY_SIZE (lager_leds), +}; + +static struct platform_device leds_device = { + .name ="leds-gpio" , + .id =0 , + .dev = { + .platform_data = &lager_leds_pdata, + }, +}; + +static struct platform_device *lager_devices[]__initdata = { + &leds_device, +}; +static const struct pinctrl_map lager_pinctrl_map[] = {/* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices)); }static const char *lager_boards_compat_dt[]__initdata = {
Signature · 1 line
1.8.2.1
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Hi Simon,
Thank you for the patch.
Quoted 35 lines · On Monday 22 April 2013 12:06:30 Simon Horman wrote:
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/board-lager.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.(quoted diff) +0
-0
b/arch/arm/mach-shmobile/board-lager.cindex 6114edd..a8aa04f 100644arch/arm/mach-shmobile/board-lager.c +6
-0@@ -21,13 +21,49 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> +#include <linux/leds.h> #include <linux/pinctrl/machine.h> +#include <linux/platform_data/gpio-rcar.h> #include <linux/platform_device.h> #include <mach/common.h> #include <mach/r8a7790.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> +/* LEDS */ +static struct gpio_led lager_leds[] = { + { + .name ="led8" ,
arch/arm/mach-shmobile/board-lager.c line 46
Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .gpio = RCAR_GP_PIN(5, 17), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led7", + .gpio = RCAR_GP_PIN(4, 23), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led6", + .gpio = RCAR_GP_PIN(4, 22), + .default_state = LEDS_GPIO_DEFSTATE_ON,
Just out of curiosity, why is the default state on ?
arch/arm/mach-shmobile/board-lager.c line 57
Quoted 11 lines
arch/arm/mach-shmobile/board-lager.c +11
-0+ }, +}; + +static struct gpio_led_platform_data lager_leds_pdata = { + .leds = lager_leds, + .num_leds =ARRAY_SIZE (lager_leds), +}; + +static struct platform_device leds_device = { + .name ="leds-gpio" , + .id =0 ,
As there's a single leds-gpio device, maybe id = -1 ?
Quoted 20 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .dev = { + .platform_data = &lager_leds_pdata, + }, +}; + +static struct platform_device *lager_devices[]__initdata = { + &leds_device, +}; +static const struct pinctrl_map lager_pinctrl_map[] = {/* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices)); }static const char *lager_boards_compat_dt[]__initdata = {
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Quoted 36 lines · Laurent Pinchart
Hi Simon,
Thank you for the patch.
Quoted 31 lines · On Monday 22 April 2013 12:06:30 Simon Horman wrote:
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/board-lager.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.(quoted diff) +0
-0
b/arch/arm/mach-shmobile/board-lager.cindex 6114edd..a8aa04f 100644arch/arm/mach-shmobile/board-lager.c +2
-0@@ -21,13 +21,49 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> +#include <linux/leds.h> #include <linux/pinctrl/machine.h> +#include <linux/platform_data/gpio-rcar.h> #include <linux/platform_device.h> #include <mach/common.h> #include <mach/r8a7790.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
Quoted 16 lines
Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +4
-0+/* LEDS */ +static struct gpio_led lager_leds[] = { + { + .name ="led8" ,arch/arm/mach-shmobile/board-lager.c line 46
Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .gpio = RCAR_GP_PIN(5, 17), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led7", + .gpio = RCAR_GP_PIN(4, 23), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led6", + .gpio = RCAR_GP_PIN(4, 22), + .default_state = LEDS_GPIO_DEFSTATE_ON,Just out of curiosity, why is the default state on ?
Only because thats what the marzen code does.
Would off be a better choice?
Quoted 14 lines
arch/arm/mach-shmobile/board-lager.c line 57
Quoted 12 lines
arch/arm/mach-shmobile/board-lager.c +11
-0+ }, +}; + +static struct gpio_led_platform_data lager_leds_pdata = { + .leds = lager_leds, + .num_leds =ARRAY_SIZE (lager_leds), +}; + +static struct platform_device leds_device = { + .name ="leds-gpio" , + .id =0 ,As there's a single leds-gpio device, maybe id = -1 ?
Yes, true. I'll fix that.
I think the marzen code should probably be fixed too.
Quoted 26 lines
Quoted 20 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .dev = { + .platform_data = &lager_leds_pdata, + }, +}; + +static struct platform_device *lager_devices[]__initdata = { + &leds_device, +}; +static const struct pinctrl_map lager_pinctrl_map[] = {/* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices)); }static const char *lager_boards_compat_dt[]__initdata = {Signature · 3 lines
Regards, Laurent Pinchart
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Hi Simon,
Quoted 55 lines · On Tuesday 23 April 2013 10:15:25 Simon Horman wrote:
Quoted 37 lines · Laurent Pinchart
Hi Simon,
Thank you for the patch.
Quoted 32 lines · On Monday 22 April 2013 12:06:30 Simon Horman wrote:
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>---
arch/arm/mach-shmobile/board-lager.c | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.(quoted diff) +0
-0
b/arch/arm/mach-shmobile/board-lager.cindex 6114edd..a8aa04f 100644arch/arm/mach-shmobile/board-lager.c +2
-0@@ -21,13 +21,49 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> +#include <linux/leds.h> #include <linux/pinctrl/machine.h> +#include <linux/platform_data/gpio-rcar.h> #include <linux/platform_device.h> #include <mach/common.h> #include <mach/r8a7790.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> Quoted 16 lines
Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +4
-0+/* LEDS */ +static struct gpio_led lager_leds[] = { + { + .name ="led8" ,arch/arm/mach-shmobile/board-lager.c line 46
Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .gpio = RCAR_GP_PIN(5, 17), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led7", + .gpio = RCAR_GP_PIN(4, 23), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led6", + .gpio = RCAR_GP_PIN(4, 22), + .default_state = LEDS_GPIO_DEFSTATE_ON,Just out of curiosity, why is the default state on ?
Quoted 2 lines
Only because thats what the marzen code does.
Would off be a better choice?
It would save a little bit of power by default :-)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
arch/arm/mach-shmobile/board-lager.c +2
-0+ }, +};
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Quoted 58 lines · Laurent Pinchart
Hi Simon,
Quoted 55 lines · On Tuesday 23 April 2013 10:15:25 Simon Horman wrote:
Quoted 53 lines · Laurent Pinchart
Hi Simon,
Thank you for the patch.
Quoted 36 lines · On Monday 22 April 2013 12:06:30 Simon Horman wrote:
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>---
arch/arm/mach-shmobile/board-lager.c | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.(quoted diff) +0
-0
b/arch/arm/mach-shmobile/board-lager.cindex 6114edd..a8aa04f 100644arch/arm/mach-shmobile/board-lager.c +6
-0@@ -21,13 +21,49 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <linux/kernel.h> +#include <linux/leds.h> #include <linux/pinctrl/machine.h> +#include <linux/platform_data/gpio-rcar.h> #include <linux/platform_device.h> #include <mach/common.h> #include <mach/r8a7790.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> +/* LEDS */ +static struct gpio_led lager_leds[] = { + { + .name ="led8" ,arch/arm/mach-shmobile/board-lager.c line 46
Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10
-0+ .gpio = RCAR_GP_PIN(5, 17), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led7", + .gpio = RCAR_GP_PIN(4, 23), + .default_state = LEDS_GPIO_DEFSTATE_ON, + }, { + .name = "led6", + .gpio = RCAR_GP_PIN(4, 22), + .default_state = LEDS_GPIO_DEFSTATE_ON,Just out of curiosity, why is the default state on ?
Quoted 4 lines
Quoted 2 lines
Only because thats what the marzen code does.
Would off be a better choice?It would save a little bit of power by default :-)
:^)
I think that I would rather leave it _ON for consistency with other shmobile board code.
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
In reply to Simon HormanHello.
Quoted 18 lines · Simon Horman
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/board-lager.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.arch/arm/mach-shmobile/board-lager.c +0
-0
[...]
arch/arm/mach-shmobile/board-lager.c static void __init lager_add_standard_devices(void) · line 85
Quoted 5 lines
arch/arm/mach-shmobile/board-lager.c +1
-0@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices));
I thought we shouldn't use platform_add_devices() anymore, being close
relative to platform_device_register()?
WBR, Sergei
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Quoted 23 lines · Sergei Shtylyov
Hello.
Quoted 18 lines · Simon Horman
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/board-lager.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.arch/arm/mach-shmobile/board-lager.c +0
-0[...]
Quoted 8 lines
arch/arm/mach-shmobile/board-lager.c static void __init lager_add_standard_devices(void) · line 85
Quoted 5 lines
arch/arm/mach-shmobile/board-lager.c +1
-0@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices));I thought we shouldn't use
platform_add_devices()anymore, being
close relative toplatform_device_register()?
Thanks, as there is only one device I think this can be changed to use platform_device_register_resndata(). I'll see about making it so.
PATCH 1/1 ARM: shmobile: lager: Add GPIO LEDs
Quoted 33 lines · Simon Horman
Quoted 23 lines · Sergei Shtylyov
Hello.
Quoted 18 lines · Simon Horman
The board has 3 LEDs connected to GPIOs. Add a led-gpio device to support them.
Based on "ARM: shmobile: marzen: Add GPIO LEDs" by Laurent Pinchart.
Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/board-lager.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)Tested on lager board.
Based on the tag renesas-next-20130419 of my renesas tree.arch/arm/mach-shmobile/board-lager.c +0
-0[...]
Quoted 8 lines
arch/arm/mach-shmobile/board-lager.c static void __init lager_add_standard_devices(void) · line 85
Quoted 5 lines
arch/arm/mach-shmobile/board-lager.c +1
-0@@ -46,6 +82,7 @@ static void __init lager_add_standard_devices(void)r8a7790_pinmux_init ();r8a7790_add_standard_devices (); +platform_add_devices (lager_devices,ARRAY_SIZE (lager_devices));I thought we shouldn't use
platform_add_devices()anymore, being
close relative toplatform_device_register()?
Quoted 3 lines
Thanks, as there is only one device I think this can be changed to use
platform_device_register_resndata(). I'll see about making it so.
On closer examination platform_device_register_data() seems more appropriate.