zephyr/soc/arm/nuvoton_npcx/common/reg/reg_def.h

124 lines
3.9 KiB
C
Raw Normal View History

/*
* Copyright (c) 2020 Nuvoton Technology Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _NUVOTON_NPCX_REG_DEF_H
#define _NUVOTON_NPCX_REG_DEF_H
/*
* 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
#endif /* _NUVOTON_NPCX_REG_DEF_H */