1
- /* Copyright 2017, 2019-2024 NXP
1
+ /* Copyright 2017, 2019-2025 NXP
2
2
*
3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
30
30
#include "usb_phy.h"
31
31
#include "usb.h"
32
32
#endif
33
- #if defined(CONFIG_SOC_LPC55S36 ) && (defined( CONFIG_ADC_MCUX_LPADC ) \
34
- || defined(CONFIG_DAC_MCUX_LPDAC ))
33
+ #if defined(CONFIG_SOC_LPC55S36 ) && \
34
+ (defined( CONFIG_ADC_MCUX_LPADC ) || defined(CONFIG_DAC_MCUX_LPDAC ))
35
35
#include <fsl_vref.h>
36
36
#endif
37
37
@@ -41,35 +41,31 @@ extern uint32_t SystemCoreClock;
41
41
/*Should be in the range of 12MHz to 32MHz */
42
42
static uint32_t ExternalClockFrequency ;
43
43
44
-
45
- #define CTIMER_CLOCK_SOURCE (node_id ) \
44
+ #define CTIMER_CLOCK_SOURCE (node_id ) \
46
45
TO_CTIMER_CLOCK_SOURCE(DT_CLOCKS_CELL(node_id, name), DT_PROP(node_id, clk_source))
47
46
#define TO_CTIMER_CLOCK_SOURCE (inst , val ) TO_CLOCK_ATTACH_ID(inst, val)
48
- #define TO_CLOCK_ATTACH_ID (inst , val ) MUX_A(CM_CTIMERCLKSEL##inst, val)
49
- #define CTIMER_CLOCK_SETUP (node_id ) CLOCK_AttachClk(CTIMER_CLOCK_SOURCE(node_id));
47
+ #define TO_CLOCK_ATTACH_ID (inst , val ) MUX_A(CM_CTIMERCLKSEL##inst, val)
48
+ #define CTIMER_CLOCK_SETUP (node_id ) CLOCK_AttachClk(CTIMER_CLOCK_SOURCE(node_id));
50
49
51
50
#ifdef CONFIG_INIT_PLL0
52
51
const pll_setup_t pll0Setup = {
53
- .pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI ( 2U ) |
54
- SYSCON_PLL0CTRL_SELP (31U ),
52
+ .pllctrl =
53
+ SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI ( 2U ) | SYSCON_PLL0CTRL_SELP (31U ),
55
54
.pllndec = SYSCON_PLL0NDEC_NDIV (125U ),
56
55
.pllpdec = SYSCON_PLL0PDEC_PDIV (8U ),
57
56
.pllsscg = {0x0U , (SYSCON_PLL0SSCG1_MDIV_EXT (3072U ) | SYSCON_PLL0SSCG1_SEL_EXT_MASK )},
58
57
.pllRate = 24576000U ,
59
- .flags = PLL_SETUPFLAG_WAITLOCK
60
- };
58
+ .flags = PLL_SETUPFLAG_WAITLOCK };
61
59
#endif
62
60
63
61
#ifdef CONFIG_INIT_PLL1
64
- const pll_setup_t pll1Setup = {
65
- .pllctrl = SYSCON_PLL1CTRL_CLKEN_MASK | SYSCON_PLL1CTRL_SELI (53U ) |
66
- SYSCON_PLL1CTRL_SELP (31U ),
67
- .pllndec = SYSCON_PLL1NDEC_NDIV (8U ),
68
- .pllpdec = SYSCON_PLL1PDEC_PDIV (1U ),
69
- .pllmdec = SYSCON_PLL1MDEC_MDIV (144U ),
70
- .pllRate = 144000000U ,
71
- .flags = PLL_SETUPFLAG_WAITLOCK
72
- };
62
+ const pll_setup_t pll1Setup = {.pllctrl = SYSCON_PLL1CTRL_CLKEN_MASK | SYSCON_PLL1CTRL_SELI (53U ) |
63
+ SYSCON_PLL1CTRL_SELP (31U ),
64
+ .pllndec = SYSCON_PLL1NDEC_NDIV (8U ),
65
+ .pllpdec = SYSCON_PLL1PDEC_PDIV (1U ),
66
+ .pllmdec = SYSCON_PLL1MDEC_MDIV (144U ),
67
+ .pllRate = 144000000U ,
68
+ .flags = PLL_SETUPFLAG_WAITLOCK };
73
69
#endif
74
70
75
71
/**
@@ -87,8 +83,8 @@ __weak void clock_init(void)
87
83
POWER_PowerInit ();
88
84
#endif
89
85
90
- #if defined(CONFIG_SOC_LPC55S06 ) || defined(CONFIG_SOC_LPC55S16 ) || \
91
- defined(CONFIG_SOC_LPC55S26 ) || defined(CONFIG_SOC_LPC55S28 ) || \
86
+ #if defined(CONFIG_SOC_LPC55S06 ) || defined(CONFIG_SOC_LPC55S16 ) || \
87
+ defined(CONFIG_SOC_LPC55S26 ) || defined(CONFIG_SOC_LPC55S28 ) || \
92
88
defined(CONFIG_SOC_LPC55S36 ) || defined(CONFIG_SOC_LPC55S69_CPU0 )
93
89
/* Set up the clock sources */
94
90
/* Configure FRO192M */
@@ -110,7 +106,6 @@ __weak void clock_init(void)
110
106
SystemCoreClock = 144000000U ;
111
107
#endif
112
108
113
-
114
109
/* These functions must be called before increasing to a higher frequency
115
110
* Additionally, CONFIG_TRUSTED_EXECUTION_NONSECURE is being used
116
111
* since the non-secure SOCs should not have access to the flash
@@ -123,7 +118,6 @@ __weak void clock_init(void)
123
118
CLOCK_SetFLASHAccessCyclesForFreq (SystemCoreClock );
124
119
#endif /* !CONFIG_TRUSTED_EXECUTION_NONSECURE */
125
120
126
-
127
121
#if defined(CONFIG_INIT_PLL0 ) || defined(CONFIG_INIT_PLL1 )
128
122
/* Configure XTAL32M */
129
123
ExternalClockFrequency = 16000000U ;
@@ -152,7 +146,6 @@ __weak void clock_init(void)
152
146
153
147
#endif /* CONFIG_SOC_LPC55S06 || !CONFIG_INIT_PLL1 */
154
148
155
-
156
149
#ifdef CONFIG_INIT_PLL0
157
150
/* Switch PLL0 clock source selector to XTAL32M */
158
151
CLOCK_AttachClk (kEXT_CLK_to_PLL0 );
@@ -169,27 +162,26 @@ __weak void clock_init(void)
169
162
#endif /* CONFIG_SOC_LPC55S36 */
170
163
#endif /* CONFIG_INIT_PLL0 */
171
164
172
-
173
165
/* Set up dividers */
174
166
CLOCK_SetClkDiv (kCLOCK_DivAhbClk , 1U , false);
175
167
176
168
/* Enables the clock for the I/O controller.: Enable Clock. */
177
169
CLOCK_EnableClock (kCLOCK_Iocon );
178
170
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 ) || \
171
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm0 ), nxp_lpc_i2c , okay ) || \
172
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm0 ), nxp_lpc_spi , okay ) || \
181
173
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm0 ), nxp_lpc_usart , okay )
182
174
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM0 );
183
175
#endif
184
176
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 ) || \
177
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm1 ), nxp_lpc_i2c , okay ) || \
178
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm1 ), nxp_lpc_spi , okay ) || \
187
179
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm1 ), nxp_lpc_usart , okay )
188
180
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM1 );
189
181
#endif
190
182
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 ) || \
183
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm2 ), nxp_lpc_i2c , okay ) || \
184
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm2 ), nxp_lpc_spi , okay ) || \
193
185
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm2 ), nxp_lpc_usart , okay )
194
186
#if defined(CONFIG_SOC_LPC55S36 )
195
187
CLOCK_SetClkDiv (kCLOCK_DivFlexcom2Clk , 0U , true);
@@ -198,14 +190,14 @@ __weak void clock_init(void)
198
190
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM2 );
199
191
#endif
200
192
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 ) || \
193
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm3 ), nxp_lpc_i2c , okay ) || \
194
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm3 ), nxp_lpc_spi , okay ) || \
203
195
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm3 ), nxp_lpc_usart , okay )
204
196
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM3 );
205
197
#endif
206
198
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 ) || \
199
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm4 ), nxp_lpc_i2c , okay ) || \
200
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm4 ), nxp_lpc_spi , okay ) || \
209
201
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm4 ), nxp_lpc_usart , okay )
210
202
#if defined(CONFIG_SOC_LPC55S36 )
211
203
CLOCK_SetClkDiv (kCLOCK_DivFlexcom4Clk , 0U , true);
@@ -214,20 +206,20 @@ __weak void clock_init(void)
214
206
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM4 );
215
207
#endif
216
208
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 ) || \
209
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm5 ), nxp_lpc_i2c , okay ) || \
210
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm5 ), nxp_lpc_spi , okay ) || \
219
211
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm5 ), nxp_lpc_usart , okay )
220
212
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM5 );
221
213
#endif
222
214
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 ) || \
215
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm6 ), nxp_lpc_i2c , okay ) || \
216
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm6 ), nxp_lpc_spi , okay ) || \
225
217
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm6 ), nxp_lpc_usart , okay )
226
218
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM6 );
227
219
#endif
228
220
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 ) || \
221
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm7 ), nxp_lpc_i2c , okay ) || \
222
+ DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm7 ), nxp_lpc_spi , okay ) || \
231
223
DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm7 ), nxp_lpc_usart , okay )
232
224
CLOCK_AttachClk (kFRO_HF_DIV_to_FLEXCOMM7 );
233
225
#endif
@@ -347,9 +339,9 @@ __weak void clock_init(void)
347
339
348
340
#endif
349
341
350
- DT_FOREACH_STATUS_OKAY (nxp_lpc_ctimer , CTIMER_CLOCK_SETUP )
342
+ DT_FOREACH_STATUS_OKAY (nxp_lpc_ctimer , CTIMER_CLOCK_SETUP )
351
343
352
- DT_FOREACH_STATUS_OKAY (nxp_ctimer_pwm , CTIMER_CLOCK_SETUP )
344
+ DT_FOREACH_STATUS_OKAY (nxp_ctimer_pwm , CTIMER_CLOCK_SETUP )
353
345
354
346
#if (DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (flexcomm6 ), nxp_lpc_i2s , okay ))
355
347
#if defined(CONFIG_SOC_LPC55S36 )
@@ -374,8 +366,7 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
374
366
CLOCK_AttachClk (kMCAN_DIV_to_MCAN );
375
367
#endif
376
368
377
- #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (sdif ), nxp_lpc_sdif , okay ) && \
378
- CONFIG_MCUX_SDIF
369
+ #if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (sdif ), nxp_lpc_sdif , okay ) && CONFIG_MCUX_SDIF
379
370
/* attach main clock to SDIF */
380
371
CLOCK_AttachClk (kMAIN_CLK_to_SDIO_CLK );
381
372
CLOCK_SetClkDiv (kCLOCK_DivSdioClk , 3 , true);
@@ -385,21 +376,18 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
385
376
386
377
#if defined(CONFIG_SOC_LPC55S36 ) && defined(CONFIG_PWM )
387
378
/* Set the Submodule Clocks for FlexPWM */
388
- SYSCON -> PWM0SUBCTL |=
389
- (SYSCON_PWM0SUBCTL_CLK0_EN_MASK | SYSCON_PWM0SUBCTL_CLK1_EN_MASK |
390
- SYSCON_PWM0SUBCTL_CLK2_EN_MASK );
391
- SYSCON -> PWM1SUBCTL |=
392
- (SYSCON_PWM1SUBCTL_CLK0_EN_MASK | SYSCON_PWM1SUBCTL_CLK1_EN_MASK |
393
- SYSCON_PWM1SUBCTL_CLK2_EN_MASK );
379
+ SYSCON -> PWM0SUBCTL |= (SYSCON_PWM0SUBCTL_CLK0_EN_MASK | SYSCON_PWM0SUBCTL_CLK1_EN_MASK |
380
+ SYSCON_PWM0SUBCTL_CLK2_EN_MASK );
381
+ SYSCON -> PWM1SUBCTL |= (SYSCON_PWM1SUBCTL_CLK0_EN_MASK | SYSCON_PWM1SUBCTL_CLK1_EN_MASK |
382
+ SYSCON_PWM1SUBCTL_CLK2_EN_MASK );
394
383
#endif
395
384
396
385
#if DT_NODE_HAS_COMPAT_STATUS (DT_NODELABEL (adc0 ), nxp_lpc_lpadc , okay )
397
386
#if defined(CONFIG_SOC_LPC55S36 )
398
387
CLOCK_SetClkDiv (kCLOCK_DivAdc0Clk , 2U , true);
399
388
CLOCK_AttachClk (kFRO_HF_to_ADC0 );
400
389
#else /* not LPC55s36 */
401
- CLOCK_SetClkDiv (kCLOCK_DivAdcAsyncClk ,
402
- DT_PROP (DT_NODELABEL (adc0 ), clk_divider ), true);
390
+ CLOCK_SetClkDiv (kCLOCK_DivAdcAsyncClk , DT_PROP (DT_NODELABEL (adc0 ), clk_divider ), true);
403
391
CLOCK_AttachClk (MUX_A (CM_ADCASYNCCLKSEL , DT_PROP (DT_NODELABEL (adc0 ), clk_source )));
404
392
405
393
/* Power up the ADC */
@@ -422,6 +410,23 @@ DT_FOREACH_STATUS_OKAY(nxp_ctimer_pwm, CTIMER_CLOCK_SETUP)
422
410
#endif /* SOC platform */
423
411
#endif /* DAC */
424
412
413
+ #if DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (opamp0 ))
414
+ RESET_PeripheralReset (kOPAMP0_RST_SHIFT_RSTn );
415
+ CLOCK_EnableClock (kCLOCK_Opamp0 );
416
+ POWER_DisablePD (kPDRUNCFG_PD_OPAMP0 );
417
+ #endif
418
+
419
+ #if DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (opamp1 ))
420
+ RESET_PeripheralReset (kOPAMP1_RST_SHIFT_RSTn );
421
+ CLOCK_EnableClock (kCLOCK_Opamp1 );
422
+ POWER_DisablePD (kPDRUNCFG_PD_OPAMP1 );
423
+ #endif
424
+
425
+ #if DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (opamp2 ))
426
+ RESET_PeripheralReset (kOPAMP2_RST_SHIFT_RSTn );
427
+ CLOCK_EnableClock (kCLOCK_Opamp2 );
428
+ POWER_DisablePD (kPDRUNCFG_PD_OPAMP2 );
429
+ #endif
425
430
}
426
431
427
432
/**
@@ -455,7 +460,6 @@ void soc_reset_hook(void)
455
460
{
456
461
SystemInit ();
457
462
458
-
459
463
#ifndef CONFIG_LOG_BACKEND_SWO
460
464
/*
461
465
* SystemInit unconditionally enables the trace clock.
@@ -484,7 +488,6 @@ int _second_core_init(void)
484
488
{
485
489
int32_t temp ;
486
490
487
-
488
491
/* Setup the reset handler pointer (PC) and stack pointer value.
489
492
* This is used once the second core runs its startup code.
490
493
* The second core first boots from flash (address 0x00000000)
@@ -496,15 +499,12 @@ int _second_core_init(void)
496
499
SYSCON -> CPUCFG |= SYSCON_CPUCFG_CPU1ENABLE_MASK ;
497
500
498
501
/* Boot source for Core 1 from flash */
499
- SYSCON -> CPBOOT = SYSCON_CPBOOT_CPBOOT (DT_REG_ADDR (
500
- DT_CHOSEN (zephyr_code_cpu1_partition )));
502
+ SYSCON -> CPBOOT = SYSCON_CPBOOT_CPBOOT (DT_REG_ADDR (DT_CHOSEN (zephyr_code_cpu1_partition )));
501
503
502
504
temp = SYSCON -> CPUCTRL ;
503
505
temp |= 0xc0c48000 ;
504
- SYSCON -> CPUCTRL = temp | SYSCON_CPUCTRL_CPU1RSTEN_MASK |
505
- SYSCON_CPUCTRL_CPU1CLKEN_MASK ;
506
- SYSCON -> CPUCTRL = (temp | SYSCON_CPUCTRL_CPU1CLKEN_MASK ) &
507
- (~SYSCON_CPUCTRL_CPU1RSTEN_MASK );
506
+ SYSCON -> CPUCTRL = temp | SYSCON_CPUCTRL_CPU1RSTEN_MASK | SYSCON_CPUCTRL_CPU1CLKEN_MASK ;
507
+ SYSCON -> CPUCTRL = (temp | SYSCON_CPUCTRL_CPU1CLKEN_MASK ) & (~SYSCON_CPUCTRL_CPU1RSTEN_MASK );
508
508
509
509
return 0 ;
510
510
}
0 commit comments