Commit 5b7e42b2 authored by Philipp Zabel's avatar Philipp Zabel Committed by Linus Torvalds

[PATCH] GPIO API: SA1100 wrapper cleanup

Based on the discussion last december (http://lkml.org/lkml/2006/12/20/241),
this patch
  - adds gpio_direction_input/output functions to
    generic.c instead of making them inline,
  - fixes comment and includes and uses inline functions
    instead of macros in gpio.h
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent adff264f
...@@ -138,6 +138,36 @@ unsigned long long sched_clock(void) ...@@ -138,6 +138,36 @@ unsigned long long sched_clock(void)
return v; return v;
} }
int gpio_direction_input(unsigned gpio)
{
unsigned long flags;
if (gpio > GPIO_MAX)
return -EINVAL;
local_irq_save(flags);
GPDR &= ~GPIO_GPIO(gpio);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_input);
int gpio_direction_output(unsigned gpio)
{
unsigned long flags;
if (gpio > GPIO_MAX)
return -EINVAL;
local_irq_save(flags);
GPDR |= GPIO_GPIO(gpio);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_output);
/* /*
* Default power-off for SA1100 * Default power-off for SA1100
*/ */
......
/* /*
* linux/include/asm-arm/arch-pxa/gpio.h * linux/include/asm-arm/arch-sa1100/gpio.h
* *
* SA1100 GPIO wrappers for arch-neutral GPIO calls * SA1100 GPIO wrappers for arch-neutral GPIO calls
* *
...@@ -24,11 +24,8 @@ ...@@ -24,11 +24,8 @@
#ifndef __ASM_ARCH_SA1100_GPIO_H #ifndef __ASM_ARCH_SA1100_GPIO_H
#define __ASM_ARCH_SA1100_GPIO_H #define __ASM_ARCH_SA1100_GPIO_H
#include <asm/arch/SA-1100.h> #include <asm/hardware.h>
#include <asm/arch/irqs.h> #include <asm/irq.h>
#include <asm/arch/hardware.h>
#include <asm/errno.h>
static inline int gpio_request(unsigned gpio, const char *label) static inline int gpio_request(unsigned gpio, const char *label)
{ {
...@@ -40,26 +37,23 @@ static inline void gpio_free(unsigned gpio) ...@@ -40,26 +37,23 @@ static inline void gpio_free(unsigned gpio)
return; return;
} }
static inline int gpio_direction_input(unsigned gpio) extern int gpio_direction_input(unsigned gpio);
extern int gpio_direction_output(unsigned gpio);
static inline int gpio_get_value(unsigned gpio)
{ {
if (gpio > GPIO_MAX) return GPLR & GPIO_GPIO(gpio);
return -EINVAL;
GPDR = (GPDR_In << gpio) 0
} }
static inline int gpio_direction_output(unsigned gpio) static inline void gpio_set_value(unsigned gpio, int value)
{ {
if (gpio > GPIO_MAX) if (value)
return -EINVAL; GPSR = GPIO_GPIO(gpio);
GPDR = (GPDR_Out << gpio) 0 else
GPCR = GPIO_GPIO(gpio);
} }
#define gpio_get_value(gpio) \
(GPLR & GPIO_GPIO(gpio))
#define gpio_set_value(gpio,value) \
((value) ? (GPSR = GPIO_GPIO(gpio)) : (GPCR(gpio) = GPIO_GPIO(gpio)))
#include <asm-generic/gpio.h> /* cansleep wrappers */ #include <asm-generic/gpio.h> /* cansleep wrappers */
static inline unsigned gpio_to_irq(unsigned gpio) static inline unsigned gpio_to_irq(unsigned gpio)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment