drivers: pwm: nrfx: add pin retention

Add pin retenion if GPD is enabled for nRF54H20.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
This commit is contained in:
Michał Stasiak 2024-11-13 10:51:09 +01:00 committed by Benjamin Cabé
parent 085a4fa92e
commit d04b3e0323

View file

@ -13,6 +13,9 @@
#include <zephyr/linker/devicetree_regions.h>
#include <zephyr/cache.h>
#include <zephyr/mem_mgmt/mem_attr.h>
#ifdef CONFIG_SOC_NRF54H20_GPD
#include <nrf/gpd.h>
#endif
#include <zephyr/logging/log.h>
@ -274,6 +277,10 @@ static void pwm_resume(const struct device *dev)
(void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(config->pcfg, false);
#endif
for (size_t i = 0; i < NRF_PWM_CHANNEL_COUNT; i++) {
uint32_t psel;
@ -302,6 +309,10 @@ static void pwm_suspend(const struct device *dev)
while (!nrfx_pwm_stopped_check(&config->pwm)) {
}
#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(config->pcfg, true);
#endif
memset(dev->data, 0, sizeof(struct pwm_nrfx_data));
(void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP);
}