From 67b7c993e19837335392c406e225217d4a5b3e06 Mon Sep 17 00:00:00 2001 From: Emilio Benavente Date: Mon, 5 Aug 2024 03:52:06 +0000 Subject: [PATCH] boards: nxp: frdm_mcxn947: Updated Init Clock for LPTMR Updated the clocks that get initialized for the MCXN947 when using the LPTMR. The LPTMR allows the user to select and Input clock, however said input clock must be initialized before the user can select it. Update description for clk-source in binding file. Signed-off-by: Emilio Benavente --- boards/nxp/frdm_mcxn947/board.c | 22 +++++++++++++++++++++- dts/bindings/counter/nxp,lptmr.yaml | 8 +++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/boards/nxp/frdm_mcxn947/board.c b/boards/nxp/frdm_mcxn947/board.c index ab41600737c..a98c236f6ff 100644 --- a/boards/nxp/frdm_mcxn947/board.c +++ b/boards/nxp/frdm_mcxn947/board.c @@ -299,8 +299,28 @@ static int frdm_mcxn947_init(void) #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(lptmr0), okay) + +/* + * Clock Select Decides what input source the lptmr will clock from + * + * 0 <- 12MHz FRO + * 1 <- 16K FRO + * 2 <- 32K OSC + * 3 <- Output from the OSC_SYS + */ +#if DT_PROP(DT_NODELABEL(lptmr0), clk_source) == 0x0 + CLOCK_SetupClockCtrl(kCLOCK_FRO12MHZ_ENA); +#elif DT_PROP(DT_NODELABEL(lptmr0), clk_source) == 0x1 CLOCK_SetupClk16KClocking(kCLOCK_Clk16KToVsys); -#endif +#elif DT_PROP(DT_NODELABEL(lptmr0), clk_source) == 0x2 + CLOCK_SetupOsc32KClocking(kCLOCK_Osc32kToVsys); +#elif DT_PROP(DT_NODELABEL(lptmr0), clk_source) == 0x3 + /* Value here should not exceed 25MHZ when using lptmr */ + CLOCK_SetupExtClocking(MHZ(24)); + CLOCK_SetupClockCtrl(kCLOCK_CLKIN_ENA_FM_USBH_LPT); +#endif /* DT_PROP(DT_NODELABEL(lptmr0), clk_source) */ + +#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(lptmr0), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(flexio0), okay) CLOCK_SetClkDiv(kCLOCK_DivFlexioClk, 1u); diff --git a/dts/bindings/counter/nxp,lptmr.yaml b/dts/bindings/counter/nxp,lptmr.yaml index d44fcb5ef54..bf6252e6c84 100644 --- a/dts/bindings/counter/nxp,lptmr.yaml +++ b/dts/bindings/counter/nxp,lptmr.yaml @@ -20,7 +20,13 @@ properties: clk-source: type: int required: true - description: Prescaler clock source (0 to 3) + enum: [0, 1, 2, 3] + description: | + Selects the clock to be used by the LPMTR prescaler/glitch filter. + In time counter mode, this field selects the input clock to the prescaler. + In pulse counter mode, this field selects the input clock to the glitch filter. + The clock connections vary by device, see the device reference manual for + more details. input-pin: type: int