/*
 * Copyright (C) 2011 Apple Inc. All rights reserved.
 *
 * This document is the property of Apple Inc.
 * It is considered confidential and proprietary.
 *
 * This document may not be reproduced or transmitted in any form,
 * in whole or in part, without the express written permission of
 * Apple Inc.
 */

#ifndef __DIALOG_D1972_H
#define __DIALOG_D1972_H

#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_VIB		1
#define PMU_HAS_WLED		1

enum {
	kDIALOG_ADDR_R	= 0xe9,
	kDIALOG_ADDR_W	= 0xe8,
	kDIALOG_REG_BYTES	= 1,
};

enum {
	kDIALOG_EVENT_COUNT		= 9,
	kDIALOG_STATUS_COUNT		= 8,
	kDIALOG_HIBERNATE_COUNT		= 4,
	kDIALOG_CHIPID_COUNT		= 1,
	kDIALOG_FAULTLOG_COUNT		= 1,
	kDIALOG_GPIO_COUNT		= 12,
};

#include "dCommon.h"

enum {
	kDIALOG_BANK_COUNT		= 2,
    	kDIALOG_BANK0_SHARED_COUNT	= 0x5e,
};

enum {
	// Bank 0 registers
	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_STATUS_A		= 0x0a,
	kDIALOG_STATUS_B		= 0x0b,
	kDIALOG_STATUS_C		= 0x0c,
	kDIALOG_STATUS_D		= 0x0d,
	kDIALOG_STATUS_E		= 0x0e,
	kDIALOG_STATUS_F		= 0x0f,
	kDIALOG_STATUS_G		= 0x10,
	kDIALOG_STATUS_H		= 0x11,
	kDIALOG_STATUS_GPIO_1_8		= kDIALOG_STATUS_C,
	kDIALOG_STATUS_GPIO_9_16	= kDIALOG_STATUS_D,
	kDIALOG_STATUS_GPIO_17_24	= 0,

	kDIALOG_IRQ_MASK_A		= 0x12,
	kDIALOG_IRQ_MASK_B		= 0x13,
	kDIALOG_IRQ_MASK_C		= 0x14,
	kDIALOG_IRQ_MASK_D		= 0x15,
	kDIALOG_IRQ_MASK_E		= 0x16,
	kDIALOG_IRQ_MASK_F		= 0x17,
	kDIALOG_IRQ_MASK_G		= 0x18,
	kDIALOG_IRQ_MASK_H		= 0x19,
	kDIALOG_IRQ_MASK_I		= 0x1a,

	kDIALOG_SYS_CONTROL		= 0x1b,
	kDIALOG_SYS_CONTROL2		= 0x1c,

	kDIALOG_FAULT_LOG		= 0x1d,
	kDIALOG_BANKSEL			= 0x1e,

	kD1972_ACTIVE1			= 0x20,
	kD1972_ACTIVE2			= 0x21,
	kD1972_ACTIVE3			= 0x22,
	kDIALOG_LCM_ACTIVE		= kD1972_ACTIVE3,
	kD1972_ACTIVE4			= 0x23,
	kD1972_STANDBY			= 0x24,
	kDIALOG_STANDBY			= kD1972_STANDBY,
	kD1972_HIBERNATE1		= 0x25,
	kD1972_HIBERNATE2		= 0x26,
	kD1972_HIBERNATE3		= 0x27,
	kD1972_HIBERNATE4		= 0x28,

	kD1972_BUCK0			= 0x29,
	kDIALOG_BUCK0			= kD1972_BUCK0,
	kD1972_BUCK2			= 0x2a,
	kDIALOG_BUCK2			= kD1972_BUCK2,
	kD1972_BUCK3			= 0x2b,
	kD1972_BUCK4			= 0x2c,

	kD1972_LDO1			= 0x2d,
	kD1972_LDO2			= 0x2e,
	kD1972_LDO3			= 0x2f,
	kD1972_LDO4			= 0x30,
	kD1972_LDO5			= 0x31,
	kD1972_LDO6			= 0x32,
	kD1972_LDO7			= 0x33,
	kD1972_LDO8			= 0x34,
	kD1972_LDO9			= 0x35,
	kD1972_LDO10			= 0x36,
	kD1972_LDO11			= 0x37,
	kD1972_LDO12			= 0x38,
	kD1972_LDO16			= 0x39,

	kD1972_BUCK_CTRL1		= 0x3a,
	kD1972_BUCK_CTRL2		= 0x3b,
	kD1972_BUCK_CTRL3		= 0x3c,
	kD1972_BUCK_CTRL4		= 0x3d,
	kD1972_BUCK_CTRL5		= 0x3e,

	kDIALOG_CHARGE_BUCK_CONTROL	= 0x3f,
	kDIALOG_CHARGE_BUCK_CONTROL_B	= 0x40,
	kDIALOG_CHARGE_BUCK_STATUS	= 0x41,
	kDIALOG_CHARGE_CONTROL_A	= 0x42,
	kDIALOG_CHARGE_CONTROL_B	= 0x43,
	kDIALOG_CHARGE_CONTROL_C	= 0x44,
	kDIALOG_CHARGE_STATUS		= 0x45,
	kDIALOG_CHARGE_CONTROL_D	= 0x46,
	kDIALOG_CHARGE_TIME		= 0x47,
	kDIALOG_CHARGE_CONTROL_ICHG_BAT = kDIALOG_CHARGE_CONTROL_B,
	kDIALOG_CHARGE_CONTROL_HIB	= kDIALOG_CHARGE_CONTROL_B,
	kDIALOG_CHARGE_CONTROL_TIME	= kDIALOG_CHARGE_CONTROL_D,
	kDIALOG_CHARGE_CONTROL_EN	= kDIALOG_CHARGE_CONTROL_A,
	kDIALOG_OTP_ISET_BAT		= kDIALOG_CHARGE_CONTROL_B,

	kDIALOG_ADC_CONTROL		= 0x48,
	kDIALOG_ADC_LSB			= 0x49,
	kDIALOG_ADC_MSB			= 0x4a,
	kDIALOG_ADC_TEMP_CTRL		= 0x4b,

	kDIALOG_ICHG_AVG		= 0x4c,
	kDIALOG_VCC_MAIN_MON		= 0x4d,
	kDIALOG_ICHG_END		= 0x4e,

	kDIALOG_TBAT_0			= 0x4f,
	kDIALOG_ICHG_TBAT_0		= 0x50,
	kDIALOG_TBAT_1			= 0x51,
	kDIALOG_ICHG_TBAT_1		= 0x52,
	kDIALOG_TBAT_2			= 0x53,
	kDIALOG_ICHG_TBAT_2		= 0x54,
	kDIALOG_TBAT_3			= 0x55,
	kDIALOG_ICHG_TBAT_3		= 0x56,
	kDIALOG_TBAT_4			= 0x57,
	kDIALOG_ICHG_TBAT_4		= 0x58,
	kDIALOG_TBAT_MAX		= 0x59,
	kDIALOG_ICHG_TBAT_NUM		= 5,

	kDIALOG_T_OFFSET_MSB		= 0x5A,
	kDIALOG_T_OFFSET_LSB		= 0x5B,
	kD1972_IBUSCAL1			= 0x5c,
	kD1972_IBUSCAL2			= 0x5d,

	kDIALOG_RTC_ALARM_A		= 0x5e,
	kDIALOG_RTC_ALARM_B		= 0x5f,
	kDIALOG_RTC_ALARM_C		= 0x60,
	kDIALOG_RTC_ALARM_D		= 0x61,
	kDIALOG_RTC_CONTROL		= 0x62,
	kDIALOG_RTC_TIMEZONE		= 0x63,
	kDIALOG_UPCOUNT_A		= 0x64,
	kDIALOG_UPCOUNT_B		= 0x65,
	kDIALOG_UPCOUNT_C		= 0x66,
	kDIALOG_UPCOUNT_D		= 0x67,

	kD1972_SYS_GPIO_1		= 0x68,
	kDIALOG_SYS_GPIO_REG_START	= kD1972_SYS_GPIO_1,
	kD1972_SYS_GPIO_2		= 0x69,
	kD1972_SYS_GPIO_3		= 0x6a,
	kD1972_SYS_GPIO_4		= 0x6b,
	kD1972_SYS_GPIO_5		= 0x6c,
	kD1972_SYS_GPIO_6		= 0x6d,
	kD1972_SYS_GPIO_7		= 0x6e,
	kD1972_SYS_GPIO_8		= 0x6f,
	kD1972_SYS_GPIO_9		= 0x70,
	kD1972_SYS_GPIO_10		= 0x71,
	kD1972_SYS_GPIO_11		= 0x72,
	kD1972_SYS_GPIO_12		= 0x73,

	kD1972_SYS_GPIO_DEB1		= 0x74,
	kD1972_SYS_GPIO_DEB2		= 0x75,
	kD1972_SYS_GPIO_DEB3		= 0x76,
	kD1972_SYS_GPIO_DEB4		= 0x77,
	kD1972_SYS_GPIO_DEB5		= 0x78,
	kD1972_SYS_GPIO_DEB6		= 0x79,
	
	kDIALOG_LDO_CONTROL		= 0x7a,

	kDIALOG_WLED_ISET		= 0x7b,
	kDIALOG_WLED_ISET2		= 0x7c,
	kDIALOG_WLED_CONTROL		= 0x7d,
	kDIALOG_WLED_CONTROL2		= 0x7e,
	kDIALOG_WLED_DWI_CONTROL	= kDIALOG_WLED_CONTROL,
	kDIALOG_WLED_OPTIONS		= kDIALOG_WLED_CONTROL,

	kD1972_LCM_CONTROL1		= 0x7f,
	kD1972_LCM_CONTROL2		= 0x80,
	kD1972_LCM_CONTROL3		= 0x81,
	kD1972_LCM_BST_CONTROL		= 0x82,
	kDIALOG_LCM_BOOST		= kD1972_LCM_BST_CONTROL,

	kDIALOG_VIB_CTRL		= 0x83,
	kDIALOG_VIB_VSET		= 0x84,

	kD1972_TDEV1_RISE		= 0x85,
	kD1972_TDEV1_FALL		= 0x86,
	kD1972_TDEV2_RISE		= 0x87,
	kD1972_TDEV2_FALL		= 0x88,
	kD1972_TDEV3_RISE		= 0x89,
	kD1972_TDEV3_FALL		= 0x8a,
	kD1972_TDEV4_RISE		= 0x8b,
	kD1972_TDEV4_FALL		= 0x8c,
	kD1972_TLDO5_RISE		= 0x8d,
	kD1972_TLDO16_RISE		= 0x8e,
	kD1972_TVCENTER_RISE		= 0x8f,
	kD1972_TLINCHG_RISE		= 0x90,
	kD1972_TBUCK0_RISE		= 0x91,
	kD1972_TBUCK2_RISE		= 0x92,
	kD1972_TBUCK3_RISE		= 0x93,
	kD1972_TBUCK4_RISE		= 0x94,
	kD1972_TISENSE_HYSE		= 0x95,

	kD1972_BUTTON1			= 0x96,
	kD1972_BUTTON2			= 0x97,
	kD1972_BUTTON3			= 0x98,
	kDIALOG_SYS_CONFIG		= 0x99,

	kD1972_BUCK3_ALT		= 0x9a,
	kD1972_BUCK4_ALT		= 0x9b,
	kD1972_GPIO_SOFTHIB1		= 0x9c,
	kD1972_GPIO_SOFTHIB2		= 0x9d,
	kDIALOG_BUTTON_DBL		= 0x9e,

	kDIALOG_MEMBYTE0		= 0xa1,
	kDIALOG_MEMBYTE_LAST		= 0xc8,

	kD1972_TEST_MODE                = 0xdc,

	kDIALOG_APP_TMUX		= 0x15e,
	kDIALOG_BIST_ADC_CTRL		= 0x15f,
	kDIALOG_BIST_ADC_LSB		= 0x160,
	kDIALOG_BIST_ADC_MSB		= 0x161,
};

enum {
	kD1972_CHIP_ID_MRC_MASK		= (0xf << 0),
	kD1972_CHIP_ID_MRC_A0		= (0 << 0),
	kD1972_CHIP_ID_MRC_A1		= (1 << 0),
};

enum {
	kD1972_EVENT_A_BUTTON1		= (1 << 0),
	kD1972_EVENT_A_BUTTON2		= (1 << 1),
	kD1972_EVENT_A_BUTTON3		= (1 << 2),
	kD1972_EVENT_A_VCENTER_DET	= (1 << 3),
	kD1972_EVENT_A_FW_DET		= (1 << 4),
	kD1972_EVENT_A_ACC_DET		= (1 << 5),
	kD1972_EVENT_A_VBUS_EXT_DET	= (1 << 6),
	kD1972_EVENT_A_VDD_LOW		= (1 << 7),
};

// EVENT_B events are assumed volatile (lost over sleep/wake)
enum {
	kD1972_EVENT_B_DWI_TO		= (1 << 0),
	kD1972_EVENT_B_CHG_PRE		= (1 << 1),
	kD1972_EVENT_B_CHG_FAST		= (1 << 2),
	kD1972_EVENT_B_CHG_END		= (1 << 3),
	kD1972_EVENT_B_TBAT		= (1 << 4),
	kD1972_EVENT_B_EOMC		= (1 << 5),
	kD1972_EVENT_B_FW_OV		= (1 << 6),
	kDIALOG_EVENT_B_HIB		= (1 << 7),
};

enum {
	kD1972_EVENT_C_GPIO1		= (1 << 0),
	kD1972_EVENT_C_GPIO2		= (1 << 1),
	kD1972_EVENT_C_GPIO3		= (1 << 2),
	kD1972_EVENT_C_GPIO4		= (1 << 3),
	kD1972_EVENT_C_GPIO5		= (1 << 4),
	kD1972_EVENT_C_GPIO6		= (1 << 5),
	kD1972_EVENT_C_GPIO7		= (1 << 6),
	kD1972_EVENT_C_GPIO8		= (1 << 7),
};

enum {
	kD1972_EVENT_D_GPIO9		= (1 << 0),
	kD1972_EVENT_D_GPIO10		= (1 << 1),
	kD1972_EVENT_D_GPIO11		= (1 << 2),
	kD1972_EVENT_D_GPIO12		= (1 << 3),
	kD1972_EVENT_D_DPHP		= (1 << 4),
	kD1972_EVENT_D_CHG_ABCC_ACT	= (1 << 5),
	kD1972_EVENT_D_CHG_BUCK_FLG	= (1 << 6),
	kD1972_EVENT_D_VBUS_OV		= (1 << 7),
};

enum {
	kD1972_EVENT_E_TDEV1_FALL	= (1 << 0),
	kD1972_EVENT_E_TDEV1_RISE	= (1 << 1),
	kD1972_EVENT_E_TDEV2_FALL	= (1 << 2),
	kD1972_EVENT_E_TDEV2_RISE	= (1 << 3),
	kD1972_EVENT_E_TDEV3_FALL	= (1 << 4),
	kD1972_EVENT_E_TDEV3_RISE	= (1 << 5),
	kD1972_EVENT_E_TDEV4_FALL	= (1 << 6),
	kD1972_EVENT_E_TDEV4_RISE	= (1 << 7),
};

enum {
	kD1972_EVENT_F_ALARM		= (1 << 0),
	kD1972_EVENT_F_LDO1_OC		= (1 << 1),
	kD1972_EVENT_F_LDO5_OC		= (1 << 2),
	kD1972_EVENT_F_LDO6_OC		= (1 << 3),
	kD1972_EVENT_F_FW_DPHP_REM	= (1 << 4),
	kD1972_EVENT_F_LDO10_OC		= (1 << 5),
	kD1972_EVENT_F_VBUS_EXT_REM	= (1 << 6),
	kD1972_EVENT_F_VBUS_OC		= (1 << 7),
};

enum {
	kD1972_EVENT_G_TLDO5		= (1 << 0),
	kD1972_EVENT_G_TLDO16		= (1 << 1),
	kD1972_EVENT_G_TVCENTER		= (1 << 2),
	kD1972_EVENT_G_TLINCHG		= (1 << 3),
	kD1972_EVENT_G_TBUCK0		= (1 << 4),
	kD1972_EVENT_G_TBUCK2		= (1 << 5),
	kD1972_EVENT_G_TBUCK3		= (1 << 6),
	kD1972_EVENT_G_TBUCK4		= (1 << 7),
};

enum {
	kD1972_EVENT_H_EOMC_BIST	= (1 << 0),
};

enum {
	kD1972_EVENT_I_BTN1_DBL		= (1 << 3),
	kD1972_EVENT_I_BTN2_DBL		= (1 << 4),
	kD1972_EVENT_I_BTN3_DBL		= (1 << 5),
};

enum {
	kD1972_STATUS_A_BUTTON1		= (1 << 0),
	kD1972_STATUS_A_BUTTON2		= (1 << 1),
	kD1972_STATUS_A_BUTTON3		= (1 << 2),
	kD1972_STATUS_A_VCENTER_DET	= (1 << 3),
	kD1972_STATUS_A_FW_DPHP_DET	= (1 << 4),
	kD1972_STATUS_A_ACC_DET		= (1 << 5),
	kD1972_STATUS_A_VBUS_EXT_DET	= (1 << 6),
	kD1972_STATUS_A_VDD_LOW		= (1 << 7),
};

enum {
	kD1972_STATUS_B_CHG_PRE		= (1 << 1),
	kD1972_STATUS_B_CHG_FAST	= (1 << 2),
	kD1972_STATUS_B_CHG_END		= (1 << 3),
	kD1972_STATUS_B_TBAT		= (1 << 4),
	kD1972_STATUS_B_FW_OV		= (1 << 6),
};

enum {
	kD1972_STATUS_C_GPIO1		= (1 << 0),
	kD1972_STATUS_C_GPIO2		= (1 << 1),
	kD1972_STATUS_C_GPIO3		= (1 << 2),
	kD1972_STATUS_C_GPIO4		= (1 << 3),
	kD1972_STATUS_C_GPIO5		= (1 << 4),
	kD1972_STATUS_C_GPIO6		= (1 << 5),
	kD1972_STATUS_C_GPIO7		= (1 << 6),
	kD1972_STATUS_C_GPIO8		= (1 << 7),
};

enum {
	kD1972_STATUS_D_GPIO9		= (1 << 0),
	kD1972_STATUS_D_GPIO10		= (1 << 1),
	kD1972_STATUS_D_GPIO11		= (1 << 2),
	kD1972_STATUS_D_GPIO12		= (1 << 3),
	kD1972_STATUS_D_DPHP		= (1 << 4),
	kD1972_STATUS_D_CHG_ABCC_ACT	= (1 << 5),
	kD1972_STATUS_D_CHG_BUCK_FLG	= (1 << 6),
	kD1972_STATUS_D_VBUS_OV		= (1 << 7),
};

enum {
	kD1972_STATUS_E_TDEV1_FALL	= (1 << 0),
	kD1972_STATUS_E_TDEV1_RISE	= (1 << 1),
	kD1972_STATUS_E_TDEV2_FALL	= (1 << 2),
	kD1972_STATUS_E_TDEV2_RISE	= (1 << 3),
	kD1972_STATUS_E_TDEV3_FALL	= (1 << 4),
	kD1972_STATUS_E_TDEV3_RISE	= (1 << 5),
	kD1972_STATUS_E_TDEV4_FALL	= (1 << 6),
	kD1972_STATUS_E_TDEV4_RISE	= (1 << 7),
};

enum {
	kD1972_STATUS_F_CHG_ATT		= (1 << 0),
	kD1972_STATUS_F_CPUA_EN_STAT	= (1 << 1),
	kD1972_STATUS_F_CPUB_EN_STAT	= (1 << 2),
	kD1972_STATUS_F_PROT_FET_ON	= (1 << 3),
	kD1972_STATUS_F_CHG_TO		= (1 << 5),
	kD1972_STATUS_F_VBUS_OC		= (1 << 7),
};

enum {
	kD1972_STATUS_G_TLDO5		= (1 << 0),
	kD1972_STATUS_G_TLDO16		= (1 << 1),
	kD1972_STATUS_G_TVCENTER	= (1 << 2),
	kD1972_STATUS_G_TLINCHG		= (1 << 3),
	kD1972_STATUS_G_TBUCK0		= (1 << 4),
	kD1972_STATUS_G_TBUCK2		= (1 << 5),
	kD1972_STATUS_G_TBUCK3		= (1 << 6),
	kD1972_STATUS_G_TBUCK4		= (1 << 7),
};

enum {
	kDIALOG_EVENT_HOLD_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_BUTTON2),
	kDIALOG_EVENT_MENU_BUTTON_MASK	= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_BUTTON1),
	kDIALOG_EVENT_RINGER_BUTTON_MASK= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_BUTTON3),
	kDIALOG_EVENT_BUTTONS		= (kD1972_EVENT_A_BUTTON2 | 
					   kD1972_EVENT_A_BUTTON1 | 
					   kD1972_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(5, kD1972_EVENT_F_ALARM),
	kDIALOG_EVENT_ACC_DET_MASK	= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_ACC_DET),
	kDIALOG_EVENT_VBUS_DET_MASK	= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_VBUS_EXT_DET),
	kDIALOG_EVENT_VHP_DET_MASK	= EVENT_FLAG_MAKE(0, kD1972_EVENT_A_FW_DET),
	kDIALOG_EVENT_VBUS_EXT_REM_MASK	= EVENT_FLAG_MAKE(5, kD1972_EVENT_F_VBUS_EXT_REM),
	kDIALOG_EVENT_EOMC_MASK		= EVENT_FLAG_MAKE(1, kD1972_EVENT_B_EOMC),
	kDIALOG_EVENT_HIB_MASK		= EVENT_FLAG_MAKE(1, kDIALOG_EVENT_B_HIB),
	kDIALOG_EVENT_ABCC_MASK		= EVENT_FLAG_MAKE(3, kD1972_EVENT_D_CHG_ABCC_ACT),
	
	kDIALOG_EVENT_CHG_END_MASK	= EVENT_FLAG_MAKE(1, kD1972_EVENT_B_CHG_END),
	kDIALOG_EVENT_TBAT_MASK		= EVENT_FLAG_MAKE(1, kD1972_EVENT_B_TBAT),
	
	kDIALOG_EVENT_GPIO1_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO1),
	kDIALOG_EVENT_GPIO2_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO2),
	kDIALOG_EVENT_GPIO3_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO3),
	kDIALOG_EVENT_GPIO4_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO4),
	kDIALOG_EVENT_GPIO5_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO5),
	kDIALOG_EVENT_GPIO6_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO6),
	kDIALOG_EVENT_GPIO7_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO7),
	kDIALOG_EVENT_GPIO8_MASK	= EVENT_FLAG_MAKE(2, kD1972_EVENT_C_GPIO8),
	kDIALOG_EVENT_GPIO9_MASK	= EVENT_FLAG_MAKE(3, kD1972_EVENT_D_GPIO9),
	kDIALOG_EVENT_GPIO10_MASK	= EVENT_FLAG_MAKE(3, kD1972_EVENT_D_GPIO10),
	kDIALOG_EVENT_GPIO11_MASK	= EVENT_FLAG_MAKE(3, kD1972_EVENT_D_GPIO11),
	kDIALOG_EVENT_GPIO12_MASK	= EVENT_FLAG_MAKE(3, kD1972_EVENT_D_GPIO12),

	kDIALOG_EVENT_HOLD_DBL_MASK	= EVENT_FLAG_MAKE(8, kD1972_EVENT_I_BTN2_DBL),
	kDIALOG_EVENT_MENU_DBL_MASK	= EVENT_FLAG_MAKE(8, kD1972_EVENT_I_BTN1_DBL),
	kDIALOG_EVENT_RINGER_DBL_MASK	= EVENT_FLAG_MAKE(8, kD1972_EVENT_I_BTN3_DBL),

	kDIALOG_EVENT_ON_MASK		= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_LDO2_EN_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO13_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO14_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO15_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO16_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO17_MASK	= kDIALOG_NOTEXIST_MASK,
	kDIALOG_EVENT_GPIO18_MASK	= kDIALOG_NOTEXIST_MASK,
};

enum {
	kDIALOG_STATUS_USB_MASK		= STATUS_FLAG_MAKE(0, kD1972_STATUS_A_VCENTER_DET),
	kDIALOG_STATUS_VBUS_MASK	= STATUS_FLAG_MAKE(0, kD1972_STATUS_A_VBUS_EXT_DET),
	kDIALOG_STATUS_FW_MASK		= STATUS_FLAG_MAKE(0, kD1972_STATUS_A_FW_DPHP_DET),
	kDIALOG_STATUS_ACC_DET_MASK	= STATUS_FLAG_MAKE(0, kD1972_STATUS_A_ACC_DET),
	kDIALOG_STATUS_CHARGING_MASK	= STATUS_FLAG_MAKE(1, kD1972_STATUS_B_CHG_PRE | kD1972_STATUS_B_CHG_FAST),
	kDIALOG_STATUS_CHG_TO_MASK	= STATUS_FLAG_MAKE(5, kD1972_STATUS_F_CHG_TO),
	kDIALOG_STATUS_CHG_END_MASK	= STATUS_FLAG_MAKE(1, kD1972_STATUS_B_CHG_END),
	kDIALOG_STATUS_TBAT_MASK	= STATUS_FLAG_MAKE(1, kD1972_STATUS_B_TBAT),
	kDIALOG_STATUS_CHG_ATT_MASK     = STATUS_FLAG_MAKE(5, kD1972_STATUS_F_CHG_ATT),
	kDIALOG_STATUS_ABCC_MASK	= STATUS_FLAG_MAKE(3, kD1972_STATUS_D_CHG_ABCC_ACT),
#define	kDIALOG_STATUS_GPIO_MASK(gpio)	   STATUS_FLAG_MAKE(2 + ((gpio)/8), (1 << ((gpio) % 8)))
};

static const statusRegisters kDialogStatusFWMask = {kD1972_STATUS_A_FW_DPHP_DET, 0, 0, 0, 0, 0};
static const statusRegisters kDialogStatusChargingMask = {0, kD1972_STATUS_B_CHG_PRE | kD1972_STATUS_B_CHG_FAST, 0, 0, 0, 0};

enum {
	kD1972_EVENT_A_WAKEMASK = (kD1972_EVENT_A_BUTTON1 |
				   kD1972_EVENT_A_BUTTON2 |
				   kD1972_EVENT_A_BUTTON3 |
				   kD1972_EVENT_A_VBUS_EXT_DET |
				   kD1972_STATUS_A_FW_DPHP_DET |
				   kD1972_EVENT_A_ACC_DET),
	kD1972_EVENT_B_WAKEMASK = 0,
	kD1972_EVENT_C_WAKEMASK = 0,
	kD1972_EVENT_D_WAKEMASK = 0,
	kD1972_EVENT_E_WAKEMASK = 0,
	kD1972_EVENT_F_WAKEMASK = (kD1972_EVENT_F_ALARM |
				   kD1972_EVENT_F_FW_DPHP_REM |
				   kD1972_EVENT_F_VBUS_EXT_REM),
	kD1972_EVENT_G_WAKEMASK = 0,
	kD1972_EVENT_H_WAKEMASK = 0,
	kD1972_EVENT_I_WAKEMASK = 0,
};

// All events that are masked during shutdown - inverse of the wake mask,
// events that wake up the system
static const eventRegisters kDialogEventIntMasks = {
	~kD1972_EVENT_A_WAKEMASK,
	~kD1972_EVENT_B_WAKEMASK,
	~kD1972_EVENT_C_WAKEMASK,
	~kD1972_EVENT_D_WAKEMASK,
	~kD1972_EVENT_E_WAKEMASK,
	~kD1972_EVENT_F_WAKEMASK,
	~kD1972_EVENT_G_WAKEMASK,
	~kD1972_EVENT_H_WAKEMASK,
	~kD1972_EVENT_I_WAKEMASK,
};


// All wake events without the buttons
static const eventRegisters kDialogEventNotButtonMasks = {
	kD1972_EVENT_A_WAKEMASK & ~kDIALOG_EVENT_BUTTONS,
	kD1972_EVENT_B_WAKEMASK,
	kD1972_EVENT_C_WAKEMASK,
	kD1972_EVENT_D_WAKEMASK,
	kD1972_EVENT_E_WAKEMASK,
	kD1972_EVENT_F_WAKEMASK,
	kD1972_EVENT_G_WAKEMASK,
	kD1972_EVENT_H_WAKEMASK,
	kD1972_EVENT_I_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,
	EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ALARM_MASK, 5),
	0,
	0,
	0,
};

// All events indicating external power supply
static const eventRegisters kDialogEventPwrsupplyMask = {
	kD1972_EVENT_A_VBUS_EXT_DET | kD1972_EVENT_A_FW_DET | kD1972_EVENT_A_VCENTER_DET,
	0,
	0,
	0,
	0,
	kD1972_EVENT_F_FW_DPHP_REM | kD1972_EVENT_F_VBUS_EXT_REM,
	0,
	0,
	0,
};

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

static const eventRegisters kDialogEventFWMask = {
	kD1972_EVENT_A_FW_DET,
	0,
	0,
	0,
	0,
	kD1972_EVENT_F_FW_DPHP_REM,
	0,
	0,
	0,
};

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

enum {
	kDIALOG_LCM_ACTIVE_BOOST_EN		= (1 << 6),
	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_CONTROL_DWI_EN		= (1 << 4),
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MIN  = 0x00,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_100  = 0x03,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_200  = 0x0d,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_500  = 0x2b,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1000 = 0x5d,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2000 = 0xc1,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MAX  = 0xff,
	kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MASK = 0xff,
};

enum {
	kDIALOG_CHARGE_BUCK_CONTROL_MIN		   = 70,
	kDIALOG_CHARGE_BUCK_CONTROL_STEP_PER_100MA = 10,
	kDIALOG_CHARGE_BUCK_CONTROL_MAX		   = 2620,
};


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_B_CHG_SUSP	= (1 << 6),
	kDIALOG_CHARGE_CONTROL_B_CHG_HIB	= (1 << 7),
	kDIALOG_CHARGE_CONTROL_CHG_HIB		= kDIALOG_CHARGE_CONTROL_B_CHG_HIB,
};

enum {
	kDIALOG_CHARGE_CONTROL_STEP		= 30,
	kDIALOG_CHARGE_CONTROL_MAX		= kDIALOG_CHARGE_CONTROL_A_ISET_BAT_MASK * kDIALOG_CHARGE_CONTROL_STEP,
};

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_IBUS_IN_LG	= (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_IBUS_IN_HG	= (0x9 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VIBUS	= kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_HG,
	kDIALOG_ADC_CONTROL_MUX_SEL_NTC0	= (0xa << 0),
	kDIALOG_ADC_CONTROL_MUX_NUM_NTC		= 5,
	kDIALOG_ADC_CONTROL_MUX_SEL_VBUS	= (0xf << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN_HG_OFF	= (16 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_IBUS_IN__LG_OFF	= (17 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_LDO5_TEMP	= (18 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_LDO16_TEMP	= (19 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_VCENTER_TEMP	= (20 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_CHG_TEMP	= (21 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK0_TEMP	= (22 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK2_TEMP	= (23 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK3_TEMP	= (24 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_BUCK4_TEMP	= (25 << 0),
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_START	= kDIALOG_ADC_CONTROL_MUX_SEL_LDO5_TEMP,
	kDIALOG_ADC_CONTROL_MUX_SEL_TINT_END	= kDIALOG_ADC_CONTROL_MUX_SEL_BUCK4_TEMP,
	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	= (0 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO1	= (1 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO2	= (2 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO2	= (3 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO3	= (4 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO3	= (5 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO4	= (6 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO4	= (7 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO5	= (8 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO5	= (9 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO6	= (10 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO6	= (11 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO7	= (12 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO7	= (13 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO8	= (14 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO8	= (15 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO9	= (16 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO9	= (17 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO10	= (18 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO10	= (19 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO11	= (20 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO11	= (21 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO12	= (22 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO12	= (23 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM1	= (24 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM1	= (25 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM2	= (26 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM2	= (27 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLCM3	= (28 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILCM3	= (29 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO16	= (30 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_ILDO16	= (31 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VRTC	= (32 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IRTC	= (33 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUF_ON	= (34 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_IBUF_ON	= (35 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0A	= (36 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0B	= (38 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK0C	= (40 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK2	= (42 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK3	= (44 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK4	= (46 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_CPUA_SW_S	= (48 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_CPUB_SW_S	= (50 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VOUT_LED	= (52 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBOOST_LCM	= (54 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_A	= (56 << 0),
	kDIALOG_BIST_ADC_CTRL_MUX_SEL_APP_MUX_B	= (58 << 0),
	kDIALOG_BIST_ADC_CTRL_AUTO_RUN		= (1 << 6),
	kDIALOG_BIST_ADC_CTRL_MAN_CONV		= (1 << 7),
};

enum {
	kDIALOG_APP_TMUX_SEL_MASK		= (7 << 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_RAMP_EN	= (1 << 2),
	kDIALOG_WLED_CONTROL_WLED_DWI_EN	= (1 << 3),
	kDIALOG_WLED_CONTROL_WLED_DITH_EN	= (1 << 4),
	kDIALOG_WLED_CONTROL_WLED_DITH_RAMP_EN	= (1 << 5),
	
	kDIALOG_WLED_OPTIONS_DEFAULT		= kDIALOG_WLED_CONTROL_WLED_DITH_EN,
	kDIALOG_WLED_OPTIONS_xWI_EN		= kDIALOG_WLED_CONTROL_WLED_DWI_EN,
	kDIALOG_WLED_OPTIONS_MASK		= (kDIALOG_WLED_CONTROL_WLED_RAMP_EN|
						   kDIALOG_WLED_CONTROL_WLED_DITH_EN|
						   kDIALOG_WLED_CONTROL_WLED_DITH_RAMP_EN),	
};

#define WLED_ISET_BITS	(11)

#define NUM_LDOS 23
static const struct ldo_params ldo_1972[NUM_LDOS] = {
{ 2500, 50, 0x15, 0x1f, 0x1, kD1972_LDO1,            kD1972_ACTIVE1, 0x40 },	// LDO1
// LDO2 is funny and has a gap from 1.335V to 1.65V, only supporting the top part
{ 1490, 5,  0x3f, 0x3f, 0x0, kD1972_LDO2,            kD1972_ACTIVE1, 0x80 },	// LDO2
{ 2500, 50, 0x10, 0x1f, 0x0, kD1972_LDO3,            kD1972_ACTIVE2, 0x01 },	// LDO3
{ 1800, 50, 0x1e, 0x1f, 0x0, kD1972_LDO4,            kD1972_ACTIVE2, 0x02 },	// LDO4
{ 2500, 50, 0x16, 0x1f, 0x0, kD1972_LDO5,            kD1972_ACTIVE2, 0x04 },	// LDO5
{ 2500, 50, 0x16, 0x1f, 0x2, kD1972_LDO6,            kD1972_ACTIVE2, 0x08 },	// LDO6
{ 1500, 100,0x16, 0x1f, 0x0, kD1972_LDO7,            kD1972_ACTIVE2, 0x10 },	// LDO7
{ 2000, 50, 0x1f, 0x1f, 0x0, kD1972_LDO8,            kD1972_ACTIVE2, 0x20 },	// LDO8
{ 1200, 100,0x12, 0x1f, 0x0, kD1972_LDO9,            kD1972_ACTIVE2, 0x40 },	// LDO9
{ 2500, 50, 0x15, 0x1f, 0x4, kD1972_LDO10,           kD1972_ACTIVE2, 0x80 },	// LDO10
{ 1700, 50, 0x1a, 0x1f, 0x0, kD1972_LDO11,           kD1972_ACTIVE3, 0x01 },	// LDO11
{ 600,  25, 0x1c, 0x1f, 0x0, kD1972_LDO12,           kD1972_ACTIVE3, 0x02 },	// LDO12
{ 5000, 50, 0x14, 0x1f, 0x0, kD1972_LCM_CONTROL1,    kD1972_ACTIVE3, 0x04 },	// LCM1_LDO
{ 5000, 50, 0x14, 0x1f, 0x0, kD1972_LCM_CONTROL2,    kD1972_ACTIVE3, 0x08 },	// LCM2_LDO
{ 5000, 50, 0x14, 0x1f, 0x0, kD1972_LCM_CONTROL3,    kD1972_ACTIVE3, 0x10 },	// LCM3_LDO
{ 5000, 50, 0x1f, 0x1f, 0x0, kD1972_LCM_BST_CONTROL, kD1972_ACTIVE3, 0x40 },	// LCM_BOOST
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_ACTIVE3, 0x80 },	// 17 - WLED_BST_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_ACTIVE4, 0x10 },	// 18 - DSP_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_ACTIVE4, 0x20 },	// 19 - CPU1V2_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_ACTIVE4, 0x40 },	// 20 - WDIG_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_ACTIVE4, 0x80 },	// 21 - CPU1V8_SW_EN
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_HIBERNATE1, 0x20 },	// 22 - set LDO1_EN in HIB
{ 0,    0,  0,    0,    0x0, 0,			     kD1972_HIBERNATE2, 0x08 },	// 23 - set LDO6_EN in HIB
};
#define LDOP ldo_1972

enum {
	kDIALOG_VIB_CTRL_PWM_EN			= (1 << 0),
	kDIALOG_VIB_CTRL_BRAKE			= (1 << 1),
	kDIALOG_VIB_CTRL_PWM_CLK_MASK		= (3 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_2MHZ		= (0 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_1MHZ		= (1 << 2),
	kDIALOG_VIB_CTRL_PWM_CLK_500KHZ		= (2 << 2),

	kDIALOG_VIB_VSET_MASK			= (0x3f << 0),
};

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),
	kD1972_BUTTON_DBL_BTN1_DBL_EN		= (1 << 3),
	kD1972_BUTTON_DBL_BTN2_DBL_EN		= (1 << 4),
	kD1972_BUTTON_DBL_BTN3_DBL_EN		= (1 << 5),
	kDIALOG_BUTTON_DBL_HOLD_DBL_EN		= kD1972_BUTTON_DBL_BTN2_DBL_EN,
	kDIALOG_BUTTON_DBL_MENU_DBL_EN		= kD1972_BUTTON_DBL_BTN1_DBL_EN,
	kDIALOG_BUTTON_DBL_RINGER_DBL_EN	= kD1972_BUTTON_DBL_BTN3_DBL_EN,
};

#endif /* __DIALOG_D1972_H */
