driver: uart: add wake-up support for uart device.
This CL configures the UART wake-up event triggered from a falling edge (START condition) on CR_SIN pin. It also includes: 1. Introduce wui_maps property in yaml file to present relationship between Wake-Up Input (WUI) and UART device. 2. Implement wake-up mechanism by MIWU api functions. Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
This commit is contained in:
parent
6deb68a517
commit
288e35ab1a
3 changed files with 30 additions and 0 deletions
|
@ -7,10 +7,12 @@
|
||||||
#define DT_DRV_COMPAT nuvoton_npcx_uart
|
#define DT_DRV_COMPAT nuvoton_npcx_uart
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <drivers/gpio.h>
|
||||||
#include <drivers/uart.h>
|
#include <drivers/uart.h>
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
#include "soc_miwu.h"
|
||||||
|
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_REGISTER(uart_npcx, LOG_LEVEL_ERR);
|
LOG_MODULE_REGISTER(uart_npcx, LOG_LEVEL_ERR);
|
||||||
|
@ -20,6 +22,8 @@ struct uart_npcx_config {
|
||||||
struct uart_device_config uconf;
|
struct uart_device_config uconf;
|
||||||
/* clock configuration */
|
/* clock configuration */
|
||||||
struct npcx_clk_cfg clk_cfg;
|
struct npcx_clk_cfg clk_cfg;
|
||||||
|
/* int-mux configuration */
|
||||||
|
const struct npcx_wui wui_map;
|
||||||
/* pinmux configuration */
|
/* pinmux configuration */
|
||||||
const uint8_t alts_size;
|
const uint8_t alts_size;
|
||||||
const struct npcx_alt *alts_list;
|
const struct npcx_alt *alts_list;
|
||||||
|
@ -334,6 +338,19 @@ static int uart_npcx_init(struct device *dev)
|
||||||
config->uconf.irq_config_func(dev);
|
config->uconf.irq_config_func(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYS_POWER_DEEP_SLEEP_STATES)
|
||||||
|
/*
|
||||||
|
* Configure the UART wake-up event triggered from a falling edge
|
||||||
|
* on CR_SIN pin. No need for callback function.
|
||||||
|
*/
|
||||||
|
soc_miwu_interrupt_configure(&config->wui_map,
|
||||||
|
NPCX_MIWU_MODE_EDGE, NPCX_MIWU_TRIG_LOW);
|
||||||
|
|
||||||
|
/* Enable irq of interrupt-input module */
|
||||||
|
soc_miwu_irq_enable(&config->wui_map);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Configure pin-mux for uart device */
|
/* Configure pin-mux for uart device */
|
||||||
soc_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
|
soc_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
interrupts = <33 0>;
|
interrupts = <33 0>;
|
||||||
clocks = <&pcc NPCX_CLOCK_BUS_APB2 NPCX_PWDWN_CTL1 4>;
|
clocks = <&pcc NPCX_CLOCK_BUS_APB2 NPCX_PWDWN_CTL1 4>;
|
||||||
pinctrl = <&alta_uart1_sl1>; /* PIN10.11 */
|
pinctrl = <&alta_uart1_sl1>; /* PIN10.11 */
|
||||||
|
wui_map = <&wui_cr_sin1>;
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
label = "UART_1";
|
label = "UART_1";
|
||||||
};
|
};
|
||||||
|
@ -82,6 +83,7 @@
|
||||||
interrupts = <32 0>;
|
interrupts = <32 0>;
|
||||||
clocks = <&pcc NPCX_CLOCK_BUS_APB2 NPCX_PWDWN_CTL7 6>;
|
clocks = <&pcc NPCX_CLOCK_BUS_APB2 NPCX_PWDWN_CTL7 6>;
|
||||||
pinctrl = <&alta_uart2_sl>; /* PIN75.86 */
|
pinctrl = <&alta_uart2_sl>; /* PIN75.86 */
|
||||||
|
wui_map = <&wui_cr_sin2>;
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
label = "UART_2";
|
label = "UART_2";
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,3 +16,14 @@ properties:
|
||||||
type: phandles
|
type: phandles
|
||||||
required: true
|
required: true
|
||||||
description: configurations of pinmux controllers
|
description: configurations of pinmux controllers
|
||||||
|
wui_map:
|
||||||
|
type: phandle
|
||||||
|
required: true
|
||||||
|
description: mapping item between wui and source device
|
||||||
|
description: |
|
||||||
|
Mapping table between Wake-Up Input (WUI) and its source device.
|
||||||
|
|
||||||
|
For example the WUI mapping on NPCX7 UART1 would be
|
||||||
|
wui_map = <&wui_cr_sin1>;
|
||||||
|
|
||||||
|
required: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue