boards/soc: nxp: MCXA, imxrt11xx: reconfigure clock source of lpspi

In spi loopback test, high bandrate is 16Mbps while some source of lpspi
are too low to support this bandrate. According the reference mannual,
to support 16Mbps, Input frequency at least should be 2*16MHz.
Update LPSPI input freq to maximum to get more accurate band rate
because band rate must be divisible by input freq.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
This commit is contained in:
Raymond Lei 2025-03-03 14:00:35 -06:00 committed by Benjamin Cabé
commit 8199a247a6
5 changed files with 25 additions and 14 deletions

View file

@ -199,13 +199,15 @@ void board_early_init_hook(void)
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi0)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi0))
/* Configure input clock to be able to reach the datasheet specified band rate. */
CLOCK_SetClockDiv(kCLOCK_DivLPSPI0, 1u); CLOCK_SetClockDiv(kCLOCK_DivLPSPI0, 1u);
CLOCK_AttachClk(kFRO12M_to_LPSPI0); CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi1)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi1))
/* Configure input clock to be able to reach the datasheet specified band rate. */
CLOCK_SetClockDiv(kCLOCK_DivLPSPI1, 1u); CLOCK_SetClockDiv(kCLOCK_DivLPSPI1, 1u);
CLOCK_AttachClk(kFRO12M_to_LPSPI1); CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0))

View file

@ -119,23 +119,27 @@ void board_early_init_hook(void)
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm3)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm3))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom3Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom3Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM3); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm5)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm5))

View file

@ -148,23 +148,27 @@ void board_early_init_hook(void)
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm7)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm7))
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
CLOCK_SetClkDiv(kCLOCK_DivFlexcom7Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom7Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM7); CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM7);
#endif #endif
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(os_timer)) #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(os_timer))

View file

@ -209,8 +209,9 @@ __weak void clock_init(void)
#endif #endif
#ifdef CONFIG_SPI_MCUX_LPSPI #ifdef CONFIG_SPI_MCUX_LPSPI
CLOCK_SetMux(kCLOCK_LpspiMux, 1); /* Set SPI source to USB1 PFD0 720M */ /* Configure input clock to be able to reach the datasheet specified band rate. */
CLOCK_SetDiv(kCLOCK_LpspiDiv, 7); /* Set SPI divider to 8 */ CLOCK_SetMux(kCLOCK_LpspiMux, 1); /* Set SPI source to USB1 PFD0 */
CLOCK_SetDiv(kCLOCK_LpspiDiv, 0); /* Set SPI divider to 1 */
#endif #endif
#ifdef CONFIG_DISPLAY_MCUX_ELCDIF #ifdef CONFIG_DISPLAY_MCUX_ELCDIF

View file

@ -463,8 +463,8 @@ __weak void clock_init(void)
#endif #endif
#ifdef CONFIG_SPI_MCUX_LPSPI #ifdef CONFIG_SPI_MCUX_LPSPI
/* Configure lpspi using Osc48MDiv2 */ /* Configure input clock to be able to reach the datasheet specified band rate. */
rootCfg.mux = kCLOCK_LPSPI1_ClockRoot_MuxOscRc48MDiv2; rootCfg.mux = kCLOCK_LPSPI1_ClockRoot_MuxOscRc400M;
rootCfg.div = 1; rootCfg.div = 1;
CLOCK_SetRootClock(kCLOCK_Root_Lpspi1, &rootCfg); CLOCK_SetRootClock(kCLOCK_Root_Lpspi1, &rootCfg);
#endif #endif