linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / 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 related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] unicore32: Get rid of <linux/gpio.h> dependency
  2020-07-27  8:33 [PATCH 1/2] unicore32: Convert GPIO LEDs to use machine descriptor table Linus Walleij
@ 2020-07-27  8:33 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2020-07-27  8:33 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: linux-gpio, Linus Walleij

Instead of writing to the GPIO lines through the gpiolib
API, call the appropriate function directly in the driver.

Cc: Guan Xuetao <gxt@pku.edu.cn>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/unicore32/kernel/gpio.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/arch/unicore32/kernel/gpio.c b/arch/unicore32/kernel/gpio.c
index 887ea29c380a..3f6b5747b094 100644
--- a/arch/unicore32/kernel/gpio.c
+++ b/arch/unicore32/kernel/gpio.c
@@ -13,8 +13,6 @@
 #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>
 
 #ifdef CONFIG_LEDS
@@ -110,22 +108,22 @@ void __init puv3_init_gpio(void)
 	writel(GPIO_DIR, GPIO_GPDR);
 #if	defined(CONFIG_PUV3_NB0916) || defined(CONFIG_PUV3_SMW0919)	\
 	|| defined(CONFIG_PUV3_DB0913)
-	gpio_set_value(GPO_WIFI_EN, 1);
-	gpio_set_value(GPO_HDD_LED, 1);
-	gpio_set_value(GPO_VGA_EN, 1);
-	gpio_set_value(GPO_LCD_EN, 1);
-	gpio_set_value(GPO_CAM_PWR_EN, 0);
-	gpio_set_value(GPO_LCD_VCC_EN, 1);
-	gpio_set_value(GPO_SOFT_OFF, 1);
-	gpio_set_value(GPO_BT_EN, 1);
-	gpio_set_value(GPO_FAN_ON, 0);
-	gpio_set_value(GPO_SPKR, 0);
-	gpio_set_value(GPO_CPU_HEALTH, 1);
-	gpio_set_value(GPO_LAN_SEL, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_WIFI_EN, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_HDD_LED, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_VGA_EN, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_LCD_EN, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_CAM_PWR_EN, 0);
+	puv3_direction_output(&puv3_gpio_chip, GPO_LCD_VCC_EN, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_SOFT_OFF, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_BT_EN, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_FAN_ON, 0);
+	puv3_direction_output(&puv3_gpio_chip, GPO_SPKR, 0);
+	puv3_direction_output(&puv3_gpio_chip, GPO_CPU_HEALTH, 1);
+	puv3_direction_output(&puv3_gpio_chip, GPO_LAN_SEL, 1);
 /*
  * DO NOT modify the GPO_SET_V1 and GPO_SET_V2 in kernel
- *	gpio_set_value(GPO_SET_V1, 1);
- *	gpio_set_value(GPO_SET_V2, 1);
+ *	puv3_direction_output(&puv3_gpio_chip, GPO_SET_V1, 1);
+ *	puv3_direction_output(&puv3_gpio_chip, GPO_SET_V2, 1);
  */
 #endif
 	gpiochip_add_data(&puv3_gpio_chip, NULL);
-- 
2.26.2


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

end of thread, other threads:[~2020-07-27  8:35 UTC | newest]

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

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