Skip to content

Commit 8199a24

Browse files
Raymond0225kartben
authored andcommitted
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 <[email protected]>
1 parent 3610724 commit 8199a24

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

boards/nxp/frdm_mcxa156/board.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,15 @@ void board_early_init_hook(void)
199199
#endif
200200

201201
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi0))
202+
/* Configure input clock to be able to reach the datasheet specified band rate. */
202203
CLOCK_SetClockDiv(kCLOCK_DivLPSPI0, 1u);
203-
CLOCK_AttachClk(kFRO12M_to_LPSPI0);
204+
CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0);
204205
#endif
205206

206207
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lpspi1))
208+
/* Configure input clock to be able to reach the datasheet specified band rate. */
207209
CLOCK_SetClockDiv(kCLOCK_DivLPSPI1, 1u);
208-
CLOCK_AttachClk(kFRO12M_to_LPSPI1);
210+
CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1);
209211
#endif
210212

211213
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lptmr0))

boards/nxp/frdm_mcxn236/board.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,27 @@ void board_early_init_hook(void)
119119
#endif
120120

121121
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1))
122+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
122123
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
123-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1);
124+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
124125
#endif
125126

126127
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2))
128+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
127129
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u);
128-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
130+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
129131
#endif
130132

131133
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm3))
134+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
132135
CLOCK_SetClkDiv(kCLOCK_DivFlexcom3Clk, 1u);
133-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM3);
136+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);
134137
#endif
135138

136139
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4))
140+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
137141
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
138-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);
142+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
139143
#endif
140144

141145
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm5))

boards/nxp/frdm_mcxn947/board.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,27 @@ void board_early_init_hook(void)
148148
#endif
149149

150150
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1))
151+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
151152
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
152-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1);
153+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
153154
#endif
154155

155156
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm2))
157+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
156158
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1u);
157-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
159+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
158160
#endif
159161

160162
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm4))
163+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
161164
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
162-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);
165+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
163166
#endif
164167

165168
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm7))
169+
/* Configure input clock to be able to reach the datasheet specified SPI band rate. */
166170
CLOCK_SetClkDiv(kCLOCK_DivFlexcom7Clk, 1u);
167-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM7);
171+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM7);
168172
#endif
169173

170174
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(os_timer))

soc/nxp/imxrt/imxrt10xx/soc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ __weak void clock_init(void)
209209
#endif
210210

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

216217
#ifdef CONFIG_DISPLAY_MCUX_ELCDIF

soc/nxp/imxrt/imxrt11xx/soc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ __weak void clock_init(void)
463463
#endif
464464

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

0 commit comments

Comments
 (0)