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 1212#include <zephyr/spinlock.h>
1313#include <zephyr/sys/util.h>
1414
15+ #include <hal/nrf_gpio.h>
1516#include <nrf/gpd.h>
1617#include <nrfs_gdpwr.h>
1718#include <nrfs_backend_ipc_service.h>
@@ -207,6 +208,34 @@ int nrf_gpd_release(uint8_t id)
207208 return onoff_release (& gpd_mgr -> mgr );
208209}
209210
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+
210239static int nrf_gpd_pre_init (void )
211240{
212241 int ret ;
Original file line number Diff line number Diff line change 99#include <stdint.h>
1010
1111#include <zephyr/dt-bindings/power/nordic-nrf-gpd.h>
12+ #include <zephyr/drivers/pinctrl.h>
1213
1314/**
1415 * @brief Request a global power domain.
@@ -30,4 +31,15 @@ int nrf_gpd_request(uint8_t id);
3031 */
3132int nrf_gpd_release (uint8_t id );
3233
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+
3345#endif /* ZEPHYR_SOC_NORDIC_NRF54H_GPD_INCLUDE_NRF_GPD_H_ */
You can’t perform that action at this time.
0 commit comments