[U-Boot] [PATCH 1/2] nios2: add gpio_request

This will be used by nand_plat.
Signed-off-by: Thomas Chou thomas@wytron.com.tw --- arch/nios2/include/asm/gpio.h | 6 ++++++ board/altera/nios2-generic/gpio.c | 5 +++++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h index 76c425e..cff1dd9 100644 --- a/arch/nios2/include/asm/gpio.h +++ b/arch/nios2/include/asm/gpio.h @@ -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); diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c index 6c9c6c2..d449684 100644 --- a/board/altera/nios2-generic/gpio.c +++ b/board/altera/nios2-generic/gpio.c @@ -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;

This patcha adds the gpio usage request.
Signed-off-by: Thomas Chou thomas@wytron.com.tw --- drivers/misc/gpio_led.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c index acd6a90..e00b9fa 100644 --- a/drivers/misc/gpio_led.c +++ b/drivers/misc/gpio_led.c @@ -2,10 +2,7 @@ * Status LED driver based on GPIO access conventions of Linux * * Copyright (C) 2010 Thomas Chou thomas@wytron.com.tw - * - * 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); }

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 :/.
Signed-off-by: Mike Frysinger vapier@gentoo.org -mike

This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.
Signed-off-by: Thomas Chou thomas@wytron.com.tw --- v2: fix typo, change led polarity
drivers/misc/gpio_led.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c index acd6a90..3fedddc 100644 --- a/drivers/misc/gpio_led.c +++ b/drivers/misc/gpio_led.c @@ -2,26 +2,22 @@ * Status LED driver based on GPIO access conventions of Linux * * Copyright (C) 2010 Thomas Chou thomas@wytron.com.tw - * - * 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)

Applied to: git://git.denx.de/u-boot-nios.git next Thanks, --Scott
Thomas Chou wrote:
This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.
Signed-off-by: Thomas Chou thomas@wytron.com.tw
v2: fix typo, change led polarity
drivers/misc/gpio_led.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c index acd6a90..3fedddc 100644 --- a/drivers/misc/gpio_led.c +++ b/drivers/misc/gpio_led.c @@ -2,26 +2,22 @@
- Status LED driver based on GPIO access conventions of Linux
- Copyright (C) 2010 Thomas Chou thomas@wytron.com.tw
- 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)

On 06/16/2010 09:29 AM, Scott McNutt wrote:
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
Thomas Chou wrote:
This patch adds the gpio usage request. The polarity is changed to positive as suggested by Mike Frysinger.
Signed-off-by: Thomas Chou thomas@wytron.com.tw
v2: fix typo, change led polarity
drivers/misc/gpio_led.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c index acd6a90..3fedddc 100644 --- a/drivers/misc/gpio_led.c +++ b/drivers/misc/gpio_led.c @@ -2,26 +2,22 @@
- Status LED driver based on GPIO access conventions of Linux
- Copyright (C) 2010 Thomas Chou thomas@wytron.com.tw
- 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)

Mike Frysinger wrote:
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 :/.
Signed-off-by: Mike Frysinger vapier@gentoo.org -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

Applied to: git://git.denx.de/u-boot-nios.git next Thanks, --Scott
Thomas Chou wrote:
This will be used by nand_plat.
Signed-off-by: Thomas Chou thomas@wytron.com.tw
arch/nios2/include/asm/gpio.h | 6 ++++++ board/altera/nios2-generic/gpio.c | 5 +++++ 2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h index 76c425e..cff1dd9 100644 --- a/arch/nios2/include/asm/gpio.h +++ b/arch/nios2/include/asm/gpio.h @@ -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); diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c index 6c9c6c2..d449684 100644 --- a/board/altera/nios2-generic/gpio.c +++ b/board/altera/nios2-generic/gpio.c @@ -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;
participants (3)
-
Mike Frysinger
-
Scott McNutt
-
Thomas Chou