linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table
@ 2020-07-27  7:03 Linus Walleij
  2020-08-03 19:47 ` Bartosz Golaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2020-07-27  7:03 UTC (permalink / raw)
  To: Sekhar Nori, Bartosz Golaszewski; +Cc: Linus Walleij, linux-arm-kernel

This converts the DaVinci DM644x LEDs to use GPIO
descriptor look-ups.

Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-davinci/board-dm644x-evm.c | 46 +++++++++++++++---------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index a5d3708fedf6..69f799e8036a 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -319,17 +319,14 @@ static struct platform_device rtc_dev = {
 /* U2 -- LEDs */
 
 static struct gpio_led evm_leds[] = {
-	{ .name = "DS8", .active_low = 1,
-		.default_trigger = "heartbeat", },
-	{ .name = "DS7", .active_low = 1, },
-	{ .name = "DS6", .active_low = 1, },
-	{ .name = "DS5", .active_low = 1, },
-	{ .name = "DS4", .active_low = 1, },
-	{ .name = "DS3", .active_low = 1, },
-	{ .name = "DS2", .active_low = 1,
-		.default_trigger = "mmc0", },
-	{ .name = "DS1", .active_low = 1,
-		.default_trigger = "disk-activity", },
+	{ .name = "DS8", .default_trigger = "heartbeat", },
+	{ .name = "DS7", },
+	{ .name = "DS6", },
+	{ .name = "DS5", },
+	{ .name = "DS4", },
+	{ .name = "DS3", },
+	{ .name = "DS2", .default_trigger = "mmc0", },
+	{ .name = "DS1", .default_trigger = "disk-activity", },
 };
 
 static const struct gpio_led_platform_data evm_led_data = {
@@ -337,18 +334,35 @@ static const struct gpio_led_platform_data evm_led_data = {
 	.leds		= evm_leds,
 };
 
+static struct gpiod_lookup_table evm_leds_gpio_table = {
+	.dev_id = "leds-gpio.0",
+	.table = {
+		/*
+		 * These GPIOs are on a PCF8574 GPIO expander, which
+		 * is in turn named after the I2C device name. This is
+		 * device "u2" on I2C bus 1 with address 0x38.
+		 */
+		GPIO_LOOKUP_IDX("1-0038", 0, NULL, 0, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 1, NULL, 1, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 2, NULL, 2, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 3, NULL, 3, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 4, NULL, 4, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 5, NULL, 5, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 6, NULL, 6, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 7, NULL, 7, GPIO_ACTIVE_LOW),
+		{ },
+	},
+};
+
 static struct platform_device *evm_led_dev;
 
 static int
 evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
 {
-	struct gpio_led *leds = evm_leds;
 	int status;
 
-	while (ngpio--) {
-		leds->gpio = gpio++;
-		leds++;
-	}
+	/* Add the lookup table */
+	gpiod_add_lookup_table(&evm_leds_gpio_table);
 
 	/* what an extremely annoying way to be forced to handle
 	 * device unregistration ...
-- 
2.26.2


_______________________________________________
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] 3+ messages in thread

* Re: [PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table
  2020-07-27  7:03 [PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table Linus Walleij
@ 2020-08-03 19:47 ` Bartosz Golaszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2020-08-03 19:47 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Sekhar Nori, arm-soc

On Mon, Jul 27, 2020 at 9:05 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> This converts the DaVinci DM644x LEDs to use GPIO
> descriptor look-ups.
>
> Cc: Sekhar Nori <nsekhar@ti.com>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  arch/arm/mach-davinci/board-dm644x-evm.c | 46 +++++++++++++++---------
>  1 file changed, 30 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
> index a5d3708fedf6..69f799e8036a 100644
> --- a/arch/arm/mach-davinci/board-dm644x-evm.c
> +++ b/arch/arm/mach-davinci/board-dm644x-evm.c
> @@ -319,17 +319,14 @@ static struct platform_device rtc_dev = {
>  /* U2 -- LEDs */
>
>  static struct gpio_led evm_leds[] = {
> -       { .name = "DS8", .active_low = 1,
> -               .default_trigger = "heartbeat", },
> -       { .name = "DS7", .active_low = 1, },
> -       { .name = "DS6", .active_low = 1, },
> -       { .name = "DS5", .active_low = 1, },
> -       { .name = "DS4", .active_low = 1, },
> -       { .name = "DS3", .active_low = 1, },
> -       { .name = "DS2", .active_low = 1,
> -               .default_trigger = "mmc0", },
> -       { .name = "DS1", .active_low = 1,
> -               .default_trigger = "disk-activity", },
> +       { .name = "DS8", .default_trigger = "heartbeat", },
> +       { .name = "DS7", },
> +       { .name = "DS6", },
> +       { .name = "DS5", },
> +       { .name = "DS4", },
> +       { .name = "DS3", },
> +       { .name = "DS2", .default_trigger = "mmc0", },
> +       { .name = "DS1", .default_trigger = "disk-activity", },
>  };
>
>  static const struct gpio_led_platform_data evm_led_data = {
> @@ -337,18 +334,35 @@ static const struct gpio_led_platform_data evm_led_data = {
>         .leds           = evm_leds,
>  };
>
> +static struct gpiod_lookup_table evm_leds_gpio_table = {
> +       .dev_id = "leds-gpio.0",
> +       .table = {
> +               /*
> +                * These GPIOs are on a PCF8574 GPIO expander, which
> +                * is in turn named after the I2C device name. This is
> +                * device "u2" on I2C bus 1 with address 0x38.
> +                */
> +               GPIO_LOOKUP_IDX("1-0038", 0, NULL, 0, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 1, NULL, 1, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 2, NULL, 2, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 3, NULL, 3, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 4, NULL, 4, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 5, NULL, 5, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 6, NULL, 6, GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP_IDX("1-0038", 7, NULL, 7, GPIO_ACTIVE_LOW),
> +               { },
> +       },
> +};
> +
>  static struct platform_device *evm_led_dev;
>
>  static int
>  evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
>  {
> -       struct gpio_led *leds = evm_leds;
>         int status;
>
> -       while (ngpio--) {
> -               leds->gpio = gpio++;
> -               leds++;
> -       }
> +       /* Add the lookup table */
> +       gpiod_add_lookup_table(&evm_leds_gpio_table);
>
>         /* what an extremely annoying way to be forced to handle
>          * device unregistration ...
> --
> 2.26.2
>

Looks good to me. Unfortunately I don't have this specific davinci board.

Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

_______________________________________________
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] 3+ messages in thread

* [PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table
@ 2020-08-26 14:30 Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2020-08-26 14:30 UTC (permalink / raw)
  To: Sekhar Nori, Bartosz Golaszewski; +Cc: Linus Walleij, linux-arm-kernel

This converts the DaVinci DM644x LEDs to use GPIO
descriptor look-ups.

Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Collect Bartosz' review tag
- Rebase on v5.9-rc1
- Resend
---
 arch/arm/mach-davinci/board-dm644x-evm.c | 46 +++++++++++++++---------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index a5d3708fedf6..69f799e8036a 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -319,17 +319,14 @@ static struct platform_device rtc_dev = {
 /* U2 -- LEDs */
 
 static struct gpio_led evm_leds[] = {
-	{ .name = "DS8", .active_low = 1,
-		.default_trigger = "heartbeat", },
-	{ .name = "DS7", .active_low = 1, },
-	{ .name = "DS6", .active_low = 1, },
-	{ .name = "DS5", .active_low = 1, },
-	{ .name = "DS4", .active_low = 1, },
-	{ .name = "DS3", .active_low = 1, },
-	{ .name = "DS2", .active_low = 1,
-		.default_trigger = "mmc0", },
-	{ .name = "DS1", .active_low = 1,
-		.default_trigger = "disk-activity", },
+	{ .name = "DS8", .default_trigger = "heartbeat", },
+	{ .name = "DS7", },
+	{ .name = "DS6", },
+	{ .name = "DS5", },
+	{ .name = "DS4", },
+	{ .name = "DS3", },
+	{ .name = "DS2", .default_trigger = "mmc0", },
+	{ .name = "DS1", .default_trigger = "disk-activity", },
 };
 
 static const struct gpio_led_platform_data evm_led_data = {
@@ -337,18 +334,35 @@ static const struct gpio_led_platform_data evm_led_data = {
 	.leds		= evm_leds,
 };
 
+static struct gpiod_lookup_table evm_leds_gpio_table = {
+	.dev_id = "leds-gpio.0",
+	.table = {
+		/*
+		 * These GPIOs are on a PCF8574 GPIO expander, which
+		 * is in turn named after the I2C device name. This is
+		 * device "u2" on I2C bus 1 with address 0x38.
+		 */
+		GPIO_LOOKUP_IDX("1-0038", 0, NULL, 0, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 1, NULL, 1, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 2, NULL, 2, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 3, NULL, 3, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 4, NULL, 4, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 5, NULL, 5, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 6, NULL, 6, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("1-0038", 7, NULL, 7, GPIO_ACTIVE_LOW),
+		{ },
+	},
+};
+
 static struct platform_device *evm_led_dev;
 
 static int
 evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
 {
-	struct gpio_led *leds = evm_leds;
 	int status;
 
-	while (ngpio--) {
-		leds->gpio = gpio++;
-		leds++;
-	}
+	/* Add the lookup table */
+	gpiod_add_lookup_table(&evm_leds_gpio_table);
 
 	/* what an extremely annoying way to be forced to handle
 	 * device unregistration ...
-- 
2.26.2


_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2020-08-26 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  7:03 [PATCH] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table Linus Walleij
2020-08-03 19:47 ` Bartosz Golaszewski
2020-08-26 14:30 Linus Walleij

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).