17 #include <linux/module.h>
18 #include <linux/kernel.h>
28 #define PGSR(x) __REG2(0x40F00020, (x) << 2)
29 #define __GAFR(u, x) __REG2((u) ? 0x40E00058 : 0x40E00054, (x) << 3)
30 #define GAFR_L(x) __GAFR(0, x)
31 #define GAFR_U(x) __GAFR(1, x)
33 #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
34 #define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5))
35 #define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c)
36 #define GPSR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x18)
37 #define GPCR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x24)
39 #define PWER_WE35 (1 << 24)
53 static unsigned long gpdr_lpm[4];
55 static int __mfp_config_gpio(
unsigned gpio,
unsigned long c)
59 int uorl = !!(gpio & 0x10);
60 int shft = (gpio & 0xf) << 1;
69 gafr = (gafr & ~(0x3 << shft)) | (fn << shft);
96 pr_warning(
"%s: GPIO%d: unsupported low power mode\n",
101 if (is_out ^
gpio_desc[gpio].dir_inverted)
102 gpdr_lpm[bank] |=
mask;
104 gpdr_lpm[bank] &= ~mask;
115 if ((c & MFP_LPM_CAN_WAKEUP) && is_out) {
116 pr_warning(
"%s: output GPIO%d unable to wakeup\n",
124 static inline int __mfp_validate(
int mfp)
129 pr_warning(
"%s: GPIO%d is invalid pin\n", __func__, gpio);
142 for (i = 0, c = mfp_cfgs; i < num; i++, c++) {
144 gpio = __mfp_validate(
MFP_PIN(*c));
151 __mfp_config_gpio(gpio, *c);
162 gpio = __mfp_validate(mfp);
169 c = (c & ~MFP_LPM_STATE_MASK) | lpm;
170 __mfp_config_gpio(gpio, c);
178 unsigned long c, mux_taken;
193 (d->
config & MFP_LPM_CAN_WAKEUP)) {
205 if (d->
can_wakeup && (c & MFP_LPM_CAN_WAKEUP)) {
228 static void __init pxa25x_mfp_init(
void)
233 #ifdef CONFIG_CPU_PXA26x
241 for (i = 0; i <= 15; i++) {
253 static inline void pxa25x_mfp_init(
void) {}
257 static int pxa27x_pkwr_gpio[] = {
258 13, 16, 17, 34, 36, 37, 38, 39, 90, 91, 93, 94,
259 95, 96, 97, 98, 99, 100, 101, 102
264 unsigned int i,
gpio, mask = 0;
267 for (i = 0; i <
ARRAY_SIZE(pxa27x_pkwr_gpio); i++) {
269 gpio = pxa27x_pkwr_gpio[
i];
276 if (d->
config & MFP_LPM_CAN_WAKEUP)
287 #define PWER_WEMUX2_GPIO38 (1 << 16)
288 #define PWER_WEMUX2_GPIO53 (2 << 16)
289 #define PWER_WEMUX2_GPIO40 (3 << 16)
290 #define PWER_WEMUX2_GPIO36 (4 << 16)
291 #define PWER_WEMUX2_MASK (7 << 16)
292 #define PWER_WEMUX3_GPIO31 (1 << 19)
293 #define PWER_WEMUX3_GPIO113 (2 << 19)
294 #define PWER_WEMUX3_MASK (3 << 19)
296 #define INIT_GPIO_DESC_MUXED(mux, gpio) \
298 gpio_desc[(gpio)].can_wakeup = 1; \
299 gpio_desc[(gpio)].mask = PWER_ ## mux ## _GPIO ##gpio; \
300 gpio_desc[(gpio)].mux_mask = PWER_ ## mux ## _MASK; \
303 static void __init pxa27x_mfp_init(
void)
312 if (i == 2 || i == 5 || i == 6 || i == 7 || i == 8)
319 for (i = 0; i <
ARRAY_SIZE(pxa27x_pkwr_gpio); i++) {
320 gpio = pxa27x_pkwr_gpio[
i];
327 for (i = 0; i <= 15; i++) {
339 INIT_GPIO_DESC_MUXED(WEMUX3, 31);
340 INIT_GPIO_DESC_MUXED(WEMUX3, 113);
341 INIT_GPIO_DESC_MUXED(WEMUX2, 38);
342 INIT_GPIO_DESC_MUXED(WEMUX2, 53);
343 INIT_GPIO_DESC_MUXED(WEMUX2, 40);
344 INIT_GPIO_DESC_MUXED(WEMUX2, 36);
347 static inline void pxa27x_mfp_init(
void) {}
351 static unsigned long saved_gafr[2][4];
352 static unsigned long saved_gpdr[4];
353 static unsigned long saved_gplr[4];
354 static unsigned long saved_pgsr[4];
374 saved_gpdr[
i] =
GPDR(i * 32);
375 saved_gplr[
i] =
GPLR(i * 32);
376 saved_pgsr[
i] =
PGSR(i);
402 GPSR(i * 32) = saved_gplr[
i];
403 GPCR(i * 32) = ~saved_gplr[
i];
404 GPDR(i * 32) = saved_gpdr[
i];
405 PGSR(i) = saved_pgsr[
i];
410 #define pxa2xx_mfp_suspend NULL
411 #define pxa2xx_mfp_resume NULL
419 static int __init pxa2xx_mfp_init(
void)
437 gpdr_lpm[i] =
GPDR(i * 32);