Skip to content

Commit 86dca04

Browse files
adamkondraciukkartben
authored andcommitted
drivers: pinctrl: nrf: Add support for clock outputs
Add support for GRTC clock output pins. Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent 50c21f1 commit 86dca04

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = {
9999
#define NRF_PSEL_TWIS(reg, line) ((NRF_TWIS_Type *)reg)->PSEL.line
100100
#endif
101101

102+
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_grtc) || defined(CONFIG_NRFX_GRTC)
103+
#if DT_NODE_HAS_PROP(DT_NODELABEL(grtc), clkout_fast_frequency_hz)
104+
#define NRF_GRTC_CLKOUT_FAST 1
105+
#endif
106+
#if DT_NODE_HAS_PROP(DT_NODELABEL(grtc), clkout_32k)
107+
#define NRF_GRTC_CLKOUT_SLOW 1
108+
#endif
109+
#endif
110+
102111
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
103112
uintptr_t reg)
104113
{
@@ -345,6 +354,24 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
345354
input = NRF_GPIO_PIN_INPUT_DISCONNECT;
346355
break;
347356
#endif /* defined(NRF_PSEL_QSPI) */
357+
#if defined(NRF_GRTC_CLKOUT_FAST)
358+
case NRF_FUN_GRTC_CLKOUT_FAST:
359+
#if NRF_GPIO_HAS_SEL && defined(GPIO_PIN_CNF_CTRLSEL_GRTC)
360+
nrf_gpio_pin_control_select(psel, NRF_GPIO_PIN_SEL_GRTC);
361+
#endif
362+
dir = NRF_GPIO_PIN_DIR_OUTPUT;
363+
input = NRF_GPIO_PIN_INPUT_DISCONNECT;
364+
break;
365+
#endif /* defined(NRF_GRTC_CLKOUT_FAST) */
366+
#if defined(NRF_GRTC_CLKOUT_SLOW)
367+
case NRF_FUN_GRTC_CLKOUT_32K:
368+
#if NRF_GPIO_HAS_SEL && defined(GPIO_PIN_CNF_CTRLSEL_GRTC)
369+
nrf_gpio_pin_control_select(psel, NRF_GPIO_PIN_SEL_GRTC);
370+
#endif
371+
dir = NRF_GPIO_PIN_DIR_OUTPUT;
372+
input = NRF_GPIO_PIN_INPUT_DISCONNECT;
373+
break;
374+
#endif /* defined(NRF_GRTC_CLKOUT_SLOW) */
348375
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_can)
349376
/* Pin routing is controlled by secure domain, via UICR */
350377
case NRF_FUN_CAN_TX:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
#define NRF_FUN_TWIS_SCL 48U
167167
/** TWIS SDA */
168168
#define NRF_FUN_TWIS_SDA 49U
169+
/** GRTC fast clock output */
170+
#define NRF_FUN_GRTC_CLKOUT_FAST 55U
171+
/** GRTC slow clock output */
172+
#define NRF_FUN_GRTC_CLKOUT_32K 56U
169173

170174
/** @} */
171175

0 commit comments

Comments
 (0)