File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -2174,6 +2174,26 @@ static int uart_stm32_init(const struct device *dev)
2174
2174
#endif
2175
2175
}
2176
2176
2177
+ static int uart_stm32_deinit (const struct device * dev )
2178
+ {
2179
+ const struct uart_stm32_config * config = dev -> config ;
2180
+ struct uart_stm32_data * data = dev -> data ;
2181
+ USART_TypeDef * usart = config -> usart ;
2182
+
2183
+ /* TODO: is this correct? */
2184
+ while (!LL_USART_IsActiveFlag_TC (usart )) {
2185
+ }
2186
+
2187
+ /* Reset UART to default state using RCC */
2188
+ (void )reset_line_toggle_dt (& config -> reset );
2189
+
2190
+ (void )clock_control_off (data -> clock , (clock_control_subsys_t )& config -> pclken [0 ]);
2191
+
2192
+ (void )pinctrl_apply_state (config -> pcfg , PINCTRL_STATE_RESET );
2193
+
2194
+ return 0 ;
2195
+ }
2196
+
2177
2197
#ifdef CONFIG_PM_DEVICE
2178
2198
static void uart_stm32_suspend_setup (const struct device * dev )
2179
2199
{
@@ -2463,8 +2483,9 @@ static struct uart_stm32_data uart_stm32_data_##index = { \
2463
2483
\
2464
2484
PM_DEVICE_DT_INST_DEFINE(index, uart_stm32_pm_action); \
2465
2485
\
2466
- DEVICE_DT_INST_DEFINE (index, \
2486
+ DEVICE_DT_INST_DEINIT_DEFINE (index, \
2467
2487
uart_stm32_init, \
2488
+ uart_stm32_deinit, \
2468
2489
PM_DEVICE_DT_INST_GET(index), \
2469
2490
&uart_stm32_data_##index, &uart_stm32_cfg_##index, \
2470
2491
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
You can’t perform that action at this time.
0 commit comments