[U-Boot] [PATCH] OMAP: Add function to get state of a GPIO output

From: Joel A Fernandes agnel.joel@gmail.com
Read directly from OMAP_GPIO_DATAOUT to get the output state of the GPIO pin
Signed-off-by: Joel A Fernandes agnel.joel@gmail.com Signed-off-by: Jason Kridner jkridner@beagleboard.org Signed-off-by: Sandeep Paulraj s-paulraj@ti.com --- arch/arm/cpu/armv7/omap-common/gpio.c | 20 ++++++++++++++++++++ arch/arm/include/asm/omap_gpio.h | 2 ++ 2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/gpio.c b/arch/arm/cpu/armv7/omap-common/gpio.c index 2fcaf5a..4749524 100644 --- a/arch/arm/cpu/armv7/omap-common/gpio.c +++ b/arch/arm/cpu/armv7/omap-common/gpio.c @@ -151,6 +151,26 @@ int omap_get_gpio_datain(int gpio) & (1 << get_gpio_index(gpio))) != 0; }
+int omap_get_gpio_dataout(int gpio) +{ + struct gpio_bank *bank; + void *reg; + + if (check_gpio(gpio) < 0) + return -EINVAL; + bank = get_gpio_bank(gpio); + reg = bank->base; + switch (bank->method) { + case METHOD_GPIO_24XX: + reg += OMAP_GPIO_DATAOUT; + break; + default: + return -EINVAL; + } + return (__raw_readl(reg) + & (1 << get_gpio_index(gpio))) != 0; +} + static void _reset_gpio(const struct gpio_bank *bank, int gpio) { _set_gpio_direction(bank, get_gpio_index(gpio), 1); diff --git a/arch/arm/include/asm/omap_gpio.h b/arch/arm/include/asm/omap_gpio.h index 3089e1c..8741572 100644 --- a/arch/arm/include/asm/omap_gpio.h +++ b/arch/arm/include/asm/omap_gpio.h @@ -61,5 +61,7 @@ void omap_set_gpio_direction(int gpio, int is_input); void omap_set_gpio_dataout(int gpio, int enable); /* Get the value of a gpio input */ int omap_get_gpio_datain(int gpio); +/* Get the value of a gpio output */ +int omap_get_gpio_dataout(int gpio);
#endif /* _GPIO_H_ */

Hi Sandeep, Joel,
On Sun, Sep 4, 2011 at 11:10 PM, s-paulraj@ti.com wrote:
From: Joel A Fernandes agnel.joel@gmail.com
Read directly from OMAP_GPIO_DATAOUT to get the output state of the GPIO pin
Signed-off-by: Joel A Fernandes agnel.joel@gmail.com Signed-off-by: Jason Kridner jkridner@beagleboard.org Signed-off-by: Sandeep Paulraj s-paulraj@ti.com
arch/arm/cpu/armv7/omap-common/gpio.c | 20 ++++++++++++++++++++ arch/arm/include/asm/omap_gpio.h | 2 ++ 2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/gpio.c b/arch/arm/cpu/armv7/omap-common/gpio.c index 2fcaf5a..4749524 100644 --- a/arch/arm/cpu/armv7/omap-common/gpio.c +++ b/arch/arm/cpu/armv7/omap-common/gpio.c @@ -151,6 +151,26 @@ int omap_get_gpio_datain(int gpio) & (1 << get_gpio_index(gpio))) != 0; }
+int omap_get_gpio_dataout(int gpio)
This patch added a build warning like this:
gpio.c: In function 'omap_get_gpio_dataout': gpio.c:161: warning: assignment discards qualifiers from pointer target type
The fix is this:
diff --git a/arch/arm/cpu/armv7/omap-common/gpio.c b/arch/arm/cpu/armv7/omap-common/gpio.c index 4749524..c4126fe 100644 --- a/arch/arm/cpu/armv7/omap-common/gpio.c +++ b/arch/arm/cpu/armv7/omap-common/gpio.c @@ -153,7 +153,7 @@ int omap_get_gpio_datain(int gpio)
int omap_get_gpio_dataout(int gpio) { - struct gpio_bank *bank; + const struct gpio_bank *bank; void *reg;
if (check_gpio(gpio) < 0)
+{
- struct gpio_bank *bank;
- void *reg;
- if (check_gpio(gpio) < 0)
- return -EINVAL;
- bank = get_gpio_bank(gpio);
- reg = bank->base;
- switch (bank->method) {
- case METHOD_GPIO_24XX:
- reg += OMAP_GPIO_DATAOUT;
- break;
- default:
- return -EINVAL;
- }
- return (__raw_readl(reg)
- & (1 << get_gpio_index(gpio))) != 0;
+}
static void _reset_gpio(const struct gpio_bank *bank, int gpio) { _set_gpio_direction(bank, get_gpio_index(gpio), 1); diff --git a/arch/arm/include/asm/omap_gpio.h b/arch/arm/include/asm/omap_gpio.h index 3089e1c..8741572 100644 --- a/arch/arm/include/asm/omap_gpio.h +++ b/arch/arm/include/asm/omap_gpio.h @@ -61,5 +61,7 @@ void omap_set_gpio_direction(int gpio, int is_input); void omap_set_gpio_dataout(int gpio, int enable); /* Get the value of a gpio input */ int omap_get_gpio_datain(int gpio); +/* Get the value of a gpio output */ +int omap_get_gpio_dataout(int gpio);
#endif /* _GPIO_H_ */
1.6.0.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

This patch added a build warning like this:
gpio.c: In function 'omap_get_gpio_dataout': gpio.c:161: warning: assignment discards qualifiers from pointer target type
The fix is this:
We will have to co ordinate the best way to move forward on this. Sanjeev submitted a patch set to move to the generic GPIO framework.
Regards, Sandeep

I don't remember seeing any errors/warnings after applying my patches... on all boards listed in the cover letter. ...except for SMSC95x - in case of Panda.
Infact, once the patches are applied, this function shouldn't even exist.
~sanjeev ________________________________________ From: u-boot-bounces@lists.denx.de [u-boot-bounces@lists.denx.de] On Behalf Of Paulraj, Sandeep Sent: Tuesday, September 06, 2011 9:48 PM To: V, Aneesh Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH] OMAP: Add function to get state of a GPIO output
This patch added a build warning like this:
gpio.c: In function 'omap_get_gpio_dataout': gpio.c:161: warning: assignment discards qualifiers from pointer target type
The fix is this:
We will have to co ordinate the best way to move forward on this. Sanjeev submitted a patch set to move to the generic GPIO framework.
Regards, Sandeep _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On Tue, Sep 6, 2011 at 1:16 PM, Premi, Sanjeev premi@ti.com wrote:
I don't remember seeing any errors/warnings after applying my patches... on all boards listed in the cover letter. ...except for SMSC95x - in case of Panda.
Infact, once the patches are applied, this function shouldn't even exist.
I didn't follow, why shouldn't the function be required? Is it being replaced with another one?
Thanks, Joel
participants (5)
-
Joel A Fernandes
-
Paulraj, Sandeep
-
Premi, Sanjeev
-
s-paulraj@ti.com
-
V, Aneesh