Lines Matching +full:pxa3xx +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/mfp-pxa2xx.c
9 * on PXA3xx, what's more important, the low power pin state and
12 #include <linux/gpio.h>
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))
46 unsigned int mux_mask; /* bit mask of muxed gpio bits, 0 if no mux */
54 static int __mfp_config_gpio(unsigned gpio, unsigned long c) in __mfp_config_gpio() argument
56 unsigned long gafr, mask = GPIO_bit(gpio); in __mfp_config_gpio()
57 int bank = gpio_to_bank(gpio); in __mfp_config_gpio()
58 int uorl = !!(gpio & 0x10); /* GAFRx_U or GAFRx_L ? */ in __mfp_config_gpio()
59 int shft = (gpio & 0xf) << 1; in __mfp_config_gpio()
64 return -EINVAL; in __mfp_config_gpio()
66 /* alternate function and direction at run-time */ in __mfp_config_gpio()
75 if (is_out ^ gpio_desc[gpio].dir_inverted) in __mfp_config_gpio()
76 GPDR(gpio) |= mask; in __mfp_config_gpio()
78 GPDR(gpio) &= ~mask; in __mfp_config_gpio()
95 pr_warn("%s: GPIO%d: unsupported low power mode\n", in __mfp_config_gpio()
96 __func__, gpio); in __mfp_config_gpio()
100 if (is_out ^ gpio_desc[gpio].dir_inverted) in __mfp_config_gpio()
108 if ((c & MFP_LPM_CAN_WAKEUP) && !gpio_desc[gpio].can_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()
123 int gpio = mfp_to_gpio(mfp); in __mfp_validate() local
125 if ((mfp > MFP_PIN_GPIO127) || !gpio_desc[gpio].valid) { in __mfp_validate()
126 pr_warn("%s: GPIO%d is invalid pin\n", __func__, gpio); in __mfp_validate()
127 return -1; in __mfp_validate()
130 return gpio; in __mfp_validate()
137 int i, gpio; in pxa2xx_mfp_config() local
141 gpio = __mfp_validate(MFP_PIN(*c)); in pxa2xx_mfp_config()
142 if (gpio < 0) in pxa2xx_mfp_config()
147 gpio_desc[gpio].config = *c; in pxa2xx_mfp_config()
148 __mfp_config_gpio(gpio, *c); in pxa2xx_mfp_config()
157 int gpio; in pxa2xx_mfp_set_lpm() local
159 gpio = __mfp_validate(mfp); in pxa2xx_mfp_set_lpm()
160 if (gpio < 0) in pxa2xx_mfp_set_lpm()
165 c = gpio_desc[gpio].config; in pxa2xx_mfp_set_lpm()
167 __mfp_config_gpio(gpio, c); in pxa2xx_mfp_set_lpm()
172 int gpio_set_wake(unsigned int gpio, unsigned int on) in gpio_set_wake() argument
177 if (gpio > mfp_to_gpio(MFP_PIN_GPIO127)) in gpio_set_wake()
178 return -EINVAL; in gpio_set_wake()
180 d = &gpio_desc[gpio]; 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()
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()
257 unsigned int i, gpio, mask = 0; in keypad_set_wake() local
262 gpio = pxa27x_pkwr_gpio[i]; in keypad_set_wake()
263 d = &gpio_desc[gpio]; in keypad_set_wake()
265 /* skip if configured as generic GPIO */ in keypad_set_wake()
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()
289 #define INIT_GPIO_DESC_MUXED(mux, gpio) \ argument
291 gpio_desc[(gpio)].can_wakeup = 1; \
292 gpio_desc[(gpio)].mask = PWER_ ## mux ## _GPIO ##gpio; \
293 gpio_desc[(gpio)].mux_mask = PWER_ ## mux ## _MASK; \
298 int i, gpio; in pxa27x_mfp_init() local
313 gpio = pxa27x_pkwr_gpio[i]; in pxa27x_mfp_init()
314 gpio_desc[gpio].can_wakeup = 1; in pxa27x_mfp_init()
315 gpio_desc[gpio].keypad_gpio = 1; in pxa27x_mfp_init()
316 gpio_desc[gpio].mask = 1 << i; in pxa27x_mfp_init()
425 /* clear RDH bit to enable GPIO receivers after reset/sleep exit */ in pxa2xx_mfp_init()