iBoot/drivers/dialog/pmu/d1815.h

678 lines
22 KiB
C

#define PMU_HAS_SWI 1
#define PMU_HAS_DWI 0
#define PMU_HAS_REG_BANK 0
#define PMU_HAS_LCM_LDO 1
#define PMU_HAS_BIST_ADC 1
#define PMU_HAS_VIB 1
#define PMU_HAS_WLED 1
enum {
kDIALOG_ADDR_R = 0xe8,
kDIALOG_ADDR_W = 0xe9,
kDIALOG_REG_BYTES = 1,
};
enum {
kDIALOG_EVENT_COUNT = 6,
kDIALOG_STATUS_COUNT = 5,
kDIALOG_HIBERNATE_COUNT = 3,
kDIALOG_CHIPID_COUNT = 1,
kDIALOG_FAULTLOG_COUNT = 1,
kDIALOG_GPIO_COUNT = 10,
};
#include "dCommon.h"
enum {
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_STATUS_A = 0x07,
kDIALOG_STATUS_B = 0x08,
kDIALOG_STATUS_C = 0x09,
kDIALOG_STATUS_D = 0x0a,
kDIALOG_STATUS_E = 0x0b,
kDIALOG_IRQ_MASK_A = 0x0c,
kDIALOG_IRQ_MASK_B = 0x0d,
kDIALOG_IRQ_MASK_C = 0x0e,
kDIALOG_IRQ_MASK_D = 0x0f,
kDIALOG_IRQ_MASK_E = 0x10,
kDIALOG_IRQ_MASK_F = 0x11,
kDIALOG_SYS_CONTROL = 0x12,
kDIALOG_FAULT_LOG = 0x13,
kD1815_ACTIVE1 = 0x14,
kD1815_ACTIVE2 = 0x15,
kD1815_ACTIVE3 = 0x16,
kDIALOG_LCM_ACTIVE = kD1815_ACTIVE3,
kD1815_STANDBY1 = 0x17,
kDIALOG_STANDBY = kD1815_STANDBY1,
kD1815_HIBERNATE1 = 0x18,
kD1815_HIBERNATE2 = 0x19,
kD1815_HIBERNATE3 = 0x1a,
kD1815_BUCK1 = 0x1b,
kDIALOG_BUCK1 = kD1815_BUCK1,
kD1815_BUCK2 = 0x1c,
kD1815_LDO1 = 0x1d,
kD1815_LDO2 = 0x1e,
kD1815_LDO3 = 0x1f,
kD1815_LDO4 = 0x20,
kD1815_LDO5 = 0x21,
kD1815_LDO6 = 0x22,
kD1815_LDO7 = 0x23,
kD1815_LDO8 = 0x24,
kD1815_LDO9 = 0x25,
kD1815_LDO10 = 0x26,
kD1815_LDO11 = 0x27,
kD1815_LDO12 = 0x28,
kDIALOG_BUCK_CONTROL = 0x29,
kDIALOG_BUCK_CONTROL2 = 0x2a,
kDIALOG_CHARGE_BUCK_CONTROL = 0x2b,
kDIALOG_CHARGE_CONTROL_A = 0x2c,
kDIALOG_CHARGE_CONTROL_B = 0x2d,
kDIALOG_CHARGE_CONTROL_C = 0x2e,
kDIALOG_CHARGE_TIME = 0x2f,
kDIALOG_CHARGE_CONTROL_ICHG_BAT = kDIALOG_CHARGE_CONTROL_A,
kDIALOG_CHARGE_CONTROL_HIB = kDIALOG_CHARGE_CONTROL_A,
kDIALOG_CHARGE_CONTROL_TIME = kDIALOG_CHARGE_CONTROL_C,
kDIALOG_OTP_ISET_BAT = kDIALOG_CHARGE_CONTROL_A, // not a real OTP register
kDIALOG_ADC_CONTROL = 0x30,
kDIALOG_ADC_LSB = 0x31,
kDIALOG_ADC_MSB = 0x32,
kDIALOG_ADC_BIST_CONTROL = 0x33,
kD1815_ADC_T_ISET = 0x34,
kDIALOG_ICHG_AVG = 0x35,
kDIALOG_TBAT_0 = 0x38,
kDIALOG_ICHG_TBAT_0 = 0x39,
kDIALOG_TBAT_1 = 0x3a,
kDIALOG_ICHG_TBAT_1 = 0x3b,
kDIALOG_TBAT_2 = 0x3c,
kDIALOG_ICHG_TBAT_2 = 0x3d,
kDIALOG_TBAT_3 = 0x3e,
kDIALOG_ICHG_TBAT_3 = 0x3f,
kDIALOG_TBAT_4 = 0x40,
kDIALOG_ICHG_TBAT_4 = 0x41,
kDIALOG_TBAT_MAX = 0x42,
kDIALOG_ICHG_TBAT_NUM = 5,
kDIALOG_T_OFFSET_MSB = 0x43,
kDIALOG_T_OFFSET_LSB = 0x44,
kDIALOG_RTC_ALARM_A = 0x46,
kDIALOG_RTC_ALARM_B = 0x47,
kDIALOG_RTC_ALARM_C = 0x48,
kDIALOG_RTC_ALARM_D = 0x49,
kDIALOG_RTC_CONTROL = 0x4a,
kDIALOG_RTC_TIMEZONE = 0x4b,
kDIALOG_UPCOUNT_A = 0x4c,
kDIALOG_UPCOUNT_B = 0x4d,
kDIALOG_UPCOUNT_C = 0x4e,
kDIALOG_UPCOUNT_D = 0x4f,
kD1815_SYS_GPIO_1 = 0x50,
kDIALOG_SYS_GPIO_REG_START = kD1815_SYS_GPIO_1,
kD1815_SYS_GPIO_2 = 0x51,
kD1815_SYS_GPIO_3 = 0x52,
kD1815_SYS_GPIO_4 = 0x53,
kD1815_SYS_GPIO_5 = 0x54,
kD1815_SYS_GPIO_6 = 0x55,
kD1815_SYS_GPIO_7 = 0x56,
kD1815_SYS_GPIO_8 = 0x57,
kD1815_SYS_GPIO_TEMP = 0x58,
kD1815_SYS_GPIO_SPARE = 0x59,
kD1815_SYS_GPIO_DEB1 = 0x5a,
kDIALOG_SYS_GPIO_DEB_REG_START = kD1815_SYS_GPIO_DEB1,
kD1815_SYS_GPIO_DEB2 = 0x5b,
kD1815_SYS_GPIO_DEB3 = 0x5c,
kD1815_SYS_GPIO_DEB4 = 0x5d,
kD1815_SYS_GPIO_DEB6 = 0x5e,
kDIALOG_LDO_CONTROL = 0x5f,
kDIALOG_WLED_ISET = 0x66,
kDIALOG_WLED_ISET2 = 0x67,
kDIALOG_WLED_CONTROL = 0x68,
kDIALOG_WLED_OPTIONS = kDIALOG_WLED_CONTROL,
kD1815_LCM_CONTROL1 = 0x6a,
kD1815_LCM_CONTROL2 = 0x6b,
kD1815_LCM_CONTROL3 = 0x6c,
kDIALOG_LCM_BOOST = kD1815_LCM_CONTROL3,
kDIALOG_VIB_CTRL = 0x6e,
kDIALOG_VIB_VSET = 0x6f,
kD1815_BUTTON1 = 0x78,
kD1815_BUTTON2 = 0x79,
kD1815_BUTTON3 = 0x7a,
kDIALOG_SYS_CONFIG = 0x7b,
kD1815_BUCK1_PRE1 = 0x7c,
kDIALOG_BUCK1_PRE1 = kD1815_BUCK1_PRE1,
kD1815_BUCK1_PRE2 = 0x7d,
kD1815_BUCK1_PRE3 = 0x7e,
kD1815_BUCK1_SEL = 0x7f,
kDIALOG_BUCK1_SEL = kD1815_BUCK1_SEL,
kDIALOG_MEMBYTE0 = 0x80,
kDIALOG_MEMBYTE_LAST = 0xa7,
kDIALOG_BUTTON_DBL = 0xAD,
};
enum {
kD1815_CHIP_ID_MRC_MASK = (0xf << 0),
kD1815_CHIP_ID_MRC_A0 = (0 << 0),
kD1815_CHIP_ID_MRC_A1 = (1 << 0),
};
enum {
kD1815_EVENT_A_BUTTON1 = (1 << 0),
kD1815_EVENT_A_BUTTON2 = (1 << 1),
kD1815_EVENT_A_BUTTON3 = (1 << 2),
kD1815_EVENT_A_VBUS_DET = (1 << 3),
kD1815_EVENT_A_FW_DET = (1 << 4),
kD1815_EVENT_A_ACC_DET = (1 << 5),
kD1815_EVENT_A_VBUS_EXT = (1 << 6),
kD1815_EVENT_A_VDD_LOW = (1 << 7),
};
// EVENT_B events are assumed volatile (lost over sleep/wake)
enum {
kD1815_EVENT_B_SWI = (1 << 0),
kD1815_EVENT_B_CHG_PRE = (1 << 1),
kD1815_EVENT_B_CHG_FAST = (1 << 2),
kD1815_EVENT_B_CHG_END = (1 << 3),
kD1815_EVENT_B_TBAT = (1 << 4),
kD1815_EVENT_B_EOMC = (1 << 5),
kD1815_EVENT_B_FW_OV = (1 << 6),
kDIALOG_EVENT_B_HIB = (1 << 7),
};
enum {
kD1815_EVENT_C_GPIO1 = (1 << 0),
kD1815_EVENT_C_GPIO2 = (1 << 1),
kD1815_EVENT_C_GPIO3 = (1 << 2),
kD1815_EVENT_C_GPIO4 = (1 << 3),
kD1815_EVENT_C_GPIO5 = (1 << 4),
kD1815_EVENT_C_GPIO6 = (1 << 5),
kD1815_EVENT_C_GPIO7 = (1 << 6),
kD1815_EVENT_C_GPIO8 = (1 << 7),
};
enum {
kD1815_EVENT_E_ALARM = (1 << 0),
kD1815_EVENT_E_FW_REM = (1 << 4),
kD1815_EVENT_E_VBUS_REM = (1 << 6),
};
enum {
kD1815_EVENT_F_GPIO9 = (1 << 0),
kD1815_EVENT_F_GPIO10 = (1 << 1),
kD1815_EVENT_F_BTN1_DBL = (1 << 2),
kD1815_EVENT_F_BTN2_DBL = (1 << 3),
kD1815_EVENT_F_BTN3_DBL = (1 << 4),
};
enum {
kD1815_STATUS_A_BUTTON1 = (1 << 0),
kD1815_STATUS_A_BUTTON2 = (1 << 1),
kD1815_STATUS_A_BUTTON3 = (1 << 2),
kD1815_STATUS_A_VBUS_DET = (1 << 3),
kD1815_STATUS_A_FW_DET = (1 << 4),
kD1815_STATUS_A_ACC_DET = (1 << 5),
kD1815_STATUS_A_VBUS_EXT = (1 << 6),
kD1815_STATUS_A_VDD_LOW = (1 << 7),
};
enum {
kD1815_STATUS_B_CHG_ATT = (1 << 0),
kD1815_STATUS_B_CHG_PRE = (1 << 1),
kD1815_STATUS_B_CHG_FAST = (1 << 2),
kD1815_STATUS_B_CHG_END = (1 << 3),
kD1815_STATUS_B_TBAT = (1 << 4),
kD1815_STATUS_B_CHG_TO = (1 << 5),
kD1815_STATUS_B_FW_OV = (1 << 6),
};
enum {
kD1815_STATUS_C_GPIO1 = (1 << 0),
kD1815_STATUS_C_GPIO2 = (1 << 1),
kD1815_STATUS_C_GPIO3 = (1 << 2),
kD1815_STATUS_C_GPIO4 = (1 << 3),
kD1815_STATUS_C_GPIO5 = (1 << 4),
kD1815_STATUS_C_GPIO6 = (1 << 5),
kD1815_STATUS_C_GPIO7 = (1 << 6),
kD1815_STATUS_C_GPIO8 = (1 << 7),
};
enum {
kD1815_STATUS_E_GPIO9 = (1 << 0),
kD1815_STATUS_E_GPIO10 = (1 << 1),
};
enum {
kDIALOG_EVENT_HOLD_BUTTON_MASK = EVENT_FLAG_MAKE(0, kD1815_EVENT_A_BUTTON2),
kDIALOG_EVENT_MENU_BUTTON_MASK = EVENT_FLAG_MAKE(0, kD1815_EVENT_A_BUTTON1),
kDIALOG_EVENT_RINGER_BUTTON_MASK= EVENT_FLAG_MAKE(0, kD1815_EVENT_A_BUTTON3),
kDIALOG_EVENT_BUTTONS = (kD1815_EVENT_A_BUTTON2 |
kD1815_EVENT_A_BUTTON1 |
kD1815_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(4, kD1815_EVENT_E_ALARM),
kDIALOG_EVENT_ACC_DET_MASK = EVENT_FLAG_MAKE(0, kD1815_EVENT_A_ACC_DET),
kDIALOG_EVENT_VBUS_DET_MASK = EVENT_FLAG_MAKE(0, kD1815_EVENT_A_VBUS_DET),
kDIALOG_EVENT_VHP_DET_MASK = EVENT_FLAG_MAKE(0, kD1815_STATUS_A_FW_DET),
kDIALOG_EVENT_EOMC_MASK = EVENT_FLAG_MAKE(1, kD1815_EVENT_B_EOMC),
kDIALOG_EVENT_HIB_MASK = EVENT_FLAG_MAKE(1, kDIALOG_EVENT_B_HIB),
kDIALOG_EVENT_CHG_END_MASK = EVENT_FLAG_MAKE(1, kD1815_STATUS_B_CHG_END),
kDIALOG_EVENT_TBAT_MASK = EVENT_FLAG_MAKE(1, kD1815_STATUS_B_TBAT),
kDIALOG_EVENT_GPIO1_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO1),
kDIALOG_EVENT_GPIO2_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO2),
kDIALOG_EVENT_GPIO3_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO3),
kDIALOG_EVENT_GPIO4_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO4),
kDIALOG_EVENT_GPIO5_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO5),
kDIALOG_EVENT_GPIO6_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO6),
kDIALOG_EVENT_GPIO7_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO7),
kDIALOG_EVENT_GPIO8_MASK = EVENT_FLAG_MAKE(2, kD1815_EVENT_C_GPIO8),
kDIALOG_EVENT_GPIO9_MASK = EVENT_FLAG_MAKE(5, kD1815_EVENT_F_GPIO9),
kDIALOG_EVENT_GPIO10_MASK = EVENT_FLAG_MAKE(5, kD1815_EVENT_F_GPIO10),
kDIALOG_EVENT_HOLD_DBL_MASK = EVENT_FLAG_MAKE(5, kD1815_EVENT_F_BTN2_DBL),
kDIALOG_EVENT_MENU_DBL_MASK = EVENT_FLAG_MAKE(5, kD1815_EVENT_F_BTN1_DBL),
kDIALOG_EVENT_RINGER_DBL_MASK = EVENT_FLAG_MAKE(5, kD1815_EVENT_F_BTN3_DBL),
kDIALOG_EVENT_ON_MASK = kDIALOG_NOTEXIST_MASK,
kDIALOG_EVENT_LDO2_EN_MASK = kDIALOG_NOTEXIST_MASK,
kDIALOG_EVENT_GPIO11_MASK = kDIALOG_NOTEXIST_MASK,
kDIALOG_EVENT_GPIO12_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,
/*
kDIALOG_EVENT_WAKE_MASK = ((kD1815_EVENT_A_WAKEMASK << 0)
| (kD1815_EVENT_B_WAKEMASK << 8)
| (kD1815_EVENT_C_WAKEMASK << 16)
| (kD1815_EVENT_D_WAKEMASK << 24)),
kDIALOG_EVENT_BUTTONS_MASK = (kDIALOG_EVENT_HOLD_BUTTON_MASK |
kDIALOG_EVENT_MENU_BUTTON_MASK |
kDIALOG_EVENT_RINGER_BUTTON_MASK),
kDIALOG_EVENT_PWRSUPPLY_MASK
= (((kD1815_EVENT_A_VBUS_DET | kD1815_STATUS_A_FW_DET) << 0)
| (kD1815_EVENT_C_GPIO_FW_DETECT << 16)
| ((kD1815_EVENT_D_VHP_REM | kD1815_EVENT_D_VBUS_REM) << 24)),
*/
// not on D1755
/*
kDIALOG_EVENT_ON_MASK = 0,
kDIALOG_EVENT_LDO2_EN_MASK = 0,
*/
};
enum {
kDIALOG_STATUS_USB_MASK = STATUS_FLAG_MAKE(0, kD1815_STATUS_A_VBUS_DET),
kDIALOG_STATUS_FW_MASK = STATUS_FLAG_MAKE(0, kD1815_STATUS_A_FW_DET),
kDIALOG_STATUS_ACC_DET_MASK = STATUS_FLAG_MAKE(0, kD1815_STATUS_A_ACC_DET),
kDIALOG_STATUS_CHARGING_MASK = STATUS_FLAG_MAKE(1, kD1815_STATUS_B_CHG_PRE | kD1815_STATUS_B_CHG_FAST),
kDIALOG_STATUS_CHG_TO_MASK = STATUS_FLAG_MAKE(1, kD1815_STATUS_B_CHG_TO),
kDIALOG_STATUS_CHG_END_MASK = STATUS_FLAG_MAKE(1, kD1815_STATUS_B_CHG_END),
kDIALOG_STATUS_TBAT_MASK = STATUS_FLAG_MAKE(1, kD1815_STATUS_B_TBAT),
kDIALOG_STATUS_CHG_ATT_MASK = STATUS_FLAG_MAKE(1, kD1815_STATUS_B_CHG_ATT),
#define kDIALOG_STATUS_GPIO_MASK(gpio) STATUS_FLAG_MAKE(((gpio) < 8) ? 2 : 5, (1 << ((gpio) % 8)))
};
static const statusRegisters kDialogStatusFWMask = {kD1815_STATUS_A_FW_DET, 0, 0, 0, 0};
static const statusRegisters kDialogStatusChargingMask = {0, kD1815_STATUS_B_CHG_PRE | kD1815_STATUS_B_CHG_FAST, 0, 0, 0};
enum {
kD1815_EVENT_A_WAKEMASK = kD1815_EVENT_A_BUTTON1 | kD1815_EVENT_A_BUTTON2 | kD1815_EVENT_A_BUTTON3 | kD1815_EVENT_A_VBUS_DET | kD1815_STATUS_A_FW_DET | kD1815_EVENT_A_ACC_DET,
kD1815_EVENT_B_WAKEMASK = kDIALOG_EVENT_B_HIB | kD1815_EVENT_B_TBAT | kD1815_EVENT_B_CHG_END,
kD1815_EVENT_C_WAKEMASK = kD1815_EVENT_C_GPIO1 | kD1815_EVENT_C_GPIO2 | kD1815_EVENT_C_GPIO3 | kD1815_EVENT_C_GPIO4 | kD1815_EVENT_C_GPIO5 | kD1815_EVENT_C_GPIO6 | kD1815_EVENT_C_GPIO7 | kD1815_EVENT_C_GPIO8,
kD1815_EVENT_D_WAKEMASK = 0,
kD1815_EVENT_E_WAKEMASK = kD1815_EVENT_E_ALARM | kD1815_EVENT_E_FW_REM | kD1815_EVENT_E_VBUS_REM,
kD1815_EVENT_F_WAKEMASK = kD1815_EVENT_F_GPIO9 | kD1815_EVENT_F_GPIO10,
};
// All events that are masked during shutdown - inverse of the wake mask,
// events that wake up the system
static const eventRegisters kDialogEventIntMasks = {
(UInt8)~kD1815_EVENT_A_WAKEMASK,
(UInt8)~kD1815_EVENT_B_WAKEMASK,
(UInt8)~kD1815_EVENT_C_WAKEMASK,
(UInt8)~kD1815_EVENT_D_WAKEMASK,
(UInt8)~kD1815_EVENT_E_WAKEMASK,
(UInt8)~kD1815_EVENT_F_WAKEMASK,
};
// All wake events without the buttons
static const eventRegisters kDialogEventNotButtonMasks = {
kD1815_EVENT_A_WAKEMASK & ~kDIALOG_EVENT_BUTTONS,
kD1815_EVENT_B_WAKEMASK,
kD1815_EVENT_C_WAKEMASK,
kD1815_EVENT_D_WAKEMASK,
kD1815_EVENT_E_WAKEMASK,
kD1815_EVENT_F_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,
EVENT_FLAG_GET_BIT_FOR_BYTE(kDIALOG_EVENT_ALARM_MASK, 4),
0
};
// All events indicating external power supply
static const eventRegisters kDialogEventPwrsupplyMask = {
kD1815_EVENT_A_VBUS_DET | kD1815_EVENT_A_FW_DET,
0,
0,
0,
kD1815_EVENT_E_FW_REM | kD1815_EVENT_E_VBUS_REM,
0,
};
static const eventRegisters kDialogEventUSBMask = {
kD1815_EVENT_A_VBUS_DET,
0,
0,
0,
kD1815_EVENT_E_VBUS_REM,
0,
};
static const eventRegisters kDialogEventFWMask = {
kD1815_EVENT_A_FW_DET,
0,
0,
0,
kD1815_EVENT_E_FW_REM,
0,
};
enum {
kDialogEventPwrsupplyCount = 4,
kDialogEventUSBCount = 2,
kDialogEventFWCount = 2,
};
enum {
kDIALOG_SYS_CONTROL_STANDBY = (1 << 0),
kDIALOG_SYS_CONTROL_HIBERNATE = (1 << 1),
kDIALOG_SYS_CONTROL_BAT_PWR_SUSPEND = (1 << 2),
kDIALOG_SYS_CONTROL_SWI_EN = (1 << 4),
kD1815_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_FAULT_LOG_WDOG = FAULTLOG_FLAG_MAKE(0, (1 << 5)),
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_OVER_TEMP = FAULTLOG_FLAG_MAKE(0, (1 << 1)),
kDIALOG_FAULT_LOG_VDD_UNDER = FAULTLOG_FLAG_MAKE(0, (1 << 0)),
kDIALOG_FAULT_LOG_BOOST = kDIALOG_NOTEXIST_MASK,
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 {
kD1815_ACTIVE3_LCM_BOOST_EN = (1 << 3),
kD1815_ACTIVE3_LCM_LDO1_EN = (1 << 4),
kD1815_ACTIVE3_LCM_LDO2_EN = (1 << 5),
kDIALOG_LCM_ACTIVE_BOOST_EN = kD1815_ACTIVE3_LCM_BOOST_EN,
kDIALOG_LCM_ACTIVE_MASK = (kD1815_ACTIVE3_LCM_LDO1_EN|
kD1815_ACTIVE3_LCM_LDO2_EN),
};
enum {
kDIALOG_BUCK_CONTROL_BUCK1_GO = (1 << 6),
kDIALOG_BUCK_CONTROL_BUCK1_SWI_EN = (1 << 7)
};
enum {
kDIALOG_BUCK_CONTROL2_HIB_CLK = (1 << 7),
};
enum {
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_50 = 0x00,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_100 = 0x05,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_200 = 0x0f,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_300 = 0x11,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_400 = 0x13,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_450 = 0x14,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_500 = 0x15,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_600 = 0x17,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_700 = 0x18,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_900 = 0x19,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_1000 = 0x1a,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_2000 = 0x1f,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_BUCK_MASK = 0x1f,
kDIALOG_CHARGE_BUCK_CONTROL_ISET_VBUS_CHG_BUCK_EN = (1 << 7),
};
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 = 30,
kDIALOG_CHARGE_CONTROL_MAX = 1890,
};
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 = (0xf << 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_IBAT_IN = (0x9 << 0),
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_MAN_CONV = (1 << 4),
kDIALOG_ADC_CONTROL_ADC_REF_EN = (1 << 5),
kDIALOG_ADC_CONTROL_AUTO_VDD_OUT_EN = (1 << 6),
kDIALOG_ADC_CONTROL_TBAT_ISRC_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 = (15 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK1 = (0 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO1 = (1 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO2 = (2 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO3 = (3 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO4 = (4 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO5 = (5 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO6 = (6 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO7 = (7 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO8 = (8 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO9 = (9 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO10 = (10 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO11 = (11 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VLDO12 = (12 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_VBUCK2 = (13 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_IBAT_IN_OFF = (14 << 0),
kDIALOG_BIST_ADC_CTRL_MUX_SEL_IBAT_OUT_OFF = (15 << 0),
kDIALOG_BIST_ADC_CTRL_BIST_EN = (1 << 7),
kD1815_BIST_CONTROL_STD_USB_LIMIT = (1 << 4),
};
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_SWI_EN = (1 << 3),
kDIALOG_WLED_CONTROL_WLED_DITHER_EN = (1 << 4),
kDIALOG_WLED_CONTROL_WLED_DITH_RAMP_EN = (1 << 5),
kDIALOG_WLED_OPTIONS_DEFAULT = kDIALOG_WLED_CONTROL_WLED_DITHER_EN,
kDIALOG_WLED_OPTIONS_xWI_EN = kDIALOG_WLED_CONTROL_WLED_SWI_EN,
kDIALOG_WLED_OPTIONS_MASK = (kDIALOG_WLED_CONTROL_WLED_RAMP_EN|
kDIALOG_WLED_CONTROL_WLED_DITHER_EN|
kDIALOG_WLED_CONTROL_WLED_DITH_RAMP_EN),
};
#define WLED_ISET_BITS (11)
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_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_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_WDOG_EN = (1 << 0),
kDIALOG_SYS_CONFIG_WDOG_ACTIVE = 0,
};
enum {
kDIALOG_SWI_WLED_ISET = (1 << 12),
kDIALOG_SWI_BUCK1_VSEL = (6 << 12),
};
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),
kD1815_BUTTON_DBL_BTN1_DBL_EN = (1 << 3),
kD1815_BUTTON_DBL_BTN2_DBL_EN = (1 << 4),
kD1815_BUTTON_DBL_BTN3_DBL_EN = (1 << 5),
kDIALOG_BUTTON_DBL_HOLD_DBL_EN = kD1815_BUTTON_DBL_BTN2_DBL_EN,
kDIALOG_BUTTON_DBL_MENU_DBL_EN = kD1815_BUTTON_DBL_BTN1_DBL_EN,
kDIALOG_BUTTON_DBL_RINGER_DBL_EN = kD1815_BUTTON_DBL_BTN3_DBL_EN,
};
#define NUM_LDOS 19
static const struct ldo_params ldo_1815[NUM_LDOS] = {
{ 2500, 50, 0x15, 0x1f, 0x1, kD1815_LDO1, kD1815_ACTIVE1, 0x04 }, // LDO1
{ 1650, 5, 0x1f, 0x1f, 0x0, kD1815_LDO2, kD1815_ACTIVE1, 0x08 }, // LDO2
{ 2500, 50, 0x10, 0x1f, 0x0, kD1815_LDO3, kD1815_ACTIVE1, 0x10 }, // LDO3
{ 1800, 50, 0x1e, 0x1f, 0x0, kD1815_LDO4, kD1815_ACTIVE1, 0x20 }, // LDO4
{ 2500, 50, 0x16, 0x1f, 0x2, kD1815_LDO5, kD1815_ACTIVE1, 0x40 }, // LDO5
{ 2500, 50, 0x16, 0x1f, 0x4, kD1815_LDO6, kD1815_ACTIVE1, 0x80 }, // LDO6
{ 1500, 100,0x1f, 0x1f, 0x0, kD1815_LDO7, kD1815_ACTIVE2, 0x01 }, // LDO7
{ 2000, 50, 0x1f, 0x1f, 0x0, kD1815_LDO8, kD1815_ACTIVE2, 0x02 }, // LDO8
{ 1200, 25, 0x0c, 0x0f, 0x0, kD1815_LDO9, kD1815_ACTIVE2, 0x04 }, // LDO9
{ 1700, 50, 0x1a, 0x1f, 0x8, kD1815_LDO10, kD1815_ACTIVE2, 0x08 }, // LDO10
{ 1700, 50, 0x1a, 0x1f, 0x0, kD1815_LDO11, kD1815_ACTIVE2, 0x10 }, // LDO11
{ 600, 25, 0x1c, 0x1f, 0x0, kD1815_LDO12, kD1815_ACTIVE2, 0x20 }, // LDO12
{ 0, 0, 0, 0, 0x0, 0, kD1815_ACTIVE3, 0x02 }, // 13 - WDIG_EN
{ 0, 0, 0, 0, 0x0, 0, kD1815_ACTIVE3, 0x01 }, // 14 - LDO9_DSW
{ 5000, 50, 0x14, 0x1f, 0x0, 0, kD1815_ACTIVE3, 0x10 }, // 15 - LCM_LDO1_EN
{ 5000, 50, 0x14, 0x1f, 0x0, 0, kD1815_ACTIVE3, 0x20 }, // 16 - LCM_LDO2_EN
{ 5000, 50, 0x1f, 0x1f, 0x0, 0, kD1815_ACTIVE3, 0x08 }, // 17 - LCM_BOOST_EN
{ 0, 0, 0, 0, 0x0, 0, kD1815_HIBERNATE1, 0x04 }, // 18 - set LDO1_EN in HIB
{ 0, 0, 0, 0, 0x0, 0, kD1815_HIBERNATE1, 0x80 }, // 19 - set LDO6_EN in HIB
};
#define LDOP ldo_1815