[ARM] pxa: Avoid pxa_gpio_mode() in gpio_direction_{in,out}put()
pxa_gpio_mode() is a universal call that fiddles with the GAFR (gpio alternate function register.) GAFR does not exist on PXA3 CPUs, but instead the alternate functions are controlled via the MFP support code. Platforms are expected to configure the MFP according to their needs in their platform support code rather than drivers. We extend this idea to the GAFR, and make the gpio_direction_*() functions purely operate on the GPIO level. This means platform support code is entirely responsible for configuring the GPIOs alternate functions on all PXA CPU types. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
committed by
Russell King
parent
39cbd4896e
commit
3e0cc7ee04
@@ -105,6 +105,44 @@ int pxa_gpio_mode(int gpio_mode)
|
||||
|
||||
EXPORT_SYMBOL(pxa_gpio_mode);
|
||||
|
||||
int gpio_direction_input(unsigned gpio)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 mask;
|
||||
|
||||
if (gpio > pxa_last_gpio)
|
||||
return -EINVAL;
|
||||
|
||||
mask = GPIO_bit(gpio);
|
||||
local_irq_save(flags);
|
||||
GPDR(gpio) &= ~mask;
|
||||
local_irq_restore(flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(gpio_direction_input);
|
||||
|
||||
int gpio_direction_output(unsigned gpio, int value)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 mask;
|
||||
|
||||
if (gpio > pxa_last_gpio)
|
||||
return -EINVAL;
|
||||
|
||||
mask = GPIO_bit(gpio);
|
||||
local_irq_save(flags);
|
||||
if (value)
|
||||
GPSR(gpio) = mask;
|
||||
else
|
||||
GPCR(gpio) = mask;
|
||||
GPDR(gpio) |= mask;
|
||||
local_irq_restore(flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(gpio_direction_output);
|
||||
|
||||
/*
|
||||
* Return GPIO level
|
||||
*/
|
||||
|
Reference in New Issue
Block a user