Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-29 Thread Tony Lindgren
* Linus Walleij  [181114 12:51]:
> On Tue, Nov 6, 2018 at 12:22 AM Janusz Krzysztofik  
> wrote:
> 
> > Global GPIO numbers no longer have to be passed to leds-gpio driver,
> > replace their assignment with a lookup table.
> >
> > Signed-off-by: Janusz Krzysztofik 
> 
> Excellent Janusz! :)
> Reviewed-by: Linus Walleij 

Applying into omap-for-v4.21/omap1 thanks.

Tony


Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-29 Thread Tony Lindgren
* Linus Walleij  [181114 12:51]:
> On Tue, Nov 6, 2018 at 12:22 AM Janusz Krzysztofik  
> wrote:
> 
> > Global GPIO numbers no longer have to be passed to leds-gpio driver,
> > replace their assignment with a lookup table.
> >
> > Signed-off-by: Janusz Krzysztofik 
> 
> Excellent Janusz! :)
> Reviewed-by: Linus Walleij 

Applying into omap-for-v4.21/omap1 thanks.

Tony


Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-14 Thread Linus Walleij
On Tue, Nov 6, 2018 at 12:22 AM Janusz Krzysztofik  wrote:

> Global GPIO numbers no longer have to be passed to leds-gpio driver,
> replace their assignment with a lookup table.
>
> Signed-off-by: Janusz Krzysztofik 

Excellent Janusz! :)
Reviewed-by: Linus Walleij 

Yours,
Linus Walleij


Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-14 Thread Linus Walleij
On Tue, Nov 6, 2018 at 12:22 AM Janusz Krzysztofik  wrote:

> Global GPIO numbers no longer have to be passed to leds-gpio driver,
> replace their assignment with a lookup table.
>
> Signed-off-by: Janusz Krzysztofik 

Excellent Janusz! :)
Reviewed-by: Linus Walleij 

Yours,
Linus Walleij


Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-11 Thread Pavel Machek
On Tue 2018-11-06 00:23:49, Janusz Krzysztofik wrote:
> Global GPIO numbers no longer have to be passed to leds-gpio driver,
> replace their assignment with a lookup table.
> 
> Signed-off-by: Janusz Krzysztofik 

Acked-by: Pavel Machek 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-11 Thread Pavel Machek
On Tue 2018-11-06 00:23:49, Janusz Krzysztofik wrote:
> Global GPIO numbers no longer have to be passed to leds-gpio driver,
> replace their assignment with a lookup table.
> 
> Signed-off-by: Janusz Krzysztofik 

Acked-by: Pavel Machek 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-05 Thread Janusz Krzysztofik
Global GPIO numbers no longer have to be passed to leds-gpio driver,
replace their assignment with a lookup table.

Signed-off-by: Janusz Krzysztofik 
---
 arch/arm/mach-omap1/board-ams-delta.c | 95 ++-
 1 file changed, 26 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c 
b/arch/arm/mach-omap1/board-ams-delta.c
index b8acc9912a58..19e0c071d675 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -371,15 +371,9 @@ static struct gpiod_lookup_table ams_delta_lcd_gpio_table 
= {
},
 };
 
-/*
- * Dynamically allocated GPIO numbers must be obtained fromm GPIO device
- * before they can be put in the gpio_led table.  Before that happens,
- * initialize the table with invalid GPIO numbers, not 0.
- */
 static struct gpio_led gpio_leds[] __initdata = {
[LATCH1_PIN_LED_CAMERA] = {
.name= "camera",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
 #ifdef CONFIG_LEDS_TRIGGERS
.default_trigger = "ams_delta_camera",
@@ -387,27 +381,22 @@ static struct gpio_led gpio_leds[] __initdata = {
},
[LATCH1_PIN_LED_ADVERT] = {
.name= "advert",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_MAIL] = {
.name= "email",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_HANDSFREE] = {
.name= "handsfree",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_VOICEMAIL] = {
.name= "voicemail",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_VOICE] = {
.name= "voice",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
 };
@@ -417,6 +406,24 @@ static const struct gpio_led_platform_data leds_pdata 
__initconst = {
.num_leds   = ARRAY_SIZE(gpio_leds),
 };
 
+static struct gpiod_lookup_table leds_gpio_table = {
+   .table = {
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL,
+   LATCH1_PIN_LED_CAMERA, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL,
+   LATCH1_PIN_LED_ADVERT, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL,
+   LATCH1_PIN_LED_MAIL, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL,
+   LATCH1_PIN_LED_HANDSFREE, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL,
+   LATCH1_PIN_LED_VOICEMAIL, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL,
+   LATCH1_PIN_LED_VOICE, 0),
+   { },
+   },
+};
+
 static struct i2c_board_info ams_delta_camera_board_info[] = {
{
I2C_BOARD_INFO("ov6650", 0x60),
@@ -677,6 +684,8 @@ static void __init ams_delta_latch2_init(void)
 
 static void __init ams_delta_init(void)
 {
+   struct platform_device *leds_pdev;
+
/* mux pins for uarts */
omap_cfg_reg(UART1_TX);
omap_cfg_reg(UART1_RTS);
@@ -740,6 +749,12 @@ static void __init ams_delta_init(void)
gpiod_add_lookup_tables(ams_delta_gpio_tables,
ARRAY_SIZE(ams_delta_gpio_tables));
 
+   leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, _pdata);
+   if (!IS_ERR(leds_pdev)) {
+   leds_gpio_table.dev_id = dev_name(_pdev->dev);
+   gpiod_add_lookup_table(_gpio_table);
+   }
+
omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
 
omapfb_set_lcd_config(_delta_lcd_config);
@@ -793,64 +808,6 @@ static struct platform_device ams_delta_modem_device = {
},
 };
 
-/*
- * leds-gpio driver doesn't make use of GPIO lookup tables,
- * it has to be provided with GPIO numbers over platform data
- * if GPIO descriptor info can't be obtained from device tree.
- * We could either define GPIO lookup tables and use them on behalf
- * of the leds-gpio device, or we can use GPIO driver level methods
- * for identification of GPIO numbers as long as we don't support
- * device tree.  Let's do the latter.
- */
-static void __init ams_delta_led_init(struct gpio_chip *chip)
-{
-   struct gpio_desc *gpiod;
-   int i;
-
-   for (i = LATCH1_PIN_LED_CAMERA; i < LATCH1_PIN_DOCKIT1; i++) {
-   gpiod = gpiochip_request_own_desc(chip, i, NULL);
-

[PATCH] ARM: OMAP1: ams-delta: Provide GPIO lookup table for LED device

2018-11-05 Thread Janusz Krzysztofik
Global GPIO numbers no longer have to be passed to leds-gpio driver,
replace their assignment with a lookup table.

Signed-off-by: Janusz Krzysztofik 
---
 arch/arm/mach-omap1/board-ams-delta.c | 95 ++-
 1 file changed, 26 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-omap1/board-ams-delta.c 
b/arch/arm/mach-omap1/board-ams-delta.c
index b8acc9912a58..19e0c071d675 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -371,15 +371,9 @@ static struct gpiod_lookup_table ams_delta_lcd_gpio_table 
= {
},
 };
 
-/*
- * Dynamically allocated GPIO numbers must be obtained fromm GPIO device
- * before they can be put in the gpio_led table.  Before that happens,
- * initialize the table with invalid GPIO numbers, not 0.
- */
 static struct gpio_led gpio_leds[] __initdata = {
[LATCH1_PIN_LED_CAMERA] = {
.name= "camera",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
 #ifdef CONFIG_LEDS_TRIGGERS
.default_trigger = "ams_delta_camera",
@@ -387,27 +381,22 @@ static struct gpio_led gpio_leds[] __initdata = {
},
[LATCH1_PIN_LED_ADVERT] = {
.name= "advert",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_MAIL] = {
.name= "email",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_HANDSFREE] = {
.name= "handsfree",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_VOICEMAIL] = {
.name= "voicemail",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
[LATCH1_PIN_LED_VOICE] = {
.name= "voice",
-   .gpio= -EINVAL,
.default_state   = LEDS_GPIO_DEFSTATE_OFF,
},
 };
@@ -417,6 +406,24 @@ static const struct gpio_led_platform_data leds_pdata 
__initconst = {
.num_leds   = ARRAY_SIZE(gpio_leds),
 };
 
+static struct gpiod_lookup_table leds_gpio_table = {
+   .table = {
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL,
+   LATCH1_PIN_LED_CAMERA, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL,
+   LATCH1_PIN_LED_ADVERT, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL,
+   LATCH1_PIN_LED_MAIL, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL,
+   LATCH1_PIN_LED_HANDSFREE, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL,
+   LATCH1_PIN_LED_VOICEMAIL, 0),
+   GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL,
+   LATCH1_PIN_LED_VOICE, 0),
+   { },
+   },
+};
+
 static struct i2c_board_info ams_delta_camera_board_info[] = {
{
I2C_BOARD_INFO("ov6650", 0x60),
@@ -677,6 +684,8 @@ static void __init ams_delta_latch2_init(void)
 
 static void __init ams_delta_init(void)
 {
+   struct platform_device *leds_pdev;
+
/* mux pins for uarts */
omap_cfg_reg(UART1_TX);
omap_cfg_reg(UART1_RTS);
@@ -740,6 +749,12 @@ static void __init ams_delta_init(void)
gpiod_add_lookup_tables(ams_delta_gpio_tables,
ARRAY_SIZE(ams_delta_gpio_tables));
 
+   leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, _pdata);
+   if (!IS_ERR(leds_pdev)) {
+   leds_gpio_table.dev_id = dev_name(_pdev->dev);
+   gpiod_add_lookup_table(_gpio_table);
+   }
+
omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
 
omapfb_set_lcd_config(_delta_lcd_config);
@@ -793,64 +808,6 @@ static struct platform_device ams_delta_modem_device = {
},
 };
 
-/*
- * leds-gpio driver doesn't make use of GPIO lookup tables,
- * it has to be provided with GPIO numbers over platform data
- * if GPIO descriptor info can't be obtained from device tree.
- * We could either define GPIO lookup tables and use them on behalf
- * of the leds-gpio device, or we can use GPIO driver level methods
- * for identification of GPIO numbers as long as we don't support
- * device tree.  Let's do the latter.
- */
-static void __init ams_delta_led_init(struct gpio_chip *chip)
-{
-   struct gpio_desc *gpiod;
-   int i;
-
-   for (i = LATCH1_PIN_LED_CAMERA; i < LATCH1_PIN_DOCKIT1; i++) {
-   gpiod = gpiochip_request_own_desc(chip, i, NULL);
-