Skip to content

Commit 1d5c148

Browse files
diegoherranzjhedberg
authored andcommitted
soc: nxp: imx: imx7d: soc.c: enable uart1/3/4/5/7 if used in DT
Only uart2 and uart6 were considered before, so if any other uart was used, it wouldn't work and even worse, it would crash when trying to access it because the RDC wasn't configured. Signed-off-by: Diego Herranz <[email protected]>
1 parent df6857b commit 1d5c148

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

soc/nxp/imx/imx7d/soc.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ static void nxp_mcimx7_gpio_config(void)
8484
static void nxp_mcimx7_uart_config(void)
8585
{
8686

87+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart1))
88+
/* We need to grasp board uart exclusively */
89+
RDC_SetPdapAccess(RDC, rdcPdapUart1, RDC_DT_VAL(uart1), false, false);
90+
/* Select clock derived from OSC clock(24M) */
91+
CCM_UpdateRoot(CCM, ccmRootUart1, ccmRootmuxUartOsc24m, 0, 0);
92+
/* Enable uart clock */
93+
CCM_EnableRoot(CCM, ccmRootUart1);
94+
/*
95+
* IC Limitation
96+
* M4 stop will cause A7 UART lose functionality
97+
* So we need UART clock all the time
98+
*/
99+
CCM_ControlGate(CCM, ccmCcgrGateUart1, ccmClockNeededAll);
100+
#endif
101+
87102
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart2))
88103
/* We need to grasp board uart exclusively */
89104
RDC_SetPdapAccess(RDC, rdcPdapUart2, RDC_DT_VAL(uart2), false, false);
@@ -99,6 +114,51 @@ static void nxp_mcimx7_uart_config(void)
99114
CCM_ControlGate(CCM, ccmCcgrGateUart2, ccmClockNeededAll);
100115
#endif
101116

117+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart3))
118+
/* We need to grasp board uart exclusively */
119+
RDC_SetPdapAccess(RDC, rdcPdapUart3, RDC_DT_VAL(uart3), false, false);
120+
/* Select clock derived from OSC clock(24M) */
121+
CCM_UpdateRoot(CCM, ccmRootUart3, ccmRootmuxUartOsc24m, 0, 0);
122+
/* Enable uart clock */
123+
CCM_EnableRoot(CCM, ccmRootUart3);
124+
/*
125+
* IC Limitation
126+
* M4 stop will cause A7 UART lose functionality
127+
* So we need UART clock all the time
128+
*/
129+
CCM_ControlGate(CCM, ccmCcgrGateUart3, ccmClockNeededAll);
130+
#endif
131+
132+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart4))
133+
/* We need to grasp board uart exclusively */
134+
RDC_SetPdapAccess(RDC, rdcPdapUart4, RDC_DT_VAL(uart4), false, false);
135+
/* Select clock derived from OSC clock(24M) */
136+
CCM_UpdateRoot(CCM, ccmRootUart4, ccmRootmuxUartOsc24m, 0, 0);
137+
/* Enable uart clock */
138+
CCM_EnableRoot(CCM, ccmRootUart4);
139+
/*
140+
* IC Limitation
141+
* M4 stop will cause A7 UART lose functionality
142+
* So we need UART clock all the time
143+
*/
144+
CCM_ControlGate(CCM, ccmCcgrGateUart4, ccmClockNeededAll);
145+
#endif
146+
147+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart5))
148+
/* We need to grasp board uart exclusively */
149+
RDC_SetPdapAccess(RDC, rdcPdapUart5, RDC_DT_VAL(uart5), false, false);
150+
/* Select clock derived from OSC clock(24M) */
151+
CCM_UpdateRoot(CCM, ccmRootUart5, ccmRootmuxUartOsc24m, 0, 0);
152+
/* Enable uart clock */
153+
CCM_EnableRoot(CCM, ccmRootUart5);
154+
/*
155+
* IC Limitation
156+
* M4 stop will cause A7 UART lose functionality
157+
* So we need UART clock all the time
158+
*/
159+
CCM_ControlGate(CCM, ccmCcgrGateUart5, ccmClockNeededAll);
160+
#endif
161+
102162
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart6))
103163
/* We need to grasp board uart exclusively */
104164
RDC_SetPdapAccess(RDC, rdcPdapUart6, RDC_DT_VAL(uart6), false, false);
@@ -113,6 +173,21 @@ static void nxp_mcimx7_uart_config(void)
113173
*/
114174
CCM_ControlGate(CCM, ccmCcgrGateUart6, ccmClockNeededAll);
115175
#endif
176+
177+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(uart7))
178+
/* We need to grasp board uart exclusively */
179+
RDC_SetPdapAccess(RDC, rdcPdapUart7, RDC_DT_VAL(uart7), false, false);
180+
/* Select clock derived from OSC clock(24M) */
181+
CCM_UpdateRoot(CCM, ccmRootUart7, ccmRootmuxUartOsc24m, 0, 0);
182+
/* Enable uart clock */
183+
CCM_EnableRoot(CCM, ccmRootUart7);
184+
/*
185+
* IC Limitation
186+
* M4 stop will cause A7 UART lose functionality
187+
* So we need UART clock all the time
188+
*/
189+
CCM_ControlGate(CCM, ccmCcgrGateUart7, ccmClockNeededAll);
190+
#endif
116191
}
117192
#endif /* CONFIG_UART_IMX */
118193

0 commit comments

Comments
 (0)