#define PMU_HAS_SWI		0
#define PMU_HAS_DWI		1
#define PMU_HAS_LCM_LDO		1
#define PMU_HAS_REG_BANK	1
#define PMU_HAS_BIST_ADC	1
#define PMU_HAS_CHG_ABCC_FLAG	1
#define PMU_HAS_WLED		1

enum {
	kDIALOG_ADDR_R	= 0x79,
	kDIALOG_ADDR_W	= 0x78,
	kDIALOG_REG_BYTES	= 1,
};

enum {
	kDIALOG_EVENT_COUNT		= 10,
	kDIALOG_STATUS_COUNT		= 10,
	kDIALOG_HIBERNATE_COUNT		= 4,
	kDIALOG_CHIPID_COUNT		= 1,
	kDIALOG_FAULTLOG_COUNT		= 1,
	kDIALOG_GPIO_COUNT		= 16,
};

#include "dCommon.h"

enum {
	kDIALOG_BANK_COUNT		= 3,
    	kDIALOG_BANK0_SHARED_COUNT	= 0x59,
};

enum {
	// Register Bank 0

	kDIALOG_CHIP_ID			= 0x00,
	
	kDIALOG_EVENT_A			= 0x01,
	kDIALOG_EVENT_B			= 0x02,
	kDIALOG_EVENT_C			= 0x03,
	kDIALOG_EVENT_D			= 0x04,
	kDIALOG_EVENT_E			= 0x05,
	kDIALOG_EVENT_F			= 0x06,
	kDIALOG_EVENT_G			= 0x07,
	kDIALOG_EVENT_H			= 0x08,
	kDIALOG_EVENT_I			= 0x09,
	kDIALOG_EVENT_J			= 0x0a,
	
	kDIALOG_STATUS_A		= 0x0b,
	kDIALOG_STATUS_B		= 0x0c,
	kDIALOG_STATUS_C		= 0x0d,
	kDIALOG_STATUS_D		= 0x0e,
	kDIALOG_STATUS_E		= 0x0f,
	kDIALOG_STATUS_F		= 0x10,
	kDIALOG_STATUS_G		= 0x11,
	kDIALOG_STATUS_H		= 0x12,
	kDIALOG_STATUS_I		= 0x13,
	kDIALOG_STATUS_J		= 0x14,
	
	kDIALOG_IRQ_MASK_A		= 0x15,
	kDIALOG_IRQ_MASK_B		= 0x16,
	kDIALOG_IRQ_MASK_C		= 0x17,
	kDIALOG_IRQ_MASK_D		= 0x18,
	kDIALOG_IRQ_MASK_E		= 0x19,
	kDIALOG_IRQ_MASK_F		= 0x1a,
	kDIALOG_IRQ_MASK_G		= 0x1b,
	kDIALOG_IRQ_MASK_H		= 0x1c,
	kDIALOG_IRQ_MASK_I		= 0x1d,
	kDIALOG_IRQ_MASK_J		= 0x1e,
	
	kDIALOG_SYS_CONTROL		= 0x1f,
	kDIALOG_SYS_CONTROL2		= 0x20,
	
	kDIALOG_FAULT_LOG		= 0x21,
	kDIALOG_BANKSEL			= 0x22,
	
	kD1974_ACTIVE1			= 0x23,
	kD1974_ACTIVE2			= 0x24,
	kD1974_ACTIVE3			= 0x25,
	kDIALOG_LCM_ACTIVE		= kD1974_ACTIVE3,
	kD1974_ACTIVE4			= 0x26,
	kD1974_STANDBY1			= 0x27,
	kDIALOG_STANDBY			= kD1974_STANDBY1,
	kD1974_HIBERNATE1		= 0x28,
	kD1974_HIBERNATE2		= 0x29,
	kD1974_HIBERNATE3		= 0x2a,
	kD1974_HIBERNATE4		= 0x2b,
	
	kD1974_BUCK0			= 0x2c,
	kDIALOG_BUCK0			= kD1974_BUCK0,
	kD1974_BUCK2			= 0x2d,
	kDIALOG_BUCK2			= kD1974_BUCK2,
	kD1974_BUCK3			= 0x2e,
	kD1974_BUCK4			= 0x2f,
	kD1974_BUCK5			= 0x30,
	
	kD1974_LDO1			= 0x31,
	kD1974_LDO2			= 0x32,
	kD1974_LDO3			= 0x33,
	kD1974_LDO4			= 0x34,
	kD1974_LDO5			= 0x35,
	kD1974_LDO6			= 0x36,
	kD1974_LDO7			= 0x37,
	kD1974_LDO8			= 0x38,
	kD1974_LDO9			= 0x39,
	kD1974_LDO10			= 0x3a,
	kD1974_LDO11			= 0x3b,
	kD1974_LDO12			= 0x3c,
	
	kDIALOG_BUCK_DWI		= 0x3d,
	
	kDIALOG_CHARGE_BUCK_CONTROL	= 0x3e,
	
	kDIALOG_CHARGE_CONTROL_A	= 0x3f,
	kDIALOG_CHARGE_CONTROL_B	= 0x40,
	kDIALOG_CHARGE_CONTROL_C	= 0x41,
	kDIALOG_CHARGE_CONTROL_D	= 0x42,
	kDIALOG_CHARGE_TIME		= 0x43,
	kDIALOG_CHARGE_CONTROL_ICHG_BAT = kDIALOG_CHARGE_CONTROL_B,
	kDIALOG_CHARGE_CONTROL_HIB	= kDIALOG_CHARGE_CONTROL_A,
	kDIALOG_CHARGE_CONTROL_TIME	= kDIALOG_CHARGE_CONTROL_D,
	kDIALOG_CHARGE_CONTROL_EN	= kDIALOG_CHARGE_CONTROL_C,
	kDIALOG_OTP_ISET_BAT		= kDIALOG_CHARGE_CONTROL_A,  // not a real OTP register
	
	kDIALOG_ADC_CONTROL		= 0x44,
	kDIALOG_ADC_LSB			= 0x45,
	kDIALOG_ADC_MSB			= 0x46,
	kDIALOG_ICHG_AVG		= 0x47,
		
	kDIALOG_TBAT_0			= 0x4c,
	kDIALOG_ICHG_TBAT_0		= 0x4d,
	kDIALOG_TBAT_1			= 0x4e,
	kDIALOG_ICHG_TBAT_1		= 0x4f,
	kDIALOG_TBAT_2			= 0x50,
	kDIALOG_ICHG_TBAT_2		= 0x51,
	kDIALOG_TBAT_3			= 0x52,
	kDIALOG_ICHG_TBAT_3		= 0x53,
	kDIALOG_TBAT_4			= 0x54,
	kDIALOG_ICHG_TBAT_4		= 0x55,
	kDIALOG_TBAT_MAX		= 0x56,
	kDIALOG_ICHG_TBAT_NUM		= 5,
	
	kDIALOG_T_OFFSET_MSB		= 0x57,
	kDIALOG_T_OFFSET_LSB		= 0x58,
	kD1974_IVBUS_GAIN		= 0x59,
	
	kDIALOG_RTC_ALARM_A		= 0x5a,
	kDIALOG_RTC_ALARM_B		= 0x5b,
	kDIALOG_RTC_ALARM_C		= 0x5c,
	kDIALOG_RTC_ALARM_D		= 0x5d,
	kDIALOG_RTC_CONTROL		= 0x5e,
	kDIALOG_RTC_TIMEZONE		= 0x5f,
	kDIALOG_UPCOUNT_A		= 0x60,
	kDIALOG_UPCOUNT_B		= 0x61,
	kDIALOG_UPCOUNT_C		= 0x62,
	kDIALOG_UPCOUNT_D		= 0x63,
	
	kD1974_SYS_GPIO_1		= 0x64,
	kDIALOG_SYS_GPIO_REG_START	= kD1974_SYS_GPIO_1,
	kD1974_SYS_GPIO_2		= 0x65,
	kD1974_SYS_GPIO_3		= 0x66,
	kD1974_SYS_GPIO_4		= 0x67,
	kD1974_SYS_GPIO_5		= 0x68,
	kD1974_SYS_GPIO_6		= 0x69,
	kD1974_SYS_GPIO_7		= 0x6a,
	kD1974_SYS_GPIO_8		= 0x6b,
	kD1974_SYS_GPIO_9		= 0x6c,
	kD1974_SYS_GPIO_10		= 0x6d,
	kD1974_SYS_GPIO_11		= 0x6e,
	kD1974_SYS_GPIO_12		= 0x6f,
	kD1974_SYS_GPIO_13		= 0x70,
	kD1974_SYS_GPIO_14		= 0x71,
	kD1974_SYS_GPIO_15		= 0x72,
	kD1974_SYS_GPIO_16		= 0x73,
	kD1974_SYS_GPIO_17		= 0x74,
	
	kD1974_SYS_GPIO_DEB1		= 0x75,
	kD1974_SYS_GPIO_DEB2		= 0x76,
	kD1974_SYS_GPIO_DEB3		= 0x77,
	kD1974_SYS_GPIO_DEB4		= 0x78,
	kD1974_SYS_GPIO_DEB5		= 0x79,
	kD1974_SYS_GPIO_DEB6		= 0x7a,
	kD1974_SYS_GPIO_DEB7		= 0x7b,
	kD1974_SYS_GPIO_DEB8		= 0x7c,
	kD1974_SYS_GPIO_DEB9		= 0x7d,
	
	kDIALOG_LDO_CONTROL		= 0x7e,
	
	kD1974_BUTTON1			= 0x7f,
	kD1974_BUTTON2			= 0x80,
	kD1974_BUTTON3			= 0x81,
	kDIALOG_SYS_CONFIG		= 0x82,
	
	kD1974_LCM_CONTROL1		= 0x83,
	kD1974_LCM_CONTROL2		= 0x84,
	kD1974_LCM_CONTROL3		= 0x85,
	kD1974_LCM_BST_CONTROL		= 0x86,
	kDIALOG_LCM_BOOST		= kD1974_LCM_BST_CONTROL,
	
	kD1974_BUCK3_HIB		= 0xa1,
	kD1974_BUCK4_HIB		= 0xa2,
	kD1974_GPIO_SOFTHIB1		= 0xa3,
	kD1974_GPIO_SOFTHIB2		= 0xa4,
	kD1974_GPIO_SOFTHIB3		= 0xa5,
	kDIALOG_BUTTON_DBL		= 0xa6,
	
	kDIALOG_MEMBYTE0		= 0xa7,
	kDIALOG_MEMBYTE_LAST		= 0xce,
	
	kDIALOG_WLED_ISET		= 0xd3,
	kDIALOG_WLED_ISET2		= 0xd4,
	kDIALOG_WLED_CONTROL		= 0xd5,
	kDIALOG_WLED_CONTROL2		= 0xd6,
	kDIALOG_WLED_DWI_CONTROL	= kDIALOG_WLED_CONTROL2,
	kDIALOG_WLED_OPTIONS		= kDIALOG_WLED_CONTROL2,

	// Register Bank 1
	
	kDIALOG_APP_TMUX		= 0x162,
	kDIALOG_BIST_ADC_CTRL		= 0x163,
	kDIALOG_BIST_ADC_LSB		= 0x164,
	kDIALOG_BIST_ADC_MSB		= 0x165,
	kDIALOG_BIST_ADC0		= 0x166,

	kDIALOG_BUCK_CTRL1		= 0x1b3,
    
	kD1974_IVBUS_OFFS		= 0x1fc,
	
	// Bank 2 Test Registers
	kD1974_TEST_MODE		= 0x2d0,
};

enum {
	kD1974_CHIP_ID_MRC_MASK		= (0xf << 0),
	kD1974_CHIP_ID_MRC_A0		= (0 << 0),
	kD1974_CHIP_ID_MRC_A1		= (1 << 0),
	kD1974_CHIP_ID_TRC_MASK		= (0xf << 4),
	kD1974_CHIP_ID_TRC_AK		= (0xa << 4),
};

enum {
	kD1974_EVENT_A_BUTTON1		= (1 << 0),
	kD1974_EVENT_A_BUTTON2		= (1 << 1),
	kD1974_EVENT_A_BUTTON3		= (1 << 2),
	kD1974_EVENT_A_VCENTER_DET	= (1 << 3),
	kD1974_EVENT_A_FW_DET		= (1 << 4),
	kD1974_EVENT_A_ACC_DET		= (1 << 5),
	kD1974_EVENT_A_VBUS_EXT_DET	= (1 << 6),
	kD1974_EVENT_A_VDD_LOW		= (1 << 7),
};

// EVENT_B events are assumed volatile (lost over sleep/wake)
enum {
	kD1974_EVENT_B_CHG_PRE		= (1 << 1),
	kD1974_EVENT_B_CHG_FAST		= (1 << 2),
	kD1974_EVENT_B_CHG_END		= (1 << 3),
	kD1974_EVENT_B_TBAT		= (1 << 4),
	kD1974_EVENT_B_FW_OV		= (1 << 6),
	kDIALOG_EVENT_B_HIB		= (1 << 7),
};

enum {
	kD1974_EVENT_C_GPIO1		= (1 << 0),
	kD1974_EVENT_C_GPIO2		= (1 << 1),
	kD1974_EVENT_C_GPIO3		= (1 << 2),
	kD1974_EVENT_C_GPIO4		= (1 << 3),
	kD1974_EVENT_C_GPIO5		= (1 << 4),
	kD1974_EVENT_C_GPIO6		= (1 << 5),
	kD1974_EVENT_C_GPIO7		= (1 << 6),
	kD1974_EVENT_C_GPIO8		= (1 << 7),
};

enum {
	kD1974_EVENT_D_GPIO9		= (1 << 0),
	kD1974_EVENT_D_GPIO10		= (1 << 1),
	kD1974_EVENT_D_GPIO11		= (1 << 2),
	kD1974_EVENT_D_GPIO12		= (1 << 3),
	kD1974_EVENT_D_GPIO13		= (1 << 4),
	kD1974_EVENT_D_GPIO14		= (1 << 5),
	kD1974_EVENT_D_GPIO15		= (1 << 6),
	kD1974_EVENT_D_GPIO16		= (1 << 7),
};

enum {
	kD1974_EVENT_E_GPIO17		= (1 << 0),
	kD1974_EVENT_E_BTN1_DBL		= (1 << 3),
	kD1974_EVENT_E_BTN2_DBL		= (1 << 4),
	kD1974_EVENT_E_BTN3_DBL		= (1 << 5),
	kD1974_EVENT_E_CHG_BUCK_FLG	= (1 << 6),
	kD1974_EVENT_E_VBUS_OV		= (1 << 7),
};

enum {
	kD1974_EVENT_H_ALARM		= (1 << 0),
	kD1974_EVENT_H_FW_REM		= (1 << 4),
	kD1974_EVENT_H_VBUS_REM		= (1 << 6),
	kD1974_EVENT_H_ABCC_FLAG	= (1 << 7),
};

enum {
	kD1974_EVENT_J_DWI_TO		= (1 << 1),
	kD1974_EVENT_J_EOMC		= (1 << 2),
	kD1974_EVENT_J_DPHP_DET		= (1 << 4),
};

enum {
	kD1974_STATUS_A_BUTTON1		= (1 << 0),
	kD1974_STATUS_A_BUTTON2		= (1 << 1),
	kD1974_STATUS_A_BUTTON3		= (1 << 2),
	kD1974_STATUS_A_VCENTER_DET	= (1 << 3),
	kD1974_STATUS_A_FW_DET		= (1 << 4),
	kD1974_STATUS_A_ACC_DET		= (1 << 5),
	kD1974_STATUS_A_VBUS_EXT_DET	= (1 << 6),
	kD1974_STATUS_A_VDD_LOW		= (1 << 7),
};

enum {
	kD1974_STATUS_B_CHG_ATT		= (1 << 0),
	kD1974_STATUS_B_CHG_PRE		= (1 << 1),
	kD1974_STATUS_B_CHG_FAST	= (1 << 2),
	kD1974_STATUS_B_CHG_END		= (1 << 3),
	kD1974_STATUS_B_TBAT		= (1 << 4),
	kD1974_STATUS_B_CHG_TO		= (1 << 5),
	kD1974_STATUS_B_FW_OV		= (1 << 6),
};

enum {
	kD1974_STATUS_C_GPIO1		= (1 << 0),
	kD1974_STATUS_C_GPIO2		= (1 << 1),
	kD1974_STATUS_C_GPIO3		= (1 << 2),
	kD1974_STATUS_C_GPIO4		= (1 << 3),
	kD1974_STATUS_C_GPIO5		= (1 << 4),
	kD1974_STATUS_C_GPIO6		= (1 << 5),
	kD1974_STATUS_C_GPIO7		= (1 << 6),
	kD1974_STATUS_C_GPIO8		= (1 << 7),
};

enum {
	kD1974_STATUS_D_GPIO9		= (1 << 0),
	kD1974_STATUS_D_GPIO10		= (1 << 1),
	kD1974_STATUS_D_GPIO11		= (1 << 2),
	kD1974_STATUS_D_GPIO12		= (1 << 3),
	kD1974_STATUS_D_GPIO13		= (1 << 4),
	kD1974_STATUS_D_GPIO14		= (1 << 5),
	kD1974_STATUS_D_GPIO15		= (1 << 6),
	kD1974_STATUS_D_GPIO16		= (1 << 7),
};

enum {
	kD1974_STATUS_E_GPIO17		= (1 << 0),
	kD1974_STATUS_E_CHG_BUCK_FLG	= (1 << 6),
	kD1974_STATUS_E_VBUS_OV		= (1 << 7),
};

enum {
	kD1974_STATUS_H_ABCC_FLAG	= (1 << 7),
};

enum {
    kD1974_BUCK4_CONT_MASK      = (3 << 4),
    kD1974_BUCK4_CONT_SLEEP     = (0 << 4),
    kD1974_BUCK4_CONT_AUTO      = (1 << 4),
};

enum {
	kDIALOG_EVENT_HOLD_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1974_EVENT_A_BUTTON2),
	kDIALOG_EVENT_MENU_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1974_EVENT_A_BUTTON1),
	kDIALOG_EVENT_RINGER_BUTTON_MASK= EVENT_FLAG_MAKE(0, kD1974_EVENT_A_BUTTON3),
	kDIALOG_EVENT_BUTTONS		= (kD1974_EVENT_A_BUTTON2 | 
					   kD1974_EVENT_A_BUTTON1 | 
					   kD1974_EVENT_A_BUTTON3),
	kDIALOG_EVENT_BUTTONS_MASK	= EVENT_FLAG_MAKE(0, kDIALOG_EVENT_BUTTONS),
	kDIALOG_EVENT_PWR_BUTTON_MASK	= kDIALOG_EVENT_HOLD_BUTTON_MASK,
	
	kDIALOG_EVENT_ALARM_MASK	= EVENT_FLAG_MAKE(7, kD1974_EVENT_H_ALARM),
	kDIALOG_EVENT_ACC_DET_MASK	= EVENT_FLAG_MAKE(0, kD1974_EVENT_A_ACC_DET),
	kDIALOG_EVENT_VBUS_DET_MASK	= EVENT_FLAG_MAKE(0, kD1974_EVENT_A_VBUS_EXT_DET),
	kDIALOG_EVENT_VHP_DET_MASK	= EVENT_FLAG_MAKE(0, kD1974_STATUS_A_FW_DET),
	kDIALOG_EVENT_VBUS_REM_MASK	= EVENT_FLAG_MAKE(7, kD1974_EVENT_H_VBUS_REM),
	kDIALOG_EVENT_EOMC_MASK		= EVENT_FLAG_MAKE(9, kD1974_EVENT_J_EOMC),
	kDIALOG_EVENT_HIB_MASK		= EVENT_FLAG_MAKE(1, kDIALOG_EVENT_B_HIB),
	kDIALOG_EVENT_ABCC_MASK		= EVENT_FLAG_MAKE(7, kD1974_EVENT_H_ABCC_FLAG),
	
	kDIALOG_EVENT_CHG_END_MASK	= EVENT_FLAG_MAKE(1, kD1974_EVENT_B_CHG_END),
	kDIALOG_EVENT_TBAT_MASK		= EVENT_FLAG_MAKE(1, kD1974_EVENT_B_TBAT),
	
	kDIALOG_EVENT_GPIO1_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO1),
	kDIALOG_EVENT_GPIO2_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO2),
	kDIALOG_EVENT_GPIO3_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO3),
	kDIALOG_EVENT_GPIO4_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO4),
	kDIALOG_EVENT_GPIO5_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO5),
	kDIALOG_EVENT_GPIO6_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO6),
	kDIALOG_EVENT_GPIO7_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO7),
	kDIALOG_EVENT_GPIO8_MASK	= EVENT_FLAG_MAKE(2, kD1974_EVENT_C_GPIO8),
	kDIALOG_EVENT_GPIO9_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO9),
	kDIALOG_EVENT_GPIO10_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO10),
	kDIALOG_EVENT_GPIO11_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO11),
	kDIALOG_EVENT_GPIO12_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO12),
	kDIALOG_EVENT_GPIO13_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO13),
	kDIALOG_EVENT_GPIO14_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO14),
	kDIALOG_EVENT_GPIO15_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO15),
	kDIALOG_EVENT_GPIO16_MASK	= EVENT_FLAG_MAKE(3, kD1974_EVENT_D_GPIO16),
	kDIALOG_EVENT_GPIO17_MASK	= EVENT_FLAG_MAKE(4, kD1974_EVENT_E_GPIO17),

	kDIALOG_EVENT_HOLD_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1974_EVENT_E_BTN2_DBL),
	kDIALOG_EVENT_MENU_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1974_EVENT_E_BTN1_DBL),
	kDIALOG_EVENT_RINGER_DBL_MASK	= EVENT_FLAG_MAKE(4, kD1974_EVENT_E_BTN3_DBL),
	
	kDIALOG_EVENT_GPIO18_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_ON_MASK		= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_LDO2_EN_MASK	= kDIALOG_NOTEXIST_MASK,
};

enum {
	kDIALOG_STATUS_USB_MASK		 = STATUS_FLAG_MAKE(0, kD1974_STATUS_A_VCENTER_DET),
	kDIALOG_STATUS_VBUS_MASK	 = STATUS_FLAG_MAKE(0, kD1974_STATUS_A_VBUS_EXT_DET),
	kDIALOG_STATUS_FW_MASK		 = STATUS_FLAG_MAKE(0, kD1974_STATUS_A_FW_DET),
	kDIALOG_STATUS_ACC_DET_MASK	 = STATUS_FLAG_MAKE(0, kD1974_STATUS_A_ACC_DET),
	kDIALOG_STATUS_CHARGING_MASK	 = STATUS_FLAG_MAKE(1, kD1974_STATUS_B_CHG_PRE | kD1974_STATUS_B_CHG_FAST),
	kDIALOG_STATUS_CHG_TO_MASK	 = STATUS_FLAG_MAKE(1, kD1974_STATUS_B_CHG_TO),
	kDIALOG_STATUS_CHG_END_MASK	 = STATUS_FLAG_MAKE(1, kD1974_STATUS_B_CHG_END),
	kDIALOG_STATUS_TBAT_MASK	 = STATUS_FLAG_MAKE(1, kD1974_STATUS_B_TBAT),
	kDIALOG_STATUS_CHG_ATT_MASK      = STATUS_FLAG_MAKE(1, kD1974_STATUS_B_CHG_ATT),
	kDIALOG_STATUS_ABCC_MASK	 = STATUS_FLAG_MAKE(7, kD1974_STATUS_H_ABCC_FLAG),
#define	kDIALOG_STATUS_GPIO_MASK(gpio)	   STATUS_FLAG_MAKE(2 + ((gpio)/8), (1 << ((gpio) % 8)))
};

static const statusRegisters kDialogStatusFWMask = {kD1974_STATUS_A_FW_DET, 0, 0, 0, 0, 0};
static const statusRegisters kDialogStatusChargingMask = {0, kD1974_STATUS_B_CHG_PRE | kD1974_STATUS_B_CHG_FAST, 0, 0, 0, 0};

enum {
	kD1974_EVENT_A_WAKEMASK = (kD1974_EVENT_A_BUTTON1 |
				   kD1974_EVENT_A_BUTTON2 |
				   kD1974_EVENT_A_BUTTON3 |
				   kD1974_EVENT_A_VBUS_EXT_DET |
				   kD1974_STATUS_A_FW_DET |
				   kD1974_EVENT_A_ACC_DET),
	kD1974_EVENT_B_WAKEMASK = 0,
	kD1974_EVENT_C_WAKEMASK = 0,
	kD1974_EVENT_D_WAKEMASK = 0,
	kD1974_EVENT_E_WAKEMASK = 0,
	kD1974_EVENT_F_WAKEMASK = 0,
	kD1974_EVENT_G_WAKEMASK = 0,
	kD1974_EVENT_H_WAKEMASK = (kD1974_EVENT_H_ALARM |
				   kD1974_EVENT_H_FW_REM |
				   kD1974_EVENT_H_VBUS_REM),
	kD1974_EVENT_I_WAKEMASK = 0,
	kD1974_EVENT_J_WAKEMASK = 0,
};

// All events that are masked during shutdown - inverse of the wake mask,
// events that wake up the system
static const eventRegisters kDialogEventIntMasks = {
	~kD1974_EVENT_A_WAKEMASK,
	~kD1974_EVENT_B_WAKEMASK,
	~kD1974_EVENT_C_WAKEMASK,
	~kD1974_EVENT_D_WAKEMASK,
	~kD1974_EVENT_E_WAKEMASK,
	~kD1974_EVENT_F_WAKEMASK,
	~kD1974_EVENT_G_WAKEMASK,
	~kD1974_EVENT_H_WAKEMASK,
	~kD1974_EVENT_I_WAKEMASK,
	~kD1974_EVENT_J_WAKEMASK,
};


// All wake events without the buttons
static const eventRegisters kDialogEventNotButtonMasks = {
	kD1974_EVENT_A_WAKEMASK & ~kDIALOG_EVENT_BUTTONS,
	kD1974_EVENT_B_WAKEMASK,
	kD1974_EVENT_C_WAKEMASK,
	kD1974_EVENT_D_WAKEMASK,
	kD1974_EVENT_E_WAKEMASK,
	kD1974_EVENT_F_WAKEMASK,
	kD1974_EVENT_G_WAKEMASK,
	kD1974_EVENT_H_WAKEMASK,
	kD1974_EVENT_I_WAKEMASK,
	kD1974_EVENT_J_WAKEMASK,
};

// All events that defer shutdown
static const eventRegisters kDialogEventRestartMask = { 
	EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_HOLD_BUTTON_MASK, 0) | EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ACC_DET_MASK, 0),
	0,
	0,
	0,
	0,
	0,
	0,
	EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ALARM_MASK, 7),
	0,
	0,
};

// All events indicating external power supply
static const eventRegisters kDialogEventPwrsupplyMask = {
	kD1974_EVENT_A_VBUS_EXT_DET | kD1974_EVENT_A_FW_DET | kD1974_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	0,
	0,
	kD1974_EVENT_H_FW_REM | kD1974_EVENT_H_VBUS_REM,
	0,
	0,
};

static const eventRegisters kDialogEventUSBMask = {
	// only include VCENTER_DET; VBUS can come and go while charger still usable
	kD1974_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	0,
	0,
	kD1974_EVENT_H_ABCC_FLAG,
	0,
	0,
};

static const eventRegisters kDialogEventFWMask = {
	kD1974_EVENT_A_FW_DET,
	0,
	0,
	0,
	0,
	0,
	0,
	kD1974_EVENT_H_FW_REM,
	0,
	0,
};

// XXXKW
enum {
	kDialogEventPwrsupplyCount = 5,
	kDialogEventUSBCount = 2,
	kDialogEventFWCount = 2,
};

enum {
	kDIALOG_LCM_ACTIVE_BOOST_EN		= (1 << 1),
	kDIALOG_LCM_ACTIVE_MASK			= (1 << 2) | (1 << 3) | (1 << 4),
};

enum {
	kDIALOG_SYS_CONTROL_STANDBY		= (1 << 0),
	kDIALOG_SYS_CONTROL_HIBERNATE		= (1 << 1),
	kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND	= (1 << 2),
	kDIALOG_SYS_CONTROL_SOFT_HIB		= (1 << 3),
	kDIALOG_SYS_CONTROL_HIB_CLK		= (1 << 4),
	kDIALOG_SYS_CONTROL_PRO_FET_DIS		= (1 << 5),
	kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND	= (1 << 6),
	kDIALOG_SYS_CONTROL_CHRG_CONTROLS	= kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND
						| kDIALOG_SYS_CONTROL_BUS_PWR_SUSPEND,
	kDIALOG_SYS_CONTROL_HIBERNATE_ALWAYS    = kDIALOG_SYS_CONTROL_HIBERNATE,
};

enum {
	kDIALOG_SYS_CONTROL2_DWI_EN		= (1 << 0),
	kDIALOG_SYS_CONTROL2_DWI_TEST_EN	= (1 << 1),
	kDIALOG_SYS_CONTROL2_HIB_32K		= (1 << 4),
};

enum {
	kDIALOG_FAULT_LOG_WDOG		= FAULTLOG_FLAG_MAKE(0, (1 << 6)),
	kDIALOG_FAULT_LOG_RESET_IN_1	= FAULTLOG_FLAG_MAKE(0, (1 << 5)),
	kDIALOG_FAULT_LOG_RST		= FAULTLOG_FLAG_MAKE(0, (1 << 4)),
	kDIALOG_FAULT_LOG_POR		= FAULTLOG_FLAG_MAKE(0, (1 << 3)),
	kDIALOG_FAULT_LOG_BOOST		= FAULTLOG_FLAG_MAKE(0, (1 << 2)),
	kDIALOG_FAULT_LOG_OVER_TEMP	= FAULTLOG_FLAG_MAKE(0, (1 << 1)),
	kDIALOG_FAULT_LOG_VDD_UNDER	= FAULTLOG_FLAG_MAKE(0, (1 << 0)),
	kDIALOG_FAULT_LOG_RESET_IN_2	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_RESET_IN_3	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_NTC_SHDN	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_BTN_SHUTDOWN	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_FAULT_LOG_TWO_FINGER_RESET	= kDIALOG_NOTEXIST_MASK,
};

enum {
	kDIALOG_BUCK_DWI_BUCK0			= (1 << 0),
	kDIALOG_BUCK_DWI_BUCK1			= (1 << 1),
	kDIALOG_BUCK_DWI_BUCK2			= (1 << 2),
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MIN  = 0x00,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_100  = 0x02,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_200  = 0x0a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_250  = 0xe,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_300  = 0x12,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_350  = 0x16,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_400  = 0x1a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_500  = 0x22,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_600  = 0x2a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_700  = 0x32,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_750  = 0x36,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_900  = 0x42,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1000 = 0x4a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1500 = 0x72,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1900 = 0x92,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2000 = 0x9a,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2100 = 0xa2,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2200 = 0xaa,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2300 = 0xb2,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MAX  = 0xff,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MASK = 0xff,
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_MIN		   = 75,
	kDIALOG_CHARGE_BUCK_CONTROL_STEP_PER_100MA = 8,
	kDIALOG_CHARGE_BUCK_CONTROL_MAX		   = 3262,
};

enum {
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_MASK	 = 0x3f,
	kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT  = 0,
	kDIALOG_OTP_ISET_BAT_SHIFT		= kDIALOG_CHARGE_CONTROL_A_ISET_BAT_SHIFT,
	kDIALOG_CHARGE_CONTROL_A_CHG_SUSP	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_A_CHG_HIB	= (1 << 7),
	kDIALOG_CHARGE_CONTROL_CHG_HIB		= kDIALOG_CHARGE_CONTROL_A_CHG_HIB,
};

enum {
	kDIALOG_CHARGE_CONTROL_STEP		= 50,
	kDIALOG_CHARGE_CONTROL_MAX		= 3150,
};

enum {
	kDIALOG_CHARGE_CONTROL_C_ALT_USB_DIS	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_C_CHG_BUCK_EN	= (1 << 7),
	
	kDIALOG_CHARGE_CONTROL_ALT_USB_DIS			= kDIALOG_CHARGE_CONTROL_C_ALT_USB_DIS,
	kDIALOG_CHARGE_CONTROL_CHG_BUCK_EN			= kDIALOG_CHARGE_CONTROL_C_CHG_BUCK_EN,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_VBUS_CHG_BUCK_EN	= kDIALOG_CHARGE_CONTROL_C_CHG_BUCK_EN,
};

enum {
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_MASK	    = 0xF0,
	kDIALOG_CHARGE_CONTROL_TIME_TCTR_DISABLED   = 0x00,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_MASK	    = 0x07,
	kDIALOG_CHARGE_CONTROL_TIME_PCTR_DISABLED   = 0x00,
};

enum {
	kDIALOG_ADC_LSB_ADC_OVL			= (1 << 7),
};

enum {
	kDIALOG_ADC_CONTROL_MUX_SEL_MASK	= (0x1f << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VDD_OUT	= (0x0 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ICH		= (0x1 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TBAT	= (0x2 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ACC_ID	= (0x3 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VBAT	= (0x4 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_OUT	= (0x5 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BRICK_ID	= (0x6 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IN7	= (0x7 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TJUNC	= (0x8 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VIBUS	= (0x9 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_NTC0	= (0xa << 0),
	kDIALOG_ADC_CONTROL_MUX_NUM_NTC		= 9,
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS	= (19 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VIBUS_OFF	= (20 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBAT_OUT_OFF= (21 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK5_TEMP	= (22 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_LDO9_TEMP	= (23 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_B_TEMP= (24 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CHG_TEMP	= (25 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK0_TEMP	= (26 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK2_TEMP	= (27 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK3_TEMP	= (28 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK4_TEMP	= (29 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP= (30 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_START	= kDIALOG_ADC_CONTROL_MUX_SEL_BUCK5_TEMP,
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_END	= kDIALOG_ADC_CONTROL_MUX_SEL_CBUCK_A_TEMP,
	kDIALOG_ADC_CONTROL_MUX_SEL_ADC_IN31	= (31 << 0),
	kDIALOG_ADC_CONTROL_MAN_CONV		= (1 << 5),
	kDIALOG_ADC_CONTROL_ADC_REF_EN		= (1 << 6),
	kDIALOG_ADC_CONTROL_AUTO_VDD_OUT_EN	= (1 << 7),
};

enum {
	kDIALOG_ADC_CONTROL_DEFAULTS	= 0,
};

enum {
	kDIALOG_ADC_RESOLUTION_BITS	= 12,
	kDIALOG_ADC_FULL_SCALE_MV	= 2500,
	kDIALOG_ADC_BRICK_ID_OFFSET_MV	= 40,
};

enum {
    	kDIALOG_BIST_ADC_CTRL_MUX_SEL_MASK	= (0x3f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO1	= (0x00 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO1	= (0x01 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO2	= (0x02 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO2	= (0x03 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO3	= (0x04 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO3	= (0x05 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO4	= (0x06 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO4	= (0x07 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO5	= (0x08 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO5	= (0x09 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO6	= (0x0a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO6	= (0x0b << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO7	= (0x0c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO7	= (0x0d << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO8	= (0x0e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO8	= (0x0f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO9	= (0x10 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO9	= (0x11 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO10	= (0x12 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO10	= (0x13 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO11	= (0x14 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO11	= (0x15 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO12	= (0x16 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO12	= (0x17 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM1	= (0x18 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM1	= (0x19 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM2	= (0x1a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM2	= (0x1b << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM3	= (0x1c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM3	= (0x1d << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VRTC	= (0x1e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IRTC	= (0x1f << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUF_ON	= (0x20 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IBUF_ON	= (0x21 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0	= (0x22 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_WLEDB	= (0x24 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK2	= (0x26 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK3	= (0x28 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK4	= (0x2a << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_WLEDA	= (0x2c << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBOOST_LCM	= (0x2e << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_A	= (0x30 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_B	= (0x32 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK5	= (0x34 << 0),
	kDIALOG_BIST_ADC_CTRL_AUTO_RUN		= (1 << 6),
	kDIALOG_BIST_ADC_CTRL_MAN_CONV		= (1 << 7),
};

enum {
	kDIALOG_APP_TMUX_SEL_MASK		= (15 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_0		= (0 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_1		= (1 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_2		= (2 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_3		= (3 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_4		= (4 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_5		= (5 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_6		= (6 << 0),
	kDIALOG_APP_TMUX_SEL_AMUX_7		= (7 << 0),
	KDIALOG_APP_TMUX_EN			= (1 << 7),
};

enum {
	kDIALOG_RTC_CONTROL_MONITOR		= (1 << 0),
	kDIALOG_RTC_CONTROL_ALARM_EN		= (1 << 6),
};

enum {
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_LOW		= (0 << 1),
	kDIALOG_SYS_GPIO_OUTPUT_LEVEL_HIGH		= (1 << 1),
	
	kDIALOG_SYS_GPIO_INPUT_WAKE			= (1 << 1),
	
	kDIALOG_SYS_GPIO_DIRECTION_MASK			= (7 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT			= (0 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_OUT_32KHZ		= (2 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH	= (3 << 5),
	kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_LOW		= (4 << 5),
};

#define IS_GPIO_OUTPUT(gpio) (((gpio)&kDIALOG_SYS_GPIO_DIRECTION_MASK) \
< kDIALOG_SYS_GPIO_DIRECTION_IN_LEVEL_HIGH)

enum {
	kDIALOG_WLED_CONTROL_WLED_ENABLE1	= (1 << 0),
	kDIALOG_WLED_CONTROL_WLED_ENABLE2	= (1 << 1),
	kDIALOG_WLED_CONTROL_WLED_ENABLE3	= (1 << 2),
	kDIALOG_WLED_CONTROL_WLED_ENABLE4	= (1 << 3),
	kDIALOG_WLED_CONTROL_WLED_ENABLE5	= (1 << 4),
	kDIALOG_WLED_CONTROL_WLED_ENABLE6	= (1 << 5),
};

enum {
	kDIALOG_WLED_CONTROL2_WLED_RAMP_EN	= (1 << 2),
	kDIALOG_WLED_CONTROL2_WLED_DWI_EN	= (1 << 3),
	kDIALOG_WLED_CONTROL2_WLED_DITH_EN	= (1 << 4),
	kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN	= (1 << 5),
	
	kDIALOG_WLED_CONTROL_WLED_DWI_EN	= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,
	
	kDIALOG_WLED_OPTIONS_DEFAULT		= kDIALOG_WLED_CONTROL2_WLED_DITH_EN,
	kDIALOG_WLED_OPTIONS_xWI_EN		= kDIALOG_WLED_CONTROL2_WLED_DWI_EN,
	kDIALOG_WLED_OPTIONS_MASK		= (kDIALOG_WLED_CONTROL2_WLED_RAMP_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_EN|
						   kDIALOG_WLED_CONTROL2_WLED_DITH_RAMP_EN),
};

#define WLED_ISET_BITS	(11)

#define NUM_LDOS 23
static const struct ldo_params ldo_1974[NUM_LDOS] = {
{ 2500, 50, 0x0a, 0x1f, 0x1, kD1974_LDO1,            kD1974_ACTIVE1, 0x20 },	// LDO1
{ 1650, 5,  0x0a, 0x1f, 0x0, kD1974_LDO2,            kD1974_ACTIVE1, 0x40 },	// LDO2
{ 2500, 50, 0x0a, 0x1f, 0x0, kD1974_LDO3,            kD1974_ACTIVE1, 0x80 },	// LDO3
{ 1800, 50, 0x18, 0x1f, 0x0, kD1974_LDO4,            kD1974_ACTIVE2, 0x01 },	// LDO4
{ 2500, 50, 0x0a, 0x1f, 0x0, kD1974_LDO5,            kD1974_ACTIVE2, 0x02 },	// LDO5
{ 2500, 50, 0x10, 0x1f, 0x2, kD1974_LDO6,            kD1974_ACTIVE2, 0x04 },	// LDO6
{ 1500, 100,0x0a, 0x1f, 0x0, kD1974_LDO7,            kD1974_ACTIVE2, 0x08 },	// LDO7
{ 2000, 50, 0x16, 0x1f, 0x0, kD1974_LDO8,            kD1974_ACTIVE2, 0x10 },	// LDO8
{ 1200, 100,0x00, 0x1f, 0x0, kD1974_LDO9,            kD1974_ACTIVE2, 0x20 },	// LDO9
{ 2500, 50, 0x0a, 0x1f, 0x4, kD1974_LDO10,           kD1974_ACTIVE2, 0x40 },	// LDO10
{ 1700, 50, 0x17, 0x1f, 0x0, kD1974_LDO11,           kD1974_ACTIVE2, 0x80 },	// LDO11
{ 600,  25, 0x14, 0x1f, 0x0, kD1974_LDO12,           kD1974_ACTIVE3, 0x01 },	// LDO12
{ 5000, 50, 0x0c, 0x1f, 0x0, kD1974_LCM_CONTROL1,    kD1974_ACTIVE3, 0x04 },	// LCM1_LDO
{ 5000, 50, 0x05, 0x1f, 0x0, kD1974_LCM_CONTROL2,    kD1974_ACTIVE3, 0x08 },	// LCM2_LDO
{ 5000, 50, 0x00, 0x1f, 0x0, kD1974_LCM_CONTROL3,    kD1974_ACTIVE3, 0x10 },	// LCM3_LDO
{ 5000, 50, 0x1f, 0x1f, 0x0, kD1974_LCM_BST_CONTROL, kD1974_ACTIVE3, 0x02 },	// LCM_BOOST
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_ACTIVE3, 0x20 },	// 17 - WLED_BST_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_ACTIVE4, 0x10 },	// 18 - DSP_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_ACTIVE4, 0x20 },	// 19 - CPU1V2_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_ACTIVE4, 0x40 },	// 20 - WDIG_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_ACTIVE4, 0x80 },	// 21 - CPU1V8_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_HIBERNATE1, 0x20 },	// 22 - set LDO1_EN in HIB
{ 0,    0,  0,    0,    0x0, 0,			     kD1974_HIBERNATE2, 0x04 },	// 23 - set LDO6_EN in HIB
};
#define LDOP ldo_1974

enum {
	kDIALOG_SYS_CONFIG_WDOG_EN		= (1 << 0),
	
	kDIALOG_SYS_CONFIG_WDOG_MODE_100MS	= (0 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_250MS	= (1 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_500MS	= (2 << 1),
	kDIALOG_SYS_CONFIG_WDOG_MODE_1000MS	= (3 << 1),
	
	kDIALOG_SYS_CONFIG_RESET_TIMER_MASK	= (3 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_4S	= (0 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_6S	= (1 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_8S	= (2 << 3),
	kDIALOG_SYS_CONFIG_RESET_TIMER_10S	= (3 << 3),
	
	kDIALOG_SYS_CONFIG_WDOG_ACTIVE		= (1 << 5),
};

enum {
	kDIALOG_BUTTON_DBL_CLICK_RATE_MASK	= (7 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_50MS	= (0 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_100MS	= (1 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_150MS	= (2 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_200MS	= (3 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_250MS	= (4 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_300MS	= (5 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_350MS	= (6 << 0),
	kDIALOG_BUTTON_DBL_CLICK_RATE_400MS	= (7 << 0),
	kD1974_BUTTON_DBL_BTN1_DBL_EN		= (1 << 3),
	kD1974_BUTTON_DBL_BTN2_DBL_EN		= (1 << 4),
	kD1974_BUTTON_DBL_BTN3_DBL_EN		= (1 << 5),
	kDIALOG_BUTTON_DBL_HOLD_DBL_EN		= kD1974_BUTTON_DBL_BTN2_DBL_EN,
	kDIALOG_BUTTON_DBL_MENU_DBL_EN		= kD1974_BUTTON_DBL_BTN1_DBL_EN,
	kDIALOG_BUTTON_DBL_RINGER_DBL_EN	= kD1974_BUTTON_DBL_BTN3_DBL_EN,
};

