ARM: orion5x: Convert MV2120 board to GPIO descriptors for LEDs
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 23 Apr 2024 13:53:59 +0000 (15:53 +0200)
committerGregory CLEMENT <gregory.clement@bootlin.com>
Sun, 5 May 2024 16:18:17 +0000 (18:18 +0200)
This makes the LEDs on the MV2120 Orion5x board use GPIO
descriptors instead of hardcoded GPIOs from the global
numberspace.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
arch/arm/mach-orion5x/mv2120-setup.c

index 2bf8ec75e9089b85d82f3abfd51cb722a641b17e..b7327a61283531bef0a53546e623b76fb7968698 100644 (file)
@@ -8,6 +8,7 @@
  * License, or (at your option) any later version.
  */
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
@@ -139,34 +140,45 @@ static struct i2c_board_info __initdata mv2120_i2c_rtc = {
 static struct gpio_led mv2120_led_pins[] = {
        {
                .name                   = "mv2120:blue:health",
-               .gpio                   = 0,
        },
        {
                .name                   = "mv2120:red:health",
-               .gpio                   = 1,
        },
        {
                .name                   = "mv2120:led:bright",
-               .gpio                   = 4,
                .default_trigger        = "default-on",
        },
        {
                .name                   = "mv2120:led:dimmed",
-               .gpio                   = 5,
        },
        {
                .name                   = "mv2120:red:sata0",
-               .gpio                   = 8,
-               .active_low             = 1,
        },
        {
                .name                   = "mv2120:red:sata1",
-               .gpio                   = 9,
-               .active_low             = 1,
        },
 
 };
 
+static struct gpiod_lookup_table mv2120_leds_gpio_table = {
+       .dev_id = "leds-gpio",
+       .table = {
+               GPIO_LOOKUP_IDX("orion_gpio0", 0, NULL,
+                               0, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("orion_gpio0", 1, NULL,
+                               1, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("orion_gpio0", 4, NULL,
+                               2, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("orion_gpio0", 5, NULL,
+                               3, GPIO_ACTIVE_HIGH),
+               GPIO_LOOKUP_IDX("orion_gpio0", 8, NULL,
+                               4, GPIO_ACTIVE_LOW),
+               GPIO_LOOKUP_IDX("orion_gpio0", 9, NULL,
+                               5, GPIO_ACTIVE_LOW),
+               { },
+       },
+};
+
 static struct gpio_led_platform_data mv2120_led_data = {
        .leds           = mv2120_led_pins,
        .num_leds       = ARRAY_SIZE(mv2120_led_pins),
@@ -219,6 +231,7 @@ static void __init mv2120_init(void)
                        gpio_free(MV2120_GPIO_RTC_IRQ);
        }
        i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
+       gpiod_add_lookup_table(&mv2120_leds_gpio_table);
        platform_device_register(&mv2120_leds);
 
        /* register mv2120 specific power-off method */