File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 12
12
#include <zephyr/spinlock.h>
13
13
#include <zephyr/sys/util.h>
14
14
15
+ #include <hal/nrf_gpio.h>
15
16
#include <nrf/gpd.h>
16
17
#include <nrfs_gdpwr.h>
17
18
#include <nrfs_backend_ipc_service.h>
@@ -207,6 +208,34 @@ int nrf_gpd_release(uint8_t id)
207
208
return onoff_release (& gpd_mgr -> mgr );
208
209
}
209
210
211
+ int nrf_gpd_retain_pins_set (const struct pinctrl_dev_config * pcfg , bool retain )
212
+ {
213
+ const struct pinctrl_state * state ;
214
+ int ret ;
215
+
216
+ ret = pinctrl_lookup_state (pcfg , PINCTRL_STATE_DEFAULT , & state );
217
+ if (ret < 0 ) {
218
+ return ret ;
219
+ }
220
+
221
+ for (uint8_t i = 0U ; i < state -> pin_cnt ; i ++ ) {
222
+ uint32_t pin = NRF_GET_PIN (state -> pins [i ]);
223
+ NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode (& pin );
224
+
225
+ if (pin == NRF_PIN_DISCONNECTED ) {
226
+ continue ;
227
+ }
228
+
229
+ if (retain ) {
230
+ reg -> RETAINSET = BIT (pin );
231
+ } else {
232
+ reg -> RETAINCLR = BIT (pin );
233
+ }
234
+ }
235
+
236
+ return 0 ;
237
+ }
238
+
210
239
static int nrf_gpd_pre_init (void )
211
240
{
212
241
int ret ;
Original file line number Diff line number Diff line change 9
9
#include <stdint.h>
10
10
11
11
#include <zephyr/dt-bindings/power/nordic-nrf-gpd.h>
12
+ #include <zephyr/drivers/pinctrl.h>
12
13
13
14
/**
14
15
* @brief Request a global power domain.
@@ -30,4 +31,15 @@ int nrf_gpd_request(uint8_t id);
30
31
*/
31
32
int nrf_gpd_release (uint8_t id );
32
33
34
+ /**
35
+ * @brief Retain set/clear a set of pins.
36
+ *
37
+ * @param pcfg Device pin configuration.
38
+ * @param retain Retain or not.
39
+ *
40
+ * @retval 0 If the request was successful.
41
+ * @retval -errno If the request was not successful.
42
+ */
43
+ int nrf_gpd_retain_pins_set (const struct pinctrl_dev_config * pcfg , bool retain );
44
+
33
45
#endif /* ZEPHYR_SOC_NORDIC_NRF54H_GPD_INCLUDE_NRF_GPD_H_ */
You can’t perform that action at this time.
0 commit comments