From: David Brownell <dbrownell@users.sourceforge.net> Fix GPIO-related build error on mach-imx platform: CC drivers/spi/spi_gpio.o In file included from /home/db/kernel/scratch/arch/arm/include/asm/gpio.h:5, from include/linux/gpio.h:7, from drivers/spi/spi_gpio.c:23: arch/arm/mach-imx/include/mach/gpio.h: In function 'imx_gpio_get_value': arch/arm/mach-imx/include/mach/gpio.h:27: error: implicit declaration of function '__REG2' arch/arm/mach-imx/include/mach/gpio.h:27: error: 'IMX_IO_BASE' undeclared (first use in this function) arch/arm/mach-imx/include/mach/gpio.h:27: error: (Each undeclared identifier is reported only once arch/arm/mach-imx/include/mach/gpio.h:27: error: for each function it appears in.) arch/arm/mach-imx/include/mach/gpio.h: In function 'imx_gpio_set_value_inline': arch/arm/mach-imx/include/mach/gpio.h:36: error: 'IMX_IO_BASE' undeclared (first use in this function) arch/arm/mach-imx/include/mach/gpio.h:36: error: lvalue required as left operand of assignment arch/arm/mach-imx/include/mach/gpio.h:38: error: lvalue required as left operand of assignment ... Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
107 lines
2.4 KiB
C
107 lines
2.4 KiB
C
#ifndef _IMX_GPIO_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <mach/hardware.h>
|
|
#include <mach/imx-regs.h>
|
|
|
|
#define IMX_GPIO_ALLOC_MODE_NORMAL 0
|
|
#define IMX_GPIO_ALLOC_MODE_NO_ALLOC 1
|
|
#define IMX_GPIO_ALLOC_MODE_TRY_ALLOC 2
|
|
#define IMX_GPIO_ALLOC_MODE_ALLOC_ONLY 4
|
|
#define IMX_GPIO_ALLOC_MODE_RELEASE 8
|
|
|
|
extern int imx_gpio_request(unsigned gpio, const char *label);
|
|
|
|
extern void imx_gpio_free(unsigned gpio);
|
|
|
|
extern int imx_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
|
|
int alloc_mode, const char *label);
|
|
|
|
extern int imx_gpio_direction_input(unsigned gpio);
|
|
|
|
extern int imx_gpio_direction_output(unsigned gpio, int value);
|
|
|
|
extern void __imx_gpio_set_value(unsigned gpio, int value);
|
|
|
|
static inline int imx_gpio_get_value(unsigned gpio)
|
|
{
|
|
return SSR(gpio >> GPIO_PORT_SHIFT) & (1 << (gpio & GPIO_PIN_MASK));
|
|
}
|
|
|
|
static inline void imx_gpio_set_value_inline(unsigned gpio, int value)
|
|
{
|
|
unsigned long flags;
|
|
|
|
raw_local_irq_save(flags);
|
|
if(value)
|
|
DR(gpio >> GPIO_PORT_SHIFT) |= (1 << (gpio & GPIO_PIN_MASK));
|
|
else
|
|
DR(gpio >> GPIO_PORT_SHIFT) &= ~(1 << (gpio & GPIO_PIN_MASK));
|
|
raw_local_irq_restore(flags);
|
|
}
|
|
|
|
static inline void imx_gpio_set_value(unsigned gpio, int value)
|
|
{
|
|
if(__builtin_constant_p(gpio))
|
|
imx_gpio_set_value_inline(gpio, value);
|
|
else
|
|
__imx_gpio_set_value(gpio, value);
|
|
}
|
|
|
|
extern int imx_gpio_to_irq(unsigned gpio);
|
|
|
|
extern int imx_irq_to_gpio(unsigned irq);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Wrappers for "new style" GPIO calls. These calls i.MX specific versions
|
|
* to allow future extension of GPIO logic.
|
|
*/
|
|
|
|
static inline int gpio_request(unsigned gpio, const char *label)
|
|
{
|
|
return imx_gpio_request(gpio, label);
|
|
}
|
|
|
|
static inline void gpio_free(unsigned gpio)
|
|
{
|
|
might_sleep();
|
|
|
|
imx_gpio_free(gpio);
|
|
}
|
|
|
|
static inline int gpio_direction_input(unsigned gpio)
|
|
{
|
|
return imx_gpio_direction_input(gpio);
|
|
}
|
|
|
|
static inline int gpio_direction_output(unsigned gpio, int value)
|
|
{
|
|
return imx_gpio_direction_output(gpio, value);
|
|
}
|
|
|
|
static inline int gpio_get_value(unsigned gpio)
|
|
{
|
|
return imx_gpio_get_value(gpio);
|
|
}
|
|
|
|
static inline void gpio_set_value(unsigned gpio, int value)
|
|
{
|
|
imx_gpio_set_value(gpio, value);
|
|
}
|
|
|
|
#include <asm-generic/gpio.h> /* cansleep wrappers */
|
|
|
|
static inline int gpio_to_irq(unsigned gpio)
|
|
{
|
|
return imx_gpio_to_irq(gpio);
|
|
}
|
|
|
|
static inline int irq_to_gpio(unsigned irq)
|
|
{
|
|
return imx_irq_to_gpio(irq);
|
|
}
|
|
|
|
|
|
#endif
|