Skip to content

Commit 2256755

Browse files
[nrf fromlist] drivers: nordic: support pin retention for AIN
Devices which use AIN (COMP, LPCOMP, SAADC) don't use pinctrl to configure their pins, thus pinctrl can't manage pin retention like is done for other devices. Thus for now, add manually disabling pin retention to the drivers. In the future, we should probably use pinctrl for these inputs as well, at which point this commit can be reverted. Upstream PR #: 97452 Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent aa01278 commit 2256755

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

drivers/adc/adc_nrfx_saadc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <zephyr/pm/device_runtime.h>
1717
#include <dmm.h>
1818
#include <soc.h>
19+
#include <hal/nrf_gpio.h>
1920

2021
LOG_MODULE_REGISTER(adc_nrfx_saadc, CONFIG_ADC_LOG_LEVEL);
2122

@@ -200,6 +201,10 @@ static int input_assign(nrf_saadc_input_t *pin_p,
200201

201202
*pin_p = saadc_psels[channel_cfg->input_positive];
202203

204+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
205+
nrf_gpio_pin_retain_disable(saadc_psels[channel_cfg->input_positive]);
206+
#endif
207+
203208
if (channel_cfg->differential) {
204209
if (channel_cfg->input_negative > ARRAY_SIZE(saadc_psels) ||
205210
(IS_ENABLED(CONFIG_NRF_PLATFORM_HALTIUM) &&
@@ -212,6 +217,11 @@ static int input_assign(nrf_saadc_input_t *pin_p,
212217
*pin_n = channel_cfg->input_negative == NRF_SAADC_GND ?
213218
NRF_SAADC_INPUT_DISABLED :
214219
saadc_psels[channel_cfg->input_negative];
220+
221+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
222+
nrf_gpio_pin_retain_disable(saadc_psels[channel_cfg->input_negative]);
223+
#endif
224+
215225
} else {
216226
*pin_n = NRF_SAADC_INPUT_DISABLED;
217227
}

drivers/comparator/comparator_nrf_comp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <nrfx_comp.h>
8+
#include <hal/nrf_gpio.h>
89

910
#include <zephyr/drivers/comparator/nrf_comp.h>
1011
#include <zephyr/kernel.h>
@@ -249,6 +250,11 @@ static int shim_nrf_comp_psel_to_nrf(uint8_t shim,
249250
}
250251

251252
*nrf = shim_nrf_comp_ain_map[shim];
253+
254+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
255+
nrf_gpio_pin_retain_disable(shim_nrf_comp_ain_map[shim]);
256+
#endif
257+
252258
return 0;
253259
}
254260
#else

drivers/comparator/comparator_nrf_lpcomp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <nrfx_lpcomp.h>
8+
#include <hal/nrf_gpio.h>
89

910
#include <zephyr/drivers/comparator/nrf_lpcomp.h>
1011
#include <zephyr/kernel.h>
@@ -142,6 +143,11 @@ static int shim_nrf_lpcomp_psel_to_nrf(uint8_t shim,
142143
}
143144

144145
*nrf = shim_nrf_comp_ain_map[shim];
146+
147+
#if NRF_GPIO_HAS_RETENTION_SETCLEAR
148+
nrf_gpio_pin_retain_disable(shim_nrf_comp_ain_map[shim]);
149+
#endif
150+
145151
return 0;
146152
}
147153
#else

0 commit comments

Comments
 (0)