* [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs
@ 2019-05-31 22:43 Linus Walleij
2019-06-04 11:51 ` Bartosz Golaszewski
2019-06-07 9:04 ` Bartosz Golaszewski
0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2019-05-31 22:43 UTC (permalink / raw)
To: Sekhar Nori, Bartosz Golaszewski; +Cc: Linus Walleij, linux-arm-kernel
This switches the DA850 board to use a GPIO lookup table to
look up the GPIO LEDs. Thanks to the offset handling when
we define GPIOs as an offset into the chip, we can drop
some complex code.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Sekhar, Bartosz: I had this patch sitting around in my
tree, can any of you test it and/or apply it? The
prerequisite patch naming the GPIO expander properly
after .dev_name was commited a while back.
---
arch/arm/mach-davinci/board-da850-evm.c | 43 +++++++++++++------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 4ee65a8a3b80..acf3013f4ae5 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -631,13 +631,12 @@ static void da850_evm_bb_keys_init(unsigned gpio)
}
}
-#define DA850_N_BB_USER_LED 2
-
static struct gpio_led da850_evm_bb_leds[] = {
- [0 ... DA850_N_BB_USER_LED - 1] = {
- .active_low = 1,
- .gpio = -1, /* assigned at runtime */
- .name = NULL, /* assigned at runtime */
+ {
+ .name = "user_led2",
+ },
+ {
+ .name = "user_led1",
},
};
@@ -646,6 +645,20 @@ static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
};
+static struct gpiod_lookup_table da850_evm_bb_leds_gpio_table = {
+ .dev_id = "leds-gpio",
+ .table = {
+ GPIO_LOOKUP_IDX("i2c-bb-expander",
+ DA850_EVM_BB_EXP_USER_LED2, NULL,
+ 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("i2c-bb-expander",
+ DA850_EVM_BB_EXP_USER_LED2 + 1, NULL,
+ 1, GPIO_ACTIVE_LOW),
+
+ { },
+ },
+};
+
static struct platform_device da850_evm_bb_leds_device = {
.name = "leds-gpio",
.id = -1,
@@ -654,20 +667,6 @@ static struct platform_device da850_evm_bb_leds_device = {
}
};
-static void da850_evm_bb_leds_init(unsigned gpio)
-{
- int i;
- struct gpio_led *led;
-
- for (i = 0; i < DA850_N_BB_USER_LED; i++) {
- led = &da850_evm_bb_leds[i];
-
- led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
- led->name =
- da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
- }
-}
-
static int da850_evm_bb_expander_setup(struct i2c_client *client,
unsigned gpio, unsigned ngpio,
void *c)
@@ -685,7 +684,7 @@ static int da850_evm_bb_expander_setup(struct i2c_client *client,
goto io_exp_setup_sw_fail;
}
- da850_evm_bb_leds_init(gpio);
+ gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table);
ret = platform_device_register(&da850_evm_bb_leds_device);
if (ret) {
pr_warn("Could not register baseboard GPIO expander LEDs");
@@ -729,10 +728,12 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
},
{
I2C_BOARD_INFO("tca6416", 0x20),
+ .dev_name = "ui-expander",
.platform_data = &da850_evm_ui_expander_info,
},
{
I2C_BOARD_INFO("tca6416", 0x21),
+ .dev_name = "bb-expander",
.platform_data = &da850_evm_bb_expander_info,
},
};
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs
2019-05-31 22:43 [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs Linus Walleij
@ 2019-06-04 11:51 ` Bartosz Golaszewski
2019-06-07 9:04 ` Bartosz Golaszewski
1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-06-04 11:51 UTC (permalink / raw)
To: Linus Walleij; +Cc: Bartosz Golaszewski, Sekhar Nori, Linux ARM
sob., 1 cze 2019 o 00:43 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> This switches the DA850 board to use a GPIO lookup table to
> look up the GPIO LEDs. Thanks to the offset handling when
> we define GPIOs as an offset into the chip, we can drop
> some complex code.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Sekhar, Bartosz: I had this patch sitting around in my
> tree, can any of you test it and/or apply it? The
> prerequisite patch naming the GPIO expander properly
> after .dev_name was commited a while back.
> ---
> arch/arm/mach-davinci/board-da850-evm.c | 43 +++++++++++++------------
> 1 file changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
> index 4ee65a8a3b80..acf3013f4ae5 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -631,13 +631,12 @@ static void da850_evm_bb_keys_init(unsigned gpio)
> }
> }
>
> -#define DA850_N_BB_USER_LED 2
> -
> static struct gpio_led da850_evm_bb_leds[] = {
> - [0 ... DA850_N_BB_USER_LED - 1] = {
> - .active_low = 1,
> - .gpio = -1, /* assigned at runtime */
> - .name = NULL, /* assigned at runtime */
> + {
> + .name = "user_led2",
> + },
> + {
> + .name = "user_led1",
> },
> };
>
> @@ -646,6 +645,20 @@ static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
> .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
> };
>
> +static struct gpiod_lookup_table da850_evm_bb_leds_gpio_table = {
> + .dev_id = "leds-gpio",
> + .table = {
> + GPIO_LOOKUP_IDX("i2c-bb-expander",
> + DA850_EVM_BB_EXP_USER_LED2, NULL,
> + 0, GPIO_ACTIVE_LOW),
> + GPIO_LOOKUP_IDX("i2c-bb-expander",
> + DA850_EVM_BB_EXP_USER_LED2 + 1, NULL,
> + 1, GPIO_ACTIVE_LOW),
> +
> + { },
> + },
> +};
> +
> static struct platform_device da850_evm_bb_leds_device = {
> .name = "leds-gpio",
> .id = -1,
> @@ -654,20 +667,6 @@ static struct platform_device da850_evm_bb_leds_device = {
> }
> };
>
> -static void da850_evm_bb_leds_init(unsigned gpio)
> -{
> - int i;
> - struct gpio_led *led;
> -
> - for (i = 0; i < DA850_N_BB_USER_LED; i++) {
> - led = &da850_evm_bb_leds[i];
> -
> - led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
> - led->name =
> - da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
> - }
> -}
> -
> static int da850_evm_bb_expander_setup(struct i2c_client *client,
> unsigned gpio, unsigned ngpio,
> void *c)
> @@ -685,7 +684,7 @@ static int da850_evm_bb_expander_setup(struct i2c_client *client,
> goto io_exp_setup_sw_fail;
> }
>
> - da850_evm_bb_leds_init(gpio);
> + gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table);
> ret = platform_device_register(&da850_evm_bb_leds_device);
> if (ret) {
> pr_warn("Could not register baseboard GPIO expander LEDs");
> @@ -729,10 +728,12 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
> },
> {
> I2C_BOARD_INFO("tca6416", 0x20),
> + .dev_name = "ui-expander",
> .platform_data = &da850_evm_ui_expander_info,
> },
> {
> I2C_BOARD_INFO("tca6416", 0x21),
> + .dev_name = "bb-expander",
> .platform_data = &da850_evm_bb_expander_info,
> },
> };
> --
> 2.20.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Linus,
this expander fails to probe on da850-evm in current mainline:
pca953x 1-0021: incomplete constraints, dummy supplies not allowed
pca953x 1-0021: reg get err: -19
I'm not sure how long it's been this way but it should be easy to fix.
Unfortunately I'm very busy this week and leaving on vacation for the
next two weeks, so this has to wait on my side.
Bart
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs
2019-05-31 22:43 [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs Linus Walleij
2019-06-04 11:51 ` Bartosz Golaszewski
@ 2019-06-07 9:04 ` Bartosz Golaszewski
2019-06-20 11:16 ` Sekhar Nori
1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-06-07 9:04 UTC (permalink / raw)
To: Linus Walleij; +Cc: Bartosz Golaszewski, Sekhar Nori, Linux ARM
sob., 1 cze 2019 o 00:43 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> This switches the DA850 board to use a GPIO lookup table to
> look up the GPIO LEDs. Thanks to the offset handling when
> we define GPIOs as an offset into the chip, we can drop
> some complex code.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Sekhar, Bartosz: I had this patch sitting around in my
> tree, can any of you test it and/or apply it? The
> prerequisite patch naming the GPIO expander properly
> after .dev_name was commited a while back.
> ---
> arch/arm/mach-davinci/board-da850-evm.c | 43 +++++++++++++------------
> 1 file changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
> index 4ee65a8a3b80..acf3013f4ae5 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -631,13 +631,12 @@ static void da850_evm_bb_keys_init(unsigned gpio)
> }
> }
>
> -#define DA850_N_BB_USER_LED 2
> -
> static struct gpio_led da850_evm_bb_leds[] = {
> - [0 ... DA850_N_BB_USER_LED - 1] = {
> - .active_low = 1,
> - .gpio = -1, /* assigned at runtime */
> - .name = NULL, /* assigned at runtime */
> + {
> + .name = "user_led2",
> + },
> + {
> + .name = "user_led1",
> },
> };
>
> @@ -646,6 +645,20 @@ static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
> .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
> };
>
> +static struct gpiod_lookup_table da850_evm_bb_leds_gpio_table = {
> + .dev_id = "leds-gpio",
> + .table = {
> + GPIO_LOOKUP_IDX("i2c-bb-expander",
> + DA850_EVM_BB_EXP_USER_LED2, NULL,
> + 0, GPIO_ACTIVE_LOW),
> + GPIO_LOOKUP_IDX("i2c-bb-expander",
> + DA850_EVM_BB_EXP_USER_LED2 + 1, NULL,
> + 1, GPIO_ACTIVE_LOW),
> +
> + { },
> + },
> +};
> +
> static struct platform_device da850_evm_bb_leds_device = {
> .name = "leds-gpio",
> .id = -1,
> @@ -654,20 +667,6 @@ static struct platform_device da850_evm_bb_leds_device = {
> }
> };
>
> -static void da850_evm_bb_leds_init(unsigned gpio)
> -{
> - int i;
> - struct gpio_led *led;
> -
> - for (i = 0; i < DA850_N_BB_USER_LED; i++) {
> - led = &da850_evm_bb_leds[i];
> -
> - led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
> - led->name =
> - da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
> - }
> -}
> -
> static int da850_evm_bb_expander_setup(struct i2c_client *client,
> unsigned gpio, unsigned ngpio,
> void *c)
> @@ -685,7 +684,7 @@ static int da850_evm_bb_expander_setup(struct i2c_client *client,
> goto io_exp_setup_sw_fail;
> }
>
> - da850_evm_bb_leds_init(gpio);
> + gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table);
> ret = platform_device_register(&da850_evm_bb_leds_device);
> if (ret) {
> pr_warn("Could not register baseboard GPIO expander LEDs");
> @@ -729,10 +728,12 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
> },
> {
> I2C_BOARD_INFO("tca6416", 0x20),
> + .dev_name = "ui-expander",
> .platform_data = &da850_evm_ui_expander_info,
> },
> {
> I2C_BOARD_INFO("tca6416", 0x21),
> + .dev_name = "bb-expander",
> .platform_data = &da850_evm_bb_expander_info,
> },
> };
> --
> 2.20.1
>
>
Expander now probes with my patch[1] applied.
This patch looks good and LEDs still work.
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
[1] https://patchwork.kernel.org/patch/10981093/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs
2019-06-07 9:04 ` Bartosz Golaszewski
@ 2019-06-20 11:16 ` Sekhar Nori
0 siblings, 0 replies; 4+ messages in thread
From: Sekhar Nori @ 2019-06-20 11:16 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij; +Cc: Bartosz Golaszewski, Linux ARM
On 07/06/19 2:34 PM, Bartosz Golaszewski wrote:
> sob., 1 cze 2019 o 00:43 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>>
>> This switches the DA850 board to use a GPIO lookup table to
>> look up the GPIO LEDs. Thanks to the offset handling when
>> we define GPIOs as an offset into the chip, we can drop
>> some complex code.
>>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>> Sekhar, Bartosz: I had this patch sitting around in my
>> tree, can any of you test it and/or apply it? The
>> prerequisite patch naming the GPIO expander properly
>> after .dev_name was commited a while back.
>> ---
>> arch/arm/mach-davinci/board-da850-evm.c | 43 +++++++++++++------------
>> 1 file changed, 22 insertions(+), 21 deletions(-)
>>
>> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
>> index 4ee65a8a3b80..acf3013f4ae5 100644
>> --- a/arch/arm/mach-davinci/board-da850-evm.c
>> +++ b/arch/arm/mach-davinci/board-da850-evm.c
>> @@ -631,13 +631,12 @@ static void da850_evm_bb_keys_init(unsigned gpio)
>> }
>> }
>>
>> -#define DA850_N_BB_USER_LED 2
>> -
>> static struct gpio_led da850_evm_bb_leds[] = {
>> - [0 ... DA850_N_BB_USER_LED - 1] = {
>> - .active_low = 1,
>> - .gpio = -1, /* assigned at runtime */
>> - .name = NULL, /* assigned at runtime */
>> + {
>> + .name = "user_led2",
>> + },
>> + {
>> + .name = "user_led1",
>> },
>> };
>>
>> @@ -646,6 +645,20 @@ static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
>> .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
>> };
>>
>> +static struct gpiod_lookup_table da850_evm_bb_leds_gpio_table = {
>> + .dev_id = "leds-gpio",
>> + .table = {
>> + GPIO_LOOKUP_IDX("i2c-bb-expander",
>> + DA850_EVM_BB_EXP_USER_LED2, NULL,
>> + 0, GPIO_ACTIVE_LOW),
>> + GPIO_LOOKUP_IDX("i2c-bb-expander",
>> + DA850_EVM_BB_EXP_USER_LED2 + 1, NULL,
>> + 1, GPIO_ACTIVE_LOW),
>> +
>> + { },
>> + },
>> +};
>> +
>> static struct platform_device da850_evm_bb_leds_device = {
>> .name = "leds-gpio",
>> .id = -1,
>> @@ -654,20 +667,6 @@ static struct platform_device da850_evm_bb_leds_device = {
>> }
>> };
>>
>> -static void da850_evm_bb_leds_init(unsigned gpio)
>> -{
>> - int i;
>> - struct gpio_led *led;
>> -
>> - for (i = 0; i < DA850_N_BB_USER_LED; i++) {
>> - led = &da850_evm_bb_leds[i];
>> -
>> - led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
>> - led->name =
>> - da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
>> - }
>> -}
>> -
>> static int da850_evm_bb_expander_setup(struct i2c_client *client,
>> unsigned gpio, unsigned ngpio,
>> void *c)
>> @@ -685,7 +684,7 @@ static int da850_evm_bb_expander_setup(struct i2c_client *client,
>> goto io_exp_setup_sw_fail;
>> }
>>
>> - da850_evm_bb_leds_init(gpio);
>> + gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table);
>> ret = platform_device_register(&da850_evm_bb_leds_device);
>> if (ret) {
>> pr_warn("Could not register baseboard GPIO expander LEDs");
>> @@ -729,10 +728,12 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
>> },
>> {
>> I2C_BOARD_INFO("tca6416", 0x20),
>> + .dev_name = "ui-expander",
>> .platform_data = &da850_evm_ui_expander_info,
>> },
>> {
>> I2C_BOARD_INFO("tca6416", 0x21),
>> + .dev_name = "bb-expander",
>> .platform_data = &da850_evm_bb_expander_info,
>> },
>> };
>> --
>> 2.20.1
>>
>>
>
> Expander now probes with my patch[1] applied.
>
> This patch looks good and LEDs still work.
>
> Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> [1] https://patchwork.kernel.org/patch/10981093/
Patch applied and pull request for v5.3 sent.
Thanks,
Sekhar
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-20 11:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 22:43 [PATCH] ARM: davinci: Use GPIO lookup table for DA850 LEDs Linus Walleij
2019-06-04 11:51 ` Bartosz Golaszewski
2019-06-07 9:04 ` Bartosz Golaszewski
2019-06-20 11:16 ` Sekhar Nori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).