Skip to content

Commit 515adfa

Browse files
fbnorsdanieldegrasse
authored andcommitted
soc: nxp lpc55xxxx: Enable clock on all used Flexcomm ports
Previously the clock was not attached to all Flexcomm ports. Some ports were configured with FRO_12M, others with FRO_HF, some not at all. Now every Flexcomm port in I2C, SPI or USART mode uses the FRO_HF clock, if it is enabled in the device tree, to cover all use cases. Signed-off-by: Fabian Otto <[email protected]>
1 parent 542ea03 commit 515adfa

File tree

1 file changed

+31
-13
lines changed
  • soc/nxp/lpc/lpc55xxx

1 file changed

+31
-13
lines changed

soc/nxp/lpc/lpc55xxx/soc.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,45 +176,63 @@ __weak void clock_init(void)
176176
/* Enables the clock for the I/O controller.: Enable Clock. */
177177
CLOCK_EnableClock(kCLOCK_Iocon);
178178

179-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay)
179+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_i2c, okay) || \
180+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_spi, okay) || \
181+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay)
182+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM0);
183+
#endif
184+
185+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm1), nxp_lpc_i2c, okay) || \
186+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm1), nxp_lpc_spi, okay) || \
187+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm1), nxp_lpc_usart, okay)
188+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM1);
189+
#endif
190+
191+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_i2c, okay) || \
192+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_spi, okay) || \
193+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay)
180194
#if defined(CONFIG_SOC_LPC55S36)
181195
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 0U, true);
182196
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1U, false);
183197
#endif
184-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
198+
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM2);
185199
#endif
186200

187-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_usart, okay)
201+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_i2c, okay) || \
202+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_spi, okay) || \
203+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_usart, okay)
188204
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);
189205
#endif
190206

191-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay)
207+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) || \
208+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_spi, okay) || \
209+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_usart, okay)
192210
#if defined(CONFIG_SOC_LPC55S36)
193211
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 0U, true);
194212
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1U, false);
195213
#endif
196-
/* attach 12 MHz clock to FLEXCOMM4 */
197-
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);
198-
#endif
199-
200-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_usart, okay)
201214
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
202215
#endif
203216

204-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_usart, okay)
217+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_i2c, okay) || \
218+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_spi, okay) || \
219+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_usart, okay)
205220
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM5);
206221
#endif
207222

208-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_usart, okay)
223+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_i2c, okay) || \
224+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_spi, okay) || \
225+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_usart, okay)
209226
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM6);
210227
#endif
211228

212-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_usart, okay)
229+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_i2c, okay) || \
230+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_spi, okay) || \
231+
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_usart, okay)
213232
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM7);
214233
#endif
215234

216235
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(hs_lspi))
217-
/* Attach 12 MHz clock to HSLSPI */
218236
CLOCK_AttachClk(kFRO_HF_DIV_to_HSLSPI);
219237
#endif
220238

0 commit comments

Comments
 (0)