Skip to content

Commit fda3d81

Browse files
soc: nxp: lpc: lpc55sxxx: make clocks for peripherals depend on Kconfig
Make clock setup for each peripheral on the LPC55S69 dependent on if the Kconfig for that peripheral driver is enabled. This reduces the flash size of the LPC55S69 hello world image, since the code to setup these clocks no longer needs to run at boot. It also better mirrors how clocks will be setup within clock management, IE where each peripheral will setup its own clocks. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
1 parent 877c879 commit fda3d81

File tree

1 file changed

+40
-18
lines changed
  • soc/nxp/lpc/lpc55xxx

1 file changed

+40
-18
lines changed

soc/nxp/lpc/lpc55xxx/soc.c

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,22 @@ __weak void clock_init(void)
253253
/* Enables the clock for the I/O controller.: Enable Clock. */
254254
CLOCK_EnableClock(kCLOCK_Iocon);
255255

256-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay)
256+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay) && \
257+
CONFIG_UART_MCUX_FLEXCOMM
257258
#if defined(CONFIG_SOC_LPC55S36)
258259
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 0U, true);
259260
CLOCK_SetClkDiv(kCLOCK_DivFlexcom2Clk, 1U, false);
260261
#endif
261262
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);
262263
#endif
263264

264-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_usart, okay)
265+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_usart, okay) && \
266+
CONFIG_UART_MCUX_FLEXCOMM
265267
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);
266268
#endif
267269

268-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay)
270+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) && \
271+
CONFIG_I2C_MCUX_FLEXCOMM
269272
#if defined(CONFIG_SOC_LPC55S36)
270273
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 0U, true);
271274
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1U, false);
@@ -274,39 +277,48 @@ __weak void clock_init(void)
274277
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);
275278
#endif
276279

277-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_usart, okay)
280+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_usart, okay) && \
281+
CONFIG_UART_MCUX_FLEXCOMM
278282
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM4);
279283
#endif
280284

281-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_usart, okay)
285+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_usart, okay) && \
286+
CONFIG_UART_MCUX_FLEXCOMM
282287
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM5);
283288
#endif
284289

285-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_usart, okay)
290+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_usart, okay) && \
291+
CONFIG_UART_MCUX_FLEXCOMM
286292
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM6);
287293
#endif
288294

289-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_usart, okay)
295+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_usart, okay) && \
296+
CONFIG_UART_MCUX_FLEXCOMM
290297
CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM7);
291298
#endif
292299

293-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(hs_lspi))
300+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(hs_lspi)) && \
301+
CONFIG_SPI_MCUX_FLEXCOMM
294302
/* Attach 12 MHz clock to HSLSPI */
295303
CLOCK_AttachClk(kFRO_HF_DIV_to_HSLSPI);
296304
#endif
297305

298-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(wwdt0), nxp_lpc_wwdt, okay)
306+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(wwdt0), nxp_lpc_wwdt, okay) && \
307+
CONFIG_WDT_MCUX_WWDT
299308
/* Enable 1 MHz FRO clock for WWDT */
300309
SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_FRO1MHZ_CLK_ENA_MASK;
301310
#endif
302311

303-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(mailbox0), nxp_lpc_mailbox, okay)
312+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(mailbox0), nxp_lpc_mailbox, okay) && \
313+
CONFIG_IPM_MCUX
304314
CLOCK_EnableClock(kCLOCK_Mailbox);
305315
#endif
306316

307317
#if CONFIG_USB_DC_NXP_LPCIP3511 || CONFIG_UDC_NXP_IP3511
308318

309-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(usbfs), nxp_lpcip3511, okay)
319+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(usbfs), nxp_lpcip3511, okay) && \
320+
CONFIG_USB_MCUX
321+
310322
/*< Turn on USB Phy */
311323
#if defined(CONFIG_SOC_LPC55S36)
312324
POWER_DisablePD(kPDRUNCFG_PD_USBFSPHY);
@@ -337,7 +349,8 @@ __weak void clock_init(void)
337349

338350
#endif /* USB_DEVICE_TYPE_FS */
339351

340-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(usbhs), nxp_lpcip3511, okay)
352+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(usbhs), nxp_lpcip3511, okay) && \
353+
CONFIG_USB_MCUX
341354
/* enable usb1 host clock */
342355
CLOCK_EnableClock(kCLOCK_Usbh1);
343356
/* Put PHY powerdown under software control */
@@ -364,11 +377,15 @@ __weak void clock_init(void)
364377

365378
#endif /* CONFIG_USB_DC_NXP_LPCIP3511 */
366379

380+
#if (CONFIG_PWM_MCUX_CTIMER) || (CONFIG_COUNTER_MCUX_CTIMER)
367381
DT_FOREACH_STATUS_OKAY(nxp_lpc_ctimer, CTIMER_CLOCK_SETUP)
368382

369383
DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
384+
#endif
385+
370386

371-
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_i2s, okay))
387+
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm6), nxp_lpc_i2s, okay)) && \
388+
CONFIG_I2S_MCUX_FLEXCOMM
372389
#if defined(CONFIG_SOC_LPC55S36)
373390
CLOCK_SetClkDiv(kCLOCK_DivFlexcom6Clk, 0U, true);
374391
CLOCK_SetClkDiv(kCLOCK_DivFlexcom6Clk, 1U, false);
@@ -377,7 +394,8 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
377394
CLOCK_AttachClk(kPLL0_DIV_to_FLEXCOMM6);
378395
#endif
379396

380-
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_i2s, okay))
397+
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm7), nxp_lpc_i2s, okay)) && \
398+
CONFIG_I2S_MCUX_FLEXCOMM
381399
#if defined(CONFIG_SOC_LPC55S36)
382400
CLOCK_SetClkDiv(kCLOCK_DivFlexcom7Clk, 0U, true);
383401
CLOCK_SetClkDiv(kCLOCK_DivFlexcom7Clk, 1U, false);
@@ -386,7 +404,8 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
386404
CLOCK_AttachClk(kPLL0_DIV_to_FLEXCOMM7);
387405
#endif
388406

389-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can0), nxp_lpc_mcan, okay)
407+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can0), nxp_lpc_mcan, okay) && \
408+
CONFIG_CAN_MCUX_MCAN
390409
CLOCK_SetClkDiv(kCLOCK_DivCanClk, 1U, false);
391410
CLOCK_AttachClk(kMCAN_DIV_to_MCAN);
392411
#endif
@@ -410,7 +429,8 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
410429
SYSCON_PWM1SUBCTL_CLK2_EN_MASK);
411430
#endif
412431

413-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(adc0), nxp_lpc_lpadc, okay)
432+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(adc0), nxp_lpc_lpadc, okay) && \
433+
CONFIG_ADC_MCUX_LPADC
414434
#if defined(CONFIG_SOC_LPC55S36)
415435
CLOCK_SetClkDiv(kCLOCK_DivAdc0Clk, 2U, true);
416436
CLOCK_AttachClk(kFRO_HF_to_ADC0);
@@ -424,12 +444,14 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
424444
#endif /* SOC platform */
425445
#endif /* ADC */
426446

427-
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(vref0), nxp_vref, okay))
447+
#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(vref0), nxp_vref, okay)) && \
448+
CONFIG_REGULATOR_NXP_VREF
428449
CLOCK_EnableClock(kCLOCK_Vref);
429450
POWER_DisablePD(kPDRUNCFG_PD_VREF);
430451
#endif /* vref0 */
431452

432-
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(dac0), nxp_lpdac, okay)
453+
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(dac0), nxp_lpdac, okay) && \
454+
CONFIG_DAC_MCUX_LPDAC
433455
#if defined(CONFIG_SOC_LPC55S36)
434456
CLOCK_SetClkDiv(kCLOCK_DivDac0Clk, 1U, true);
435457
CLOCK_AttachClk(kMAIN_CLK_to_DAC0);

0 commit comments

Comments
 (0)