@@ -34,6 +34,7 @@ struct uart_npcx_config {
3434struct uart_npcx_data {
3535 /* Baud rate */
3636 uint32_t baud_rate ;
37+ struct miwu_dev_callback uart_rx_cb ;
3738#ifdef CONFIG_UART_INTERRUPT_DRIVEN
3839 uart_irq_callback_user_data_t user_cb ;
3940 void * user_data ;
@@ -209,6 +210,12 @@ static void uart_npcx_isr(const struct device *dev)
209210{
210211 struct uart_npcx_data * data = DRV_DATA (dev );
211212
213+ /* Refresh console expired time if got UART Rx event */
214+ if (IS_ENABLED (CONFIG_UART_CONSOLE_INPUT_EXPIRED ) &&
215+ uart_npcx_irq_rx_ready (dev )) {
216+ npcx_power_console_is_in_use_refresh ();
217+ }
218+
212219 if (data -> user_cb ) {
213220 data -> user_cb (dev , data -> user_data );
214221 }
@@ -285,6 +292,15 @@ static int uart_npcx_err_check(const struct device *dev)
285292 return err ;
286293}
287294
295+ static __unused void uart_npcx_rx_wk_isr (const struct device * dev ,
296+ struct npcx_wui * wui )
297+ {
298+ /* Refresh console expired time if got UART Rx wake-up event */
299+ if (IS_ENABLED (CONFIG_UART_CONSOLE_INPUT_EXPIRED )) {
300+ npcx_power_console_is_in_use_refresh ();
301+ }
302+ }
303+
288304/* UART driver registration */
289305static const struct uart_driver_api uart_npcx_driver_api = {
290306 .poll_in = uart_npcx_poll_in ,
@@ -311,7 +327,7 @@ static const struct uart_driver_api uart_npcx_driver_api = {
311327static int uart_npcx_init (const struct device * dev )
312328{
313329 const struct uart_npcx_config * const config = DRV_CONFIG (dev );
314- const struct uart_npcx_data * const data = DRV_DATA (dev );
330+ struct uart_npcx_data * const data = DRV_DATA (dev );
315331 struct uart_reg * const inst = HAL_INSTANCE (dev );
316332 const struct device * const clk_dev =
317333 device_get_binding (NPCX_CLK_CTRL_NAME );
@@ -366,17 +382,22 @@ static int uart_npcx_init(const struct device *dev)
366382 config -> uconf .irq_config_func (dev );
367383#endif
368384
369- #if defined(CONFIG_PM )
370- /*
371- * Configure the UART wake-up event triggered from a falling edge
372- * on CR_SIN pin. No need for callback function.
373- */
374- npcx_miwu_interrupt_configure (& config -> uart_rx_wui ,
375- NPCX_MIWU_MODE_EDGE , NPCX_MIWU_TRIG_LOW );
385+ if (IS_ENABLED (CONFIG_PM )) {
386+ /* Initialize a miwu device input and its callback function */
387+ npcx_miwu_init_dev_callback (& data -> uart_rx_cb ,
388+ & config -> uart_rx_wui ,
389+ uart_npcx_rx_wk_isr , dev );
390+ npcx_miwu_manage_dev_callback (& data -> uart_rx_cb , true);
391+ /*
392+ * Configure the UART wake-up event triggered from a falling
393+ * edge on CR_SIN pin. No need for callback function.
394+ */
395+ npcx_miwu_interrupt_configure (& config -> uart_rx_wui ,
396+ NPCX_MIWU_MODE_EDGE , NPCX_MIWU_TRIG_LOW );
376397
377- /* Enable irq of interrupt-input module */
378- npcx_miwu_irq_enable (& config -> uart_rx_wui );
379- #endif
398+ /* Enable irq of interrupt-input module */
399+ npcx_miwu_irq_enable (& config -> uart_rx_wui );
400+ }
380401
381402 /* Configure pin-mux for uart device */
382403 npcx_pinctrl_mux_configure (config -> alts_list , config -> alts_size , 1 );
0 commit comments