Re: [PATCH] s3c2440: mini2440: Use leds-gpio driver for board leds handling.

From: Belisko Marek
Date: Tue Mar 29 2011 - 05:59:21 EST


This should be in-reply-to https://lkml.org/lkml/2011/3/29/79 comments

On Tue, Mar 29, 2011 at 11:53 AM, Marek Belisko
<marek.belisko@xxxxxxxxxxxxxxx> wrote:
> Intention of this patch is convert existing usage of leds-s3c24xx driver
> to use generic gpio-leds driver. Leds are separated to 2 devices.
> First device handle 4 available leds. Second device is used to drive
> LCD backlight. Backlight can be controlled via parameter b so we need
> separate device which is registered or not depending on parameter.
>
> Signed-off-by: Marek Belisko <marek.belisko@xxxxxxxxxxxxxxx>
> ---
> Âarch/arm/mach-s3c2440/mach-mini2440.c | Â121 +++++++++++++++------------------
> Â1 files changed, 54 insertions(+), 67 deletions(-)
>
> diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c2440/mach-mini2440.c
> index 163d318..28ef6eb 100644
> --- a/arch/arm/mach-s3c2440/mach-mini2440.c
> +++ b/arch/arm/mach-s3c2440/mach-mini2440.c
> @@ -419,81 +419,71 @@ static struct platform_device mini2440_button_device = {
> Â};
>
> Â/* LEDS */
> -
> -static struct s3c24xx_led_platdata mini2440_led1_pdata = {
> -    .name      = "led1",
> -    .gpio      = S3C2410_GPB(5),
> -    .flags     Â= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
> -    .def_trigger  Â= "heartbeat",
> -};
> -
> -static struct s3c24xx_led_platdata mini2440_led2_pdata = {
> -    .name      = "led2",
> -    .gpio      = S3C2410_GPB(6),
> -    .flags     Â= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
> -    .def_trigger  Â= "nand-disk",
> -};
> -
> -static struct s3c24xx_led_platdata mini2440_led3_pdata = {
> -    .name      = "led3",
> -    .gpio      = S3C2410_GPB(7),
> -    .flags     Â= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
> -    .def_trigger  Â= "mmc0",
> -};
> -
> -static struct s3c24xx_led_platdata mini2440_led4_pdata = {
> -    .name      = "led4",
> -    .gpio      = S3C2410_GPB(8),
> -    .flags     Â= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
> -    .def_trigger  Â= "",
> -};
> -
> -static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = {
> -    .name      = "backlight",
> -    .gpio      = S3C2410_GPG(4),
> -    .def_trigger  Â= "backlight",
> +static struct gpio_led gpio_leds[] = {
> + Â Â Â {
> +        .name          = "led1",
> +        .gpio          = S3C2410_GPB(5),
> +        .active_low       = 1,
> +        .default_trigger    Â= "heartbeat",
> + Â Â Â },
> + Â Â Â {
> +        .name          = "led2",
> +        .gpio          = S3C2410_GPB(6),
> +        .active_low       = 1,
> +        .default_trigger    Â= "nand-disk",
> +        .default_state     Â= LEDS_GPIO_DEFSTATE_OFF,
> + Â Â Â },
> + Â Â Â {
> +        .name          = "led3",
> +        .gpio          = S3C2410_GPB(7),
> +        .active_low       = 1,
> +        .default_trigger    Â= "mmc0",
> +        .default_state     Â= LEDS_GPIO_DEFSTATE_OFF,
> + Â Â Â },
> + Â Â Â {
> +        .name          = "led4",
> +        .gpio          = S3C2410_GPB(8),
> +        .active_low       = 1,
> +        .default_trigger    Â= "none",
> +        .default_state     Â= LEDS_GPIO_DEFSTATE_OFF,
> + Â Â Â }
> Â};
>
> -static struct platform_device mini2440_led1 = {
> -    .name      = "s3c24xx_led",
> -    .id       = 1,
> -    .dev      Â= {
> - Â Â Â Â Â Â Â .platform_data Â= &mini2440_led1_pdata,
> - Â Â Â },
> +static struct gpio_led backlight_led[] = {
> + Â Â Â {
> +        .name          = "backlight",
> +        .gpio          = S3C2410_GPG(4),
> +        .active_low       = 0,
> +        .default_trigger    Â= "backlight",
> +        .default_state     Â= LEDS_GPIO_DEFSTATE_ON,
> + Â Â Â }
> Â};
>
> -static struct platform_device mini2440_led2 = {
> -    .name      = "s3c24xx_led",
> -    .id       = 2,
> -    .dev      Â= {
> - Â Â Â Â Â Â Â .platform_data Â= &mini2440_led2_pdata,
> - Â Â Â },
> +static struct gpio_led_platform_data gpio_led_info = {
> +    .leds      = gpio_leds,
> +    .num_leds    = ARRAY_SIZE(gpio_leds),
> Â};
>
> -static struct platform_device mini2440_led3 = {
> -    .name      = "s3c24xx_led",
> -    .id       = 3,
> -    .dev      Â= {
> - Â Â Â Â Â Â Â .platform_data Â= &mini2440_led3_pdata,
> - Â Â Â },
> +static struct gpio_led_platform_data backlight_info = {
> +    .leds      = backlight_led,
> +    .num_leds    = ARRAY_SIZE(backlight_led),
> Â};
>
> -static struct platform_device mini2440_led4 = {
> -    .name      = "s3c24xx_led",
> -    .id       = 4,
> -    .dev      Â= {
> - Â Â Â Â Â Â Â .platform_data Â= &mini2440_led4_pdata,
> - Â Â Â },
> +static struct platform_device mini2440_leds = {
> +    .name  = "leds-gpio",
> +    .id   = 0,
> +    .dev  Â= {
> + Â Â Â Â Â Â Â .platform_data Â= &gpio_led_info,
> + Â Â Â }
> Â};
>
> Âstatic struct platform_device mini2440_led_backlight = {
> -    .name      = "s3c24xx_led",
> -    .id       = 5,
> -    .dev      Â= {
> - Â Â Â Â Â Â Â .platform_data Â= &mini2440_led_backlight_pdata,
> - Â Â Â },
> +    .name  = "leds-gpio",
> +    .id   = 1,
> +    .dev  Â= {
> + Â Â Â Â Â Â Â .platform_data Â= &backlight_info,
> + Â Â Â }
> Â};
> -
> Â/* AUDIO */
>
> Âstatic struct s3c24xx_uda134x_platform_data mini2440_audio_pins = {
> @@ -543,10 +533,7 @@ static struct platform_device *mini2440_devices[] __initdata = {
> Â Â Â Â&s3c_device_rtc,
> Â Â Â Â&s3c_device_usbgadget,
> Â Â Â Â&mini2440_device_eth,
> - Â Â Â &mini2440_led1,
> - Â Â Â &mini2440_led2,
> - Â Â Â &mini2440_led3,
> - Â Â Â &mini2440_led4,
> + Â Â Â &mini2440_leds,
> Â Â Â Â&mini2440_button_device,
> Â Â Â Â&s3c_device_nand,
> Â Â Â Â&s3c_device_sdi,
> --
> 1.7.1
>
>

regards,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—