Lines Matching +full:valid +full:- +full:wakeup +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/mfp-pxa2xx.c
10 * wakeup detection are also supported by the same framework.
13 #include <linux/gpio-pxa.h>
21 #include "pxa2xx-regs.h"
22 #include "mfp-pxa2xx.h"
23 #include "mfp-pxa27x.h"
32 #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
41 unsigned valid : 1; member
45 unsigned int mask; /* bit mask in PWER or PKWR */ member
46 unsigned int mux_mask; /* bit mask of muxed gpio bits, 0 if no mux */
56 unsigned long gafr, mask = GPIO_bit(gpio); in __mfp_config_gpio() local
64 return -EINVAL; in __mfp_config_gpio()
66 /* alternate function and direction at run-time */ in __mfp_config_gpio()
76 GPDR(gpio) |= mask; in __mfp_config_gpio()
78 GPDR(gpio) &= ~mask; in __mfp_config_gpio()
83 PGSR(bank) |= mask; in __mfp_config_gpio()
87 PGSR(bank) &= ~mask; in __mfp_config_gpio()
101 gpdr_lpm[bank] |= mask; in __mfp_config_gpio()
103 gpdr_lpm[bank] &= ~mask; in __mfp_config_gpio()
106 * configurations of those pins not able to wakeup in __mfp_config_gpio()
109 pr_warn("%s: GPIO%d unable to wakeup\n", __func__, gpio); in __mfp_config_gpio()
110 return -EINVAL; in __mfp_config_gpio()
114 pr_warn("%s: output GPIO%d unable to wakeup\n", __func__, gpio); in __mfp_config_gpio()
115 return -EINVAL; in __mfp_config_gpio()
125 if ((mfp > MFP_PIN_GPIO127) || !gpio_desc[gpio].valid) { in __mfp_validate()
127 return -1; in __mfp_validate()
178 return -EINVAL; in gpio_set_wake()
181 c = d->config; in gpio_set_wake()
183 if (!d->valid) in gpio_set_wake()
184 return -EINVAL; in gpio_set_wake()
186 /* Allow keypad GPIOs to wakeup system when in gpio_set_wake()
189 if (d->keypad_gpio && (MFP_AF(d->config) == 0) && in gpio_set_wake()
190 (d->config & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
192 PKWR |= d->mask; in gpio_set_wake()
194 PKWR &= ~d->mask; in gpio_set_wake()
198 mux_taken = (PWER & d->mux_mask) & (~d->mask); in gpio_set_wake()
200 return -EBUSY; in gpio_set_wake()
202 if (d->can_wakeup && (c & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
204 PWER = (PWER & ~d->mux_mask) | d->mask; in gpio_set_wake()
207 PRER |= d->mask; in gpio_set_wake()
209 PRER &= ~d->mask; in gpio_set_wake()
212 PFER |= d->mask; in gpio_set_wake()
214 PFER &= ~d->mask; in gpio_set_wake()
216 PWER &= ~d->mask; in gpio_set_wake()
217 PRER &= ~d->mask; in gpio_set_wake()
218 PFER &= ~d->mask; in gpio_set_wake()
232 gpio_desc[i].valid = 1; in pxa25x_mfp_init()
236 gpio_desc[i].mask = GPIO_bit(i); in pxa25x_mfp_init()
257 unsigned int i, gpio, mask = 0; in keypad_set_wake() local
266 if (MFP_AF(d->config) == 0) in keypad_set_wake()
269 if (d->config & MFP_LPM_CAN_WAKEUP) in keypad_set_wake()
270 mask |= gpio_desc[gpio].mask; in keypad_set_wake()
274 PKWR |= mask; in keypad_set_wake()
276 PKWR &= ~mask; in keypad_set_wake()
292 gpio_desc[(gpio)].mask = PWER_ ## mux ## _GPIO ##gpio; \
303 * valid pins allow configuration in pxa27x_mfp_init()
308 gpio_desc[i].valid = 1; in pxa27x_mfp_init()
316 gpio_desc[gpio].mask = 1 << i; in pxa27x_mfp_init()
319 /* Overwrite GPIO13 as a PWER wakeup source */ in pxa27x_mfp_init()
326 gpio_desc[i].mask = GPIO_bit(i); in pxa27x_mfp_init()
330 gpio_desc[35].mask = PWER_WE35; in pxa27x_mfp_init()