diff mbox series

[1/2] unicore32: Convert GPIO LEDs to use machine descriptor table

Message ID 20200727083319.304658-1-linus.walleij@linaro.org
State New
Headers show
Series [1/2] unicore32: Convert GPIO LEDs to use machine descriptor table | expand

Commit Message

Linus Walleij July 27, 2020, 8:33 a.m. UTC
This converts the Unicore32 LEDs to use the GPIO machine
descriptor table to provide the GPIO lines.

Cc: Stephan Linz <linz@li-pro.net>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 arch/unicore32/kernel/gpio.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 
2.26.2
diff mbox series

Patch

diff --git a/arch/unicore32/kernel/gpio.c b/arch/unicore32/kernel/gpio.c
index 36d395b54b7c..887ea29c380a 100644
--- a/arch/unicore32/kernel/gpio.c
+++ b/arch/unicore32/kernel/gpio.c
@@ -12,6 +12,7 @@ 
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
 /* FIXME: needed for gpio_set_value() - convert to use descriptors or hogs */
 #include <linux/gpio.h>
 #include <mach/hardware.h>
@@ -21,10 +22,8 @@ 
 #include <linux/platform_device.h>
 
 static const struct gpio_led puv3_gpio_leds[] = {
-	{ .name = "cpuhealth", .gpio = GPO_CPU_HEALTH, .active_low = 0,
-		.default_trigger = "heartbeat",	},
-	{ .name = "hdd_led", .gpio = GPO_HDD_LED, .active_low = 1,
-		.default_trigger = "disk-activity", },
+	{ .name = "cpuhealth", .default_trigger = "heartbeat",	},
+	{ .name = "hdd_led", .default_trigger = "disk-activity", },
 };
 
 static const struct gpio_led_platform_data puv3_gpio_led_data = {
@@ -32,6 +31,17 @@  static const struct gpio_led_platform_data puv3_gpio_led_data = {
 	.leds =		(void *) puv3_gpio_leds,
 };
 
+static struct gpiod_lookup_table puv3_leds_gpio_table = {
+	.dev_id = "leds-gpio",
+	.table = {
+		GPIO_LOOKUP_IDX("gpio", GPO_CPU_HEALTH, NULL,
+				0, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX("gpio", GPO_HDD_LED, NULL,
+				1, GPIO_ACTIVE_LOW),
+		{ },
+	},
+};
+
 static struct platform_device puv3_gpio_gpio_leds = {
 	.name =		"leds-gpio",
 	.id =		-1,
@@ -42,6 +52,7 @@  static struct platform_device puv3_gpio_gpio_leds = {
 
 static int __init puv3_gpio_leds_init(void)
 {
+	gpiod_add_lookup_table(&puv3_leds_gpio_table);
 	platform_device_register(&puv3_gpio_gpio_leds);
 	return 0;
 }