• Home
  • Raw
  • Download

Lines Matching +full:gpio +full:- +full:config

1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/mfp-pxa2xx.c
12 #include <linux/gpio.h>
13 #include <linux/gpio-pxa.h>
20 #include <mach/pxa2xx-regs.h>
21 #include "mfp-pxa2xx.h"
30 #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
44 unsigned int mux_mask; /* bit mask of muxed gpio bits, 0 if no mux */
45 unsigned long config; member
52 static int __mfp_config_gpio(unsigned gpio, unsigned long c) in __mfp_config_gpio() argument
54 unsigned long gafr, mask = GPIO_bit(gpio); in __mfp_config_gpio()
55 int bank = gpio_to_bank(gpio); in __mfp_config_gpio()
56 int uorl = !!(gpio & 0x10); /* GAFRx_U or GAFRx_L ? */ in __mfp_config_gpio()
57 int shft = (gpio & 0xf) << 1; in __mfp_config_gpio()
62 return -EINVAL; in __mfp_config_gpio()
64 /* alternate function and direction at run-time */ in __mfp_config_gpio()
73 if (is_out ^ gpio_desc[gpio].dir_inverted) in __mfp_config_gpio()
74 GPDR(gpio) |= mask; in __mfp_config_gpio()
76 GPDR(gpio) &= ~mask; in __mfp_config_gpio()
93 pr_warn("%s: GPIO%d: unsupported low power mode\n", in __mfp_config_gpio()
94 __func__, gpio); in __mfp_config_gpio()
98 if (is_out ^ gpio_desc[gpio].dir_inverted) in __mfp_config_gpio()
106 if ((c & MFP_LPM_CAN_WAKEUP) && !gpio_desc[gpio].can_wakeup) { in __mfp_config_gpio()
107 pr_warn("%s: GPIO%d unable to wakeup\n", __func__, gpio); in __mfp_config_gpio()
108 return -EINVAL; in __mfp_config_gpio()
112 pr_warn("%s: output GPIO%d unable to wakeup\n", __func__, gpio); in __mfp_config_gpio()
113 return -EINVAL; in __mfp_config_gpio()
121 int gpio = mfp_to_gpio(mfp); in __mfp_validate() local
123 if ((mfp > MFP_PIN_GPIO127) || !gpio_desc[gpio].valid) { in __mfp_validate()
124 pr_warn("%s: GPIO%d is invalid pin\n", __func__, gpio); in __mfp_validate()
125 return -1; in __mfp_validate()
128 return gpio; in __mfp_validate()
135 int i, gpio; in pxa2xx_mfp_config() local
139 gpio = __mfp_validate(MFP_PIN(*c)); in pxa2xx_mfp_config()
140 if (gpio < 0) in pxa2xx_mfp_config()
145 gpio_desc[gpio].config = *c; in pxa2xx_mfp_config()
146 __mfp_config_gpio(gpio, *c); in pxa2xx_mfp_config()
155 int gpio; in pxa2xx_mfp_set_lpm() local
157 gpio = __mfp_validate(mfp); in pxa2xx_mfp_set_lpm()
158 if (gpio < 0) in pxa2xx_mfp_set_lpm()
163 c = gpio_desc[gpio].config; in pxa2xx_mfp_set_lpm()
165 __mfp_config_gpio(gpio, c); in pxa2xx_mfp_set_lpm()
170 int gpio_set_wake(unsigned int gpio, unsigned int on) in gpio_set_wake() argument
175 if (gpio > mfp_to_gpio(MFP_PIN_GPIO127)) in gpio_set_wake()
176 return -EINVAL; in gpio_set_wake()
178 d = &gpio_desc[gpio]; in gpio_set_wake()
179 c = d->config; in gpio_set_wake()
181 if (!d->valid) in gpio_set_wake()
182 return -EINVAL; in gpio_set_wake()
187 if (d->keypad_gpio && (MFP_AF(d->config) == 0) && in gpio_set_wake()
188 (d->config & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
190 PKWR |= d->mask; in gpio_set_wake()
192 PKWR &= ~d->mask; in gpio_set_wake()
196 mux_taken = (PWER & d->mux_mask) & (~d->mask); in gpio_set_wake()
198 return -EBUSY; in gpio_set_wake()
200 if (d->can_wakeup && (c & MFP_LPM_CAN_WAKEUP)) { in gpio_set_wake()
202 PWER = (PWER & ~d->mux_mask) | d->mask; in gpio_set_wake()
205 PRER |= d->mask; in gpio_set_wake()
207 PRER &= ~d->mask; in gpio_set_wake()
210 PFER |= d->mask; in gpio_set_wake()
212 PFER &= ~d->mask; in gpio_set_wake()
214 PWER &= ~d->mask; in gpio_set_wake()
215 PRER &= ~d->mask; in gpio_set_wake()
216 PFER &= ~d->mask; in gpio_set_wake()
259 unsigned int i, gpio, mask = 0; in keypad_set_wake() local
264 gpio = pxa27x_pkwr_gpio[i]; in keypad_set_wake()
265 d = &gpio_desc[gpio]; in keypad_set_wake()
267 /* skip if configured as generic GPIO */ in keypad_set_wake()
268 if (MFP_AF(d->config) == 0) in keypad_set_wake()
271 if (d->config & MFP_LPM_CAN_WAKEUP) in keypad_set_wake()
272 mask |= gpio_desc[gpio].mask; in keypad_set_wake()
291 #define INIT_GPIO_DESC_MUXED(mux, gpio) \ argument
293 gpio_desc[(gpio)].can_wakeup = 1; \
294 gpio_desc[(gpio)].mask = PWER_ ## mux ## _GPIO ##gpio; \
295 gpio_desc[(gpio)].mux_mask = PWER_ ## mux ## _MASK; \
300 int i, gpio; in pxa27x_mfp_init() local
315 gpio = pxa27x_pkwr_gpio[i]; in pxa27x_mfp_init()
316 gpio_desc[gpio].can_wakeup = 1; in pxa27x_mfp_init()
317 gpio_desc[gpio].keypad_gpio = 1; in pxa27x_mfp_init()
318 gpio_desc[gpio].mask = 1 << i; in pxa27x_mfp_init()
357 if ((gpio_desc[i].config & MFP_LPM_KEEP_OUTPUT) && in pxa2xx_mfp_suspend()
380 ((gpio_desc[i].config & MFP_LPM_KEEP_OUTPUT) && in pxa2xx_mfp_suspend()
427 /* clear RDH bit to enable GPIO receivers after reset/sleep exit */ in pxa2xx_mfp_init()