Commit 566b450c authored by Eric Miao's avatar Eric Miao Committed by Russell King

[ARM] pxa: add pxa2xx_mfp_set_lpm() to facilitate low power state change

Some boards want to change low power state of pins on-the-fly, this
function helps to facilitate that operation instead of switching
back-n-forth between two configurations with pxa2xx_mfp_config().
Signed-off-by: default avatarEric Miao <eric.miao@marvell.com>
Tested-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 0fedb0ca
...@@ -39,6 +39,28 @@ struct gpio_desc { ...@@ -39,6 +39,28 @@ struct gpio_desc {
static struct gpio_desc gpio_desc[MFP_PIN_GPIO127 + 1]; static struct gpio_desc gpio_desc[MFP_PIN_GPIO127 + 1];
static int __mfp_config_lpm(unsigned gpio, unsigned long lpm)
{
unsigned mask = GPIO_bit(gpio);
/* low power state */
switch (lpm) {
case MFP_LPM_DRIVE_HIGH:
PGSR(gpio) |= mask;
break;
case MFP_LPM_DRIVE_LOW:
PGSR(gpio) &= ~mask;
break;
case MFP_LPM_INPUT:
break;
default:
pr_warning("%s: invalid low power state for GPIO%d\n",
__func__, gpio);
return -EINVAL;
}
return 0;
}
static int __mfp_config_gpio(unsigned gpio, unsigned long c) static int __mfp_config_gpio(unsigned gpio, unsigned long c)
{ {
unsigned long gafr, mask = GPIO_bit(gpio); unsigned long gafr, mask = GPIO_bit(gpio);
...@@ -57,21 +79,8 @@ static int __mfp_config_gpio(unsigned gpio, unsigned long c) ...@@ -57,21 +79,8 @@ static int __mfp_config_gpio(unsigned gpio, unsigned long c)
else else
GPDR(gpio) &= ~mask; GPDR(gpio) &= ~mask;
/* low power state */ if (__mfp_config_lpm(gpio, c & MFP_LPM_STATE_MASK))
switch (c & MFP_LPM_STATE_MASK) {
case MFP_LPM_DRIVE_HIGH:
PGSR(gpio) |= mask;
break;
case MFP_LPM_DRIVE_LOW:
PGSR(gpio) &= ~mask;
break;
case MFP_LPM_INPUT:
break;
default:
pr_warning("%s: invalid low power state for GPIO%d\n",
__func__, gpio);
return -EINVAL; return -EINVAL;
}
/* give early warning if MFP_LPM_CAN_WAKEUP is set on the /* give early warning if MFP_LPM_CAN_WAKEUP is set on the
* configurations of those pins not able to wakeup * configurations of those pins not able to wakeup
...@@ -124,6 +133,20 @@ void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num) ...@@ -124,6 +133,20 @@ void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num)
} }
} }
void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm)
{
unsigned long flags;
int gpio;
gpio = __mfp_validate(mfp);
if (gpio < 0)
return;
local_irq_save(flags);
__mfp_config_lpm(gpio, lpm);
local_irq_restore(flags);
}
int gpio_set_wake(unsigned int gpio, unsigned int on) int gpio_set_wake(unsigned int gpio, unsigned int on)
{ {
struct gpio_desc *d; struct gpio_desc *d;
......
...@@ -128,5 +128,6 @@ ...@@ -128,5 +128,6 @@
#define GPIO84_GPIO MFP_CFG_IN(GPIO84, AF0) #define GPIO84_GPIO MFP_CFG_IN(GPIO84, AF0)
extern void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num); extern void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num);
extern void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm);
extern int gpio_set_wake(unsigned int gpio, unsigned int on); extern int gpio_set_wake(unsigned int gpio, unsigned int on);
#endif /* __ASM_ARCH_MFP_PXA2XX_H */ #endif /* __ASM_ARCH_MFP_PXA2XX_H */
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