Commit ef7c7c69 authored by Igor Grinberg's avatar Igor Grinberg Committed by Haojian Zhuang

ARM: PXA2xx: MFP: fix potential direction bug

Pins configured as input and have MFP_LPM_DRIVE_* flag set, can have a
wrong output value for some period of time (spike) during the suspend
sequence.
This can happen because the direction of the pins (GPDR) is set by
software and the output level is set by hardware (PGSR) at a later
stage.

Fix the above potential bug by setting the output levels first.
Also save the actual levels of the pins before the suspend and restore
them after the resume, but before the direction settings take place, so
the same bug as described above will not happen in the resume sequence.
Reported-by: default avatarPaul Parsons <lost.distance@yahoo.com>
Signed-off-by: default avatarIgor Grinberg <grinberg@compulab.co.il>
Tested-by: default avatarPaul Parsons <lost.distance@yahoo.com>
Signed-off-by: default avatarHaojian Zhuang <haojian.zhuang@gmail.com>
parent a13b8787
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
#define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5)) #define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5))
#define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c) #define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c)
#define GPSR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x18)
#define GPCR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x24)
#define PWER_WE35 (1 << 24) #define PWER_WE35 (1 << 24)
...@@ -348,6 +350,7 @@ static inline void pxa27x_mfp_init(void) {} ...@@ -348,6 +350,7 @@ static inline void pxa27x_mfp_init(void) {}
#ifdef CONFIG_PM #ifdef CONFIG_PM
static unsigned long saved_gafr[2][4]; static unsigned long saved_gafr[2][4];
static unsigned long saved_gpdr[4]; static unsigned long saved_gpdr[4];
static unsigned long saved_gplr[4];
static unsigned long saved_pgsr[4]; static unsigned long saved_pgsr[4];
static int pxa2xx_mfp_suspend(void) static int pxa2xx_mfp_suspend(void)
...@@ -369,7 +372,11 @@ static int pxa2xx_mfp_suspend(void) ...@@ -369,7 +372,11 @@ static int pxa2xx_mfp_suspend(void)
saved_gafr[0][i] = GAFR_L(i); saved_gafr[0][i] = GAFR_L(i);
saved_gafr[1][i] = GAFR_U(i); saved_gafr[1][i] = GAFR_U(i);
saved_gpdr[i] = GPDR(i * 32); saved_gpdr[i] = GPDR(i * 32);
saved_gplr[i] = GPLR(i * 32);
saved_pgsr[i] = PGSR(i); saved_pgsr[i] = PGSR(i);
GPSR(i * 32) = PGSR(i);
GPCR(i * 32) = ~PGSR(i);
} }
/* set GPDR bits taking into account MFP_LPM_KEEP_OUTPUT */ /* set GPDR bits taking into account MFP_LPM_KEEP_OUTPUT */
...@@ -392,6 +399,8 @@ static void pxa2xx_mfp_resume(void) ...@@ -392,6 +399,8 @@ static void pxa2xx_mfp_resume(void)
for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) {
GAFR_L(i) = saved_gafr[0][i]; GAFR_L(i) = saved_gafr[0][i];
GAFR_U(i) = saved_gafr[1][i]; GAFR_U(i) = saved_gafr[1][i];
GPSR(i * 32) = saved_gplr[i];
GPCR(i * 32) = ~saved_gplr[i];
GPDR(i * 32) = saved_gpdr[i]; GPDR(i * 32) = saved_gpdr[i];
PGSR(i) = saved_pgsr[i]; PGSR(i) = saved_pgsr[i];
} }
......
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