Lines Matching +full:wake +full:- +full:up
4 * SPDX-License-Identifier: Apache-2.0
19 #include <zephyr/dt-bindings/power/stm32_pwr.h>
42 * @brief flags for wake-up pin polarity configuration
46 /* detection of wake-up event on the high level : rising edge */
48 /* detection of wake-up event on the low level : falling edge */
54 * @brief flags for configuration of pull-ups & pull-downs of GPIO ports
55 * that are associated with wake-up pins
66 * @brief Structure for storing the devicetree configuration of a wake-up pin.
71 /* GPIO pin(s) associated with wake-up pin */
88 * @brief Get wake-up pin configuration from a given devicetree node.
117 * @brief Structure for passing the runtime configuration of a given wake-up pin.
125 uint32_t pupd_cfg; /* pull-up/down config of GPIO port associated w/ this wkup pin */
126 uint32_t ll_gpio_port; /* GPIO port associated with this wake-up pin */
127 uint32_t ll_gpio_pin; /* GPIO pin associated with this wake-up pin */
129 uint32_t src_selection; /* The source signal to use with this wake-up pin */
133 * @brief LookUp Table to store LL_PWR_WAKEUP_PINx for each wake-up pin.
189 * @brief Configure & enable a wake-up pin.
191 * @param wakeup_pin_cfg wake-up pin runtime configuration.
196 uint32_t wkup_pin_index = wakeup_pin_cfg->wkup_pin_id; in wkup_pin_setup()
199 /* Set wake-up pin polarity */ in wkup_pin_setup()
200 if (wakeup_pin_cfg->polarity == STM32_PWR_WKUP_PIN_P_FALLING) { in wkup_pin_setup()
208 if (wakeup_pin_cfg->pupd_cfg == STM32_PWR_WKUP_PIN_NOPULL) { in wkup_pin_setup()
209 LL_PWR_DisableGPIOPullUp(wakeup_pin_cfg->ll_gpio_port, in wkup_pin_setup()
210 (1u << wakeup_pin_cfg->ll_gpio_pin)); in wkup_pin_setup()
211 LL_PWR_DisableGPIOPullDown(wakeup_pin_cfg->ll_gpio_port, in wkup_pin_setup()
212 (1u << wakeup_pin_cfg->ll_gpio_pin)); in wkup_pin_setup()
214 } else if ((wakeup_pin_cfg->pupd_cfg == STM32_PWR_WKUP_PIN_PULLUP) && in wkup_pin_setup()
215 wakeup_pin_cfg->ll_gpio_port) { in wkup_pin_setup()
216 LL_PWR_EnableGPIOPullUp(wakeup_pin_cfg->ll_gpio_port, in wkup_pin_setup()
217 (1u << wakeup_pin_cfg->ll_gpio_pin)); in wkup_pin_setup()
219 } else if ((wakeup_pin_cfg->pupd_cfg == STM32_PWR_WKUP_PIN_PULLDOWN) && in wkup_pin_setup()
220 wakeup_pin_cfg->ll_gpio_port) { in wkup_pin_setup()
221 LL_PWR_EnableGPIOPullDown(wakeup_pin_cfg->ll_gpio_port, in wkup_pin_setup()
222 (1u << wakeup_pin_cfg->ll_gpio_pin)); in wkup_pin_setup()
227 /* Select the proper wake-up signal source */ in wkup_pin_setup()
228 if (wakeup_pin_cfg->src_selection & STM32_PWR_WKUP_PIN_SRC_0) { in wkup_pin_setup()
230 } else if (wakeup_pin_cfg->src_selection & STM32_PWR_WKUP_PIN_SRC_1) { in wkup_pin_setup()
232 } else if (wakeup_pin_cfg->src_selection & STM32_PWR_WKUP_PIN_SRC_2) { in wkup_pin_setup()
243 * @brief Exported function to configure a given GPIO pin as a source for wake-up pins
247 * @return 0 on success, -EINVAL if said GPIO pin is not associated with any wake-up pin.
260 /* Look for a wake-up pin that has this GPIO pin as a source, if any */ in stm32_pwr_wkup_pin_cfg_gpio()
264 wkup_pin_gpio_cfg = &(wkup_pin_dt_cfg->gpios_cfgs[j]); in stm32_pwr_wkup_pin_cfg_gpio()
265 if (wkup_pin_gpio_cfg->port == gpio->port) { in stm32_pwr_wkup_pin_cfg_gpio()
266 if (wkup_pin_gpio_cfg->pin == gpio->pin) { in stm32_pwr_wkup_pin_cfg_gpio()
278 LOG_DBG("Couldn't find a wake-up event correspending to GPIO %s pin %d\n", in stm32_pwr_wkup_pin_cfg_gpio()
279 gpio->port->name, gpio->pin); in stm32_pwr_wkup_pin_cfg_gpio()
280 LOG_DBG("=> It cannot be used as a wake-up source\n"); in stm32_pwr_wkup_pin_cfg_gpio()
281 return -EINVAL; in stm32_pwr_wkup_pin_cfg_gpio()
284 wakeup_pin_cfg.wkup_pin_id = wkup_pin_dt_cfg->wkup_pin_id; in stm32_pwr_wkup_pin_cfg_gpio()
286 /* Each wake-up pin on STM32U5 is associated with 4 wkup srcs, 3 of them correspond to GPIOs. */ in stm32_pwr_wkup_pin_cfg_gpio()
288 wakeup_pin_cfg.src_selection = wkup_pin_gpio_cfg->dt_flags & in stm32_pwr_wkup_pin_cfg_gpio()
300 if (gpio->dt_flags & GPIO_ACTIVE_LOW) { in stm32_pwr_wkup_pin_cfg_gpio()
310 if ((gpio_ports[i] == gpio->port) && (i < pwr_ll_gpio_ports_cnt)) { in stm32_pwr_wkup_pin_cfg_gpio()
316 wakeup_pin_cfg.ll_gpio_pin = gpio->pin; in stm32_pwr_wkup_pin_cfg_gpio()
319 * Get pull-up/down config, if any, from GPIO flags specified in device "gpios" property in stm32_pwr_wkup_pin_cfg_gpio()
321 if (gpio->dt_flags & GPIO_PULL_UP) { in stm32_pwr_wkup_pin_cfg_gpio()
323 } else if (gpio->dt_flags & GPIO_PULL_DOWN) { in stm32_pwr_wkup_pin_cfg_gpio()
336 * @brief Exported function to activate pull-ups/pull-downs configuration of GPIO ports
337 * associated with wake-up pins.