Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] unicore32: Convert GPIO LEDs to use machine descriptor table
@ 2020-07-27  8:33 Linus Walleij
  2020-07-27  8:33 ` [PATCH 2/2] unicore32: Get rid of <linux/gpio.h> dependency Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-07-27  8:33 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: linux-gpio, Linus Walleij, Stephan Linz

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

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;
 }
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  8:33 [PATCH 1/2] unicore32: Convert GPIO LEDs to use machine descriptor table Linus Walleij
2020-07-27  8:33 ` [PATCH 2/2] unicore32: Get rid of <linux/gpio.h> dependency Linus Walleij

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git