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-06-24 19:13:43 +08:00
|
|
|
#endif /* _NUVOTON_NPCX_REG_DEF_H */
|
|
|
|
|
|
|
|
|