Skip to contentSkip to conversation

nios2: add gpio_request

PATCH New Thomas Chou 3 participants 8 messages Jun 9, 2010 – Jul 5, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nios2: add gpio_request

This will be used by nand_plat.

---
 arch/nios2/include/asm/gpio.h     |    6 ++++++
 board/altera/nios2-generic/gpio.c |    5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)
arch/nios2/include/asm/gpio.h +6 -0
index 76c425e..cff1dd9 100644
@@ -21,6 +21,11 @@
 #ifdef CONFIG_SYS_GPIO_BASE
 #include <asm/io.h>
 
+static inline int gpio_request(unsigned gpio, const char *label)
+{
+	return 0;
+}
+
 static inline int gpio_direction_input(unsigned gpio)
 {
 	writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2));
@@ -43,6 +48,7 @@ static inline void gpio_set_value(unsigned gpio, int value)
 	writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
 }
 #else
+extern int gpio_request(unsigned gpio, const char *label);
 extern int gpio_direction_input(unsigned gpio);
 extern int gpio_direction_output(unsigned gpio, int value);
 extern int gpio_get_value(unsigned gpio);
board/altera/nios2-generic/gpio.c +5 -0
index 6c9c6c2..d449684 100644
@@ -15,6 +15,11 @@
 static u32 pio_data_reg;
 static u32 pio_dir_reg;
 
+int gpio_request(unsigned gpio, const char *label)
+{
+	return 0;
+}
+
 int gpio_direction_input(unsigned gpio)
 {
 	u32 mask = 1 << gpio;
Signature · 1 line
1.7.1.86.g0e460
#1 lore raw

PATCH 2/2 gpio_led: add gpio_request to __led_init

This patcha adds the gpio usage request.

---
 drivers/misc/gpio_led.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/misc/gpio_led.c +2 -4
index acd6a90..e00b9fa 100644
@@ -2,10 +2,7 @@
  * Status LED driver based on GPIO access conventions of Linux
  *
  * Copyright (C) 2010 Thomas Chou <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Licensed under the GPL-2 or later.
  */
 
 #include <common.h>
@@ -16,6 +13,7 @@
 
 void __led_init(led_id_t mask, int state)
 {
+	gpio_request(mask, "gpio_led");
 	gpio_direction_output(mask, (state == STATUS_LED_ON) ? 0 : 1);
 }
 
Signature · 1 line
1.7.1.86.g0e460
#2 lore raw

PATCH 2/2 gpio_led: add gpio_request to __led_init

Quoted 1 line · On Tuesday, June 08, 2010 21:51:10 Thomas Chou wrote:

This patcha adds the gpio usage request.

"patch". otherwise, i wish i knew about this driver earlier as i ended up writing a similar thing for Blackfin systems with the GPIO framework :/.

-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100609/63b4e4b0/attachment.pgp

#3 lore raw

PATCH v2 2/2 gpio_led: add gpio_request to __led_init

This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.

---
v2: fix typo, change led polarity

 drivers/misc/gpio_led.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/misc/gpio_led.c +4 -8
index acd6a90..3fedddc 100644
@@ -2,26 +2,22 @@
  * Status LED driver based on GPIO access conventions of Linux
  *
  * Copyright (C) 2010 Thomas Chou <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Licensed under the GPL-2 or later.
  */
 
 #include <common.h>
 #include <status_led.h>
 #include <asm/gpio.h>
 
-/* assume led is active low */
-
 void __led_init(led_id_t mask, int state)
 {
-	gpio_direction_output(mask, (state == STATUS_LED_ON) ? 0 : 1);
+	gpio_request(mask, "gpio_led");
+	gpio_direction_output(mask, state == STATUS_LED_ON);
 }
 
 void __led_set(led_id_t mask, int state)
 {
-	gpio_set_value(mask, (state == STATUS_LED_ON) ? 0 : 1);
+	gpio_set_value(mask, state == STATUS_LED_ON);
 }
 
 void __led_toggle(led_id_t mask)
Signature · 1 line
1.7.1.86.g0e460
#4 lore raw

PATCH v2 2/2 gpio_led: add gpio_request to __led_init

Applied to: git://git.denx.de/u-boot-nios.git next Thanks,
--Scott

Quoted 45 lines · Thomas Chou

This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.

---
v2: fix typo, change led polarity

 drivers/misc/gpio_led.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/misc/gpio_led.c +4 -8
index acd6a90..3fedddc 100644
@@ -2,26 +2,22 @@
  * Status LED driver based on GPIO access conventions of Linux
  *
  * Copyright (C) 2010 Thomas Chou <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Licensed under the GPL-2 or later.
  */
 
 #include <common.h>
 #include <status_led.h>
 #include <asm/gpio.h>
 
-/* assume led is active low */
-
 void __led_init(led_id_t mask, int state)
 {
-	gpio_direction_output(mask, (state == STATUS_LED_ON) ? 0 : 1);
+	gpio_request(mask, "gpio_led");
+	gpio_direction_output(mask, state == STATUS_LED_ON);
 }
 
 void __led_set(led_id_t mask, int state)
 {
-	gpio_set_value(mask, (state == STATUS_LED_ON) ? 0 : 1);
+	gpio_set_value(mask, state == STATUS_LED_ON);
 }
 
 void __led_toggle(led_id_t mask)
#5 lore raw

PATCH v2 2/2 gpio_led: add gpio_request to __led_init

Quoted 3 lines · Scott McNutt

Applied to: git://git.denx.de/u-boot-nios.git next Thanks,
--Scott

Dear Scott,

Would you please send a pull request to Wolfgang?

Best regards,
Thomas

Quoted 49 lines
Quoted 45 lines · Thomas Chou

This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.

---
v2: fix typo, change led polarity

drivers/misc/gpio_led.c | 12 ++++--------

1 files changed, 4 insertions(+), 8 deletions(-)
drivers/misc/gpio_led.c +4 -8
index acd6a90..3fedddc 100644
@@ -2,26 +2,22 @@
 * Status LED driver based on GPIO access conventions of Linux
 *
 * Copyright (C) 2010 Thomas Chou <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Licensed under the GPL-2 or later.
 */
 
 #include <common.h>
 #include <status_led.h>
 #include <asm/gpio.h>
 
-/* assume led is active low */
-
 void __led_init(led_id_t mask, int state)
 {
- gpio_direction_output(mask, (state == STATUS_LED_ON) ? 0 : 1);
+ gpio_request(mask, "gpio_led");
+ gpio_direction_output(mask, state == STATUS_LED_ON);
 }
 
 void __led_set(led_id_t mask, int state)
 {
- gpio_set_value(mask, (state == STATUS_LED_ON) ? 0 : 1);
+ gpio_set_value(mask, state == STATUS_LED_ON);
 }
 
 void __led_toggle(led_id_t mask)
#6 lore raw

PATCH 2/2 gpio_led: add gpio_request to __led_init

In reply to Mike Frysinger
Quoted 8 lines · Mike Frysinger
Quoted 1 line · On Tuesday, June 08, 2010 21:51:10 Thomas Chou wrote:

This patcha adds the gpio usage request.

"patch". otherwise, i wish i knew about this driver earlier as i ended up writing a similar thing for Blackfin systems with the GPIO framework :/.

-mike

Hi Mike,

Thanks. I sent an updated patch.

Will you use gpio for the bit-banging i2c driver, soft_i2c.c? Is there a good way to include asm/gpio.h to it?

Best regards,
Thomas

#7 lore raw

PATCH 1/2 nios2: add gpio_request

In reply to Thomas Chou

Applied to: git://git.denx.de/u-boot-nios.git next Thanks,
--Scott

Quoted 48 lines · Thomas Chou

This will be used by nand_plat.

---
 arch/nios2/include/asm/gpio.h     |    6 ++++++
 board/altera/nios2-generic/gpio.c |    5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)
arch/nios2/include/asm/gpio.h +6 -0
index 76c425e..cff1dd9 100644
@@ -21,6 +21,11 @@
 #ifdef CONFIG_SYS_GPIO_BASE
 #include <asm/io.h>
 
+static inline int gpio_request(unsigned gpio, const char *label)
+{
+	return 0;
+}
+
 static inline int gpio_direction_input(unsigned gpio)
 {
 	writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2));
@@ -43,6 +48,7 @@ static inline void gpio_set_value(unsigned gpio, int value)
 	writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
 }
 #else
+extern int gpio_request(unsigned gpio, const char *label);
 extern int gpio_direction_input(unsigned gpio);
 extern int gpio_direction_output(unsigned gpio, int value);
 extern int gpio_get_value(unsigned gpio);
board/altera/nios2-generic/gpio.c +5 -0
index 6c9c6c2..d449684 100644
@@ -15,6 +15,11 @@
 static u32 pio_data_reg;
 static u32 pio_dir_reg;
 
+int gpio_request(unsigned gpio, const char *label)
+{
+	return 0;
+}
+
 int gpio_direction_input(unsigned gpio)
 {
 	u32 mask = 1 << gpio;