MX31: add accessor function to get a gpio
The patch adds an accessor function to get the value of a gpio. Signed-off-by: Stefano Babic <sbabic@denx.de>
This commit is contained in:
parent
dfe83352cb
commit
7d27cd08b4
|
@ -37,12 +37,17 @@ enum mx31_gpio_direction {
|
||||||
extern int mx31_gpio_direction(unsigned int gpio,
|
extern int mx31_gpio_direction(unsigned int gpio,
|
||||||
enum mx31_gpio_direction direction);
|
enum mx31_gpio_direction direction);
|
||||||
extern void mx31_gpio_set(unsigned int gpio, unsigned int value);
|
extern void mx31_gpio_set(unsigned int gpio, unsigned int value);
|
||||||
|
extern int mx31_gpio_get(unsigned int gpio);
|
||||||
#else
|
#else
|
||||||
static inline int mx31_gpio_direction(unsigned int gpio,
|
static inline int mx31_gpio_direction(unsigned int gpio,
|
||||||
enum mx31_gpio_direction direction)
|
enum mx31_gpio_direction direction)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
static inline int mx31_gpio_get(unsigned int gpio)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
static inline void mx31_gpio_set(unsigned int gpio, unsigned int value)
|
static inline void mx31_gpio_set(unsigned int gpio, unsigned int value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,3 +71,18 @@ void mx31_gpio_set(unsigned int gpio, unsigned int value)
|
||||||
l &= ~(1 << gpio);
|
l &= ~(1 << gpio);
|
||||||
__REG(gpio_ports[port] + GPIO_DR) = l;
|
__REG(gpio_ports[port] + GPIO_DR) = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mx31_gpio_get(unsigned int gpio)
|
||||||
|
{
|
||||||
|
unsigned int port = gpio >> 5;
|
||||||
|
u32 l;
|
||||||
|
|
||||||
|
if (port >= ARRAY_SIZE(gpio_ports))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
gpio &= 0x1f;
|
||||||
|
|
||||||
|
l = (__REG(gpio_ports[port] + GPIO_DR) >> gpio) & 0x01;
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue