2020-06-24 19:13:43 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Nuvoton Technology Corporation.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NUVOTON_NPCX_REG_DEF_H
|
|
|
|
#define _NUVOTON_NPCX_REG_DEF_H
|
|
|
|
|
2020-07-02 15:44:38 +08:00
|
|
|
/*
|
|
|
|
* NPCX register structure size/offset checking macro function to mitigate
|
|
|
|
* the risk of unexpected compiling results. All addresses of NPCX registers
|
|
|
|
* must meet the alignment requirement of cortex-m4.
|
|
|
|
* DO NOT use 'packed' attribute if module contains different length ie.
|
|
|
|
* 8/16/32 bits registers.
|
|
|
|
*/
|
|
|
|
#define NPCX_REG_SIZE_CHECK(reg_def, size) \
|
|
|
|
BUILD_ASSERT(sizeof(struct reg_def) == size, \
|
|
|
|
"Failed in size check of register structure!")
|
|
|
|
#define NPCX_REG_OFFSET_CHECK(reg_def, member, offset) \
|
|
|
|
BUILD_ASSERT(offsetof(struct reg_def, member) == offset, \
|
|
|
|
"Failed in offset check of register structure member!")
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Core Domain Clock Generator (CDCG) device registers
|
|
|
|
*/
|
|
|
|
struct cdcg_reg_t {
|
|
|
|
/* High Frequency Clock Generator (HFCG) registers */
|
|
|
|
/* 0x000: HFCG Control */
|
|
|
|
volatile uint8_t HFCGCTRL;
|
|
|
|
volatile uint8_t reserved1;
|
|
|
|
/* 0x002: HFCG M Low Byte Value */
|
|
|
|
volatile uint8_t HFCGML;
|
|
|
|
volatile uint8_t reserved2;
|
|
|
|
/* 0x004: HFCG M High Byte Value */
|
|
|
|
volatile uint8_t HFCGMH;
|
|
|
|
volatile uint8_t reserved3;
|
|
|
|
/* 0x006: HFCG N Value */
|
|
|
|
volatile uint8_t HFCGN;
|
|
|
|
volatile uint8_t reserved4;
|
|
|
|
/* 0x008: HFCG Prescaler */
|
|
|
|
volatile uint8_t HFCGP;
|
|
|
|
volatile uint8_t reserved5[7];
|
|
|
|
/* 0x010: HFCG Bus Clock Dividers */
|
|
|
|
volatile uint8_t HFCBCD;
|
|
|
|
volatile uint8_t reserved6;
|
|
|
|
/* 0x012: HFCG Bus Clock Dividers */
|
|
|
|
volatile uint8_t HFCBCD1;
|
|
|
|
volatile uint8_t reserved7;
|
|
|
|
/* 0x014: HFCG Bus Clock Dividers */
|
|
|
|
volatile uint8_t HFCBCD2;
|
|
|
|
volatile uint8_t reserved8[235];
|
|
|
|
|
|
|
|
/* Low Frequency Clock Generator (LFCG) registers */
|
|
|
|
/* 0x100: LFCG Control */
|
|
|
|
volatile uint8_t LFCGCTL;
|
|
|
|
volatile uint8_t reserved9;
|
|
|
|
/* 0x102: High-Frequency Reference Divisor I */
|
|
|
|
volatile uint16_t HFRDI;
|
|
|
|
/* 0x104: High-Frequency Reference Divisor F */
|
|
|
|
volatile uint16_t HFRDF;
|
|
|
|
/* 0x106: FRCLK Clock Divisor */
|
|
|
|
volatile uint16_t FRCDIV;
|
|
|
|
/* 0x108: Divisor Correction Value 1 */
|
|
|
|
volatile uint16_t DIVCOR1;
|
|
|
|
/* 0x10A: Divisor Correction Value 2 */
|
|
|
|
volatile uint16_t DIVCOR2;
|
|
|
|
volatile uint8_t reserved10[8];
|
|
|
|
/* 0x114: LFCG Control 2 */
|
|
|
|
volatile uint8_t LFCGCTL2;
|
|
|
|
volatile uint8_t reserved11;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* CDCG register fields */
|
|
|
|
#define NPCX_HFCGCTRL_LOAD 0
|
|
|
|
#define NPCX_HFCGCTRL_LOCK 2
|
|
|
|
#define NPCX_HFCGCTRL_CLK_CHNG 7
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power Management Controller (PMC) device registers
|
|
|
|
*/
|
|
|
|
struct pmc_reg_t {
|
|
|
|
/* 0x000: Power Management Controller */
|
|
|
|
volatile uint8_t PMCSR;
|
|
|
|
volatile uint8_t reserved1[2];
|
|
|
|
/* 0x003: Enable in Sleep Control */
|
|
|
|
volatile uint8_t ENIDL_CTL;
|
|
|
|
/* 0x004: Disable in Idle Control */
|
|
|
|
volatile uint8_t DISIDL_CTL;
|
|
|
|
/* 0x005: Disable in Idle Control 1 */
|
|
|
|
volatile uint8_t DISIDL_CTL1;
|
|
|
|
volatile uint8_t reserved2[2];
|
|
|
|
/* 0x008 - 0D: Power-Down Control 1 - 6 */
|
|
|
|
volatile uint8_t PWDWN_CTL1[6];
|
|
|
|
volatile uint8_t reserved3[18];
|
|
|
|
/* 0x020 - 21: Power-Down Control 1 - 2 */
|
|
|
|
volatile uint8_t RAM_PD[2];
|
|
|
|
volatile uint8_t reserved4[2];
|
|
|
|
/* 0x024: Power-Down Control 7 */
|
|
|
|
volatile uint8_t PWDWN_CTL7[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* PMC multi-registers */
|
|
|
|
#define NPCX_PWDWN_CTL_OFFSET(n) (((n) < 6) ? (0x008 + n) : (0x024 + (n - 6)))
|
|
|
|
#define NPCX_PWDWN_CTL(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_PWDWN_CTL_OFFSET(n)))
|
|
|
|
|
|
|
|
/* PMC register fields */
|
|
|
|
#define NPCX_PMCSR_DI_INSTW 0
|
|
|
|
#define NPCX_PMCSR_DHF 1
|
|
|
|
#define NPCX_PMCSR_IDLE 2
|
|
|
|
#define NPCX_PMCSR_NWBI 3
|
|
|
|
#define NPCX_PMCSR_OHFC 6
|
|
|
|
#define NPCX_PMCSR_OLFC 7
|
|
|
|
#define NPCX_DISIDL_CTL_RAM_DID 5
|
|
|
|
#define NPCX_ENIDL_CTL_ADC_LFSL 7
|
|
|
|
#define NPCX_ENIDL_CTL_LP_WK_CTL 6
|
|
|
|
#define NPCX_ENIDL_CTL_PECI_ENI 2
|
|
|
|
#define NPCX_ENIDL_CTL_ADC_ACC_DIS 1
|
|
|
|
|
2020-07-02 17:34:21 +08:00
|
|
|
/*
|
|
|
|
* System Configuration (SCFG) device registers
|
|
|
|
*/
|
|
|
|
struct scfg_reg_t {
|
|
|
|
/* 0x000: Device Control */
|
|
|
|
volatile uint8_t DEVCNT;
|
|
|
|
/* 0x001: Straps Status */
|
|
|
|
volatile uint8_t STRPST;
|
|
|
|
/* 0x002: Reset Control and Status */
|
|
|
|
volatile uint8_t RSTCTL;
|
|
|
|
volatile uint8_t reserved1[3];
|
|
|
|
/* 0x006: Device Control 4 */
|
|
|
|
volatile uint8_t DEV_CTL4;
|
|
|
|
volatile uint8_t reserved2[9];
|
|
|
|
/* 0x010 - 1F: Device Alternate Function 0 - F */
|
|
|
|
volatile uint8_t DEVALT0[16];
|
|
|
|
volatile uint8_t reserved3[6];
|
|
|
|
/* 0x026: Low-Voltage GPIO Pins Control 5 */
|
|
|
|
volatile uint8_t LV_GPIO_CTL5[1];
|
|
|
|
volatile uint8_t reserved4;
|
|
|
|
/* 0x028: Pull-Up/Pull-Down Enable 0 */
|
|
|
|
volatile uint8_t PUPD_EN0;
|
|
|
|
/* 0x029: Pull-Up/Pull-Down Enable 1 */
|
|
|
|
volatile uint8_t PUPD_EN1;
|
|
|
|
/* 0x02A - 2E: Low-Voltage GPIO Pins Control 0 - 4 */
|
|
|
|
volatile uint8_t LV_GPIO_CTL0[5];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* SCFG multi-registers */
|
|
|
|
#define NPCX_DEVALT_OFFSET(n) (0x010 + (n))
|
|
|
|
#define NPCX_DEVALT(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_DEVALT_OFFSET(n)))
|
|
|
|
|
|
|
|
#define NPCX_LV_GPIO_CTL_OFFSET(n) (((n) < 5) ? (0x02A + (n)) \
|
|
|
|
: (0x026 + (n - 5)))
|
|
|
|
#define NPCX_LV_GPIO_CTL(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_LV_GPIO_CTL_OFFSET(n)))
|
|
|
|
|
|
|
|
/* SCFG register fields */
|
|
|
|
#define NPCX_DEVCNT_F_SPI_TRIS 6
|
|
|
|
#define NPCX_DEVCNT_HIF_TYP_SEL_FIELD FIELD(2, 2)
|
|
|
|
#define NPCX_DEVCNT_JEN1_HEN 5
|
|
|
|
#define NPCX_DEVCNT_JEN0_HEN 4
|
|
|
|
#define NPCX_STRPST_TRIST 1
|
|
|
|
#define NPCX_STRPST_TEST 2
|
|
|
|
#define NPCX_STRPST_JEN1 4
|
|
|
|
#define NPCX_STRPST_JEN0 5
|
|
|
|
#define NPCX_STRPST_SPI_COMP 7
|
|
|
|
#define NPCX_RSTCTL_VCC1_RST_STS 0
|
|
|
|
#define NPCX_RSTCTL_DBGRST_STS 1
|
|
|
|
#define NPCX_RSTCTL_VCC1_RST_SCRATCH 3
|
|
|
|
#define NPCX_RSTCTL_LRESET_PLTRST_MODE 5
|
|
|
|
#define NPCX_RSTCTL_HIPRST_MODE 6
|
|
|
|
#define NPCX_DEV_CTL4_F_SPI_SLLK 2
|
|
|
|
#define NPCX_DEV_CTL4_SPI_SP_SEL 4
|
|
|
|
#define NPCX_DEV_CTL4_WP_IF 5
|
|
|
|
#define NPCX_DEV_CTL4_VCC1_RST_LK 6
|
|
|
|
#define NPCX_DEVPU0_I2C0_0_PUE 0
|
|
|
|
#define NPCX_DEVPU0_I2C0_1_PUE 1
|
|
|
|
#define NPCX_DEVPU0_I2C1_0_PUE 2
|
|
|
|
#define NPCX_DEVPU0_I2C2_0_PUE 4
|
|
|
|
#define NPCX_DEVPU0_I2C3_0_PUE 6
|
|
|
|
#define NPCX_DEVPU1_F_SPI_PUD_EN 7
|
|
|
|
|
2020-07-02 18:15:14 +08:00
|
|
|
/*
|
|
|
|
* Universal Asynchronous Receiver-Transmitter (UART) device registers
|
|
|
|
*/
|
|
|
|
struct uart_reg_t {
|
|
|
|
/* 0x000: Transmit Data Buffer */
|
|
|
|
volatile uint8_t UTBUF;
|
|
|
|
volatile uint8_t reserved1;
|
|
|
|
/* 0x002: Receive Data Buffer */
|
|
|
|
volatile uint8_t URBUF;
|
|
|
|
volatile uint8_t reserved2;
|
|
|
|
/* 0x004: Interrupt Control */
|
|
|
|
volatile uint8_t UICTRL;
|
|
|
|
volatile uint8_t reserved3;
|
|
|
|
/* 0x006: Status */
|
|
|
|
volatile uint8_t USTAT;
|
|
|
|
volatile uint8_t reserved4;
|
|
|
|
/* 0x008: Frame Select */
|
|
|
|
volatile uint8_t UFRS;
|
|
|
|
volatile uint8_t reserved5;
|
|
|
|
/* 0x00A: Mode Select */
|
|
|
|
volatile uint8_t UMDSL;
|
|
|
|
volatile uint8_t reserved6;
|
|
|
|
/* 0x00C: Baud Rate Divisor */
|
|
|
|
volatile uint8_t UBAUD;
|
|
|
|
volatile uint8_t reserved7;
|
|
|
|
/* 0x00E: Baud Rate Prescaler */
|
|
|
|
volatile uint8_t UPSR;
|
|
|
|
volatile uint8_t reserved8[17];
|
|
|
|
/* 0x020: FIFO Mode Transmit Status */
|
|
|
|
volatile uint8_t UFTSTS;
|
|
|
|
volatile uint8_t reserved9;
|
|
|
|
/* 0x022: FIFO Mode Receive Status */
|
|
|
|
volatile uint8_t UFRSTS;
|
|
|
|
volatile uint8_t reserved10;
|
|
|
|
/* 0x024: FIFO Mode Transmit Control */
|
|
|
|
volatile uint8_t UFTCTL;
|
|
|
|
volatile uint8_t reserved11;
|
|
|
|
/* 0x026: FIFO Mode Receive Control */
|
|
|
|
volatile uint8_t UFRCTL;
|
|
|
|
};
|
2020-06-24 19:13:43 +08:00
|
|
|
|
2020-07-02 18:15:14 +08:00
|
|
|
/* UART register fields */
|
|
|
|
#define NPCX_UICTRL_TBE 0
|
|
|
|
#define NPCX_UICTRL_RBF 1
|
|
|
|
#define NPCX_UICTRL_ETI 5
|
|
|
|
#define NPCX_UICTRL_ERI 6
|
|
|
|
#define NPCX_UICTRL_EEI 7
|
|
|
|
#define NPCX_USTAT_PE 0
|
|
|
|
#define NPCX_USTAT_FE 1
|
|
|
|
#define NPCX_USTAT_DOE 2
|
|
|
|
#define NPCX_USTAT_ERR 3
|
|
|
|
#define NPCX_USTAT_BKD 4
|
|
|
|
#define NPCX_USTAT_RB9 5
|
|
|
|
#define NPCX_USTAT_XMIP 6
|
|
|
|
#define NPCX_UFRS_CHAR_FIELD FIELD(0, 2)
|
|
|
|
#define NPCX_UFRS_STP 2
|
|
|
|
#define NPCX_UFRS_XB9 3
|
|
|
|
#define NPCX_UFRS_PSEL_FIELD FIELD(4, 2)
|
|
|
|
#define NPCX_UFRS_PEN 6
|
|
|
|
#define NPCX_UMDSL_FIFO_MD 0
|
|
|
|
#define NPCX_UFTSTS_TEMPTY_LVL FIELD(0, 5)
|
|
|
|
#define NPCX_UFTSTS_TEMPTY_LVL_STS 5
|
|
|
|
#define NPCX_UFTSTS_TFIFO_EMPTY_STS 6
|
|
|
|
#define NPCX_UFTSTS_NXMIP 7
|
|
|
|
#define NPCX_UFRSTS_RFULL_LVL_STS 5
|
|
|
|
#define NPCX_UFRSTS_RFIFO_NEMPTY_STS 6
|
|
|
|
#define NPCX_UFRSTS_ERR 7
|
|
|
|
#define NPCX_UFTCTL_TEMPTY_LVL_SEL FIELD(0, 5)
|
|
|
|
#define NPCX_UFTCTL_TEMPTY_LVL_EN 5
|
|
|
|
#define NPCX_UFTCTL_TEMPTY_EN 6
|
|
|
|
#define NPCX_UFTCTL_NXMIPEN 7
|
|
|
|
#define NPCX_UFRCTL_RFULL_LVL_SEL FIELD(0, 5)
|
|
|
|
#define NPCX_UFRCTL_RFULL_LVL_EN 5
|
|
|
|
#define NPCX_UFRCTL_RNEMPTY_EN 6
|
|
|
|
#define NPCX_UFRCTL_ERR_EN 7
|
2020-06-24 19:13:43 +08:00
|
|
|
|
driver: intc: add MIWU driver support in NPCX series.
The device Multi-Input Wake-Up Unit (MIWU) supports the embedded
controller (EC) to exit 'Sleep' or 'Deep Sleep' power state which allows
chip has better power consumption. Also, it provides signal conditioning
such as 'Level' and 'Edge' trigger type and grouping of external
interrupt sources of NVIC. The NPCX series has three identical MIWU
modules: MIWU0, MIWU1, MIWU2. Together, they support a total of over 140
internal and/or external wake-up sources.
In this CL, we use device tree files to present the relationship bewteen
MIWU and the other devices in different npcx series. For npcx7 series,
it include:
1. npcx7-miwus-int-map.dtsi: it presents relationship between MIWU group
and NVIC interrupt in npcx7. Please notice it isn't 1-to-1 mapping.
2. npcx7-miwus-wui-map.dtsi: it presents relationship between input of
MIWU and its source device such as gpio, timer, eSPI VWs and so on.
This CL also includes:
1. Add MIWU device tree declarations.
2. MIWU api function declarations and implementation to configure signal
conditions and callback function mechanism. They can be be classified
into two types. One is for GPIO which connects original gpio callback
implemetation and the other is for generic devices such as timer,
eSPI, and so on.
Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-08-13 18:15:25 +08:00
|
|
|
/*
|
|
|
|
* Multi-Input Wake-Up Unit (MIWU) device registers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* MIWU multi-registers */
|
|
|
|
#define NPCX_WKEDG_OFFSET(n) (0x000 + ((n) * 2L) + ((n) < 5 ? 0 : 0x1E))
|
|
|
|
#define NPCX_WKAEDG_OFFSET(n) (0x001 + ((n) * 2L) + ((n) < 5 ? 0 : 0x1E))
|
|
|
|
#define NPCX_WKPND_OFFSET(n) (0x00A + ((n) * 4L) + ((n) < 5 ? 0 : 0x10))
|
|
|
|
#define NPCX_WKPCL_OFFSET(n) (0x00C + ((n) * 4L) + ((n) < 5 ? 0 : 0x10))
|
|
|
|
#define NPCX_WKEN_OFFSET(n) (0x01E + ((n) * 2L) + ((n) < 5 ? 0 : 0x12))
|
|
|
|
#define NPCX_WKINEN_OFFSET(n) (0x01F + ((n) * 2L) + ((n) < 5 ? 0 : 0x12))
|
|
|
|
#define NPCX_WKMOD_OFFSET(n) (0x070 + (n))
|
|
|
|
|
|
|
|
#define NPCX_WKEDG(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKEDG_OFFSET(n)))
|
|
|
|
#define NPCX_WKAEDG(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKAEDG_OFFSET(n)))
|
|
|
|
#define NPCX_WKPND(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKPND_OFFSET(n)))
|
|
|
|
#define NPCX_WKPCL(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKPCL_OFFSET(n)))
|
|
|
|
#define NPCX_WKEN(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKEN_OFFSET(n)))
|
|
|
|
#define NPCX_WKINEN(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKINEN_OFFSET(n)))
|
|
|
|
#define NPCX_WKMOD(base, n) (*(volatile uint8_t *)(base + \
|
|
|
|
NPCX_WKMOD_OFFSET(n)))
|
|
|
|
|
2020-07-02 18:15:14 +08:00
|
|
|
#endif /* _NUVOTON_NPCX_REG_DEF_H */
|