linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Guan Xuetao <gxt@pku.edu.cn>
Cc: linux-gpio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Stephan Linz <linz@li-pro.net>
Subject: [PATCH 1/2] unicore32: Convert GPIO LEDs to use machine descriptor table
Date: Mon, 27 Jul 2020 10:33:18 +0200	[thread overview]
Message-ID: <20200727083319.304658-1-linus.walleij@linaro.org> (raw)

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


             reply	other threads:[~2020-07-27  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27  8:33 Linus Walleij [this message]
2020-07-27  8:33 ` [PATCH 2/2] unicore32: Get rid of <linux/gpio.h> dependency Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200727083319.304658-1-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=gxt@pku.edu.cn \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linz@li-pro.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).