Lines Matching +full:valid +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/mfp-pxa2xx.c
13 #include <linux/gpio-pxa.h>
21 #include "pxa2xx-regs.h"
22 #include "mfp-pxa2xx.h"
31 #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
40 unsigned valid : 1; member
44 unsigned int mask; /* bit mask in PWER or PKWR */ member
45 unsigned int mux_mask; /* bit mask of muxed gpio bits, 0 if no mux */
55 unsigned long gafr, mask = GPIO_bit(gpio); in __mfp_config_gpio() local
63 return -EINVAL; in __mfp_config_gpio()
65 /* alternate function and direction at run-time */ in __mfp_config_gpio()
75 GPDR(gpio) |= mask; in __mfp_config_gpio()
77 GPDR(gpio) &= ~mask; in __mfp_config_gpio()
82 PGSR(bank) |= mask; in __mfp_config_gpio()
86 PGSR(bank) &= ~mask; in __mfp_config_gpio()
100 gpdr_lpm[bank] |= mask; in __mfp_config_gpio()
102 gpdr_lpm[bank] &= ~mask; in __mfp_config_gpio()
109 return -EINVAL; in __mfp_config_gpio()
114 return -EINVAL; in __mfp_config_gpio()
124 if ((mfp > MFP_PIN_GPIO127) || !gpio_desc[gpio].valid) { in __mfp_validate()
126 return -1; in __mfp_validate()
177 return -EINVAL; in gpio_set_wake()
180 c = d->config; in gpio_set_wake()
182 if (!d->valid) in gpio_set_wake()
183 return -EINVAL; in gpio_set_wake()
188 if (d->keypad_gpio && (MFP_AF(d->config) == 0) && in gpio_set_wake()
189 (d->config & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
191 PKWR |= d->mask; in gpio_set_wake()
193 PKWR &= ~d->mask; in gpio_set_wake()
197 mux_taken = (PWER & d->mux_mask) & (~d->mask); in gpio_set_wake()
199 return -EBUSY; in gpio_set_wake()
201 if (d->can_wakeup && (c & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
203 PWER = (PWER & ~d->mux_mask) | d->mask; in gpio_set_wake()
206 PRER |= d->mask; in gpio_set_wake()
208 PRER &= ~d->mask; in gpio_set_wake()
211 PFER |= d->mask; in gpio_set_wake()
213 PFER &= ~d->mask; in gpio_set_wake()
215 PWER &= ~d->mask; in gpio_set_wake()
216 PRER &= ~d->mask; in gpio_set_wake()
217 PFER &= ~d->mask; in gpio_set_wake()
235 gpio_desc[i].valid = 1; in pxa25x_mfp_init()
239 gpio_desc[i].mask = GPIO_bit(i); in pxa25x_mfp_init()
260 unsigned int i, gpio, mask = 0; in keypad_set_wake() local
269 if (MFP_AF(d->config) == 0) in keypad_set_wake()
272 if (d->config & MFP_LPM_CAN_WAKEUP) in keypad_set_wake()
273 mask |= gpio_desc[gpio].mask; in keypad_set_wake()
277 PKWR |= mask; in keypad_set_wake()
279 PKWR &= ~mask; in keypad_set_wake()
295 gpio_desc[(gpio)].mask = PWER_ ## mux ## _GPIO ##gpio; \
306 * valid pins allow configuration in pxa27x_mfp_init()
311 gpio_desc[i].valid = 1; in pxa27x_mfp_init()
319 gpio_desc[gpio].mask = 1 << i; in pxa27x_mfp_init()
329 gpio_desc[i].mask = GPIO_bit(i); in pxa27x_mfp_init()
333 gpio_desc[35].mask = PWER_WE35; in pxa27x_mfp_init()