diff --git a/drivers/timer/Kconfig.mcux_os b/drivers/timer/Kconfig.mcux_os index ed2920bf30015..420594a5180da 100644 --- a/drivers/timer/Kconfig.mcux_os +++ b/drivers/timer/Kconfig.mcux_os @@ -9,6 +9,7 @@ config MCUX_OS_TIMER depends on DT_HAS_NXP_OS_TIMER_ENABLED select TICKLESS_CAPABLE select TIMER_HAS_64BIT_CYCLE_COUNTER + select RESET help This module implements a kernel device driver for the NXP OS event timer and provides the standard "system clock driver" interfaces. diff --git a/drivers/timer/mcux_os_timer.c b/drivers/timer/mcux_os_timer.c index bbadcece8a37e..8b483292532a9 100644 --- a/drivers/timer/mcux_os_timer.c +++ b/drivers/timer/mcux_os_timer.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "fsl_ostimer.h" #if !defined(CONFIG_SOC_FAMILY_MCXN) && !defined(CONFIG_SOC_FAMILY_MCXA) #include "fsl_power.h" @@ -179,9 +180,12 @@ static uint32_t mcux_lpc_ostick_compensate_system_timer(void) } slept_time_us = counter_ticks_to_us(counter_dev, slept_time_ticks); cyc_sys_compensated += CYC_PER_US * slept_time_us; + if (IS_ENABLED(CONFIG_MCUX_OS_TIMER_PM_POWERED_OFF)) { /* Reset the OS Timer to a known state */ - RESET_PeripheralReset(kOSEVENT_TIMER_RST_SHIFT_RSTn); + const struct reset_dt_spec reset = RESET_DT_SPEC_GET(DT_DRV_INST(0)); + + reset_line_toggle_dt(&reset); /* Reactivate os_timer for cases where it loses its state */ OSTIMER_Init(base); } @@ -337,7 +341,9 @@ static int sys_clock_driver_init(void) /* On some SoC's, OS Timer cannot wakeup from low power mode in standby modes */ #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(standby)) && CONFIG_PM counter_dev = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(0, deep_sleep_counter)); - counter_max_val = counter_get_max_top_value(counter_dev); + if (NULL != counter_dev) { + counter_max_val = counter_get_max_top_value(counter_dev); + } #endif #if (DT_INST_PROP(0, wakeup_source)) diff --git a/dts/arm/nxp/nxp_mcxn23x_common.dtsi b/dts/arm/nxp/nxp_mcxn23x_common.dtsi index 359f8c5760e1c..4185cd4874df0 100644 --- a/dts/arm/nxp/nxp_mcxn23x_common.dtsi +++ b/dts/arm/nxp/nxp_mcxn23x_common.dtsi @@ -570,6 +570,7 @@ compatible = "nxp,os-timer"; reg = <0x49000 0x1000>; interrupts = <57 0>; + resets = <&reset NXP_SYSCON_RESET(1, 1)>; status = "disabled"; }; diff --git a/dts/arm/nxp/nxp_rt5xx_common.dtsi b/dts/arm/nxp/nxp_rt5xx_common.dtsi index c7caa322cea2d..f9f88c52814c7 100644 --- a/dts/arm/nxp/nxp_rt5xx_common.dtsi +++ b/dts/arm/nxp/nxp_rt5xx_common.dtsi @@ -494,6 +494,7 @@ compatible = "nxp,os-timer"; reg = <0x113000 0x1000>; interrupts = <41 0>; + resets = <&rstctl1 NXP_SYSCON_RESET(0, 27)>; status = "disabled"; }; diff --git a/dts/arm/nxp/nxp_rt6xx_common.dtsi b/dts/arm/nxp/nxp_rt6xx_common.dtsi index 937cbf663c9ef..6f406160debe7 100644 --- a/dts/arm/nxp/nxp_rt6xx_common.dtsi +++ b/dts/arm/nxp/nxp_rt6xx_common.dtsi @@ -438,6 +438,7 @@ compatible = "nxp,os-timer"; reg = <0x113000 0x1000>; interrupts = <41 0>; + resets = <&rstctl1 NXP_SYSCON_RESET(0, 27)>; status = "disabled"; }; diff --git a/dts/arm/nxp/nxp_rw6xx_common.dtsi b/dts/arm/nxp/nxp_rw6xx_common.dtsi index eb62e3b918db0..7703ede39f1cf 100644 --- a/dts/arm/nxp/nxp_rw6xx_common.dtsi +++ b/dts/arm/nxp/nxp_rw6xx_common.dtsi @@ -610,6 +610,7 @@ compatible = "nxp,os-timer"; reg = <0x13b000 0x1000>; interrupts = <41 0>; + resets = <&rstctl1 NXP_SYSCON_RESET(0, 27)>; status = "disabled"; }; diff --git a/dts/bindings/timer/nxp,os-timer.yaml b/dts/bindings/timer/nxp,os-timer.yaml index eb945b807fc47..519e20f73b531 100644 --- a/dts/bindings/timer/nxp,os-timer.yaml +++ b/dts/bindings/timer/nxp,os-timer.yaml @@ -20,3 +20,7 @@ properties: Instance of a counter peripheral. The OS Timer maybe powered off in certain deep power down modes. The OS Timer driver will use this counter to wakeup and also to keep track of system time. + + resets: + type: phandle-array + description: reset line