Skip to content

Commit d33f7fe

Browse files
decsnydanieldegrasse
authored andcommitted
soc: imxrt: Clean up INIT_ENET_PLL config
Initial motivation for this commit was to not force select the INIT_ENET_PLL config from SOC level to allow for board level configuration which might want it to be off. While doing that, I discovered that RT11xx actually does not have anything called by "ENET PLL" in the reference manual. So I have removed the config for RT11xx. The default clock source for this soc.c code for RT11xx is PLL1 DIV2, which I changed to just be configured if ethernet is enabled, which was the reason to configure this pll as it stands now, even though it is not specific to ethernet (although the DIV2 output is mostly for ethernet). Another config is therefore not needed. For RT10xx, the situation is a lot more complicated. There is a lot of discrepancy again between what is considered the "ENET PLL" both conceptually and literally between the RM, SDK, and Zephyr config. And also the code to define the config struct was a complete mess. So I have simplified the code and changed it so that the config is only a soft default to y instead of selected forcefully. Also, for the case of the RT1010 and RT1020 series, the SDK is appearing to configure PLL6 (again there is no clear ENET PLL meaning on these platforms) 500M output through this "enet pll" configuration function. So similarly instead of always enabling this output for those platforms, I added a new config which can be set or unset by board level. Signed-off-by: Declan Snyder <[email protected]>
1 parent f775f9a commit d33f7fe

File tree

5 files changed

+51
-64
lines changed

5 files changed

+51
-64
lines changed

soc/nxp/imxrt/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,6 @@ config INIT_ARM_PLL
184184
config INIT_VIDEO_PLL
185185
bool "Initialize Video PLL"
186186

187-
config INIT_ENET_PLL
188-
bool
189-
help
190-
If y, the Ethernet PLL is initialized. Always enabled on e.g.
191-
MIMXRT1021 - see commit 17f4d6bec7 ("soc: nxp_imx: fix ENET_PLL selection
192-
for MIMXRT1021").
193-
194187
config INIT_SYS_PLL
195188
bool "Initialize System PLL"
196189

soc/nxp/imxrt/imxrt10xx/Kconfig

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,17 @@ config SOC_MIMXRT1011
3535
select CPU_HAS_ARM_MPU
3636
select CPU_HAS_ICACHE
3737
select CPU_HAS_DCACHE
38-
select INIT_ENET_PLL
3938

4039
config SOC_MIMXRT1015
4140
select CPU_HAS_FPU
4241
select CPU_HAS_FPU_DOUBLE_PRECISION
4342
select CPU_HAS_ARM_MPU
44-
select INIT_ENET_PLL
4543

4644
config SOC_MIMXRT1021
4745
select HAS_MCUX_ENET
4846
select HAS_MCUX_SEMC
4947
select CPU_HAS_FPU_DOUBLE_PRECISION
5048
select CPU_HAS_ARM_MPU
51-
select INIT_ENET_PLL
5249
select HAS_MCUX_USDHC1
5350
select HAS_MCUX_USDHC2
5451
select HAS_MCUX_FLEXCAN
@@ -59,7 +56,6 @@ config SOC_MIMXRT1024
5956
select HAS_MCUX_SEMC
6057
select CPU_HAS_FPU_DOUBLE_PRECISION
6158
select CPU_HAS_ARM_MPU
62-
select INIT_ENET_PLL
6359
select HAS_MCUX_USDHC1
6460
select HAS_MCUX_USDHC2
6561
select HAS_MCUX_FLEXCAN
@@ -80,7 +76,6 @@ config SOC_MIMXRT1052
8076
select CPU_HAS_ARM_MPU
8177
select INIT_ARM_PLL
8278
select INIT_VIDEO_PLL if DISPLAY_MCUX_ELCDIF
83-
select INIT_ENET_PLL if NET_L2_ETHERNET && ETH_DRIVER
8479
select HAS_MCUX_USDHC1
8580
select HAS_MCUX_USDHC2
8681
select HAS_MCUX_FLEXCAN
@@ -98,7 +93,6 @@ config SOC_MIMXRT1062
9893
select CPU_HAS_ARM_MPU
9994
select INIT_ARM_PLL
10095
select INIT_VIDEO_PLL if DISPLAY_MCUX_ELCDIF
101-
select INIT_ENET_PLL if NET_L2_ETHERNET && ETH_DRIVER
10296
select HAS_MCUX_USDHC1
10397
select HAS_MCUX_USDHC2
10498
select HAS_MCUX_FLEXCAN
@@ -118,8 +112,28 @@ config SOC_MIMXRT1064
118112
select CPU_HAS_ARM_MPU
119113
select INIT_ARM_PLL
120114
select INIT_VIDEO_PLL if DISPLAY_MCUX_ELCDIF
121-
select INIT_ENET_PLL if NET_L2_ETHERNET && ETH_DRIVER
122115
select HAS_MCUX_USDHC1
123116
select HAS_MCUX_USDHC2
124117
select HAS_MCUX_FLEXCAN
125118
select HAS_SWO
119+
120+
if SOC_SERIES_IMXRT10XX
121+
122+
config INIT_ENET_PLL
123+
bool "Initialize ENET PLL"
124+
default y if ETH_NXP_ENET
125+
help
126+
When enabled, will call the SDK function to initialize the enet pll.
127+
The exact meaning of what the "enet pll" is in the hardware according
128+
to the SDK changes per platform, and so does the API signature.
129+
This configuration also assumes a certain default clocking scheme for each SOC.
130+
See soc.c code and HAL fsl_clock.c for the platform for better understanding.
131+
132+
config INIT_PLL6_500M
133+
bool "PLL6 500M output enable"
134+
default y
135+
depends on SOC_MIMXRT1011 || SOC_MIMXRT1015 || \
136+
SOC_MIMXRT1021 || SOC_MIMXRT1024
137+
select INIT_ENET_PLL
138+
139+
endif # SOC_SERIES_IMXRT10XX

soc/nxp/imxrt/imxrt10xx/soc.c

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,6 @@ const clock_sys_pll_config_t sysPllConfig = {
5757
#define BOARD_USB_PHY_TXCAL45DM (0x06U)
5858
#endif
5959

60-
#ifdef CONFIG_INIT_ENET_PLL
61-
/* ENET PLL configuration for RUN mode */
62-
const clock_enet_pll_config_t ethPllConfig = {
63-
#if defined(CONFIG_SOC_MIMXRT1011) || \
64-
defined(CONFIG_SOC_MIMXRT1015) || \
65-
defined(CONFIG_SOC_MIMXRT1021) || \
66-
defined(CONFIG_SOC_MIMXRT1024)
67-
.enableClkOutput500M = true,
68-
#endif
69-
#if defined(CONFIG_ETH_NXP_ENET)
70-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet))
71-
.enableClkOutput = true,
72-
#endif
73-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2))
74-
.enableClkOutput1 = true,
75-
#endif
76-
#endif
77-
#if defined(CONFIG_PTP_CLOCK_NXP_ENET)
78-
.enableClkOutput25M = true,
79-
#else
80-
.enableClkOutput25M = false,
81-
#endif
82-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet))
83-
.loopDivider = 1,
84-
#endif
85-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2))
86-
.loopDivider1 = 1,
87-
#endif
88-
};
89-
#endif
9060

9161
#if CONFIG_USB_DC_NXP_EHCI
9262
usb_phy_config_struct_t usbPhyConfig = {
@@ -164,9 +134,26 @@ __weak void clock_init(void)
164134
#ifdef CONFIG_INIT_ARM_PLL
165135
CLOCK_InitArmPll(&armPllConfig); /* Configure ARM PLL to 1200M */
166136
#endif
167-
#ifdef CONFIG_INIT_ENET_PLL
168-
CLOCK_InitEnetPll(&ethPllConfig);
137+
138+
static const clock_enet_pll_config_t ethPllConfig = {
139+
.enableClkOutput25M = IS_ENABLED(CONFIG_PTP_CLOCK_NXP_ENET),
140+
.enableClkOutput = DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet)),
141+
.loopDivider = DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet)),
142+
#if DT_NODE_EXISTS(DT_NODELABEL(enet2))
143+
/* some platform don't have enet 2 and sdk doesn't have these fields for it */
144+
.enableClkOutput1 = DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2)),
145+
.loopDivider1 = DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(enet2)),
146+
#endif
147+
#if IS_ENABLED(CONFIG_INIT_PLL6_500M)
148+
/* this field only exists on some platforms, so ifdef is needed */
149+
.enableClkOutput500M = true,
169150
#endif
151+
};
152+
153+
if (IS_ENABLED(CONFIG_INIT_ENET_PLL)) {
154+
CLOCK_InitEnetPll(&ethPllConfig);
155+
}
156+
170157
#ifdef CONFIG_INIT_VIDEO_PLL
171158
CLOCK_InitVideoPll(&videoPllConfig);
172159
#endif

soc/nxp/imxrt/imxrt11xx/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ config SOC_SERIES_IMXRT11XX
2424
select HAS_MCUX_FLEXCAN
2525
select CPU_HAS_ARM_MPU
2626
select INIT_ARM_PLL
27-
select INIT_ENET_PLL if NET_L2_ETHERNET && ETH_DRIVER
2827
select INIT_VIDEO_PLL
2928
select HAS_MCUX_EDMA
3029
select CPU_HAS_ICACHE if CPU_CORTEX_M7

soc/nxp/imxrt/imxrt11xx/soc.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ static const clock_sys_pll2_config_t sysPll2Config = {
9090
.ssEnable = false,
9191
};
9292

93-
#ifdef CONFIG_INIT_ENET_PLL
94-
static const clock_sys_pll1_config_t sysPll1Config = {
95-
.pllDiv2En = true,
96-
};
97-
#endif
98-
9993
#ifdef CONFIG_INIT_VIDEO_PLL
10094
static const clock_video_pll_config_t videoPllConfig = {
10195
/* PLL Loop divider, valid range for DIV_SELECT divider value: 27 ~ 54. */
@@ -261,17 +255,17 @@ __weak void clock_init(void)
261255
CLOCK_InitArmPll(&armPllConfig);
262256
#endif
263257

264-
#ifdef CONFIG_INIT_ENET_PLL
265-
CLOCK_InitSysPll1(&sysPll1Config);
266-
#else
267-
#ifndef CONFIG_SECOND_CORE_MCUX
268-
/* Bypass Sys Pll1. */
269-
CLOCK_SetPllBypass(kCLOCK_PllSys1, true);
270-
271-
/* DeInit Sys Pll1. */
272-
CLOCK_DeinitSysPll1();
273-
#endif
274-
#endif
258+
if (IS_ENABLED(CONFIG_ETH_NXP_ENET)) {
259+
/* For default clocking, we will only use pll1 for div2 output for enet */
260+
static const clock_sys_pll1_config_t sysPll1Config = {
261+
.pllDiv2En = true,
262+
};
263+
CLOCK_InitSysPll1(&sysPll1Config);
264+
} else if (!IS_ENABLED(CONFIG_SECOND_CORE_MCUX)) {
265+
/* PLL1 not used otherwise, so bypass first then deinit */
266+
CLOCK_SetPllBypass(kCLOCK_PllSys1, true);
267+
CLOCK_DeinitSysPll1();
268+
}
275269

276270
/* Init Sys Pll2. */
277271
CLOCK_InitSysPll2(&sysPll2Config);

0 commit comments

Comments
 (0)