@@ -19,6 +19,10 @@ LOG_MODULE_REGISTER(spi_nrfx_spis, CONFIG_SPI_LOG_LEVEL);
19
19
20
20
#include "spi_context.h"
21
21
22
+ #ifdef CONFIG_SOC_NRF54H20_GPD
23
+ #include <nrf/gpd.h>
24
+ #endif
25
+
22
26
struct spi_nrfx_data {
23
27
struct spi_context ctx ;
24
28
const struct device * dev ;
@@ -31,6 +35,9 @@ struct spi_nrfx_config {
31
35
nrfx_spis_config_t config ;
32
36
void (* irq_connect )(void );
33
37
uint16_t max_buf_len ;
38
+ #ifdef CONFIG_SOC_NRF54H20_GPD
39
+ bool gpd_ctrl ;
40
+ #endif
34
41
const struct pinctrl_dev_config * pcfg ;
35
42
struct gpio_dt_spec wake_gpio ;
36
43
};
@@ -299,6 +306,12 @@ static void spi_nrfx_suspend(const struct device *dev)
299
306
nrf_spis_disable (dev_config -> spis .p_reg );
300
307
}
301
308
309
+ #ifdef CONFIG_SOC_NRF54H20_GPD
310
+ if (dev_config -> gpd_ctrl ) {
311
+ nrf_gpd_retain_pins_set (dev_config -> pcfg , true);
312
+ }
313
+ #endif
314
+
302
315
(void )pinctrl_apply_state (dev_config -> pcfg , PINCTRL_STATE_SLEEP );
303
316
}
304
317
@@ -308,6 +321,12 @@ static void spi_nrfx_resume(const struct device *dev)
308
321
309
322
(void )pinctrl_apply_state (dev_config -> pcfg , PINCTRL_STATE_DEFAULT );
310
323
324
+ #ifdef CONFIG_SOC_NRF54H20_GPD
325
+ if (dev_config -> gpd_ctrl ) {
326
+ nrf_gpd_retain_pins_set (dev_config -> pcfg , false);
327
+ }
328
+ #endif
329
+
311
330
if (dev_config -> wake_gpio .port == NULL ) {
312
331
nrf_spis_enable (dev_config -> spis .p_reg );
313
332
}
@@ -338,11 +357,6 @@ static int spi_nrfx_init(const struct device *dev)
338
357
nrfx_err_t result ;
339
358
int err ;
340
359
341
- err = pinctrl_apply_state (dev_config -> pcfg , PINCTRL_STATE_DEFAULT );
342
- if (err < 0 ) {
343
- return err ;
344
- }
345
-
346
360
/* This sets only default values of mode and bit order. The ones to be
347
361
* actually used are set in configure() when a transfer is prepared.
348
362
*/
@@ -435,6 +449,9 @@ static int spi_nrfx_init(const struct device *dev)
435
449
.irq_connect = irq_connect##idx, \
436
450
.pcfg = PINCTRL_DT_DEV_CONFIG_GET(SPIS(idx)), \
437
451
.max_buf_len = BIT_MASK(SPIS_PROP(idx, easydma_maxcnt_bits)), \
452
+ IF_ENABLED(CONFIG_SOC_NRF54H20_GPD, \
453
+ (.gpd_ctrl = NRF_PERIPH_GET_FREQUENCY(SPIS(idx)) > \
454
+ NRFX_MHZ_TO_HZ(16UL),)) \
438
455
.wake_gpio = GPIO_DT_SPEC_GET_OR(SPIS(idx), wake_gpios, {0}), \
439
456
}; \
440
457
BUILD_ASSERT(!DT_NODE_HAS_PROP(SPIS(idx), wake_gpios) || \
0 commit comments