use kernel::utilities::registers::ReadWrite;
use kernel::utilities::registers::{register_bitfields, register_structs};
pub const PWRMGR_PARAM_NUM_WKUPS: u32 = 6;
pub const PWRMGR_PARAM_SYSRST_CTRL_AON_WKUP_REQ_IDX: u32 = 0;
pub const PWRMGR_PARAM_ADC_CTRL_AON_WKUP_REQ_IDX: u32 = 1;
pub const PWRMGR_PARAM_PINMUX_AON_PIN_WKUP_REQ_IDX: u32 = 2;
pub const PWRMGR_PARAM_PINMUX_AON_USB_WKUP_REQ_IDX: u32 = 3;
pub const PWRMGR_PARAM_AON_TIMER_AON_WKUP_REQ_IDX: u32 = 4;
pub const PWRMGR_PARAM_SENSOR_CTRL_WKUP_REQ_IDX: u32 = 5;
pub const PWRMGR_PARAM_NUM_RST_REQS: u32 = 2;
pub const PWRMGR_PARAM_NUM_INT_RST_REQS: u32 = 2;
pub const PWRMGR_PARAM_NUM_DEBUG_RST_REQS: u32 = 1;
pub const PWRMGR_PARAM_RESET_MAIN_PWR_IDX: u32 = 2;
pub const PWRMGR_PARAM_RESET_ESC_IDX: u32 = 3;
pub const PWRMGR_PARAM_RESET_NDM_IDX: u32 = 4;
pub const PWRMGR_PARAM_NUM_ALERTS: u32 = 1;
pub const PWRMGR_PARAM_REG_WIDTH: u32 = 32;
register_structs! {
pub PwrmgrRegisters {
(0x0000 => pub(crate) intr_state: ReadWrite<u32, INTR::Register>),
(0x0004 => pub(crate) intr_enable: ReadWrite<u32, INTR::Register>),
(0x0008 => pub(crate) intr_test: ReadWrite<u32, INTR::Register>),
(0x000c => pub(crate) alert_test: ReadWrite<u32, ALERT_TEST::Register>),
(0x0010 => pub(crate) ctrl_cfg_regwen: ReadWrite<u32, CTRL_CFG_REGWEN::Register>),
(0x0014 => pub(crate) control: ReadWrite<u32, CONTROL::Register>),
(0x0018 => pub(crate) cfg_cdc_sync: ReadWrite<u32, CFG_CDC_SYNC::Register>),
(0x001c => pub(crate) wakeup_en_regwen: ReadWrite<u32, WAKEUP_EN_REGWEN::Register>),
(0x0020 => pub(crate) wakeup_en: [ReadWrite<u32, WAKEUP_EN::Register>; 1]),
(0x0024 => pub(crate) wake_status: [ReadWrite<u32, WAKE_STATUS::Register>; 1]),
(0x0028 => pub(crate) reset_en_regwen: ReadWrite<u32, RESET_EN_REGWEN::Register>),
(0x002c => pub(crate) reset_en: [ReadWrite<u32, RESET_EN::Register>; 1]),
(0x0030 => pub(crate) reset_status: [ReadWrite<u32, RESET_STATUS::Register>; 1]),
(0x0034 => pub(crate) escalate_reset_status: ReadWrite<u32, ESCALATE_RESET_STATUS::Register>),
(0x0038 => pub(crate) wake_info_capture_dis: ReadWrite<u32, WAKE_INFO_CAPTURE_DIS::Register>),
(0x003c => pub(crate) wake_info: ReadWrite<u32, WAKE_INFO::Register>),
(0x0040 => pub(crate) fault_status: ReadWrite<u32, FAULT_STATUS::Register>),
(0x0044 => @END),
}
}
register_bitfields![u32,
pub(crate) INTR [
WAKEUP OFFSET(0) NUMBITS(1) [],
],
pub(crate) ALERT_TEST [
FATAL_FAULT OFFSET(0) NUMBITS(1) [],
],
pub(crate) CTRL_CFG_REGWEN [
EN OFFSET(0) NUMBITS(1) [],
],
pub(crate) CONTROL [
LOW_POWER_HINT OFFSET(0) NUMBITS(1) [
NONE = 0,
LOW_POWER = 1,
],
CORE_CLK_EN OFFSET(4) NUMBITS(1) [
DISABLED = 0,
ENABLED = 1,
],
IO_CLK_EN OFFSET(5) NUMBITS(1) [
DISABLED = 0,
ENABLED = 1,
],
USB_CLK_EN_LP OFFSET(6) NUMBITS(1) [
DISABLED = 0,
ENABLED = 1,
],
USB_CLK_EN_ACTIVE OFFSET(7) NUMBITS(1) [
DISABLED = 0,
ENABLED = 1,
],
MAIN_PD_N OFFSET(8) NUMBITS(1) [
POWER_DOWN = 0,
POWER_UP = 1,
],
],
pub(crate) CFG_CDC_SYNC [
SYNC OFFSET(0) NUMBITS(1) [],
],
pub(crate) WAKEUP_EN_REGWEN [
EN OFFSET(0) NUMBITS(1) [],
],
pub(crate) WAKEUP_EN [
EN_0 OFFSET(0) NUMBITS(1) [],
EN_1 OFFSET(1) NUMBITS(1) [],
EN_2 OFFSET(2) NUMBITS(1) [],
EN_3 OFFSET(3) NUMBITS(1) [],
EN_4 OFFSET(4) NUMBITS(1) [],
EN_5 OFFSET(5) NUMBITS(1) [],
],
pub(crate) WAKE_STATUS [
VAL_0 OFFSET(0) NUMBITS(1) [],
VAL_1 OFFSET(1) NUMBITS(1) [],
VAL_2 OFFSET(2) NUMBITS(1) [],
VAL_3 OFFSET(3) NUMBITS(1) [],
VAL_4 OFFSET(4) NUMBITS(1) [],
VAL_5 OFFSET(5) NUMBITS(1) [],
],
pub(crate) RESET_EN_REGWEN [
EN OFFSET(0) NUMBITS(1) [],
],
pub(crate) RESET_EN [
EN_0 OFFSET(0) NUMBITS(1) [],
EN_1 OFFSET(1) NUMBITS(1) [],
],
pub(crate) RESET_STATUS [
VAL_0 OFFSET(0) NUMBITS(1) [],
VAL_1 OFFSET(1) NUMBITS(1) [],
],
pub(crate) ESCALATE_RESET_STATUS [
VAL OFFSET(0) NUMBITS(1) [],
],
pub(crate) WAKE_INFO_CAPTURE_DIS [
VAL OFFSET(0) NUMBITS(1) [],
],
pub(crate) WAKE_INFO [
REASONS OFFSET(0) NUMBITS(6) [],
FALL_THROUGH OFFSET(6) NUMBITS(1) [],
ABORT OFFSET(7) NUMBITS(1) [],
],
pub(crate) FAULT_STATUS [
REG_INTG_ERR OFFSET(0) NUMBITS(1) [],
ESC_TIMEOUT OFFSET(1) NUMBITS(1) [],
MAIN_PD_GLITCH OFFSET(2) NUMBITS(1) [],
],
];