|
10 | 10 | #if defined(CONFIG_CLOCK_CONTROL_NRF) |
11 | 11 | #include <zephyr/drivers/clock_control/nrf_clock_control.h> |
12 | 12 | #endif |
| 13 | +#include <zephyr/drivers/pinctrl.h> |
13 | 14 | #include <zephyr/drivers/timer/system_timer.h> |
14 | 15 | #include <zephyr/drivers/timer/nrf_grtc_timer.h> |
15 | 16 | #include <nrfx_grtc.h> |
@@ -518,7 +519,31 @@ static int sys_clock_driver_init(void) |
518 | 519 | #if defined(CONFIG_NRF_GRTC_ALWAYS_ON) |
519 | 520 | nrfx_grtc_active_request_set(true); |
520 | 521 | #endif |
| 522 | + |
| 523 | +#if DT_NODE_HAS_PROP(GRTC_NODE, clkout_32k_frequency) |
| 524 | + nrfy_grtc_clkout_set(NRF_GRTC, NRF_GRTC_CLKOUT_32K, true); |
| 525 | +#endif |
| 526 | + |
| 527 | +#if DT_NODE_HAS_PROP(GRTC_NODE, clkout_fast_frequency) |
| 528 | +#if DT_PROP(GRTC_NODE, clkout_fast_frequency) > (DT_PROP(GRTC_NODE, base_frequency) / 2) |
| 529 | +#error "Invalid frequency value for fast clock output." |
| 530 | +#endif |
| 531 | + uint32_t base_frequency = DT_PROP(GRTC_NODE, base_frequency); |
| 532 | + uint32_t requested_frequency = DT_PROP(GRTC_NODE, clkout_fast_frequency); |
| 533 | + uint32_t grtc_div = base_frequency / (requested_frequency * 2); |
| 534 | + |
| 535 | + nrfy_grtc_clkout_set(NRF_GRTC, NRF_GRTC_CLKOUT_FAST, true); |
| 536 | + nrfy_grtc_clkout_divider_set(NRF_GRTC, (uint8_t)grtc_div); |
| 537 | +#endif |
| 538 | + |
| 539 | +#if DT_NODE_HAS_PROP(GRTC_NODE, clkout_32k_frequency) || \ |
| 540 | + DT_NODE_HAS_PROP(GRTC_NODE, clkout_fast_frequency) |
| 541 | + PINCTRL_DT_DEFINE(GRTC_NODE); |
| 542 | + const struct pinctrl_dev_config *pcfg = PINCTRL_DT_DEV_CONFIG_GET(GRTC_NODE); |
| 543 | + return pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT); |
| 544 | +#else |
521 | 545 | return 0; |
| 546 | +#endif |
522 | 547 | } |
523 | 548 |
|
524 | 549 | void sys_clock_set_timeout(int32_t ticks, bool idle) |
|
0 commit comments