Commit 8199a247 authored by Raymond Lei's avatar Raymond Lei Committed by Benjamin Cabé
Browse files

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: default avatarRaymond Lei <raymond.lei@nxp.com>
parent 36107241
Loading
Loading
Loading
Loading
+4 −2
Changes for boards/nxp/frdm_mcxa156/board.c: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -199,13 +199,15 @@ void board_early_init_hook(void)
#endif

#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_AttachClk(kFRO12M_to_LPSPI0);
	CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0);
#endif

#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_AttachClk(kFRO12M_to_LPSPI1);
	CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1);
#endif

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0))
+8 −4
Changes for boards/nxp/frdm_mcxn236/board.c: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -119,23 +119,27 @@ void board_early_init_hook(void)
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM1);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM2);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM3);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM4);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
#endif

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm5))
+8 −4
Changes for boards/nxp/frdm_mcxn947/board.c: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -148,23 +148,27 @@ void board_early_init_hook(void)
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM1);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM2);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM4);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
#endif

#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_AttachClk(kFRO12M_to_FLEXCOMM7);
	CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM7);
#endif

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(os_timer))
+3 −2
Changes for soc/nxp/imxrt/imxrt10xx/soc.c: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -209,8 +209,9 @@ __weak void clock_init(void)
#endif

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

#ifdef CONFIG_DISPLAY_MCUX_ELCDIF
+2 −2
Changes for soc/nxp/imxrt/imxrt11xx/soc.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -463,8 +463,8 @@ __weak void clock_init(void)
#endif

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