1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright ST-Ericsson 2012. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Author: Arun Murthy <arun.murthy@stericsson.com> 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _AB8500_BM_H 9*4882a593Smuzhiyun #define _AB8500_BM_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/kernel.h> 12*4882a593Smuzhiyun #include <linux/mfd/abx500.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun /* 15*4882a593Smuzhiyun * System control 2 register offsets. 16*4882a593Smuzhiyun * bank = 0x02 17*4882a593Smuzhiyun */ 18*4882a593Smuzhiyun #define AB8500_MAIN_WDOG_CTRL_REG 0x01 19*4882a593Smuzhiyun #define AB8500_LOW_BAT_REG 0x03 20*4882a593Smuzhiyun #define AB8500_BATT_OK_REG 0x04 21*4882a593Smuzhiyun /* 22*4882a593Smuzhiyun * USB/ULPI register offsets 23*4882a593Smuzhiyun * Bank : 0x5 24*4882a593Smuzhiyun */ 25*4882a593Smuzhiyun #define AB8500_USB_LINE_STAT_REG 0x80 26*4882a593Smuzhiyun #define AB8500_USB_LINE_CTRL2_REG 0x82 27*4882a593Smuzhiyun #define AB8500_USB_LINK1_STAT_REG 0x94 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* 30*4882a593Smuzhiyun * Charger / status register offfsets 31*4882a593Smuzhiyun * Bank : 0x0B 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun #define AB8500_CH_STATUS1_REG 0x00 34*4882a593Smuzhiyun #define AB8500_CH_STATUS2_REG 0x01 35*4882a593Smuzhiyun #define AB8500_CH_USBCH_STAT1_REG 0x02 36*4882a593Smuzhiyun #define AB8500_CH_USBCH_STAT2_REG 0x03 37*4882a593Smuzhiyun #define AB8540_CH_USBCH_STAT3_REG 0x04 38*4882a593Smuzhiyun #define AB8500_CH_STAT_REG 0x05 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* 41*4882a593Smuzhiyun * Charger / control register offfsets 42*4882a593Smuzhiyun * Bank : 0x0B 43*4882a593Smuzhiyun */ 44*4882a593Smuzhiyun #define AB8500_CH_VOLT_LVL_REG 0x40 45*4882a593Smuzhiyun #define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/ 46*4882a593Smuzhiyun #define AB8500_CH_OPT_CRNTLVL_REG 0x42 47*4882a593Smuzhiyun #define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/ 48*4882a593Smuzhiyun #define AB8500_CH_WD_TIMER_REG 0x50 49*4882a593Smuzhiyun #define AB8500_CHARG_WD_CTRL 0x51 50*4882a593Smuzhiyun #define AB8500_BTEMP_HIGH_TH 0x52 51*4882a593Smuzhiyun #define AB8500_LED_INDICATOR_PWM_CTRL 0x53 52*4882a593Smuzhiyun #define AB8500_LED_INDICATOR_PWM_DUTY 0x54 53*4882a593Smuzhiyun #define AB8500_BATT_OVV 0x55 54*4882a593Smuzhiyun #define AB8500_CHARGER_CTRL 0x56 55*4882a593Smuzhiyun #define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/ 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /* 58*4882a593Smuzhiyun * Charger / main control register offsets 59*4882a593Smuzhiyun * Bank : 0x0B 60*4882a593Smuzhiyun */ 61*4882a593Smuzhiyun #define AB8500_MCH_CTRL1 0x80 62*4882a593Smuzhiyun #define AB8500_MCH_CTRL2 0x81 63*4882a593Smuzhiyun #define AB8500_MCH_IPT_CURLVL_REG 0x82 64*4882a593Smuzhiyun #define AB8500_CH_WD_REG 0x83 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* 67*4882a593Smuzhiyun * Charger / USB control register offsets 68*4882a593Smuzhiyun * Bank : 0x0B 69*4882a593Smuzhiyun */ 70*4882a593Smuzhiyun #define AB8500_USBCH_CTRL1_REG 0xC0 71*4882a593Smuzhiyun #define AB8500_USBCH_CTRL2_REG 0xC1 72*4882a593Smuzhiyun #define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2 73*4882a593Smuzhiyun #define AB8540_USB_PP_MODE_REG 0xC5 74*4882a593Smuzhiyun #define AB8540_USB_PP_CHR_REG 0xC6 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun /* 77*4882a593Smuzhiyun * Gas Gauge register offsets 78*4882a593Smuzhiyun * Bank : 0x0C 79*4882a593Smuzhiyun */ 80*4882a593Smuzhiyun #define AB8500_GASG_CC_CTRL_REG 0x00 81*4882a593Smuzhiyun #define AB8500_GASG_CC_ACCU1_REG 0x01 82*4882a593Smuzhiyun #define AB8500_GASG_CC_ACCU2_REG 0x02 83*4882a593Smuzhiyun #define AB8500_GASG_CC_ACCU3_REG 0x03 84*4882a593Smuzhiyun #define AB8500_GASG_CC_ACCU4_REG 0x04 85*4882a593Smuzhiyun #define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05 86*4882a593Smuzhiyun #define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06 87*4882a593Smuzhiyun #define AB8500_GASG_CC_SMPL_CNVL_REG 0x07 88*4882a593Smuzhiyun #define AB8500_GASG_CC_SMPL_CNVH_REG 0x08 89*4882a593Smuzhiyun #define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09 90*4882a593Smuzhiyun #define AB8500_GASG_CC_OFFSET_REG 0x0A 91*4882a593Smuzhiyun #define AB8500_GASG_CC_NCOV_ACCU 0x10 92*4882a593Smuzhiyun #define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11 93*4882a593Smuzhiyun #define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12 94*4882a593Smuzhiyun #define AB8500_GASG_CC_NCOV_ACCU_MED 0x13 95*4882a593Smuzhiyun #define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun /* 98*4882a593Smuzhiyun * Interrupt register offsets 99*4882a593Smuzhiyun * Bank : 0x0E 100*4882a593Smuzhiyun */ 101*4882a593Smuzhiyun #define AB8500_IT_SOURCE2_REG 0x01 102*4882a593Smuzhiyun #define AB8500_IT_SOURCE21_REG 0x14 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun /* 105*4882a593Smuzhiyun * RTC register offsets 106*4882a593Smuzhiyun * Bank: 0x0F 107*4882a593Smuzhiyun */ 108*4882a593Smuzhiyun #define AB8500_RTC_BACKUP_CHG_REG 0x0C 109*4882a593Smuzhiyun #define AB8500_RTC_CC_CONF_REG 0x01 110*4882a593Smuzhiyun #define AB8500_RTC_CTRL_REG 0x0B 111*4882a593Smuzhiyun #define AB8500_RTC_CTRL1_REG 0x11 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun /* 114*4882a593Smuzhiyun * OTP register offsets 115*4882a593Smuzhiyun * Bank : 0x15 116*4882a593Smuzhiyun */ 117*4882a593Smuzhiyun #define AB8500_OTP_CONF_15 0x0E 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun /* GPADC constants from AB8500 spec, UM0836 */ 120*4882a593Smuzhiyun #define ADC_RESOLUTION 1024 121*4882a593Smuzhiyun #define ADC_CH_MAIN_MIN 0 122*4882a593Smuzhiyun #define ADC_CH_MAIN_MAX 20030 123*4882a593Smuzhiyun #define ADC_CH_VBUS_MIN 0 124*4882a593Smuzhiyun #define ADC_CH_VBUS_MAX 20030 125*4882a593Smuzhiyun #define ADC_CH_VBAT_MIN 2300 126*4882a593Smuzhiyun #define ADC_CH_VBAT_MAX 4800 127*4882a593Smuzhiyun #define ADC_CH_BKBAT_MIN 0 128*4882a593Smuzhiyun #define ADC_CH_BKBAT_MAX 3200 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /* Main charge i/p current */ 131*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_0P9A 0x80 132*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P0A 0x90 133*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P1A 0xA0 134*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P2A 0xB0 135*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P3A 0xC0 136*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P4A 0xD0 137*4882a593Smuzhiyun #define MAIN_CH_IP_CUR_1P5A 0xE0 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun /* ChVoltLevel */ 140*4882a593Smuzhiyun #define CH_VOL_LVL_3P5 0x00 141*4882a593Smuzhiyun #define CH_VOL_LVL_4P0 0x14 142*4882a593Smuzhiyun #define CH_VOL_LVL_4P05 0x16 143*4882a593Smuzhiyun #define CH_VOL_LVL_4P1 0x1B 144*4882a593Smuzhiyun #define CH_VOL_LVL_4P15 0x20 145*4882a593Smuzhiyun #define CH_VOL_LVL_4P2 0x25 146*4882a593Smuzhiyun #define CH_VOL_LVL_4P6 0x4D 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun /* ChOutputCurrentLevel */ 149*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P1 0x00 150*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P2 0x01 151*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P3 0x02 152*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P4 0x03 153*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P5 0x04 154*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P6 0x05 155*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P7 0x06 156*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P8 0x07 157*4882a593Smuzhiyun #define CH_OP_CUR_LVL_0P9 0x08 158*4882a593Smuzhiyun #define CH_OP_CUR_LVL_1P4 0x0D 159*4882a593Smuzhiyun #define CH_OP_CUR_LVL_1P5 0x0E 160*4882a593Smuzhiyun #define CH_OP_CUR_LVL_1P6 0x0F 161*4882a593Smuzhiyun #define CH_OP_CUR_LVL_2P 0x3F 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun /* BTEMP High thermal limits */ 164*4882a593Smuzhiyun #define BTEMP_HIGH_TH_57_0 0x00 165*4882a593Smuzhiyun #define BTEMP_HIGH_TH_52 0x01 166*4882a593Smuzhiyun #define BTEMP_HIGH_TH_57_1 0x02 167*4882a593Smuzhiyun #define BTEMP_HIGH_TH_62 0x03 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun /* current is mA */ 170*4882a593Smuzhiyun #define USB_0P1A 100 171*4882a593Smuzhiyun #define USB_0P2A 200 172*4882a593Smuzhiyun #define USB_0P3A 300 173*4882a593Smuzhiyun #define USB_0P4A 400 174*4882a593Smuzhiyun #define USB_0P5A 500 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun #define LOW_BAT_3P1V 0x20 177*4882a593Smuzhiyun #define LOW_BAT_2P3V 0x00 178*4882a593Smuzhiyun #define LOW_BAT_RESET 0x01 179*4882a593Smuzhiyun #define LOW_BAT_ENABLE 0x01 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun /* Backup battery constants */ 182*4882a593Smuzhiyun #define BUP_ICH_SEL_50UA 0x00 183*4882a593Smuzhiyun #define BUP_ICH_SEL_150UA 0x04 184*4882a593Smuzhiyun #define BUP_ICH_SEL_300UA 0x08 185*4882a593Smuzhiyun #define BUP_ICH_SEL_700UA 0x0C 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun enum bup_vch_sel { 188*4882a593Smuzhiyun BUP_VCH_SEL_2P5V, 189*4882a593Smuzhiyun BUP_VCH_SEL_2P6V, 190*4882a593Smuzhiyun BUP_VCH_SEL_2P8V, 191*4882a593Smuzhiyun BUP_VCH_SEL_3P1V, 192*4882a593Smuzhiyun /* 193*4882a593Smuzhiyun * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v 194*4882a593Smuzhiyun * are only available on ab8540. You can't choose these 5 195*4882a593Smuzhiyun * voltage on ab8500/ab8505/ab9540. 196*4882a593Smuzhiyun */ 197*4882a593Smuzhiyun BUP_VCH_SEL_2P7V, 198*4882a593Smuzhiyun BUP_VCH_SEL_2P9V, 199*4882a593Smuzhiyun BUP_VCH_SEL_3P0V, 200*4882a593Smuzhiyun BUP_VCH_SEL_3P2V, 201*4882a593Smuzhiyun BUP_VCH_SEL_3P3V, 202*4882a593Smuzhiyun }; 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun #define BUP_VCH_RANGE 0x02 205*4882a593Smuzhiyun #define VBUP33_VRTCN 0x01 206*4882a593Smuzhiyun 207*4882a593Smuzhiyun /* Battery OVV constants */ 208*4882a593Smuzhiyun #define BATT_OVV_ENA 0x02 209*4882a593Smuzhiyun #define BATT_OVV_TH_3P7 0x00 210*4882a593Smuzhiyun #define BATT_OVV_TH_4P75 0x01 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun /* A value to indicate over voltage */ 213*4882a593Smuzhiyun #define BATT_OVV_VALUE 4750 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun /* VBUS OVV constants */ 216*4882a593Smuzhiyun #define VBUS_OVV_SELECT_MASK 0x78 217*4882a593Smuzhiyun #define VBUS_OVV_SELECT_5P6V 0x00 218*4882a593Smuzhiyun #define VBUS_OVV_SELECT_5P7V 0x08 219*4882a593Smuzhiyun #define VBUS_OVV_SELECT_5P8V 0x10 220*4882a593Smuzhiyun #define VBUS_OVV_SELECT_5P9V 0x18 221*4882a593Smuzhiyun #define VBUS_OVV_SELECT_6P0V 0x20 222*4882a593Smuzhiyun #define VBUS_OVV_SELECT_6P1V 0x28 223*4882a593Smuzhiyun #define VBUS_OVV_SELECT_6P2V 0x30 224*4882a593Smuzhiyun #define VBUS_OVV_SELECT_6P3V 0x38 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun #define VBUS_AUTO_IN_CURR_LIM_ENA 0x04 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun /* Fuel Gauge constants */ 229*4882a593Smuzhiyun #define RESET_ACCU 0x02 230*4882a593Smuzhiyun #define READ_REQ 0x01 231*4882a593Smuzhiyun #define CC_DEEP_SLEEP_ENA 0x02 232*4882a593Smuzhiyun #define CC_PWR_UP_ENA 0x01 233*4882a593Smuzhiyun #define CC_SAMPLES_40 0x28 234*4882a593Smuzhiyun #define RD_NCONV_ACCU_REQ 0x01 235*4882a593Smuzhiyun #define CC_CALIB 0x08 236*4882a593Smuzhiyun #define CC_INTAVGOFFSET_ENA 0x10 237*4882a593Smuzhiyun #define CC_MUXOFFSET 0x80 238*4882a593Smuzhiyun #define CC_INT_CAL_N_AVG_MASK 0x60 239*4882a593Smuzhiyun #define CC_INT_CAL_SAMPLES_16 0x40 240*4882a593Smuzhiyun #define CC_INT_CAL_SAMPLES_8 0x20 241*4882a593Smuzhiyun #define CC_INT_CAL_SAMPLES_4 0x00 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun /* RTC constants */ 244*4882a593Smuzhiyun #define RTC_BUP_CH_ENA 0x10 245*4882a593Smuzhiyun 246*4882a593Smuzhiyun /* BatCtrl Current Source Constants */ 247*4882a593Smuzhiyun #define BAT_CTRL_7U_ENA 0x01 248*4882a593Smuzhiyun #define BAT_CTRL_20U_ENA 0x02 249*4882a593Smuzhiyun #define BAT_CTRL_18U_ENA 0x01 250*4882a593Smuzhiyun #define BAT_CTRL_16U_ENA 0x02 251*4882a593Smuzhiyun #define BAT_CTRL_CMP_ENA 0x04 252*4882a593Smuzhiyun #define FORCE_BAT_CTRL_CMP_HIGH 0x08 253*4882a593Smuzhiyun #define BAT_CTRL_PULL_UP_ENA 0x10 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun /* Battery type */ 256*4882a593Smuzhiyun #define BATTERY_UNKNOWN 00 257*4882a593Smuzhiyun 258*4882a593Smuzhiyun /* Registers for pcut feature in ab8505 and ab9540 */ 259*4882a593Smuzhiyun #define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12 260*4882a593Smuzhiyun #define AB8505_RTC_PCUT_TIME_REG 0x13 261*4882a593Smuzhiyun #define AB8505_RTC_PCUT_MAX_TIME_REG 0x14 262*4882a593Smuzhiyun #define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15 263*4882a593Smuzhiyun #define AB8505_RTC_PCUT_RESTART_REG 0x16 264*4882a593Smuzhiyun #define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun /* USB Power Path constants for ab8540 */ 267*4882a593Smuzhiyun #define BUS_VSYS_VOL_SELECT_MASK 0x06 268*4882a593Smuzhiyun #define BUS_VSYS_VOL_SELECT_3P6V 0x00 269*4882a593Smuzhiyun #define BUS_VSYS_VOL_SELECT_3P325V 0x02 270*4882a593Smuzhiyun #define BUS_VSYS_VOL_SELECT_3P9V 0x04 271*4882a593Smuzhiyun #define BUS_VSYS_VOL_SELECT_4P3V 0x06 272*4882a593Smuzhiyun #define BUS_POWER_PATH_MODE_ENA 0x01 273*4882a593Smuzhiyun #define BUS_PP_PRECHG_CURRENT_MASK 0x0E 274*4882a593Smuzhiyun #define BUS_POWER_PATH_PRECHG_ENA 0x01 275*4882a593Smuzhiyun 276*4882a593Smuzhiyun /** 277*4882a593Smuzhiyun * struct res_to_temp - defines one point in a temp to res curve. To 278*4882a593Smuzhiyun * be used in battery packs that combines the identification resistor with a 279*4882a593Smuzhiyun * NTC resistor. 280*4882a593Smuzhiyun * @temp: battery pack temperature in Celsius 281*4882a593Smuzhiyun * @resist: NTC resistor net total resistance 282*4882a593Smuzhiyun */ 283*4882a593Smuzhiyun struct res_to_temp { 284*4882a593Smuzhiyun int temp; 285*4882a593Smuzhiyun int resist; 286*4882a593Smuzhiyun }; 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun /** 289*4882a593Smuzhiyun * struct batres_vs_temp - defines one point in a temp vs battery internal 290*4882a593Smuzhiyun * resistance curve. 291*4882a593Smuzhiyun * @temp: battery pack temperature in Celsius 292*4882a593Smuzhiyun * @resist: battery internal reistance in mOhm 293*4882a593Smuzhiyun */ 294*4882a593Smuzhiyun struct batres_vs_temp { 295*4882a593Smuzhiyun int temp; 296*4882a593Smuzhiyun int resist; 297*4882a593Smuzhiyun }; 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun /* Forward declaration */ 300*4882a593Smuzhiyun struct ab8500_fg; 301*4882a593Smuzhiyun 302*4882a593Smuzhiyun /** 303*4882a593Smuzhiyun * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds 304*4882a593Smuzhiyun * if not specified 305*4882a593Smuzhiyun * @recovery_sleep_timer: Time between measurements while recovering 306*4882a593Smuzhiyun * @recovery_total_time: Total recovery time 307*4882a593Smuzhiyun * @init_timer: Measurement interval during startup 308*4882a593Smuzhiyun * @init_discard_time: Time we discard voltage measurement at startup 309*4882a593Smuzhiyun * @init_total_time: Total init time during startup 310*4882a593Smuzhiyun * @high_curr_time: Time current has to be high to go to recovery 311*4882a593Smuzhiyun * @accu_charging: FG accumulation time while charging 312*4882a593Smuzhiyun * @accu_high_curr: FG accumulation time in high current mode 313*4882a593Smuzhiyun * @high_curr_threshold: High current threshold, in mA 314*4882a593Smuzhiyun * @lowbat_threshold: Low battery threshold, in mV 315*4882a593Smuzhiyun * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 316*4882a593Smuzhiyun * Resolution in 50 mV step. 317*4882a593Smuzhiyun * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 318*4882a593Smuzhiyun * Resolution in 50 mV step. 319*4882a593Smuzhiyun * @user_cap_limit Capacity reported from user must be within this 320*4882a593Smuzhiyun * limit to be considered as sane, in percentage 321*4882a593Smuzhiyun * points. 322*4882a593Smuzhiyun * @maint_thres This is the threshold where we stop reporting 323*4882a593Smuzhiyun * battery full while in maintenance, in per cent 324*4882a593Smuzhiyun * @pcut_enable: Enable power cut feature in ab8505 325*4882a593Smuzhiyun * @pcut_max_time: Max time threshold 326*4882a593Smuzhiyun * @pcut_flag_time: Flagtime threshold 327*4882a593Smuzhiyun * @pcut_max_restart: Max number of restarts 328*4882a593Smuzhiyun * @pcut_debunce_time: Sets battery debounce time 329*4882a593Smuzhiyun */ 330*4882a593Smuzhiyun struct ab8500_fg_parameters { 331*4882a593Smuzhiyun int recovery_sleep_timer; 332*4882a593Smuzhiyun int recovery_total_time; 333*4882a593Smuzhiyun int init_timer; 334*4882a593Smuzhiyun int init_discard_time; 335*4882a593Smuzhiyun int init_total_time; 336*4882a593Smuzhiyun int high_curr_time; 337*4882a593Smuzhiyun int accu_charging; 338*4882a593Smuzhiyun int accu_high_curr; 339*4882a593Smuzhiyun int high_curr_threshold; 340*4882a593Smuzhiyun int lowbat_threshold; 341*4882a593Smuzhiyun int battok_falling_th_sel0; 342*4882a593Smuzhiyun int battok_raising_th_sel1; 343*4882a593Smuzhiyun int user_cap_limit; 344*4882a593Smuzhiyun int maint_thres; 345*4882a593Smuzhiyun bool pcut_enable; 346*4882a593Smuzhiyun u8 pcut_max_time; 347*4882a593Smuzhiyun u8 pcut_flag_time; 348*4882a593Smuzhiyun u8 pcut_max_restart; 349*4882a593Smuzhiyun u8 pcut_debunce_time; 350*4882a593Smuzhiyun }; 351*4882a593Smuzhiyun 352*4882a593Smuzhiyun /** 353*4882a593Smuzhiyun * struct ab8500_charger_maximization - struct used by the board config. 354*4882a593Smuzhiyun * @use_maxi: Enable maximization for this battery type 355*4882a593Smuzhiyun * @maxi_chg_curr: Maximum charger current allowed 356*4882a593Smuzhiyun * @maxi_wait_cycles: cycles to wait before setting charger current 357*4882a593Smuzhiyun * @charger_curr_step delta between two charger current settings (mA) 358*4882a593Smuzhiyun */ 359*4882a593Smuzhiyun struct ab8500_maxim_parameters { 360*4882a593Smuzhiyun bool ena_maxi; 361*4882a593Smuzhiyun int chg_curr; 362*4882a593Smuzhiyun int wait_cycles; 363*4882a593Smuzhiyun int charger_curr_step; 364*4882a593Smuzhiyun }; 365*4882a593Smuzhiyun 366*4882a593Smuzhiyun /** 367*4882a593Smuzhiyun * struct ab8500_bm_capacity_levels - ab8500 capacity level data 368*4882a593Smuzhiyun * @critical: critical capacity level in percent 369*4882a593Smuzhiyun * @low: low capacity level in percent 370*4882a593Smuzhiyun * @normal: normal capacity level in percent 371*4882a593Smuzhiyun * @high: high capacity level in percent 372*4882a593Smuzhiyun * @full: full capacity level in percent 373*4882a593Smuzhiyun */ 374*4882a593Smuzhiyun struct ab8500_bm_capacity_levels { 375*4882a593Smuzhiyun int critical; 376*4882a593Smuzhiyun int low; 377*4882a593Smuzhiyun int normal; 378*4882a593Smuzhiyun int high; 379*4882a593Smuzhiyun int full; 380*4882a593Smuzhiyun }; 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun /** 383*4882a593Smuzhiyun * struct ab8500_bm_charger_parameters - Charger specific parameters 384*4882a593Smuzhiyun * @usb_volt_max: maximum allowed USB charger voltage in mV 385*4882a593Smuzhiyun * @usb_curr_max: maximum allowed USB charger current in mA 386*4882a593Smuzhiyun * @ac_volt_max: maximum allowed AC charger voltage in mV 387*4882a593Smuzhiyun * @ac_curr_max: maximum allowed AC charger current in mA 388*4882a593Smuzhiyun */ 389*4882a593Smuzhiyun struct ab8500_bm_charger_parameters { 390*4882a593Smuzhiyun int usb_volt_max; 391*4882a593Smuzhiyun int usb_curr_max; 392*4882a593Smuzhiyun int ac_volt_max; 393*4882a593Smuzhiyun int ac_curr_max; 394*4882a593Smuzhiyun }; 395*4882a593Smuzhiyun 396*4882a593Smuzhiyun /** 397*4882a593Smuzhiyun * struct ab8500_bm_data - ab8500 battery management data 398*4882a593Smuzhiyun * @temp_under under this temp, charging is stopped 399*4882a593Smuzhiyun * @temp_low between this temp and temp_under charging is reduced 400*4882a593Smuzhiyun * @temp_high between this temp and temp_over charging is reduced 401*4882a593Smuzhiyun * @temp_over over this temp, charging is stopped 402*4882a593Smuzhiyun * @temp_interval_chg temperature measurement interval in s when charging 403*4882a593Smuzhiyun * @temp_interval_nochg temperature measurement interval in s when not charging 404*4882a593Smuzhiyun * @main_safety_tmr_h safety timer for main charger 405*4882a593Smuzhiyun * @usb_safety_tmr_h safety timer for usb charger 406*4882a593Smuzhiyun * @bkup_bat_v voltage which we charge the backup battery with 407*4882a593Smuzhiyun * @bkup_bat_i current which we charge the backup battery with 408*4882a593Smuzhiyun * @no_maintenance indicates that maintenance charging is disabled 409*4882a593Smuzhiyun * @capacity_scaling indicates whether capacity scaling is to be used 410*4882a593Smuzhiyun * @adc_therm placement of thermistor, batctrl or battemp adc 411*4882a593Smuzhiyun * @chg_unknown_bat flag to enable charging of unknown batteries 412*4882a593Smuzhiyun * @enable_overshoot flag to enable VBAT overshoot control 413*4882a593Smuzhiyun * @fg_res resistance of FG resistor in 0.1mOhm 414*4882a593Smuzhiyun * @n_btypes number of elements in array bat_type 415*4882a593Smuzhiyun * @batt_id index of the identified battery in array bat_type 416*4882a593Smuzhiyun * @interval_charging charge alg cycle period time when charging (sec) 417*4882a593Smuzhiyun * @interval_not_charging charge alg cycle period time when not charging (sec) 418*4882a593Smuzhiyun * @temp_hysteresis temperature hysteresis 419*4882a593Smuzhiyun * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 420*4882a593Smuzhiyun * @maxi: maximization parameters 421*4882a593Smuzhiyun * @cap_levels capacity in percent for the different capacity levels 422*4882a593Smuzhiyun * @bat_type table of supported battery types 423*4882a593Smuzhiyun * @chg_params charger parameters 424*4882a593Smuzhiyun * @fg_params fuel gauge parameters 425*4882a593Smuzhiyun */ 426*4882a593Smuzhiyun struct ab8500_bm_data { 427*4882a593Smuzhiyun int temp_under; 428*4882a593Smuzhiyun int temp_low; 429*4882a593Smuzhiyun int temp_high; 430*4882a593Smuzhiyun int temp_over; 431*4882a593Smuzhiyun int temp_interval_chg; 432*4882a593Smuzhiyun int temp_interval_nochg; 433*4882a593Smuzhiyun int main_safety_tmr_h; 434*4882a593Smuzhiyun int usb_safety_tmr_h; 435*4882a593Smuzhiyun int bkup_bat_v; 436*4882a593Smuzhiyun int bkup_bat_i; 437*4882a593Smuzhiyun bool no_maintenance; 438*4882a593Smuzhiyun bool capacity_scaling; 439*4882a593Smuzhiyun bool chg_unknown_bat; 440*4882a593Smuzhiyun bool enable_overshoot; 441*4882a593Smuzhiyun enum abx500_adc_therm adc_therm; 442*4882a593Smuzhiyun int fg_res; 443*4882a593Smuzhiyun int n_btypes; 444*4882a593Smuzhiyun int batt_id; 445*4882a593Smuzhiyun int interval_charging; 446*4882a593Smuzhiyun int interval_not_charging; 447*4882a593Smuzhiyun int temp_hysteresis; 448*4882a593Smuzhiyun int gnd_lift_resistance; 449*4882a593Smuzhiyun const struct ab8500_maxim_parameters *maxi; 450*4882a593Smuzhiyun const struct ab8500_bm_capacity_levels *cap_levels; 451*4882a593Smuzhiyun const struct ab8500_bm_charger_parameters *chg_params; 452*4882a593Smuzhiyun const struct ab8500_fg_parameters *fg_params; 453*4882a593Smuzhiyun }; 454*4882a593Smuzhiyun 455*4882a593Smuzhiyun struct ab8500_btemp; 456*4882a593Smuzhiyun struct ab8500_gpadc; 457*4882a593Smuzhiyun struct ab8500_fg; 458*4882a593Smuzhiyun 459*4882a593Smuzhiyun #ifdef CONFIG_AB8500_BM 460*4882a593Smuzhiyun extern struct abx500_bm_data ab8500_bm_data; 461*4882a593Smuzhiyun 462*4882a593Smuzhiyun void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 463*4882a593Smuzhiyun struct ab8500_btemp *ab8500_btemp_get(void); 464*4882a593Smuzhiyun int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp); 465*4882a593Smuzhiyun int ab8500_btemp_get_temp(struct ab8500_btemp *btemp); 466*4882a593Smuzhiyun struct ab8500_fg *ab8500_fg_get(void); 467*4882a593Smuzhiyun int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 468*4882a593Smuzhiyun int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 469*4882a593Smuzhiyun int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 470*4882a593Smuzhiyun int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 471*4882a593Smuzhiyun int ab8500_fg_inst_curr_done(struct ab8500_fg *di); 472*4882a593Smuzhiyun 473*4882a593Smuzhiyun #else 474*4882a593Smuzhiyun static struct abx500_bm_data ab8500_bm_data; 475*4882a593Smuzhiyun #endif 476*4882a593Smuzhiyun #endif /* _AB8500_BM_H */ 477