1417c0fc2SLinus Walleij /* SPDX-License-Identifier: GPL-2.0-only */ 2417c0fc2SLinus Walleij 3417c0fc2SLinus Walleij #ifndef _AB8500_CHARGER_H_ 4417c0fc2SLinus Walleij #define _AB8500_CHARGER_H_ 5417c0fc2SLinus Walleij 6417c0fc2SLinus Walleij #include <linux/kernel.h> 7417c0fc2SLinus Walleij 8417c0fc2SLinus Walleij /* 9417c0fc2SLinus Walleij * System control 2 register offsets. 10417c0fc2SLinus Walleij * bank = 0x02 11417c0fc2SLinus Walleij */ 12417c0fc2SLinus Walleij #define AB8500_MAIN_WDOG_CTRL_REG 0x01 13417c0fc2SLinus Walleij #define AB8500_LOW_BAT_REG 0x03 14417c0fc2SLinus Walleij #define AB8500_BATT_OK_REG 0x04 15417c0fc2SLinus Walleij /* 16417c0fc2SLinus Walleij * USB/ULPI register offsets 17417c0fc2SLinus Walleij * Bank : 0x5 18417c0fc2SLinus Walleij */ 19417c0fc2SLinus Walleij #define AB8500_USB_LINE_STAT_REG 0x80 20417c0fc2SLinus Walleij #define AB8500_USB_LINE_CTRL2_REG 0x82 21417c0fc2SLinus Walleij #define AB8500_USB_LINK1_STAT_REG 0x94 22417c0fc2SLinus Walleij 23417c0fc2SLinus Walleij /* 24417c0fc2SLinus Walleij * Charger / status register offfsets 25417c0fc2SLinus Walleij * Bank : 0x0B 26417c0fc2SLinus Walleij */ 27417c0fc2SLinus Walleij #define AB8500_CH_STATUS1_REG 0x00 28417c0fc2SLinus Walleij #define AB8500_CH_STATUS2_REG 0x01 29417c0fc2SLinus Walleij #define AB8500_CH_USBCH_STAT1_REG 0x02 30417c0fc2SLinus Walleij #define AB8500_CH_USBCH_STAT2_REG 0x03 31417c0fc2SLinus Walleij #define AB8540_CH_USBCH_STAT3_REG 0x04 32417c0fc2SLinus Walleij #define AB8500_CH_STAT_REG 0x05 33417c0fc2SLinus Walleij 34417c0fc2SLinus Walleij /* 35417c0fc2SLinus Walleij * Charger / control register offfsets 36417c0fc2SLinus Walleij * Bank : 0x0B 37417c0fc2SLinus Walleij */ 38417c0fc2SLinus Walleij #define AB8500_CH_VOLT_LVL_REG 0x40 39417c0fc2SLinus Walleij #define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/ 40417c0fc2SLinus Walleij #define AB8500_CH_OPT_CRNTLVL_REG 0x42 41417c0fc2SLinus Walleij #define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/ 42417c0fc2SLinus Walleij #define AB8500_CH_WD_TIMER_REG 0x50 43417c0fc2SLinus Walleij #define AB8500_CHARG_WD_CTRL 0x51 44417c0fc2SLinus Walleij #define AB8500_BTEMP_HIGH_TH 0x52 45417c0fc2SLinus Walleij #define AB8500_LED_INDICATOR_PWM_CTRL 0x53 46417c0fc2SLinus Walleij #define AB8500_LED_INDICATOR_PWM_DUTY 0x54 47417c0fc2SLinus Walleij #define AB8500_BATT_OVV 0x55 48417c0fc2SLinus Walleij #define AB8500_CHARGER_CTRL 0x56 49417c0fc2SLinus Walleij #define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/ 50417c0fc2SLinus Walleij 51417c0fc2SLinus Walleij /* 52417c0fc2SLinus Walleij * Charger / main control register offsets 53417c0fc2SLinus Walleij * Bank : 0x0B 54417c0fc2SLinus Walleij */ 55417c0fc2SLinus Walleij #define AB8500_MCH_CTRL1 0x80 56417c0fc2SLinus Walleij #define AB8500_MCH_CTRL2 0x81 57417c0fc2SLinus Walleij #define AB8500_MCH_IPT_CURLVL_REG 0x82 58417c0fc2SLinus Walleij #define AB8500_CH_WD_REG 0x83 59417c0fc2SLinus Walleij 60417c0fc2SLinus Walleij /* 61417c0fc2SLinus Walleij * Charger / USB control register offsets 62417c0fc2SLinus Walleij * Bank : 0x0B 63417c0fc2SLinus Walleij */ 64417c0fc2SLinus Walleij #define AB8500_USBCH_CTRL1_REG 0xC0 65417c0fc2SLinus Walleij #define AB8500_USBCH_CTRL2_REG 0xC1 66417c0fc2SLinus Walleij #define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2 67417c0fc2SLinus Walleij #define AB8540_USB_PP_MODE_REG 0xC5 68417c0fc2SLinus Walleij #define AB8540_USB_PP_CHR_REG 0xC6 69417c0fc2SLinus Walleij 70417c0fc2SLinus Walleij /* 71417c0fc2SLinus Walleij * Gas Gauge register offsets 72417c0fc2SLinus Walleij * Bank : 0x0C 73417c0fc2SLinus Walleij */ 74417c0fc2SLinus Walleij #define AB8500_GASG_CC_CTRL_REG 0x00 75417c0fc2SLinus Walleij #define AB8500_GASG_CC_ACCU1_REG 0x01 76417c0fc2SLinus Walleij #define AB8500_GASG_CC_ACCU2_REG 0x02 77417c0fc2SLinus Walleij #define AB8500_GASG_CC_ACCU3_REG 0x03 78417c0fc2SLinus Walleij #define AB8500_GASG_CC_ACCU4_REG 0x04 79417c0fc2SLinus Walleij #define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05 80417c0fc2SLinus Walleij #define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06 81417c0fc2SLinus Walleij #define AB8500_GASG_CC_SMPL_CNVL_REG 0x07 82417c0fc2SLinus Walleij #define AB8500_GASG_CC_SMPL_CNVH_REG 0x08 83417c0fc2SLinus Walleij #define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09 84417c0fc2SLinus Walleij #define AB8500_GASG_CC_OFFSET_REG 0x0A 85417c0fc2SLinus Walleij #define AB8500_GASG_CC_NCOV_ACCU 0x10 86417c0fc2SLinus Walleij #define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11 87417c0fc2SLinus Walleij #define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12 88417c0fc2SLinus Walleij #define AB8500_GASG_CC_NCOV_ACCU_MED 0x13 89417c0fc2SLinus Walleij #define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14 90417c0fc2SLinus Walleij 91417c0fc2SLinus Walleij /* 92417c0fc2SLinus Walleij * Interrupt register offsets 93417c0fc2SLinus Walleij * Bank : 0x0E 94417c0fc2SLinus Walleij */ 95417c0fc2SLinus Walleij #define AB8500_IT_SOURCE2_REG 0x01 96417c0fc2SLinus Walleij #define AB8500_IT_SOURCE21_REG 0x14 97417c0fc2SLinus Walleij 98417c0fc2SLinus Walleij /* 99417c0fc2SLinus Walleij * RTC register offsets 100417c0fc2SLinus Walleij * Bank: 0x0F 101417c0fc2SLinus Walleij */ 102417c0fc2SLinus Walleij #define AB8500_RTC_BACKUP_CHG_REG 0x0C 103417c0fc2SLinus Walleij #define AB8500_RTC_CC_CONF_REG 0x01 104417c0fc2SLinus Walleij #define AB8500_RTC_CTRL_REG 0x0B 105417c0fc2SLinus Walleij #define AB8500_RTC_CTRL1_REG 0x11 106417c0fc2SLinus Walleij 107417c0fc2SLinus Walleij /* 108417c0fc2SLinus Walleij * OTP register offsets 109417c0fc2SLinus Walleij * Bank : 0x15 110417c0fc2SLinus Walleij */ 111417c0fc2SLinus Walleij #define AB8500_OTP_CONF_15 0x0E 112417c0fc2SLinus Walleij 113417c0fc2SLinus Walleij /* GPADC constants from AB8500 spec, UM0836 */ 114417c0fc2SLinus Walleij #define ADC_RESOLUTION 1024 115417c0fc2SLinus Walleij #define ADC_CH_MAIN_MIN 0 116417c0fc2SLinus Walleij #define ADC_CH_MAIN_MAX 20030 117417c0fc2SLinus Walleij #define ADC_CH_VBUS_MIN 0 118417c0fc2SLinus Walleij #define ADC_CH_VBUS_MAX 20030 119417c0fc2SLinus Walleij #define ADC_CH_VBAT_MIN 2300 120417c0fc2SLinus Walleij #define ADC_CH_VBAT_MAX 4800 121417c0fc2SLinus Walleij #define ADC_CH_BKBAT_MIN 0 122417c0fc2SLinus Walleij #define ADC_CH_BKBAT_MAX 3200 123417c0fc2SLinus Walleij 124417c0fc2SLinus Walleij /* Main charge i/p current */ 125417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_0P9A 0x80 126417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P0A 0x90 127417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P1A 0xA0 128417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P2A 0xB0 129417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P3A 0xC0 130417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P4A 0xD0 131417c0fc2SLinus Walleij #define MAIN_CH_IP_CUR_1P5A 0xE0 132417c0fc2SLinus Walleij 133417c0fc2SLinus Walleij /* ChVoltLevel */ 134417c0fc2SLinus Walleij #define CH_VOL_LVL_3P5 0x00 135417c0fc2SLinus Walleij #define CH_VOL_LVL_4P0 0x14 136417c0fc2SLinus Walleij #define CH_VOL_LVL_4P05 0x16 137417c0fc2SLinus Walleij #define CH_VOL_LVL_4P1 0x1B 138417c0fc2SLinus Walleij #define CH_VOL_LVL_4P15 0x20 139417c0fc2SLinus Walleij #define CH_VOL_LVL_4P2 0x25 140417c0fc2SLinus Walleij #define CH_VOL_LVL_4P6 0x4D 141417c0fc2SLinus Walleij 142417c0fc2SLinus Walleij /* ChOutputCurrentLevel */ 143417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P1 0x00 144417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P2 0x01 145417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P3 0x02 146417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P4 0x03 147417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P5 0x04 148417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P6 0x05 149417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P7 0x06 150417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P8 0x07 151417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_0P9 0x08 152417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_1P4 0x0D 153417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_1P5 0x0E 154417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_1P6 0x0F 155417c0fc2SLinus Walleij #define CH_OP_CUR_LVL_2P 0x3F 156417c0fc2SLinus Walleij 157417c0fc2SLinus Walleij /* BTEMP High thermal limits */ 158417c0fc2SLinus Walleij #define BTEMP_HIGH_TH_57_0 0x00 159417c0fc2SLinus Walleij #define BTEMP_HIGH_TH_52 0x01 160417c0fc2SLinus Walleij #define BTEMP_HIGH_TH_57_1 0x02 161417c0fc2SLinus Walleij #define BTEMP_HIGH_TH_62 0x03 162417c0fc2SLinus Walleij 163417c0fc2SLinus Walleij /* current is mA */ 164417c0fc2SLinus Walleij #define USB_0P1A 100 165417c0fc2SLinus Walleij #define USB_0P2A 200 166417c0fc2SLinus Walleij #define USB_0P3A 300 167417c0fc2SLinus Walleij #define USB_0P4A 400 168417c0fc2SLinus Walleij #define USB_0P5A 500 169417c0fc2SLinus Walleij 170417c0fc2SLinus Walleij #define LOW_BAT_3P1V 0x20 171417c0fc2SLinus Walleij #define LOW_BAT_2P3V 0x00 172417c0fc2SLinus Walleij #define LOW_BAT_RESET 0x01 173417c0fc2SLinus Walleij #define LOW_BAT_ENABLE 0x01 174417c0fc2SLinus Walleij 175417c0fc2SLinus Walleij /* Backup battery constants */ 176417c0fc2SLinus Walleij #define BUP_ICH_SEL_50UA 0x00 177417c0fc2SLinus Walleij #define BUP_ICH_SEL_150UA 0x04 178417c0fc2SLinus Walleij #define BUP_ICH_SEL_300UA 0x08 179417c0fc2SLinus Walleij #define BUP_ICH_SEL_700UA 0x0C 180417c0fc2SLinus Walleij 181417c0fc2SLinus Walleij enum bup_vch_sel { 182417c0fc2SLinus Walleij BUP_VCH_SEL_2P5V, 183417c0fc2SLinus Walleij BUP_VCH_SEL_2P6V, 184417c0fc2SLinus Walleij BUP_VCH_SEL_2P8V, 185417c0fc2SLinus Walleij BUP_VCH_SEL_3P1V, 186417c0fc2SLinus Walleij /* 187417c0fc2SLinus Walleij * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v 188417c0fc2SLinus Walleij * are only available on ab8540. You can't choose these 5 189417c0fc2SLinus Walleij * voltage on ab8500/ab8505/ab9540. 190417c0fc2SLinus Walleij */ 191417c0fc2SLinus Walleij BUP_VCH_SEL_2P7V, 192417c0fc2SLinus Walleij BUP_VCH_SEL_2P9V, 193417c0fc2SLinus Walleij BUP_VCH_SEL_3P0V, 194417c0fc2SLinus Walleij BUP_VCH_SEL_3P2V, 195417c0fc2SLinus Walleij BUP_VCH_SEL_3P3V, 196417c0fc2SLinus Walleij }; 197417c0fc2SLinus Walleij 198417c0fc2SLinus Walleij #define BUP_VCH_RANGE 0x02 199417c0fc2SLinus Walleij #define VBUP33_VRTCN 0x01 200417c0fc2SLinus Walleij 201417c0fc2SLinus Walleij /* Battery OVV constants */ 202417c0fc2SLinus Walleij #define BATT_OVV_ENA 0x02 203417c0fc2SLinus Walleij #define BATT_OVV_TH_3P7 0x00 204417c0fc2SLinus Walleij #define BATT_OVV_TH_4P75 0x01 205417c0fc2SLinus Walleij 206417c0fc2SLinus Walleij /* A value to indicate over voltage */ 207417c0fc2SLinus Walleij #define BATT_OVV_VALUE 4750 208417c0fc2SLinus Walleij 209417c0fc2SLinus Walleij /* VBUS OVV constants */ 210417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_MASK 0x78 211417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_5P6V 0x00 212417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_5P7V 0x08 213417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_5P8V 0x10 214417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_5P9V 0x18 215417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_6P0V 0x20 216417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_6P1V 0x28 217417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_6P2V 0x30 218417c0fc2SLinus Walleij #define VBUS_OVV_SELECT_6P3V 0x38 219417c0fc2SLinus Walleij 220417c0fc2SLinus Walleij #define VBUS_AUTO_IN_CURR_LIM_ENA 0x04 221417c0fc2SLinus Walleij 222417c0fc2SLinus Walleij /* Fuel Gauge constants */ 223417c0fc2SLinus Walleij #define RESET_ACCU 0x02 224417c0fc2SLinus Walleij #define READ_REQ 0x01 225417c0fc2SLinus Walleij #define CC_DEEP_SLEEP_ENA 0x02 226417c0fc2SLinus Walleij #define CC_PWR_UP_ENA 0x01 227417c0fc2SLinus Walleij #define CC_SAMPLES_40 0x28 228417c0fc2SLinus Walleij #define RD_NCONV_ACCU_REQ 0x01 229417c0fc2SLinus Walleij #define CC_CALIB 0x08 230417c0fc2SLinus Walleij #define CC_INTAVGOFFSET_ENA 0x10 231417c0fc2SLinus Walleij #define CC_MUXOFFSET 0x80 232417c0fc2SLinus Walleij #define CC_INT_CAL_N_AVG_MASK 0x60 233417c0fc2SLinus Walleij #define CC_INT_CAL_SAMPLES_16 0x40 234417c0fc2SLinus Walleij #define CC_INT_CAL_SAMPLES_8 0x20 235417c0fc2SLinus Walleij #define CC_INT_CAL_SAMPLES_4 0x00 236417c0fc2SLinus Walleij 237417c0fc2SLinus Walleij /* RTC constants */ 238417c0fc2SLinus Walleij #define RTC_BUP_CH_ENA 0x10 239417c0fc2SLinus Walleij 240417c0fc2SLinus Walleij /* BatCtrl Current Source Constants */ 241417c0fc2SLinus Walleij #define BAT_CTRL_7U_ENA 0x01 242417c0fc2SLinus Walleij #define BAT_CTRL_20U_ENA 0x02 243417c0fc2SLinus Walleij #define BAT_CTRL_18U_ENA 0x01 244417c0fc2SLinus Walleij #define BAT_CTRL_16U_ENA 0x02 245417c0fc2SLinus Walleij #define BAT_CTRL_CMP_ENA 0x04 246417c0fc2SLinus Walleij #define FORCE_BAT_CTRL_CMP_HIGH 0x08 247417c0fc2SLinus Walleij #define BAT_CTRL_PULL_UP_ENA 0x10 248417c0fc2SLinus Walleij 249417c0fc2SLinus Walleij /* Battery type */ 250417c0fc2SLinus Walleij #define BATTERY_UNKNOWN 00 251417c0fc2SLinus Walleij 252417c0fc2SLinus Walleij /* Registers for pcut feature in ab8505 and ab9540 */ 253417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12 254417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_TIME_REG 0x13 255417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_MAX_TIME_REG 0x14 256417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15 257417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_RESTART_REG 0x16 258417c0fc2SLinus Walleij #define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17 259417c0fc2SLinus Walleij 260417c0fc2SLinus Walleij /* USB Power Path constants for ab8540 */ 261417c0fc2SLinus Walleij #define BUS_VSYS_VOL_SELECT_MASK 0x06 262417c0fc2SLinus Walleij #define BUS_VSYS_VOL_SELECT_3P6V 0x00 263417c0fc2SLinus Walleij #define BUS_VSYS_VOL_SELECT_3P325V 0x02 264417c0fc2SLinus Walleij #define BUS_VSYS_VOL_SELECT_3P9V 0x04 265417c0fc2SLinus Walleij #define BUS_VSYS_VOL_SELECT_4P3V 0x06 266417c0fc2SLinus Walleij #define BUS_POWER_PATH_MODE_ENA 0x01 267417c0fc2SLinus Walleij #define BUS_PP_PRECHG_CURRENT_MASK 0x0E 268417c0fc2SLinus Walleij #define BUS_POWER_PATH_PRECHG_ENA 0x01 269417c0fc2SLinus Walleij 270*ee0975c3SLinus Walleij /* 271*ee0975c3SLinus Walleij * ADC for the battery thermistor. 272*ee0975c3SLinus Walleij * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined 273*ee0975c3SLinus Walleij * with a NTC resistor to both identify the battery and to measure its 274*ee0975c3SLinus Walleij * temperature. Different phone manufactures uses different techniques to both 275*ee0975c3SLinus Walleij * identify the battery and to read its temperature. 276*ee0975c3SLinus Walleij */ 277*ee0975c3SLinus Walleij enum abx500_adc_therm { 278*ee0975c3SLinus Walleij ABx500_ADC_THERM_BATCTRL, 279*ee0975c3SLinus Walleij ABx500_ADC_THERM_BATTEMP, 280*ee0975c3SLinus Walleij }; 281*ee0975c3SLinus Walleij 282*ee0975c3SLinus Walleij /** 283*ee0975c3SLinus Walleij * struct abx500_res_to_temp - defines one point in a temp to res curve. To 284*ee0975c3SLinus Walleij * be used in battery packs that combines the identification resistor with a 285*ee0975c3SLinus Walleij * NTC resistor. 286*ee0975c3SLinus Walleij * @temp: battery pack temperature in Celsius 287*ee0975c3SLinus Walleij * @resist: NTC resistor net total resistance 288*ee0975c3SLinus Walleij */ 289*ee0975c3SLinus Walleij struct abx500_res_to_temp { 290*ee0975c3SLinus Walleij int temp; 291*ee0975c3SLinus Walleij int resist; 292*ee0975c3SLinus Walleij }; 293*ee0975c3SLinus Walleij 294*ee0975c3SLinus Walleij /** 295*ee0975c3SLinus Walleij * struct abx500_v_to_cap - Table for translating voltage to capacity 296*ee0975c3SLinus Walleij * @voltage: Voltage in mV 297*ee0975c3SLinus Walleij * @capacity: Capacity in percent 298*ee0975c3SLinus Walleij */ 299*ee0975c3SLinus Walleij struct abx500_v_to_cap { 300*ee0975c3SLinus Walleij int voltage; 301*ee0975c3SLinus Walleij int capacity; 302*ee0975c3SLinus Walleij }; 303*ee0975c3SLinus Walleij 304*ee0975c3SLinus Walleij /* Forward declaration */ 305*ee0975c3SLinus Walleij struct abx500_fg; 306*ee0975c3SLinus Walleij 307*ee0975c3SLinus Walleij /** 308*ee0975c3SLinus Walleij * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds 309*ee0975c3SLinus Walleij * if not specified 310*ee0975c3SLinus Walleij * @recovery_sleep_timer: Time between measurements while recovering 311*ee0975c3SLinus Walleij * @recovery_total_time: Total recovery time 312*ee0975c3SLinus Walleij * @init_timer: Measurement interval during startup 313*ee0975c3SLinus Walleij * @init_discard_time: Time we discard voltage measurement at startup 314*ee0975c3SLinus Walleij * @init_total_time: Total init time during startup 315*ee0975c3SLinus Walleij * @high_curr_time: Time current has to be high to go to recovery 316*ee0975c3SLinus Walleij * @accu_charging: FG accumulation time while charging 317*ee0975c3SLinus Walleij * @accu_high_curr: FG accumulation time in high current mode 318*ee0975c3SLinus Walleij * @high_curr_threshold: High current threshold, in mA 319*ee0975c3SLinus Walleij * @lowbat_threshold: Low battery threshold, in mV 320*ee0975c3SLinus Walleij * @overbat_threshold: Over battery threshold, in mV 321*ee0975c3SLinus Walleij * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 322*ee0975c3SLinus Walleij * Resolution in 50 mV step. 323*ee0975c3SLinus Walleij * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 324*ee0975c3SLinus Walleij * Resolution in 50 mV step. 325*ee0975c3SLinus Walleij * @user_cap_limit Capacity reported from user must be within this 326*ee0975c3SLinus Walleij * limit to be considered as sane, in percentage 327*ee0975c3SLinus Walleij * points. 328*ee0975c3SLinus Walleij * @maint_thres This is the threshold where we stop reporting 329*ee0975c3SLinus Walleij * battery full while in maintenance, in per cent 330*ee0975c3SLinus Walleij * @pcut_enable: Enable power cut feature in ab8505 331*ee0975c3SLinus Walleij * @pcut_max_time: Max time threshold 332*ee0975c3SLinus Walleij * @pcut_flag_time: Flagtime threshold 333*ee0975c3SLinus Walleij * @pcut_max_restart: Max number of restarts 334*ee0975c3SLinus Walleij * @pcut_debounce_time: Sets battery debounce time 335*ee0975c3SLinus Walleij */ 336*ee0975c3SLinus Walleij struct abx500_fg_parameters { 337*ee0975c3SLinus Walleij int recovery_sleep_timer; 338*ee0975c3SLinus Walleij int recovery_total_time; 339*ee0975c3SLinus Walleij int init_timer; 340*ee0975c3SLinus Walleij int init_discard_time; 341*ee0975c3SLinus Walleij int init_total_time; 342*ee0975c3SLinus Walleij int high_curr_time; 343*ee0975c3SLinus Walleij int accu_charging; 344*ee0975c3SLinus Walleij int accu_high_curr; 345*ee0975c3SLinus Walleij int high_curr_threshold; 346*ee0975c3SLinus Walleij int lowbat_threshold; 347*ee0975c3SLinus Walleij int overbat_threshold; 348*ee0975c3SLinus Walleij int battok_falling_th_sel0; 349*ee0975c3SLinus Walleij int battok_raising_th_sel1; 350*ee0975c3SLinus Walleij int user_cap_limit; 351*ee0975c3SLinus Walleij int maint_thres; 352*ee0975c3SLinus Walleij bool pcut_enable; 353*ee0975c3SLinus Walleij u8 pcut_max_time; 354*ee0975c3SLinus Walleij u8 pcut_flag_time; 355*ee0975c3SLinus Walleij u8 pcut_max_restart; 356*ee0975c3SLinus Walleij u8 pcut_debounce_time; 357*ee0975c3SLinus Walleij }; 358*ee0975c3SLinus Walleij 359*ee0975c3SLinus Walleij /** 360*ee0975c3SLinus Walleij * struct abx500_charger_maximization - struct used by the board config. 361*ee0975c3SLinus Walleij * @use_maxi: Enable maximization for this battery type 362*ee0975c3SLinus Walleij * @maxi_chg_curr: Maximum charger current allowed 363*ee0975c3SLinus Walleij * @maxi_wait_cycles: cycles to wait before setting charger current 364*ee0975c3SLinus Walleij * @charger_curr_step delta between two charger current settings (mA) 365*ee0975c3SLinus Walleij */ 366*ee0975c3SLinus Walleij struct abx500_maxim_parameters { 367*ee0975c3SLinus Walleij bool ena_maxi; 368*ee0975c3SLinus Walleij int chg_curr; 369*ee0975c3SLinus Walleij int wait_cycles; 370*ee0975c3SLinus Walleij int charger_curr_step; 371*ee0975c3SLinus Walleij }; 372*ee0975c3SLinus Walleij 373*ee0975c3SLinus Walleij /** 374*ee0975c3SLinus Walleij * struct abx500_battery_type - different batteries supported 375*ee0975c3SLinus Walleij * @name: battery technology 376*ee0975c3SLinus Walleij * @resis_high: battery upper resistance limit 377*ee0975c3SLinus Walleij * @resis_low: battery lower resistance limit 378*ee0975c3SLinus Walleij * @charge_full_design: Maximum battery capacity in mAh 379*ee0975c3SLinus Walleij * @nominal_voltage: Nominal voltage of the battery in mV 380*ee0975c3SLinus Walleij * @termination_vol: max voltage upto which battery can be charged 381*ee0975c3SLinus Walleij * @termination_curr battery charging termination current in mA 382*ee0975c3SLinus Walleij * @recharge_cap battery capacity limit that will trigger a new 383*ee0975c3SLinus Walleij * full charging cycle in the case where maintenan- 384*ee0975c3SLinus Walleij * -ce charging has been disabled 385*ee0975c3SLinus Walleij * @normal_cur_lvl: charger current in normal state in mA 386*ee0975c3SLinus Walleij * @normal_vol_lvl: charger voltage in normal state in mV 387*ee0975c3SLinus Walleij * @maint_a_cur_lvl: charger current in maintenance A state in mA 388*ee0975c3SLinus Walleij * @maint_a_vol_lvl: charger voltage in maintenance A state in mV 389*ee0975c3SLinus Walleij * @maint_a_chg_timer_h: charge time in maintenance A state 390*ee0975c3SLinus Walleij * @maint_b_cur_lvl: charger current in maintenance B state in mA 391*ee0975c3SLinus Walleij * @maint_b_vol_lvl: charger voltage in maintenance B state in mV 392*ee0975c3SLinus Walleij * @maint_b_chg_timer_h: charge time in maintenance B state 393*ee0975c3SLinus Walleij * @low_high_cur_lvl: charger current in temp low/high state in mA 394*ee0975c3SLinus Walleij * @low_high_vol_lvl: charger voltage in temp low/high state in mV' 395*ee0975c3SLinus Walleij * @battery_resistance: battery inner resistance in mOhm. 396*ee0975c3SLinus Walleij * @n_r_t_tbl_elements: number of elements in r_to_t_tbl 397*ee0975c3SLinus Walleij * @r_to_t_tbl: table containing resistance to temp points 398*ee0975c3SLinus Walleij * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl 399*ee0975c3SLinus Walleij * @v_to_cap_tbl: Voltage to capacity (in %) table 400*ee0975c3SLinus Walleij * @n_batres_tbl_elements number of elements in the batres_tbl 401*ee0975c3SLinus Walleij * @batres_tbl battery internal resistance vs temperature table 402*ee0975c3SLinus Walleij */ 403*ee0975c3SLinus Walleij struct abx500_battery_type { 404*ee0975c3SLinus Walleij int name; 405*ee0975c3SLinus Walleij int resis_high; 406*ee0975c3SLinus Walleij int resis_low; 407*ee0975c3SLinus Walleij int charge_full_design; 408*ee0975c3SLinus Walleij int nominal_voltage; 409*ee0975c3SLinus Walleij int termination_vol; 410*ee0975c3SLinus Walleij int termination_curr; 411*ee0975c3SLinus Walleij int recharge_cap; 412*ee0975c3SLinus Walleij int normal_cur_lvl; 413*ee0975c3SLinus Walleij int normal_vol_lvl; 414*ee0975c3SLinus Walleij int maint_a_cur_lvl; 415*ee0975c3SLinus Walleij int maint_a_vol_lvl; 416*ee0975c3SLinus Walleij int maint_a_chg_timer_h; 417*ee0975c3SLinus Walleij int maint_b_cur_lvl; 418*ee0975c3SLinus Walleij int maint_b_vol_lvl; 419*ee0975c3SLinus Walleij int maint_b_chg_timer_h; 420*ee0975c3SLinus Walleij int low_high_cur_lvl; 421*ee0975c3SLinus Walleij int low_high_vol_lvl; 422*ee0975c3SLinus Walleij int battery_resistance; 423*ee0975c3SLinus Walleij int n_temp_tbl_elements; 424*ee0975c3SLinus Walleij const struct abx500_res_to_temp *r_to_t_tbl; 425*ee0975c3SLinus Walleij int n_v_cap_tbl_elements; 426*ee0975c3SLinus Walleij const struct abx500_v_to_cap *v_to_cap_tbl; 427*ee0975c3SLinus Walleij int n_batres_tbl_elements; 428*ee0975c3SLinus Walleij const struct batres_vs_temp *batres_tbl; 429*ee0975c3SLinus Walleij }; 430*ee0975c3SLinus Walleij 431*ee0975c3SLinus Walleij /** 432*ee0975c3SLinus Walleij * struct abx500_bm_capacity_levels - abx500 capacity level data 433*ee0975c3SLinus Walleij * @critical: critical capacity level in percent 434*ee0975c3SLinus Walleij * @low: low capacity level in percent 435*ee0975c3SLinus Walleij * @normal: normal capacity level in percent 436*ee0975c3SLinus Walleij * @high: high capacity level in percent 437*ee0975c3SLinus Walleij * @full: full capacity level in percent 438*ee0975c3SLinus Walleij */ 439*ee0975c3SLinus Walleij struct abx500_bm_capacity_levels { 440*ee0975c3SLinus Walleij int critical; 441*ee0975c3SLinus Walleij int low; 442*ee0975c3SLinus Walleij int normal; 443*ee0975c3SLinus Walleij int high; 444*ee0975c3SLinus Walleij int full; 445*ee0975c3SLinus Walleij }; 446*ee0975c3SLinus Walleij 447*ee0975c3SLinus Walleij /** 448*ee0975c3SLinus Walleij * struct abx500_bm_charger_parameters - Charger specific parameters 449*ee0975c3SLinus Walleij * @usb_volt_max: maximum allowed USB charger voltage in mV 450*ee0975c3SLinus Walleij * @usb_curr_max: maximum allowed USB charger current in mA 451*ee0975c3SLinus Walleij * @ac_volt_max: maximum allowed AC charger voltage in mV 452*ee0975c3SLinus Walleij * @ac_curr_max: maximum allowed AC charger current in mA 453*ee0975c3SLinus Walleij */ 454*ee0975c3SLinus Walleij struct abx500_bm_charger_parameters { 455*ee0975c3SLinus Walleij int usb_volt_max; 456*ee0975c3SLinus Walleij int usb_curr_max; 457*ee0975c3SLinus Walleij int ac_volt_max; 458*ee0975c3SLinus Walleij int ac_curr_max; 459*ee0975c3SLinus Walleij }; 460*ee0975c3SLinus Walleij 461*ee0975c3SLinus Walleij /** 462*ee0975c3SLinus Walleij * struct abx500_bm_data - abx500 battery management data 463*ee0975c3SLinus Walleij * @temp_under under this temp, charging is stopped 464*ee0975c3SLinus Walleij * @temp_low between this temp and temp_under charging is reduced 465*ee0975c3SLinus Walleij * @temp_high between this temp and temp_over charging is reduced 466*ee0975c3SLinus Walleij * @temp_over over this temp, charging is stopped 467*ee0975c3SLinus Walleij * @temp_now present battery temperature 468*ee0975c3SLinus Walleij * @temp_interval_chg temperature measurement interval in s when charging 469*ee0975c3SLinus Walleij * @temp_interval_nochg temperature measurement interval in s when not charging 470*ee0975c3SLinus Walleij * @main_safety_tmr_h safety timer for main charger 471*ee0975c3SLinus Walleij * @usb_safety_tmr_h safety timer for usb charger 472*ee0975c3SLinus Walleij * @bkup_bat_v voltage which we charge the backup battery with 473*ee0975c3SLinus Walleij * @bkup_bat_i current which we charge the backup battery with 474*ee0975c3SLinus Walleij * @no_maintenance indicates that maintenance charging is disabled 475*ee0975c3SLinus Walleij * @capacity_scaling indicates whether capacity scaling is to be used 476*ee0975c3SLinus Walleij * @abx500_adc_therm placement of thermistor, batctrl or battemp adc 477*ee0975c3SLinus Walleij * @chg_unknown_bat flag to enable charging of unknown batteries 478*ee0975c3SLinus Walleij * @enable_overshoot flag to enable VBAT overshoot control 479*ee0975c3SLinus Walleij * @auto_trig flag to enable auto adc trigger 480*ee0975c3SLinus Walleij * @fg_res resistance of FG resistor in 0.1mOhm 481*ee0975c3SLinus Walleij * @n_btypes number of elements in array bat_type 482*ee0975c3SLinus Walleij * @batt_id index of the identified battery in array bat_type 483*ee0975c3SLinus Walleij * @interval_charging charge alg cycle period time when charging (sec) 484*ee0975c3SLinus Walleij * @interval_not_charging charge alg cycle period time when not charging (sec) 485*ee0975c3SLinus Walleij * @temp_hysteresis temperature hysteresis 486*ee0975c3SLinus Walleij * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 487*ee0975c3SLinus Walleij * @n_chg_out_curr number of elements in array chg_output_curr 488*ee0975c3SLinus Walleij * @n_chg_in_curr number of elements in array chg_input_curr 489*ee0975c3SLinus Walleij * @chg_output_curr charger output current level map 490*ee0975c3SLinus Walleij * @chg_input_curr charger input current level map 491*ee0975c3SLinus Walleij * @maxi maximization parameters 492*ee0975c3SLinus Walleij * @cap_levels capacity in percent for the different capacity levels 493*ee0975c3SLinus Walleij * @bat_type table of supported battery types 494*ee0975c3SLinus Walleij * @chg_params charger parameters 495*ee0975c3SLinus Walleij * @fg_params fuel gauge parameters 496*ee0975c3SLinus Walleij */ 497*ee0975c3SLinus Walleij struct abx500_bm_data { 498*ee0975c3SLinus Walleij int temp_under; 499*ee0975c3SLinus Walleij int temp_low; 500*ee0975c3SLinus Walleij int temp_high; 501*ee0975c3SLinus Walleij int temp_over; 502*ee0975c3SLinus Walleij int temp_now; 503*ee0975c3SLinus Walleij int temp_interval_chg; 504*ee0975c3SLinus Walleij int temp_interval_nochg; 505*ee0975c3SLinus Walleij int main_safety_tmr_h; 506*ee0975c3SLinus Walleij int usb_safety_tmr_h; 507*ee0975c3SLinus Walleij int bkup_bat_v; 508*ee0975c3SLinus Walleij int bkup_bat_i; 509*ee0975c3SLinus Walleij bool autopower_cfg; 510*ee0975c3SLinus Walleij bool ac_enabled; 511*ee0975c3SLinus Walleij bool usb_enabled; 512*ee0975c3SLinus Walleij bool no_maintenance; 513*ee0975c3SLinus Walleij bool capacity_scaling; 514*ee0975c3SLinus Walleij bool chg_unknown_bat; 515*ee0975c3SLinus Walleij bool enable_overshoot; 516*ee0975c3SLinus Walleij bool auto_trig; 517*ee0975c3SLinus Walleij enum abx500_adc_therm adc_therm; 518*ee0975c3SLinus Walleij int fg_res; 519*ee0975c3SLinus Walleij int n_btypes; 520*ee0975c3SLinus Walleij int batt_id; 521*ee0975c3SLinus Walleij int interval_charging; 522*ee0975c3SLinus Walleij int interval_not_charging; 523*ee0975c3SLinus Walleij int temp_hysteresis; 524*ee0975c3SLinus Walleij int gnd_lift_resistance; 525*ee0975c3SLinus Walleij int n_chg_out_curr; 526*ee0975c3SLinus Walleij int n_chg_in_curr; 527*ee0975c3SLinus Walleij int *chg_output_curr; 528*ee0975c3SLinus Walleij int *chg_input_curr; 529*ee0975c3SLinus Walleij const struct abx500_maxim_parameters *maxi; 530*ee0975c3SLinus Walleij const struct abx500_bm_capacity_levels *cap_levels; 531*ee0975c3SLinus Walleij struct abx500_battery_type *bat_type; 532*ee0975c3SLinus Walleij const struct abx500_bm_charger_parameters *chg_params; 533*ee0975c3SLinus Walleij const struct abx500_fg_parameters *fg_params; 534*ee0975c3SLinus Walleij }; 535*ee0975c3SLinus Walleij 536*ee0975c3SLinus Walleij enum { 537*ee0975c3SLinus Walleij NTC_EXTERNAL = 0, 538*ee0975c3SLinus Walleij NTC_INTERNAL, 539*ee0975c3SLinus Walleij }; 540*ee0975c3SLinus Walleij 541417c0fc2SLinus Walleij /** 542417c0fc2SLinus Walleij * struct res_to_temp - defines one point in a temp to res curve. To 543417c0fc2SLinus Walleij * be used in battery packs that combines the identification resistor with a 544417c0fc2SLinus Walleij * NTC resistor. 545417c0fc2SLinus Walleij * @temp: battery pack temperature in Celsius 546417c0fc2SLinus Walleij * @resist: NTC resistor net total resistance 547417c0fc2SLinus Walleij */ 548417c0fc2SLinus Walleij struct res_to_temp { 549417c0fc2SLinus Walleij int temp; 550417c0fc2SLinus Walleij int resist; 551417c0fc2SLinus Walleij }; 552417c0fc2SLinus Walleij 553417c0fc2SLinus Walleij /** 554417c0fc2SLinus Walleij * struct batres_vs_temp - defines one point in a temp vs battery internal 555417c0fc2SLinus Walleij * resistance curve. 556417c0fc2SLinus Walleij * @temp: battery pack temperature in Celsius 557417c0fc2SLinus Walleij * @resist: battery internal reistance in mOhm 558417c0fc2SLinus Walleij */ 559417c0fc2SLinus Walleij struct batres_vs_temp { 560417c0fc2SLinus Walleij int temp; 561417c0fc2SLinus Walleij int resist; 562417c0fc2SLinus Walleij }; 563417c0fc2SLinus Walleij 564417c0fc2SLinus Walleij /* Forward declaration */ 565417c0fc2SLinus Walleij struct ab8500_fg; 566417c0fc2SLinus Walleij 567417c0fc2SLinus Walleij /** 568417c0fc2SLinus Walleij * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds 569417c0fc2SLinus Walleij * if not specified 570417c0fc2SLinus Walleij * @recovery_sleep_timer: Time between measurements while recovering 571417c0fc2SLinus Walleij * @recovery_total_time: Total recovery time 572417c0fc2SLinus Walleij * @init_timer: Measurement interval during startup 573417c0fc2SLinus Walleij * @init_discard_time: Time we discard voltage measurement at startup 574417c0fc2SLinus Walleij * @init_total_time: Total init time during startup 575417c0fc2SLinus Walleij * @high_curr_time: Time current has to be high to go to recovery 576417c0fc2SLinus Walleij * @accu_charging: FG accumulation time while charging 577417c0fc2SLinus Walleij * @accu_high_curr: FG accumulation time in high current mode 578417c0fc2SLinus Walleij * @high_curr_threshold: High current threshold, in mA 579417c0fc2SLinus Walleij * @lowbat_threshold: Low battery threshold, in mV 580417c0fc2SLinus Walleij * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 581417c0fc2SLinus Walleij * Resolution in 50 mV step. 582417c0fc2SLinus Walleij * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 583417c0fc2SLinus Walleij * Resolution in 50 mV step. 584417c0fc2SLinus Walleij * @user_cap_limit Capacity reported from user must be within this 585417c0fc2SLinus Walleij * limit to be considered as sane, in percentage 586417c0fc2SLinus Walleij * points. 587417c0fc2SLinus Walleij * @maint_thres This is the threshold where we stop reporting 588417c0fc2SLinus Walleij * battery full while in maintenance, in per cent 589417c0fc2SLinus Walleij * @pcut_enable: Enable power cut feature in ab8505 590417c0fc2SLinus Walleij * @pcut_max_time: Max time threshold 591417c0fc2SLinus Walleij * @pcut_flag_time: Flagtime threshold 592417c0fc2SLinus Walleij * @pcut_max_restart: Max number of restarts 593417c0fc2SLinus Walleij * @pcut_debunce_time: Sets battery debounce time 594417c0fc2SLinus Walleij */ 595417c0fc2SLinus Walleij struct ab8500_fg_parameters { 596417c0fc2SLinus Walleij int recovery_sleep_timer; 597417c0fc2SLinus Walleij int recovery_total_time; 598417c0fc2SLinus Walleij int init_timer; 599417c0fc2SLinus Walleij int init_discard_time; 600417c0fc2SLinus Walleij int init_total_time; 601417c0fc2SLinus Walleij int high_curr_time; 602417c0fc2SLinus Walleij int accu_charging; 603417c0fc2SLinus Walleij int accu_high_curr; 604417c0fc2SLinus Walleij int high_curr_threshold; 605417c0fc2SLinus Walleij int lowbat_threshold; 606417c0fc2SLinus Walleij int battok_falling_th_sel0; 607417c0fc2SLinus Walleij int battok_raising_th_sel1; 608417c0fc2SLinus Walleij int user_cap_limit; 609417c0fc2SLinus Walleij int maint_thres; 610417c0fc2SLinus Walleij bool pcut_enable; 611417c0fc2SLinus Walleij u8 pcut_max_time; 612417c0fc2SLinus Walleij u8 pcut_flag_time; 613417c0fc2SLinus Walleij u8 pcut_max_restart; 614417c0fc2SLinus Walleij u8 pcut_debunce_time; 615417c0fc2SLinus Walleij }; 616417c0fc2SLinus Walleij 617417c0fc2SLinus Walleij /** 618417c0fc2SLinus Walleij * struct ab8500_charger_maximization - struct used by the board config. 619417c0fc2SLinus Walleij * @use_maxi: Enable maximization for this battery type 620417c0fc2SLinus Walleij * @maxi_chg_curr: Maximum charger current allowed 621417c0fc2SLinus Walleij * @maxi_wait_cycles: cycles to wait before setting charger current 622417c0fc2SLinus Walleij * @charger_curr_step delta between two charger current settings (mA) 623417c0fc2SLinus Walleij */ 624417c0fc2SLinus Walleij struct ab8500_maxim_parameters { 625417c0fc2SLinus Walleij bool ena_maxi; 626417c0fc2SLinus Walleij int chg_curr; 627417c0fc2SLinus Walleij int wait_cycles; 628417c0fc2SLinus Walleij int charger_curr_step; 629417c0fc2SLinus Walleij }; 630417c0fc2SLinus Walleij 631417c0fc2SLinus Walleij /** 632417c0fc2SLinus Walleij * struct ab8500_bm_capacity_levels - ab8500 capacity level data 633417c0fc2SLinus Walleij * @critical: critical capacity level in percent 634417c0fc2SLinus Walleij * @low: low capacity level in percent 635417c0fc2SLinus Walleij * @normal: normal capacity level in percent 636417c0fc2SLinus Walleij * @high: high capacity level in percent 637417c0fc2SLinus Walleij * @full: full capacity level in percent 638417c0fc2SLinus Walleij */ 639417c0fc2SLinus Walleij struct ab8500_bm_capacity_levels { 640417c0fc2SLinus Walleij int critical; 641417c0fc2SLinus Walleij int low; 642417c0fc2SLinus Walleij int normal; 643417c0fc2SLinus Walleij int high; 644417c0fc2SLinus Walleij int full; 645417c0fc2SLinus Walleij }; 646417c0fc2SLinus Walleij 647417c0fc2SLinus Walleij /** 648417c0fc2SLinus Walleij * struct ab8500_bm_charger_parameters - Charger specific parameters 649417c0fc2SLinus Walleij * @usb_volt_max: maximum allowed USB charger voltage in mV 650417c0fc2SLinus Walleij * @usb_curr_max: maximum allowed USB charger current in mA 651417c0fc2SLinus Walleij * @ac_volt_max: maximum allowed AC charger voltage in mV 652417c0fc2SLinus Walleij * @ac_curr_max: maximum allowed AC charger current in mA 653417c0fc2SLinus Walleij */ 654417c0fc2SLinus Walleij struct ab8500_bm_charger_parameters { 655417c0fc2SLinus Walleij int usb_volt_max; 656417c0fc2SLinus Walleij int usb_curr_max; 657417c0fc2SLinus Walleij int ac_volt_max; 658417c0fc2SLinus Walleij int ac_curr_max; 659417c0fc2SLinus Walleij }; 660417c0fc2SLinus Walleij 661417c0fc2SLinus Walleij /** 662417c0fc2SLinus Walleij * struct ab8500_bm_data - ab8500 battery management data 663417c0fc2SLinus Walleij * @temp_under under this temp, charging is stopped 664417c0fc2SLinus Walleij * @temp_low between this temp and temp_under charging is reduced 665417c0fc2SLinus Walleij * @temp_high between this temp and temp_over charging is reduced 666417c0fc2SLinus Walleij * @temp_over over this temp, charging is stopped 667417c0fc2SLinus Walleij * @temp_interval_chg temperature measurement interval in s when charging 668417c0fc2SLinus Walleij * @temp_interval_nochg temperature measurement interval in s when not charging 669417c0fc2SLinus Walleij * @main_safety_tmr_h safety timer for main charger 670417c0fc2SLinus Walleij * @usb_safety_tmr_h safety timer for usb charger 671417c0fc2SLinus Walleij * @bkup_bat_v voltage which we charge the backup battery with 672417c0fc2SLinus Walleij * @bkup_bat_i current which we charge the backup battery with 673417c0fc2SLinus Walleij * @no_maintenance indicates that maintenance charging is disabled 674417c0fc2SLinus Walleij * @capacity_scaling indicates whether capacity scaling is to be used 675417c0fc2SLinus Walleij * @adc_therm placement of thermistor, batctrl or battemp adc 676417c0fc2SLinus Walleij * @chg_unknown_bat flag to enable charging of unknown batteries 677417c0fc2SLinus Walleij * @enable_overshoot flag to enable VBAT overshoot control 678417c0fc2SLinus Walleij * @fg_res resistance of FG resistor in 0.1mOhm 679417c0fc2SLinus Walleij * @n_btypes number of elements in array bat_type 680417c0fc2SLinus Walleij * @batt_id index of the identified battery in array bat_type 681417c0fc2SLinus Walleij * @interval_charging charge alg cycle period time when charging (sec) 682417c0fc2SLinus Walleij * @interval_not_charging charge alg cycle period time when not charging (sec) 683417c0fc2SLinus Walleij * @temp_hysteresis temperature hysteresis 684417c0fc2SLinus Walleij * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 685417c0fc2SLinus Walleij * @maxi: maximization parameters 686417c0fc2SLinus Walleij * @cap_levels capacity in percent for the different capacity levels 687417c0fc2SLinus Walleij * @bat_type table of supported battery types 688417c0fc2SLinus Walleij * @chg_params charger parameters 689417c0fc2SLinus Walleij * @fg_params fuel gauge parameters 690417c0fc2SLinus Walleij */ 691417c0fc2SLinus Walleij struct ab8500_bm_data { 692417c0fc2SLinus Walleij int temp_under; 693417c0fc2SLinus Walleij int temp_low; 694417c0fc2SLinus Walleij int temp_high; 695417c0fc2SLinus Walleij int temp_over; 696417c0fc2SLinus Walleij int temp_interval_chg; 697417c0fc2SLinus Walleij int temp_interval_nochg; 698417c0fc2SLinus Walleij int main_safety_tmr_h; 699417c0fc2SLinus Walleij int usb_safety_tmr_h; 700417c0fc2SLinus Walleij int bkup_bat_v; 701417c0fc2SLinus Walleij int bkup_bat_i; 702417c0fc2SLinus Walleij bool no_maintenance; 703417c0fc2SLinus Walleij bool capacity_scaling; 704417c0fc2SLinus Walleij bool chg_unknown_bat; 705417c0fc2SLinus Walleij bool enable_overshoot; 706417c0fc2SLinus Walleij enum abx500_adc_therm adc_therm; 707417c0fc2SLinus Walleij int fg_res; 708417c0fc2SLinus Walleij int n_btypes; 709417c0fc2SLinus Walleij int batt_id; 710417c0fc2SLinus Walleij int interval_charging; 711417c0fc2SLinus Walleij int interval_not_charging; 712417c0fc2SLinus Walleij int temp_hysteresis; 713417c0fc2SLinus Walleij int gnd_lift_resistance; 714417c0fc2SLinus Walleij const struct ab8500_maxim_parameters *maxi; 715417c0fc2SLinus Walleij const struct ab8500_bm_capacity_levels *cap_levels; 716417c0fc2SLinus Walleij const struct ab8500_bm_charger_parameters *chg_params; 717417c0fc2SLinus Walleij const struct ab8500_fg_parameters *fg_params; 718417c0fc2SLinus Walleij }; 719417c0fc2SLinus Walleij 720417c0fc2SLinus Walleij extern struct abx500_bm_data ab8500_bm_data; 721417c0fc2SLinus Walleij 722417c0fc2SLinus Walleij void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 723417c0fc2SLinus Walleij struct ab8500_fg *ab8500_fg_get(void); 724417c0fc2SLinus Walleij int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 725417c0fc2SLinus Walleij int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 726417c0fc2SLinus Walleij int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 727417c0fc2SLinus Walleij int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 728417c0fc2SLinus Walleij int ab8500_fg_inst_curr_done(struct ab8500_fg *di); 729*ee0975c3SLinus Walleij int ab8500_bm_of_probe(struct device *dev, 730*ee0975c3SLinus Walleij struct device_node *np, 731*ee0975c3SLinus Walleij struct abx500_bm_data *bm); 732417c0fc2SLinus Walleij 733417c0fc2SLinus Walleij #endif /* _AB8500_CHARGER_H_ */ 734