Skip to content

Commit 9925ec9

Browse files
gmarullmmahadevan108
authored andcommitted
drivers: pinctrl: nrf: add flag to signal the FAST_ACTIVE1 peripherals
This patch introduces a new flag to indicate if a peripheral belongs to FAST_ACTIVE1 domain. This way, pinctrl knows when to request the SLOW_ACTIVE domain (where CTRLSEL multiplexer resides). Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 87a42a8 commit 9925ec9

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <zephyr/drivers/pinctrl.h>
88

99
#include <hal/nrf_gpio.h>
10+
#ifdef CONFIG_SOC_NRF54H20_GPD
11+
#include <nrf/gpd.h>
12+
#endif
1013

1114
BUILD_ASSERT(((NRF_PULL_NONE == NRF_GPIO_PIN_NOPULL) &&
1215
(NRF_PULL_DOWN == NRF_GPIO_PIN_PULLDOWN) &&
@@ -352,6 +355,21 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
352355
if (psel != PSEL_DISCONNECTED) {
353356
uint32_t pin = psel;
354357

358+
#ifdef CONFIG_SOC_NRF54H20_GPD
359+
if (NRF_GET_GPD_FAST_ACTIVE1(pins[i]) == 1U) {
360+
int ret;
361+
uint32_t d_pin = pin;
362+
NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&d_pin);
363+
364+
ret = nrf_gpd_request(NRF_GPD_SLOW_ACTIVE);
365+
if (ret < 0) {
366+
return ret;
367+
}
368+
369+
port->RETAINCLR = BIT(d_pin);
370+
}
371+
#endif /* CONFIG_SOC_NRF54H20_GPD */
372+
355373
if (write != NO_WRITE) {
356374
nrf_gpio_pin_write(pin, write);
357375
}
@@ -367,6 +385,20 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
367385
#if NRF_GPIO_HAS_CLOCKPIN
368386
nrf_gpio_pin_clock_set(pin, NRF_GET_CLOCKPIN_ENABLE(pins[i]));
369387
#endif
388+
#ifdef CONFIG_SOC_NRF54H20_GPD
389+
if (NRF_GET_GPD_FAST_ACTIVE1(pins[i]) == 1U) {
390+
int ret;
391+
uint32_t d_pin = pin;
392+
NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&d_pin);
393+
394+
port->RETAINSET = BIT(d_pin);
395+
396+
ret = nrf_gpd_release(NRF_GPD_SLOW_ACTIVE);
397+
if (ret < 0) {
398+
return ret;
399+
}
400+
}
401+
#endif /* CONFIG_SOC_NRF54H20_GPD */
370402
}
371403
}
372404

include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
* The whole nRF pin configuration information is encoded in a 32-bit bitfield
1111
* organized as follows:
1212
*
13-
* - 31..18: Pin function.
13+
* - 31..24: Pin function.
14+
* - 19-23: Reserved.
15+
* - 18: Associated peripheral belongs to GD FAST ACTIVE1 (nRF54H only)
1416
* - 17: Clockpin enable.
1517
* - 16: Pin inversion mode.
1618
* - 15: Pin low power mode.
@@ -25,9 +27,13 @@
2527
*/
2628

2729
/** Position of the function field. */
28-
#define NRF_FUN_POS 18U
30+
#define NRF_FUN_POS 24U
2931
/** Mask for the function field. */
30-
#define NRF_FUN_MSK 0x3FFFU
32+
#define NRF_FUN_MSK 0xFFU
33+
/** Position of the GPD FAST ACTIVE1 */
34+
#define NRF_GPD_FAST_ACTIVE1_POS 18U
35+
/** Mask for the GPD FAST ACTIVE1 */
36+
#define NRF_GPD_FAST_ACTIVE1_MSK 0x1U
3137
/** Position of the clockpin enable field. */
3238
#define NRF_CLOCKPIN_ENABLE_POS 17U
3339
/** Mask for the clockpin enable field. */

soc/nordic/common/pinctrl_soc.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zephyr/devicetree.h>
1616
#include <zephyr/dt-bindings/pinctrl/nrf-pinctrl.h>
17+
#include <zephyr/dt-bindings/power/nordic-nrf-gpd.h>
1718
#include <zephyr/types.h>
1819

1920
#ifdef __cplusplus
@@ -55,6 +56,16 @@ typedef uint32_t pinctrl_soc_pin_t;
5556
(), NRF_GET_FUN(DT_PROP_BY_IDX(node_id, prop, idx))) \
5657
0)), (0))
5758

59+
/**
60+
* @brief Utility macro to get the GPD_FAST_ACTIVE1 flag
61+
*
62+
* @param p_node_id Parent node identifier.
63+
*/
64+
#define Z_GET_GPD_FAST_ACTIVE1(p_node_id) \
65+
COND_CODE_1(DT_NODE_HAS_PROP(p_node_id, power_domains), \
66+
((DT_PHA(p_node_id, power_domains, id) == \
67+
NRF_GPD_FAST_ACTIVE1) << NRF_GPD_FAST_ACTIVE1_POS), (0))
68+
5869
/**
5970
* @brief Utility macro to initialize each pin.
6071
*
@@ -70,7 +81,8 @@ typedef uint32_t pinctrl_soc_pin_t;
7081
(DT_PROP(node_id, nordic_drive_mode) << NRF_DRIVE_POS) | \
7182
((NRF_LP_ENABLE * DT_PROP(node_id, low_power_enable)) << NRF_LP_POS) |\
7283
(DT_PROP(node_id, nordic_invert) << NRF_INVERT_POS) | \
73-
Z_GET_CLOCKPIN_ENABLE(node_id, prop, idx, p_node_id) \
84+
Z_GET_CLOCKPIN_ENABLE(node_id, prop, idx, p_node_id) | \
85+
Z_GET_GPD_FAST_ACTIVE1(p_node_id) \
7486
),
7587

7688
/**
@@ -99,6 +111,14 @@ typedef uint32_t pinctrl_soc_pin_t;
99111
#define NRF_GET_CLOCKPIN_ENABLE(pincfg) \
100112
(((pincfg) >> NRF_CLOCKPIN_ENABLE_POS) & NRF_CLOCKPIN_ENABLE_MSK)
101113

114+
/**
115+
* @brief Utility macro to obtain GPD_FAST_ACTIVE1 flag
116+
*
117+
* @param pincfg Pin configuration bit field.
118+
*/
119+
#define NRF_GET_GPD_FAST_ACTIVE1(pincfg) \
120+
(((pincfg) >> NRF_GPD_FAST_ACTIVE1_POS) & NRF_GPD_FAST_ACTIVE1_MSK)
121+
102122
/**
103123
* @brief Utility macro to obtain pin inversion flag.
104124
*

0 commit comments

Comments
 (0)