162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef _AB8500_CHARGER_H_ 462306a36Sopenharmony_ci#define _AB8500_CHARGER_H_ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/kernel.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci/* 962306a36Sopenharmony_ci * System control 2 register offsets. 1062306a36Sopenharmony_ci * bank = 0x02 1162306a36Sopenharmony_ci */ 1262306a36Sopenharmony_ci#define AB8500_MAIN_WDOG_CTRL_REG 0x01 1362306a36Sopenharmony_ci#define AB8500_LOW_BAT_REG 0x03 1462306a36Sopenharmony_ci#define AB8500_BATT_OK_REG 0x04 1562306a36Sopenharmony_ci/* 1662306a36Sopenharmony_ci * USB/ULPI register offsets 1762306a36Sopenharmony_ci * Bank : 0x5 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci#define AB8500_USB_LINE_STAT_REG 0x80 2062306a36Sopenharmony_ci#define AB8500_USB_LINE_CTRL2_REG 0x82 2162306a36Sopenharmony_ci#define AB8500_USB_LINK1_STAT_REG 0x94 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/* 2462306a36Sopenharmony_ci * Charger / status register offfsets 2562306a36Sopenharmony_ci * Bank : 0x0B 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_ci#define AB8500_CH_STATUS1_REG 0x00 2862306a36Sopenharmony_ci#define AB8500_CH_STATUS2_REG 0x01 2962306a36Sopenharmony_ci#define AB8500_CH_USBCH_STAT1_REG 0x02 3062306a36Sopenharmony_ci#define AB8500_CH_USBCH_STAT2_REG 0x03 3162306a36Sopenharmony_ci#define AB8540_CH_USBCH_STAT3_REG 0x04 3262306a36Sopenharmony_ci#define AB8500_CH_STAT_REG 0x05 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* 3562306a36Sopenharmony_ci * Charger / control register offfsets 3662306a36Sopenharmony_ci * Bank : 0x0B 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci#define AB8500_CH_VOLT_LVL_REG 0x40 3962306a36Sopenharmony_ci#define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/ 4062306a36Sopenharmony_ci#define AB8500_CH_OPT_CRNTLVL_REG 0x42 4162306a36Sopenharmony_ci#define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/ 4262306a36Sopenharmony_ci#define AB8500_CH_WD_TIMER_REG 0x50 4362306a36Sopenharmony_ci#define AB8500_CHARG_WD_CTRL 0x51 4462306a36Sopenharmony_ci#define AB8500_BTEMP_HIGH_TH 0x52 4562306a36Sopenharmony_ci#define AB8500_LED_INDICATOR_PWM_CTRL 0x53 4662306a36Sopenharmony_ci#define AB8500_LED_INDICATOR_PWM_DUTY 0x54 4762306a36Sopenharmony_ci#define AB8500_BATT_OVV 0x55 4862306a36Sopenharmony_ci#define AB8500_CHARGER_CTRL 0x56 4962306a36Sopenharmony_ci#define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* 5262306a36Sopenharmony_ci * Charger / main control register offsets 5362306a36Sopenharmony_ci * Bank : 0x0B 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ci#define AB8500_MCH_CTRL1 0x80 5662306a36Sopenharmony_ci#define AB8500_MCH_CTRL2 0x81 5762306a36Sopenharmony_ci#define AB8500_MCH_IPT_CURLVL_REG 0x82 5862306a36Sopenharmony_ci#define AB8500_CH_WD_REG 0x83 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* 6162306a36Sopenharmony_ci * Charger / USB control register offsets 6262306a36Sopenharmony_ci * Bank : 0x0B 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci#define AB8500_USBCH_CTRL1_REG 0xC0 6562306a36Sopenharmony_ci#define AB8500_USBCH_CTRL2_REG 0xC1 6662306a36Sopenharmony_ci#define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2 6762306a36Sopenharmony_ci#define AB8540_USB_PP_MODE_REG 0xC5 6862306a36Sopenharmony_ci#define AB8540_USB_PP_CHR_REG 0xC6 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci/* 7162306a36Sopenharmony_ci * Gas Gauge register offsets 7262306a36Sopenharmony_ci * Bank : 0x0C 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#define AB8500_GASG_CC_CTRL_REG 0x00 7562306a36Sopenharmony_ci#define AB8500_GASG_CC_ACCU1_REG 0x01 7662306a36Sopenharmony_ci#define AB8500_GASG_CC_ACCU2_REG 0x02 7762306a36Sopenharmony_ci#define AB8500_GASG_CC_ACCU3_REG 0x03 7862306a36Sopenharmony_ci#define AB8500_GASG_CC_ACCU4_REG 0x04 7962306a36Sopenharmony_ci#define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05 8062306a36Sopenharmony_ci#define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06 8162306a36Sopenharmony_ci#define AB8500_GASG_CC_SMPL_CNVL_REG 0x07 8262306a36Sopenharmony_ci#define AB8500_GASG_CC_SMPL_CNVH_REG 0x08 8362306a36Sopenharmony_ci#define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09 8462306a36Sopenharmony_ci#define AB8500_GASG_CC_OFFSET_REG 0x0A 8562306a36Sopenharmony_ci#define AB8500_GASG_CC_NCOV_ACCU 0x10 8662306a36Sopenharmony_ci#define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11 8762306a36Sopenharmony_ci#define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12 8862306a36Sopenharmony_ci#define AB8500_GASG_CC_NCOV_ACCU_MED 0x13 8962306a36Sopenharmony_ci#define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci/* 9262306a36Sopenharmony_ci * Interrupt register offsets 9362306a36Sopenharmony_ci * Bank : 0x0E 9462306a36Sopenharmony_ci */ 9562306a36Sopenharmony_ci#define AB8500_IT_SOURCE2_REG 0x01 9662306a36Sopenharmony_ci#define AB8500_IT_SOURCE21_REG 0x14 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci/* 9962306a36Sopenharmony_ci * RTC register offsets 10062306a36Sopenharmony_ci * Bank: 0x0F 10162306a36Sopenharmony_ci */ 10262306a36Sopenharmony_ci#define AB8500_RTC_BACKUP_CHG_REG 0x0C 10362306a36Sopenharmony_ci#define AB8500_RTC_CC_CONF_REG 0x01 10462306a36Sopenharmony_ci#define AB8500_RTC_CTRL_REG 0x0B 10562306a36Sopenharmony_ci#define AB8500_RTC_CTRL1_REG 0x11 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci/* 10862306a36Sopenharmony_ci * OTP register offsets 10962306a36Sopenharmony_ci * Bank : 0x15 11062306a36Sopenharmony_ci */ 11162306a36Sopenharmony_ci#define AB8500_OTP_CONF_15 0x0E 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* GPADC constants from AB8500 spec, UM0836 */ 11462306a36Sopenharmony_ci#define ADC_RESOLUTION 1024 11562306a36Sopenharmony_ci#define ADC_CH_MAIN_MIN 0 11662306a36Sopenharmony_ci#define ADC_CH_MAIN_MAX 20030 11762306a36Sopenharmony_ci#define ADC_CH_VBUS_MIN 0 11862306a36Sopenharmony_ci#define ADC_CH_VBUS_MAX 20030 11962306a36Sopenharmony_ci#define ADC_CH_VBAT_MIN 2300 12062306a36Sopenharmony_ci#define ADC_CH_VBAT_MAX 4800 12162306a36Sopenharmony_ci#define ADC_CH_BKBAT_MIN 0 12262306a36Sopenharmony_ci#define ADC_CH_BKBAT_MAX 3200 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci/* Main charge i/p current */ 12562306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_0P9A 0x80 12662306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P0A 0x90 12762306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P1A 0xA0 12862306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P2A 0xB0 12962306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P3A 0xC0 13062306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P4A 0xD0 13162306a36Sopenharmony_ci#define MAIN_CH_IP_CUR_1P5A 0xE0 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci/* ChVoltLevel */ 13462306a36Sopenharmony_ci#define CH_VOL_LVL_3P5 0x00 13562306a36Sopenharmony_ci#define CH_VOL_LVL_4P0 0x14 13662306a36Sopenharmony_ci#define CH_VOL_LVL_4P05 0x16 13762306a36Sopenharmony_ci#define CH_VOL_LVL_4P1 0x1B 13862306a36Sopenharmony_ci#define CH_VOL_LVL_4P15 0x20 13962306a36Sopenharmony_ci#define CH_VOL_LVL_4P2 0x25 14062306a36Sopenharmony_ci#define CH_VOL_LVL_4P6 0x4D 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* ChOutputCurrentLevel */ 14362306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P1 0x00 14462306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P2 0x01 14562306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P3 0x02 14662306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P4 0x03 14762306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P5 0x04 14862306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P6 0x05 14962306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P7 0x06 15062306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P8 0x07 15162306a36Sopenharmony_ci#define CH_OP_CUR_LVL_0P9 0x08 15262306a36Sopenharmony_ci#define CH_OP_CUR_LVL_1P4 0x0D 15362306a36Sopenharmony_ci#define CH_OP_CUR_LVL_1P5 0x0E 15462306a36Sopenharmony_ci#define CH_OP_CUR_LVL_1P6 0x0F 15562306a36Sopenharmony_ci#define CH_OP_CUR_LVL_2P 0x3F 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci/* BTEMP High thermal limits */ 15862306a36Sopenharmony_ci#define BTEMP_HIGH_TH_57_0 0x00 15962306a36Sopenharmony_ci#define BTEMP_HIGH_TH_52 0x01 16062306a36Sopenharmony_ci#define BTEMP_HIGH_TH_57_1 0x02 16162306a36Sopenharmony_ci#define BTEMP_HIGH_TH_62 0x03 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci#define LOW_BAT_3P1V 0x20 16462306a36Sopenharmony_ci#define LOW_BAT_2P3V 0x00 16562306a36Sopenharmony_ci#define LOW_BAT_RESET 0x01 16662306a36Sopenharmony_ci#define LOW_BAT_ENABLE 0x01 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci/* Backup battery constants */ 16962306a36Sopenharmony_ci#define BUP_ICH_SEL_50UA 0x00 17062306a36Sopenharmony_ci#define BUP_ICH_SEL_150UA 0x04 17162306a36Sopenharmony_ci#define BUP_ICH_SEL_300UA 0x08 17262306a36Sopenharmony_ci#define BUP_ICH_SEL_700UA 0x0C 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_cienum bup_vch_sel { 17562306a36Sopenharmony_ci BUP_VCH_SEL_2P5V, 17662306a36Sopenharmony_ci BUP_VCH_SEL_2P6V, 17762306a36Sopenharmony_ci BUP_VCH_SEL_2P8V, 17862306a36Sopenharmony_ci BUP_VCH_SEL_3P1V, 17962306a36Sopenharmony_ci /* 18062306a36Sopenharmony_ci * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v 18162306a36Sopenharmony_ci * are only available on ab8540. You can't choose these 5 18262306a36Sopenharmony_ci * voltage on ab8500/ab8505/ab9540. 18362306a36Sopenharmony_ci */ 18462306a36Sopenharmony_ci BUP_VCH_SEL_2P7V, 18562306a36Sopenharmony_ci BUP_VCH_SEL_2P9V, 18662306a36Sopenharmony_ci BUP_VCH_SEL_3P0V, 18762306a36Sopenharmony_ci BUP_VCH_SEL_3P2V, 18862306a36Sopenharmony_ci BUP_VCH_SEL_3P3V, 18962306a36Sopenharmony_ci}; 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci#define BUP_VCH_RANGE 0x02 19262306a36Sopenharmony_ci#define VBUP33_VRTCN 0x01 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci/* Battery OVV constants */ 19562306a36Sopenharmony_ci#define BATT_OVV_ENA 0x02 19662306a36Sopenharmony_ci#define BATT_OVV_TH_3P7 0x00 19762306a36Sopenharmony_ci#define BATT_OVV_TH_4P75 0x01 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* A value to indicate over voltage (microvolts) */ 20062306a36Sopenharmony_ci#define BATT_OVV_VALUE 4750000 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci/* VBUS OVV constants */ 20362306a36Sopenharmony_ci#define VBUS_OVV_SELECT_MASK 0x78 20462306a36Sopenharmony_ci#define VBUS_OVV_SELECT_5P6V 0x00 20562306a36Sopenharmony_ci#define VBUS_OVV_SELECT_5P7V 0x08 20662306a36Sopenharmony_ci#define VBUS_OVV_SELECT_5P8V 0x10 20762306a36Sopenharmony_ci#define VBUS_OVV_SELECT_5P9V 0x18 20862306a36Sopenharmony_ci#define VBUS_OVV_SELECT_6P0V 0x20 20962306a36Sopenharmony_ci#define VBUS_OVV_SELECT_6P1V 0x28 21062306a36Sopenharmony_ci#define VBUS_OVV_SELECT_6P2V 0x30 21162306a36Sopenharmony_ci#define VBUS_OVV_SELECT_6P3V 0x38 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define VBUS_AUTO_IN_CURR_LIM_ENA 0x04 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci/* Fuel Gauge constants */ 21662306a36Sopenharmony_ci#define RESET_ACCU 0x02 21762306a36Sopenharmony_ci#define READ_REQ 0x01 21862306a36Sopenharmony_ci#define CC_DEEP_SLEEP_ENA 0x02 21962306a36Sopenharmony_ci#define CC_PWR_UP_ENA 0x01 22062306a36Sopenharmony_ci#define CC_SAMPLES_40 0x28 22162306a36Sopenharmony_ci#define RD_NCONV_ACCU_REQ 0x01 22262306a36Sopenharmony_ci#define CC_CALIB 0x08 22362306a36Sopenharmony_ci#define CC_INTAVGOFFSET_ENA 0x10 22462306a36Sopenharmony_ci#define CC_MUXOFFSET 0x80 22562306a36Sopenharmony_ci#define CC_INT_CAL_N_AVG_MASK 0x60 22662306a36Sopenharmony_ci#define CC_INT_CAL_SAMPLES_16 0x40 22762306a36Sopenharmony_ci#define CC_INT_CAL_SAMPLES_8 0x20 22862306a36Sopenharmony_ci#define CC_INT_CAL_SAMPLES_4 0x00 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci/* RTC constants */ 23162306a36Sopenharmony_ci#define RTC_BUP_CH_ENA 0x10 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci/* BatCtrl Current Source Constants */ 23462306a36Sopenharmony_ci#define BAT_CTRL_7U_ENA 0x01 23562306a36Sopenharmony_ci#define BAT_CTRL_20U_ENA 0x02 23662306a36Sopenharmony_ci#define BAT_CTRL_18U_ENA 0x01 23762306a36Sopenharmony_ci#define BAT_CTRL_16U_ENA 0x02 23862306a36Sopenharmony_ci#define BAT_CTRL_CMP_ENA 0x04 23962306a36Sopenharmony_ci#define FORCE_BAT_CTRL_CMP_HIGH 0x08 24062306a36Sopenharmony_ci#define BAT_CTRL_PULL_UP_ENA 0x10 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci/* Battery type */ 24362306a36Sopenharmony_ci#define BATTERY_UNKNOWN 00 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci/* Registers for pcut feature in ab8505 and ab9540 */ 24662306a36Sopenharmony_ci#define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12 24762306a36Sopenharmony_ci#define AB8505_RTC_PCUT_TIME_REG 0x13 24862306a36Sopenharmony_ci#define AB8505_RTC_PCUT_MAX_TIME_REG 0x14 24962306a36Sopenharmony_ci#define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15 25062306a36Sopenharmony_ci#define AB8505_RTC_PCUT_RESTART_REG 0x16 25162306a36Sopenharmony_ci#define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci/* USB Power Path constants for ab8540 */ 25462306a36Sopenharmony_ci#define BUS_VSYS_VOL_SELECT_MASK 0x06 25562306a36Sopenharmony_ci#define BUS_VSYS_VOL_SELECT_3P6V 0x00 25662306a36Sopenharmony_ci#define BUS_VSYS_VOL_SELECT_3P325V 0x02 25762306a36Sopenharmony_ci#define BUS_VSYS_VOL_SELECT_3P9V 0x04 25862306a36Sopenharmony_ci#define BUS_VSYS_VOL_SELECT_4P3V 0x06 25962306a36Sopenharmony_ci#define BUS_POWER_PATH_MODE_ENA 0x01 26062306a36Sopenharmony_ci#define BUS_PP_PRECHG_CURRENT_MASK 0x0E 26162306a36Sopenharmony_ci#define BUS_POWER_PATH_PRECHG_ENA 0x01 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci/* Forward declaration */ 26462306a36Sopenharmony_cistruct ab8500_fg; 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci/** 26762306a36Sopenharmony_ci * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds 26862306a36Sopenharmony_ci * if not specified 26962306a36Sopenharmony_ci * @recovery_sleep_timer: Time between measurements while recovering 27062306a36Sopenharmony_ci * @recovery_total_time: Total recovery time 27162306a36Sopenharmony_ci * @init_timer: Measurement interval during startup 27262306a36Sopenharmony_ci * @init_discard_time: Time we discard voltage measurement at startup 27362306a36Sopenharmony_ci * @init_total_time: Total init time during startup 27462306a36Sopenharmony_ci * @high_curr_time: Time current has to be high to go to recovery 27562306a36Sopenharmony_ci * @accu_charging: FG accumulation time while charging 27662306a36Sopenharmony_ci * @accu_high_curr_ua: FG accumulation time in high current mode 27762306a36Sopenharmony_ci * @high_curr_threshold_ua: High current threshold, in uA 27862306a36Sopenharmony_ci * @lowbat_threshold_uv: Low battery threshold, in uV 27962306a36Sopenharmony_ci * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 28062306a36Sopenharmony_ci * Resolution in 50 mV step. 28162306a36Sopenharmony_ci * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 28262306a36Sopenharmony_ci * Resolution in 50 mV step. 28362306a36Sopenharmony_ci * @user_cap_limit Capacity reported from user must be within this 28462306a36Sopenharmony_ci * limit to be considered as sane, in percentage 28562306a36Sopenharmony_ci * points. 28662306a36Sopenharmony_ci * @maint_thres This is the threshold where we stop reporting 28762306a36Sopenharmony_ci * battery full while in maintenance, in per cent 28862306a36Sopenharmony_ci * @pcut_enable: Enable power cut feature in ab8505 28962306a36Sopenharmony_ci * @pcut_max_time: Max time threshold 29062306a36Sopenharmony_ci * @pcut_flag_time: Flagtime threshold 29162306a36Sopenharmony_ci * @pcut_max_restart: Max number of restarts 29262306a36Sopenharmony_ci * @pcut_debounce_time: Sets battery debounce time 29362306a36Sopenharmony_ci */ 29462306a36Sopenharmony_cistruct ab8500_fg_parameters { 29562306a36Sopenharmony_ci int recovery_sleep_timer; 29662306a36Sopenharmony_ci int recovery_total_time; 29762306a36Sopenharmony_ci int init_timer; 29862306a36Sopenharmony_ci int init_discard_time; 29962306a36Sopenharmony_ci int init_total_time; 30062306a36Sopenharmony_ci int high_curr_time; 30162306a36Sopenharmony_ci int accu_charging; 30262306a36Sopenharmony_ci int accu_high_curr; 30362306a36Sopenharmony_ci int high_curr_threshold_ua; 30462306a36Sopenharmony_ci int lowbat_threshold_uv; 30562306a36Sopenharmony_ci int battok_falling_th_sel0; 30662306a36Sopenharmony_ci int battok_raising_th_sel1; 30762306a36Sopenharmony_ci int user_cap_limit; 30862306a36Sopenharmony_ci int maint_thres; 30962306a36Sopenharmony_ci bool pcut_enable; 31062306a36Sopenharmony_ci u8 pcut_max_time; 31162306a36Sopenharmony_ci u8 pcut_flag_time; 31262306a36Sopenharmony_ci u8 pcut_max_restart; 31362306a36Sopenharmony_ci u8 pcut_debounce_time; 31462306a36Sopenharmony_ci}; 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/** 31762306a36Sopenharmony_ci * struct ab8500_charger_maximization - struct used by the board config. 31862306a36Sopenharmony_ci * @use_maxi: Enable maximization for this battery type 31962306a36Sopenharmony_ci * @maxi_chg_curr_ua: Maximum charger current allowed in microampere 32062306a36Sopenharmony_ci * @maxi_wait_cycles: cycles to wait before setting charger current 32162306a36Sopenharmony_ci * @charger_curr_step_ua: delta between two charger current settings (uA) 32262306a36Sopenharmony_ci */ 32362306a36Sopenharmony_cistruct ab8500_maxim_parameters { 32462306a36Sopenharmony_ci bool ena_maxi; 32562306a36Sopenharmony_ci int chg_curr_ua; 32662306a36Sopenharmony_ci int wait_cycles; 32762306a36Sopenharmony_ci int charger_curr_step_ua; 32862306a36Sopenharmony_ci}; 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci/** 33162306a36Sopenharmony_ci * struct ab8500_bm_capacity_levels - ab8500 capacity level data 33262306a36Sopenharmony_ci * @critical: critical capacity level in percent 33362306a36Sopenharmony_ci * @low: low capacity level in percent 33462306a36Sopenharmony_ci * @normal: normal capacity level in percent 33562306a36Sopenharmony_ci * @high: high capacity level in percent 33662306a36Sopenharmony_ci * @full: full capacity level in percent 33762306a36Sopenharmony_ci */ 33862306a36Sopenharmony_cistruct ab8500_bm_capacity_levels { 33962306a36Sopenharmony_ci int critical; 34062306a36Sopenharmony_ci int low; 34162306a36Sopenharmony_ci int normal; 34262306a36Sopenharmony_ci int high; 34362306a36Sopenharmony_ci int full; 34462306a36Sopenharmony_ci}; 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci/** 34762306a36Sopenharmony_ci * struct ab8500_bm_charger_parameters - Charger specific parameters 34862306a36Sopenharmony_ci * @usb_volt_max_uv: maximum allowed USB charger voltage in uV 34962306a36Sopenharmony_ci * @usb_curr_max_ua: maximum allowed USB charger current in uA 35062306a36Sopenharmony_ci * @ac_volt_max_uv: maximum allowed AC charger voltage in uV 35162306a36Sopenharmony_ci * @ac_curr_max_ua: maximum allowed AC charger current in uA 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_cistruct ab8500_bm_charger_parameters { 35462306a36Sopenharmony_ci int usb_volt_max_uv; 35562306a36Sopenharmony_ci int usb_curr_max_ua; 35662306a36Sopenharmony_ci int ac_volt_max_uv; 35762306a36Sopenharmony_ci int ac_curr_max_ua; 35862306a36Sopenharmony_ci}; 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci/** 36162306a36Sopenharmony_ci * struct ab8500_bm_data - ab8500 battery management data 36262306a36Sopenharmony_ci * @bi battery info from device tree 36362306a36Sopenharmony_ci * @temp_now present battery temperature 36462306a36Sopenharmony_ci * @temp_interval_chg temperature measurement interval in s when charging 36562306a36Sopenharmony_ci * @temp_interval_nochg temperature measurement interval in s when not charging 36662306a36Sopenharmony_ci * @main_safety_tmr_h safety timer for main charger 36762306a36Sopenharmony_ci * @usb_safety_tmr_h safety timer for usb charger 36862306a36Sopenharmony_ci * @bkup_bat_v voltage which we charge the backup battery with 36962306a36Sopenharmony_ci * @bkup_bat_i current which we charge the backup battery with 37062306a36Sopenharmony_ci * @capacity_scaling indicates whether capacity scaling is to be used 37162306a36Sopenharmony_ci * @chg_unknown_bat flag to enable charging of unknown batteries 37262306a36Sopenharmony_ci * @enable_overshoot flag to enable VBAT overshoot control 37362306a36Sopenharmony_ci * @auto_trig flag to enable auto adc trigger 37462306a36Sopenharmony_ci * @fg_res resistance of FG resistor in 0.1mOhm 37562306a36Sopenharmony_ci * @interval_charging charge alg cycle period time when charging (sec) 37662306a36Sopenharmony_ci * @interval_not_charging charge alg cycle period time when not charging (sec) 37762306a36Sopenharmony_ci * @temp_hysteresis temperature hysteresis 37862306a36Sopenharmony_ci * @maxi maximization parameters 37962306a36Sopenharmony_ci * @cap_levels capacity in percent for the different capacity levels 38062306a36Sopenharmony_ci * @chg_params charger parameters 38162306a36Sopenharmony_ci * @fg_params fuel gauge parameters 38262306a36Sopenharmony_ci */ 38362306a36Sopenharmony_cistruct ab8500_bm_data { 38462306a36Sopenharmony_ci struct power_supply_battery_info *bi; 38562306a36Sopenharmony_ci int temp_now; 38662306a36Sopenharmony_ci int temp_interval_chg; 38762306a36Sopenharmony_ci int temp_interval_nochg; 38862306a36Sopenharmony_ci int main_safety_tmr_h; 38962306a36Sopenharmony_ci int usb_safety_tmr_h; 39062306a36Sopenharmony_ci int bkup_bat_v; 39162306a36Sopenharmony_ci int bkup_bat_i; 39262306a36Sopenharmony_ci bool capacity_scaling; 39362306a36Sopenharmony_ci bool chg_unknown_bat; 39462306a36Sopenharmony_ci bool enable_overshoot; 39562306a36Sopenharmony_ci bool auto_trig; 39662306a36Sopenharmony_ci int fg_res; 39762306a36Sopenharmony_ci int interval_charging; 39862306a36Sopenharmony_ci int interval_not_charging; 39962306a36Sopenharmony_ci int temp_hysteresis; 40062306a36Sopenharmony_ci const struct ab8500_maxim_parameters *maxi; 40162306a36Sopenharmony_ci const struct ab8500_bm_capacity_levels *cap_levels; 40262306a36Sopenharmony_ci const struct ab8500_bm_charger_parameters *chg_params; 40362306a36Sopenharmony_ci const struct ab8500_fg_parameters *fg_params; 40462306a36Sopenharmony_ci}; 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci/* Forward declaration */ 40762306a36Sopenharmony_cistruct ab8500_fg; 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ciextern struct ab8500_bm_data ab8500_bm_data; 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_civoid ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 41262306a36Sopenharmony_cistruct ab8500_fg *ab8500_fg_get(void); 41362306a36Sopenharmony_ciint ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 41462306a36Sopenharmony_ciint ab8500_fg_inst_curr_start(struct ab8500_fg *di); 41562306a36Sopenharmony_ciint ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 41662306a36Sopenharmony_ciint ab8500_fg_inst_curr_started(struct ab8500_fg *di); 41762306a36Sopenharmony_ciint ab8500_fg_inst_curr_done(struct ab8500_fg *di); 41862306a36Sopenharmony_ciint ab8500_bm_of_probe(struct power_supply *psy, 41962306a36Sopenharmony_ci struct ab8500_bm_data *bm); 42062306a36Sopenharmony_civoid ab8500_bm_of_remove(struct power_supply *psy, 42162306a36Sopenharmony_ci struct ab8500_bm_data *bm); 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ciextern struct platform_driver ab8500_fg_driver; 42462306a36Sopenharmony_ciextern struct platform_driver ab8500_btemp_driver; 42562306a36Sopenharmony_ciextern struct platform_driver ab8500_chargalg_driver; 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci#endif /* _AB8500_CHARGER_H_ */ 428