Skip to content

Commit 49fa151

Browse files
ar-conclusivecarlescufi
authored andcommitted
nxp: imx: Derive i.MX8 UARTs from DT bindings
Use Device Tree bindings to configure clock source/frequency for enabled UARTs only. Get rid of UART clock ungating from `soc.c`, as that functionality has been moved to the clock controller. Signed-off-by: Artur Rojek <[email protected]>
1 parent 14912d2 commit 49fa151

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

soc/arm/nxp_imx/mimx8ml8_m7/soc.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,31 @@ static void SOC_ClockInit(void)
106106
/* switch AHB to SYSTEM PLL1 DIV6 */
107107
CLOCK_SetRootMux(kCLOCK_RootAhb, kCLOCK_AhbRootmuxSysPll1Div6);
108108

109-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay) && CONFIG_UART_MCUX_IUART
109+
#if defined(CONFIG_UART_MCUX_IUART)
110+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay)
111+
/* Set UART source to SysPLL1 Div10 80MHZ */
112+
CLOCK_SetRootMux(kCLOCK_RootUart1, kCLOCK_UartRootmuxSysPll1Div10);
113+
/* Set root clock to 80MHZ/ 1= 80MHZ */
114+
CLOCK_SetRootDivider(kCLOCK_RootUart1, 1U, 1U);
115+
#endif
116+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay)
117+
/* Set UART source to SysPLL1 Div10 80MHZ */
118+
CLOCK_SetRootMux(kCLOCK_RootUart2, kCLOCK_UartRootmuxSysPll1Div10);
119+
/* Set root clock to 80MHZ/ 1= 80MHZ */
120+
CLOCK_SetRootDivider(kCLOCK_RootUart2, 1U, 1U);
121+
#endif
122+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)
123+
/* Set UART source to SysPLL1 Div10 80MHZ */
124+
CLOCK_SetRootMux(kCLOCK_RootUart3, kCLOCK_UartRootmuxSysPll1Div10);
125+
/* Set root clock to 80MHZ/ 1= 80MHZ */
126+
CLOCK_SetRootDivider(kCLOCK_RootUart3, 1U, 1U);
127+
#endif
128+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay)
110129
/* Set UART source to SysPLL1 Div10 80MHZ */
111130
CLOCK_SetRootMux(kCLOCK_RootUart4, kCLOCK_UartRootmuxSysPll1Div10);
112131
/* Set root clock to 80MHZ/ 1= 80MHZ */
113132
CLOCK_SetRootDivider(kCLOCK_RootUart4, 1U, 1U);
133+
#endif
114134
#endif
115135

116136
CLOCK_EnableClock(kCLOCK_Rdc); /* Enable RDC clock */
@@ -126,10 +146,6 @@ static void SOC_ClockInit(void)
126146
CLOCK_EnableClock(kCLOCK_Debug);
127147
CLOCK_EnableClock(kCLOCK_Dram);
128148
CLOCK_EnableClock(kCLOCK_Sec_Debug);
129-
130-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay) && CONFIG_UART_MCUX_IUART
131-
CLOCK_EnableClock(kCLOCK_Uart4);
132-
#endif
133149
}
134150

135151
static int nxp_mimx8ml8_init(const struct device *arg)

soc/arm/nxp_imx/mimx8mm6_m4/soc.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,32 @@ static void SOC_ClockInit(void)
103103
/* switch AUDIO AHB to SYSTEM PLL1 */
104104
CLOCK_SetRootMux(kCLOCK_RootAudioAhb, kCLOCK_AudioAhbRootmuxSysPll1);
105105

106+
#if defined(CONFIG_UART_MCUX_IUART)
107+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay)
108+
/* Set UART source to SysPLL1 Div10 80MHZ */
109+
CLOCK_SetRootMux(kCLOCK_RootUart1, kCLOCK_UartRootmuxSysPll1Div10);
110+
/* Set root clock to 80MHZ/ 1= 80MHZ */
111+
CLOCK_SetRootDivider(kCLOCK_RootUart1, 1U, 1U);
112+
#endif
113+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay)
114+
/* Set UART source to SysPLL1 Div10 80MHZ */
115+
CLOCK_SetRootMux(kCLOCK_RootUart2, kCLOCK_UartRootmuxSysPll1Div10);
116+
/* Set root clock to 80MHZ/ 1= 80MHZ */
117+
CLOCK_SetRootDivider(kCLOCK_RootUart2, 1U, 1U);
118+
#endif
119+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)
120+
/* Set UART source to SysPLL1 Div10 80MHZ */
121+
CLOCK_SetRootMux(kCLOCK_RootUart3, kCLOCK_UartRootmuxSysPll1Div10);
122+
/* Set root clock to 80MHZ/ 1= 80MHZ */
123+
CLOCK_SetRootDivider(kCLOCK_RootUart3, 1U, 1U);
124+
#endif
125+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay)
106126
/* Set UART source to SysPLL1 Div10 80MHZ */
107127
CLOCK_SetRootMux(kCLOCK_RootUart4, kCLOCK_UartRootmuxSysPll1Div10);
108128
/* Set root clock to 80MHZ/ 1= 80MHZ */
109129
CLOCK_SetRootDivider(kCLOCK_RootUart4, 1U, 1U);
130+
#endif
131+
#endif
110132

111133
/* Enable RDC clock */
112134
CLOCK_EnableClock(kCLOCK_Rdc);
@@ -124,8 +146,6 @@ static void SOC_ClockInit(void)
124146
CLOCK_EnableClock(kCLOCK_Debug);
125147
CLOCK_EnableClock(kCLOCK_Dram);
126148
CLOCK_EnableClock(kCLOCK_Sec_Debug);
127-
128-
CLOCK_EnableClock(kCLOCK_Uart4);
129149
}
130150

131151
static int nxp_mimx8mm6_init(const struct device *arg)

soc/arm/nxp_imx/mimx8mq6_m4/soc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,31 @@ static void SOC_ClockInit(void)
6666
/* Switch cortex-m4 to SYSTEM PLL1 DIV3 */
6767
CLOCK_SetRootMux(kCLOCK_RootM4, kCLOCK_M4RootmuxSysPll1Div3);
6868

69+
#if defined(CONFIG_UART_MCUX_IUART)
6970
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay)
7071
/* Set UART source to SysPLL1 Div10 80MHZ */
7172
CLOCK_SetRootMux(kCLOCK_RootUart1, kCLOCK_UartRootmuxSysPll1Div10);
7273
/* Set root clock to 80MHZ/ 1= 80MHZ */
7374
CLOCK_SetRootDivider(kCLOCK_RootUart1, 1U, 1U);
7475
#endif
75-
7676
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay)
7777
/* Set UART source to SysPLL1 Div10 80MHZ */
7878
CLOCK_SetRootMux(kCLOCK_RootUart2, kCLOCK_UartRootmuxSysPll1Div10);
7979
/* Set root clock to 80MHZ/ 1= 80MHZ */
8080
CLOCK_SetRootDivider(kCLOCK_RootUart2, 1U, 1U);
8181
#endif
82-
8382
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)
8483
/* Set UART source to SysPLL1 Div10 80MHZ */
8584
CLOCK_SetRootMux(kCLOCK_RootUart3, kCLOCK_UartRootmuxSysPll1Div10);
8685
/* Set root clock to 80MHZ/ 1= 80MHZ */
8786
CLOCK_SetRootDivider(kCLOCK_RootUart3, 1U, 1U);
8887
#endif
89-
9088
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay)
9189
/* Set UART source to SysPLL1 Div10 80MHZ */
9290
CLOCK_SetRootMux(kCLOCK_RootUart4, kCLOCK_UartRootmuxSysPll1Div10);
9391
/* Set root clock to 80MHZ/ 1= 80MHZ */
9492
CLOCK_SetRootDivider(kCLOCK_RootUart4, 1U, 1U);
93+
#endif
9594
#endif
9695

9796
/* Enable RDC clock */

0 commit comments

Comments
 (0)