drivers: power: supply: Import Xiaomi changes
Change-Id: I6d150a5a4691b29648feabf8438e2dd9bc49ec41
This commit is contained in:
@@ -47,6 +47,9 @@ static const char * const power_supply_type_text[] = {
|
||||
"USB_HVDCP", "USB_HVDCP_3", "USB_HVDCP_3P5", "Wireless", "USB_FLOAT",
|
||||
"BMS", "Parallel", "Main", "USB_C_UFP", "USB_C_DFP",
|
||||
"Charge_Pump",
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
"Batt_Verify",
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char * const power_supply_usb_type_text[] = {
|
||||
@@ -215,6 +218,64 @@ static ssize_t power_supply_show_property(struct device *dev,
|
||||
case POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT:
|
||||
ret = sprintf(buf, "%lld\n", value.int64val);
|
||||
break;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
case POWER_SUPPLY_PROP_WIRELESS_VERSION:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "0x%x\n",
|
||||
value.intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_WIRELESS_FW_VERSION:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "0x%x\n",
|
||||
value.intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_WIRELESS_WAKELOCK:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
value.intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_SIGNAL_STRENGTH:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
value.intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_WIRELESS_CP_EN:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
value.intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TX_MAC:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%llx\n",
|
||||
value.int64val);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_RX_CR:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%llx\n",
|
||||
value.int64val);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_RX_CEP:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%llx\n",
|
||||
value.int64val);
|
||||
break;
|
||||
|
||||
case POWER_SUPPLY_PROP_BT_STATE:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%x\n",
|
||||
value.intval);
|
||||
break;
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
case POWER_SUPPLY_PROP_ROMID:
|
||||
case POWER_SUPPLY_PROP_DS_STATUS:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
|
||||
value.arrayval[0], value.arrayval[1], value.arrayval[2], value.arrayval[3],
|
||||
value.arrayval[4], value.arrayval[5], value.arrayval[6], value.arrayval[7]);
|
||||
break;
|
||||
|
||||
case POWER_SUPPLY_PROP_PAGE0_DATA:
|
||||
case POWER_SUPPLY_PROP_PAGE1_DATA:
|
||||
case POWER_SUPPLY_PROP_PAGEDATA:
|
||||
ret = scnprintf(buf, PAGE_SIZE, "%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
|
||||
value.arrayval[0], value.arrayval[1], value.arrayval[2], value.arrayval[3],
|
||||
value.arrayval[4], value.arrayval[5], value.arrayval[6], value.arrayval[7],
|
||||
value.arrayval[8], value.arrayval[9], value.arrayval[10], value.arrayval[11],
|
||||
value.arrayval[12], value.arrayval[13], value.arrayval[14], value.arrayval[15]);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_VERIFY_MODEL_NAME:
|
||||
#endif
|
||||
#endif
|
||||
case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER:
|
||||
ret = sprintf(buf, "%s\n", value.strval);
|
||||
break;
|
||||
@@ -232,6 +293,10 @@ static ssize_t power_supply_store_property(struct device *dev,
|
||||
struct power_supply *psy = dev_get_drvdata(dev);
|
||||
enum power_supply_property psp = attr - power_supply_attrs;
|
||||
union power_supply_propval value;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
long val;
|
||||
int64_t num_long;
|
||||
#endif
|
||||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
@@ -252,6 +317,33 @@ static ssize_t power_supply_store_property(struct device *dev,
|
||||
case POWER_SUPPLY_PROP_SCOPE:
|
||||
ret = sysfs_match_string(power_supply_scope_text, buf);
|
||||
break;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
case POWER_SUPPLY_PROP_BT_STATE:
|
||||
case POWER_SUPPLY_PROP_RX_CR:
|
||||
ret = kstrtol(buf, 16, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = val;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_RX_CEP:
|
||||
ret = kstrtol(buf, 16, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = val;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TX_MAC:
|
||||
ret = kstrtoll(buf, 16, &num_long);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
value.int64val = num_long;
|
||||
ret = power_supply_set_property(psy, psp, &value);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else
|
||||
return count;
|
||||
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
@@ -328,6 +420,13 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(capacity_alert_min),
|
||||
POWER_SUPPLY_ATTR(capacity_alert_max),
|
||||
POWER_SUPPLY_ATTR(capacity_level),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(shutdown_delay),
|
||||
POWER_SUPPLY_ATTR(shutdown_delay_en),
|
||||
POWER_SUPPLY_ATTR(soc_decimal),
|
||||
POWER_SUPPLY_ATTR(soc_decimal_rate),
|
||||
POWER_SUPPLY_ATTR(cold_thermal_level),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(temp),
|
||||
POWER_SUPPLY_ATTR(temp_max),
|
||||
POWER_SUPPLY_ATTR(temp_min),
|
||||
@@ -352,6 +451,12 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(charge_enabled),
|
||||
POWER_SUPPLY_ATTR(set_ship_mode),
|
||||
POWER_SUPPLY_ATTR(real_type),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(hvdcp3_type),
|
||||
POWER_SUPPLY_ATTR(fake_hvdcp3),
|
||||
POWER_SUPPLY_ATTR(quick_charge_type),
|
||||
POWER_SUPPLY_ATTR(quick_charge_power),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(charge_now_raw),
|
||||
POWER_SUPPLY_ATTR(charge_now_error),
|
||||
POWER_SUPPLY_ATTR(capacity_raw),
|
||||
@@ -361,7 +466,14 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(step_charging_step),
|
||||
POWER_SUPPLY_ATTR(pin_enabled),
|
||||
POWER_SUPPLY_ATTR(input_suspend),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(battery_input_suspend),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(input_voltage_regulation),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(input_voltage_vrect),
|
||||
POWER_SUPPLY_ATTR(rx_iout),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(input_current_max),
|
||||
POWER_SUPPLY_ATTR(input_current_trim),
|
||||
POWER_SUPPLY_ATTR(input_current_settled),
|
||||
@@ -386,6 +498,11 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(boost_current),
|
||||
POWER_SUPPLY_ATTR(safety_timer_enabled),
|
||||
POWER_SUPPLY_ATTR(charge_done),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(hiz_mode),
|
||||
POWER_SUPPLY_ATTR(usb_current_now),
|
||||
POWER_SUPPLY_ATTR(usb_voltage_now),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(flash_active),
|
||||
POWER_SUPPLY_ATTR(flash_trigger),
|
||||
POWER_SUPPLY_ATTR(force_tlim),
|
||||
@@ -403,11 +520,17 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(typec_mode),
|
||||
POWER_SUPPLY_ATTR(typec_cc_orientation),
|
||||
POWER_SUPPLY_ATTR(typec_power_role),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(typec_boost_otg_disable),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(typec_src_rp),
|
||||
POWER_SUPPLY_ATTR(pd_allowed),
|
||||
POWER_SUPPLY_ATTR(pd_active),
|
||||
POWER_SUPPLY_ATTR(pd_in_hard_reset),
|
||||
POWER_SUPPLY_ATTR(pd_current_max),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(apdo_max),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(pd_usb_suspend_supported),
|
||||
POWER_SUPPLY_ATTR(charger_temp),
|
||||
POWER_SUPPLY_ATTR(charger_temp_max),
|
||||
@@ -420,6 +543,11 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(parallel_mode),
|
||||
POWER_SUPPLY_ATTR(die_health),
|
||||
POWER_SUPPLY_ATTR(connector_health),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(connector_temp),
|
||||
POWER_SUPPLY_ATTR(vbus_disable),
|
||||
POWER_SUPPLY_ATTR(arti_vbus_enable),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(ctm_current_max),
|
||||
POWER_SUPPLY_ATTR(hw_current_max),
|
||||
POWER_SUPPLY_ATTR(pr_swap),
|
||||
@@ -429,13 +557,34 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(pd_voltage_max),
|
||||
POWER_SUPPLY_ATTR(pd_voltage_min),
|
||||
POWER_SUPPLY_ATTR(sdp_current_max),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(dc_thermal_levels),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(connector_type),
|
||||
POWER_SUPPLY_ATTR(parallel_batfet_mode),
|
||||
POWER_SUPPLY_ATTR(parallel_fcc_max),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(wireless_version),
|
||||
POWER_SUPPLY_ATTR(wireless_fw_version),
|
||||
POWER_SUPPLY_ATTR(signal_strength),
|
||||
POWER_SUPPLY_ATTR(wireless_cp_en),
|
||||
POWER_SUPPLY_ATTR(wireless_power_good_en),
|
||||
POWER_SUPPLY_ATTR(sw_disabel_dc_en),
|
||||
POWER_SUPPLY_ATTR(wireless_wakelock),
|
||||
POWER_SUPPLY_ATTR(wireless_tx_id),
|
||||
POWER_SUPPLY_ATTR(tx_adapter),
|
||||
POWER_SUPPLY_ATTR(tx_mac),
|
||||
POWER_SUPPLY_ATTR(rx_cr),
|
||||
POWER_SUPPLY_ATTR(rx_cep),
|
||||
POWER_SUPPLY_ATTR(bt_state),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(min_icl),
|
||||
POWER_SUPPLY_ATTR(moisture_detected),
|
||||
POWER_SUPPLY_ATTR(batt_profile_version),
|
||||
POWER_SUPPLY_ATTR(batt_full_current),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(warm_fake_charging),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(recharge_soc),
|
||||
POWER_SUPPLY_ATTR(hvdcp_opti_allowed),
|
||||
POWER_SUPPLY_ATTR(smb_en_mode),
|
||||
@@ -446,7 +595,14 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(clear_soh),
|
||||
POWER_SUPPLY_ATTR(force_recharge),
|
||||
POWER_SUPPLY_ATTR(fcc_stepper_enable),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(smb_en_allowed),
|
||||
POWER_SUPPLY_ATTR(batt_2s_mode),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(toggle_stat),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(type_recheck),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(main_fcc_max),
|
||||
POWER_SUPPLY_ATTR(fg_reset),
|
||||
POWER_SUPPLY_ATTR(qc_opti_disable),
|
||||
@@ -463,6 +619,9 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(force_main_fcc),
|
||||
POWER_SUPPLY_ATTR(comp_clamp_level),
|
||||
POWER_SUPPLY_ATTR(adapter_cc_mode),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(non_compatible),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(skin_health),
|
||||
POWER_SUPPLY_ATTR(aicl_done),
|
||||
POWER_SUPPLY_ATTR(voltage_step),
|
||||
@@ -481,6 +640,69 @@ static struct device_attribute power_supply_attrs[] = {
|
||||
POWER_SUPPLY_ATTR(cp_ilim),
|
||||
POWER_SUPPLY_ATTR(irq_status),
|
||||
POWER_SUPPLY_ATTR(parallel_output_mode),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_ATTR(cp_win_ov),
|
||||
POWER_SUPPLY_ATTR(cp_passthrough_mode),
|
||||
POWER_SUPPLY_ATTR(cp_passthrough_config),
|
||||
POWER_SUPPLY_ATTR(cp_ovp_config),
|
||||
POWER_SUPPLY_ATTR(cp_ocp_config),
|
||||
POWER_SUPPLY_ATTR(cp_cfly_ss_status),
|
||||
/* Bq charge pump properties */
|
||||
POWER_SUPPLY_ATTR(ti_battery_present),
|
||||
POWER_SUPPLY_ATTR(ti_vbus_present),
|
||||
POWER_SUPPLY_ATTR(ti_battery_voltage),
|
||||
POWER_SUPPLY_ATTR(ti_battery_current),
|
||||
POWER_SUPPLY_ATTR(ti_battery_temperature),
|
||||
POWER_SUPPLY_ATTR(ti_bus_voltage),
|
||||
POWER_SUPPLY_ATTR(ti_bus_current),
|
||||
POWER_SUPPLY_ATTR(ti_bus_temperature),
|
||||
POWER_SUPPLY_ATTR(ti_die_temperature),
|
||||
POWER_SUPPLY_ATTR(ti_alarm_status),
|
||||
POWER_SUPPLY_ATTR(ti_fault_status),
|
||||
POWER_SUPPLY_ATTR(ti_reg_status),
|
||||
POWER_SUPPLY_ATTR(ti_set_bus_protection_for_qc3),
|
||||
POWER_SUPPLY_ATTR(ti_bus_error_status),
|
||||
POWER_SUPPLY_ATTR(fastcharge_mode),
|
||||
POWER_SUPPLY_ATTR(dp_dm_bq),
|
||||
POWER_SUPPLY_ATTR(pd_authentication),
|
||||
POWER_SUPPLY_ATTR(passthrough_curr_max),
|
||||
POWER_SUPPLY_ATTR(termination_current),
|
||||
POWER_SUPPLY_ATTR(ffc_termination_current),
|
||||
POWER_SUPPLY_ATTR(sys_termination_current),
|
||||
POWER_SUPPLY_ATTR(ffc_sys_termination_current),
|
||||
POWER_SUPPLY_ATTR(vbatt_full_vol),
|
||||
POWER_SUPPLY_ATTR(fcc_vbatt_full_vol),
|
||||
POWER_SUPPLY_ATTR(ki_coeff_current),
|
||||
POWER_SUPPLY_ATTR(recharge_vbat),
|
||||
POWER_SUPPLY_ATTR(step_vfloat_index),
|
||||
POWER_SUPPLY_ATTR(night_charging),
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
/* battery verify properties */
|
||||
POWER_SUPPLY_ATTR(romid),
|
||||
POWER_SUPPLY_ATTR(ds_status),
|
||||
POWER_SUPPLY_ATTR(pagenumber),
|
||||
POWER_SUPPLY_ATTR(pagedata),
|
||||
POWER_SUPPLY_ATTR(authen_result),
|
||||
POWER_SUPPLY_ATTR(session_seed),
|
||||
POWER_SUPPLY_ATTR(s_secret),
|
||||
POWER_SUPPLY_ATTR(challenge),
|
||||
POWER_SUPPLY_ATTR(auth_anon),
|
||||
POWER_SUPPLY_ATTR(auth_bdconst),
|
||||
POWER_SUPPLY_ATTR(page0_data),
|
||||
POWER_SUPPLY_ATTR(page1_data),
|
||||
POWER_SUPPLY_ATTR(verify_model_name),
|
||||
POWER_SUPPLY_ATTR(maxim_batt_cycle_count),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(chip_ok),
|
||||
/* DIV 2 properties */
|
||||
POWER_SUPPLY_ATTR(div_2_mode),
|
||||
POWER_SUPPLY_ATTR(reverse_chg_mode),
|
||||
POWER_SUPPLY_ATTR(reverse_chg_state),
|
||||
POWER_SUPPLY_ATTR(reverse_gpio_state),
|
||||
POWER_SUPPLY_ATTR(reset_div_2_mode),
|
||||
POWER_SUPPLY_ATTR(aicl_enable),
|
||||
POWER_SUPPLY_ATTR(otg_state),
|
||||
#endif
|
||||
POWER_SUPPLY_ATTR(fg_type),
|
||||
POWER_SUPPLY_ATTR(charger_status),
|
||||
/* Local extensions of type int64_t */
|
||||
|
||||
@@ -77,6 +77,9 @@ struct pl_data {
|
||||
struct power_supply *dc_psy;
|
||||
struct power_supply *cp_master_psy;
|
||||
struct power_supply *cp_slave_psy;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct power_supply *wireless_psy;
|
||||
#endif
|
||||
int charge_type;
|
||||
int total_settled_ua;
|
||||
int pl_settled_ua;
|
||||
@@ -1206,6 +1209,19 @@ static bool is_batt_available(struct pl_data *chip)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
static bool is_wireless_available(struct pl_data *chip)
|
||||
{
|
||||
if (!chip->wireless_psy)
|
||||
chip->wireless_psy = power_supply_get_by_name("wireless");
|
||||
|
||||
if (!chip->wireless_psy)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PARALLEL_FLOAT_VOLTAGE_DELTA_UV 50000
|
||||
static int pl_fv_vote_callback(struct votable *votable, void *data,
|
||||
int fv_uv, const char *client)
|
||||
@@ -1258,6 +1274,21 @@ static int pl_fv_vote_callback(struct votable *votable, void *data,
|
||||
if (rc < 0)
|
||||
pr_err("Couldn't set force recharge rc=%d\n",
|
||||
rc);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
} else if (is_wireless_available(chip)) {
|
||||
rc = power_supply_get_property(chip->wireless_psy,
|
||||
POWER_SUPPLY_PROP_WIRELESS_POWER_GOOD_EN,
|
||||
&pval);
|
||||
if (pval.intval) {
|
||||
pr_err("wireless re-triggering charging\n");
|
||||
rc = power_supply_set_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_FORCE_RECHARGE,
|
||||
&pval);
|
||||
if (rc < 0)
|
||||
pr_err("Couldn't set force recharge rc=%d\n",
|
||||
rc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,28 @@
|
||||
|
||||
#define FULL_CAPACITY 100
|
||||
#define FULL_SOC_RAW 255
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define FULL_SOC_REPORT_THR 250
|
||||
#endif
|
||||
|
||||
#define DEBUG_BATT_SOC 67
|
||||
#define BATT_MISS_SOC 50
|
||||
#define ESR_SOH_SOC 50
|
||||
#define EMPTY_SOC 0
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define VBAT_CRITICAL_LOW_THR 2800
|
||||
#define EMPTY_DEBOUNCE_TIME_COUNT_MAX 5
|
||||
|
||||
#define VBAT_RESTART_FG_EMPTY_UV 3500000
|
||||
#define TEMP_THR_RESTART_FG 150
|
||||
#define RESTART_FG_START_WORK_MS 1000
|
||||
#define RESTART_FG_WORK_MS 2000
|
||||
#define EMPTY_REPORT_SOC 1
|
||||
|
||||
#define CRITICAL_HIGH_TEMP 580
|
||||
#endif
|
||||
|
||||
enum prof_load_status {
|
||||
PROFILE_MISSING,
|
||||
PROFILE_LOADED,
|
||||
@@ -326,12 +342,21 @@ struct fg_batt_props {
|
||||
char *batt_profile;
|
||||
int float_volt_uv;
|
||||
int vbatt_full_mv;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int ffc_vbatt_full_mv;
|
||||
#endif
|
||||
int fastchg_curr_ma;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int nom_cap_uah;
|
||||
#endif
|
||||
int *therm_coeffs;
|
||||
int therm_ctr_offset;
|
||||
int therm_pull_up_kohms;
|
||||
int *rslow_normal_coeffs;
|
||||
int *rslow_low_coeffs;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int ffc_term_curr_ma;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct fg_cyc_ctr_data {
|
||||
@@ -415,6 +440,28 @@ static const struct fg_pt fg_tsmc_osc_table[] = {
|
||||
{ 90, 444992 },
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define BATT_MA_AVG_SAMPLES 8
|
||||
struct batt_params {
|
||||
bool update_now;
|
||||
int batt_raw_soc;
|
||||
int batt_soc;
|
||||
int smooth_batt_soc;
|
||||
int smooth_low_batt_soc;
|
||||
int smooth_batt_flag;
|
||||
int smooth_full_soc;
|
||||
int samples_num;
|
||||
int samples_index;
|
||||
int batt_ma_avg_samples[BATT_MA_AVG_SAMPLES];
|
||||
int batt_ma_avg;
|
||||
int batt_ma_prev;
|
||||
int batt_ma;
|
||||
int batt_mv;
|
||||
int batt_temp;
|
||||
struct timespec last_soc_change_time;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct fg_memif {
|
||||
struct fg_dma_address *addr_map;
|
||||
int num_partitions;
|
||||
@@ -434,6 +481,11 @@ struct fg_dev {
|
||||
struct power_supply *dc_psy;
|
||||
struct power_supply *parallel_psy;
|
||||
struct power_supply *pc_port_psy;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
struct power_supply *max_verify_psy;
|
||||
#endif
|
||||
#endif
|
||||
struct fg_irq_info *irqs;
|
||||
struct votable *awake_votable;
|
||||
struct votable *delta_bsoc_irq_en_votable;
|
||||
@@ -450,6 +502,9 @@ struct fg_dev {
|
||||
struct mutex sram_rw_lock;
|
||||
struct mutex charge_full_lock;
|
||||
struct mutex qnovo_esr_ctrl_lock;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct timespec scale_soc_change_time;
|
||||
#endif
|
||||
spinlock_t suspend_lock;
|
||||
spinlock_t awake_lock;
|
||||
u32 batt_soc_base;
|
||||
@@ -457,6 +512,9 @@ struct fg_dev {
|
||||
u32 mem_if_base;
|
||||
u32 rradc_base;
|
||||
u32 wa_flags;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int cycle_count;
|
||||
#endif
|
||||
u32 esr_wakeup_ms;
|
||||
u32 awake_status;
|
||||
int batt_id_ohms;
|
||||
@@ -486,7 +544,18 @@ struct fg_dev {
|
||||
bool twm_state;
|
||||
bool use_dma;
|
||||
bool qnovo_enable;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool empty_restart_fg;
|
||||
bool report_full;
|
||||
bool profile_already_find;
|
||||
bool input_present;
|
||||
bool shutdown_delay;
|
||||
#endif
|
||||
enum fg_version version;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct batt_params param;
|
||||
struct delayed_work soc_monitor_work;
|
||||
#endif
|
||||
bool suspended;
|
||||
struct completion soc_update;
|
||||
struct completion soc_ready;
|
||||
@@ -494,6 +563,13 @@ struct fg_dev {
|
||||
struct work_struct status_change_work;
|
||||
struct work_struct esr_sw_work;
|
||||
struct delayed_work sram_dump_work;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct delayed_work empty_restart_fg_work;
|
||||
int fake_temp;
|
||||
int fake_authentic;
|
||||
int fake_chip_ok;
|
||||
int maxim_cycle_count;
|
||||
#endif
|
||||
struct work_struct esr_filter_work;
|
||||
struct alarm esr_filter_alarm;
|
||||
ktime_t last_delta_temp_time;
|
||||
|
||||
@@ -895,27 +895,78 @@ int fg_get_msoc_raw(struct fg_dev *fg, int *val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
static bool optimized_soc_flag;
|
||||
#endif
|
||||
int fg_get_msoc(struct fg_dev *fg, int *msoc)
|
||||
{
|
||||
int rc;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int raw_msoc;
|
||||
#endif
|
||||
|
||||
rc = fg_get_msoc_raw(fg, msoc);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
rc = fg_get_msoc_raw(fg, &raw_msoc);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (fg->param.smooth_batt_flag) {
|
||||
if (raw_msoc >= 255) {
|
||||
*msoc = FULL_CAPACITY;
|
||||
} else if (raw_msoc >= 252 && !optimized_soc_flag && fg->report_full) {
|
||||
*msoc = FULL_CAPACITY;
|
||||
optimized_soc_flag = true;
|
||||
} else if (raw_msoc >= 252 && !optimized_soc_flag && !fg->report_full) {
|
||||
*msoc = FULL_CAPACITY - 1;
|
||||
} else if (raw_msoc >= 245 && !optimized_soc_flag) {
|
||||
*msoc = FULL_CAPACITY - 1;
|
||||
} else if (raw_msoc >= 245 && optimized_soc_flag){
|
||||
*msoc = FULL_CAPACITY;
|
||||
} else if (raw_msoc > 19) {
|
||||
*msoc = DIV_ROUND_CLOSEST(raw_msoc * FULL_CAPACITY, FULL_SOC_RAW) + 3;
|
||||
} else if (raw_msoc > 0) {
|
||||
*msoc = raw_msoc / 2 + 1;
|
||||
} else if (raw_msoc == 0) {
|
||||
*msoc = 0;
|
||||
} else {
|
||||
*msoc = 0;
|
||||
}
|
||||
|
||||
if (raw_msoc < 245)
|
||||
optimized_soc_flag = false;
|
||||
} else {
|
||||
#endif
|
||||
/*
|
||||
* To have better endpoints for 0 and 100, it is good to tune the
|
||||
* calculation discarding values 0 and 255 while rounding off. Rest
|
||||
* of the values 1-254 will be scaled to 1-99. DIV_ROUND_UP will not
|
||||
* be suitable here as it rounds up any value higher than 252 to 100.
|
||||
*/
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if ((*msoc >= FULL_SOC_REPORT_THR - 2) && (*msoc < FULL_SOC_RAW) && fg->report_full) {
|
||||
*msoc = DIV_ROUND_CLOSEST(*msoc * FULL_CAPACITY, FULL_SOC_RAW) + 1;
|
||||
if (*msoc >= FULL_CAPACITY)
|
||||
*msoc = FULL_CAPACITY;
|
||||
} else
|
||||
#endif
|
||||
if (*msoc == FULL_SOC_RAW)
|
||||
*msoc = 100;
|
||||
else if (*msoc == 0)
|
||||
*msoc = 0;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
else if (*msoc >= FULL_SOC_REPORT_THR - 4 && *msoc <= FULL_SOC_REPORT_THR - 3 && fg->report_full)
|
||||
*msoc = DIV_ROUND_CLOSEST(*msoc * FULL_CAPACITY, FULL_SOC_RAW);
|
||||
#endif
|
||||
else
|
||||
*msoc = DIV_ROUND_CLOSEST((*msoc - 1) * (FULL_CAPACITY - 2),
|
||||
FULL_SOC_RAW - 2) + 1;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -480,6 +480,14 @@ int vote(struct votable *votable, const char *client_str, bool enabled, int val)
|
||||
*/
|
||||
if (!votable->voted_on
|
||||
|| (effective_result != votable->effective_result)) {
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (strcmp(votable->name, "FG_WS") != 0) {
|
||||
pr_info("%s: current vote is now %d voted by %s,%d, previous voted %d\n",
|
||||
votable->name, effective_result,
|
||||
get_client_str(votable, effective_id),
|
||||
effective_id, votable->effective_result);
|
||||
}
|
||||
#endif
|
||||
votable->effective_client_id = effective_id;
|
||||
votable->effective_result = effective_result;
|
||||
pr_debug("%s: effective vote is now %d voted by %s,%d\n",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,12 @@
|
||||
#include <linux/extcon-provider.h>
|
||||
#include <linux/usb/typec.h>
|
||||
#include "storm-watch.h"
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#include <linux/usb/usbpd.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#endif
|
||||
#include "battery.h"
|
||||
|
||||
enum print_reason {
|
||||
@@ -25,6 +31,9 @@ enum print_reason {
|
||||
PR_PARALLEL = BIT(3),
|
||||
PR_OTG = BIT(4),
|
||||
PR_WLS = BIT(5),
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
PR_OEM = BIT(6),
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DEFAULT_VOTER "DEFAULT_VOTER"
|
||||
@@ -57,6 +66,11 @@ enum print_reason {
|
||||
#define PL_FCC_LOW_VOTER "PL_FCC_LOW_VOTER"
|
||||
#define WBC_VOTER "WBC_VOTER"
|
||||
#define HW_LIMIT_VOTER "HW_LIMIT_VOTER"
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define CHG_AWAKE_VOTER "CHG_AWAKE_VOTER"
|
||||
#define DC_AWAKE_VOTER "DC_AWAKE_VOTER"
|
||||
#define DC_PLUGOUT_WIRELESS_VOTER "DC_PLUGOUT_WIRELESS_VOTER"
|
||||
#endif
|
||||
#define PL_SMB_EN_VOTER "PL_SMB_EN_VOTER"
|
||||
#define FORCE_RECHARGE_VOTER "FORCE_RECHARGE_VOTER"
|
||||
#define LPD_VOTER "LPD_VOTER"
|
||||
@@ -65,6 +79,9 @@ enum print_reason {
|
||||
#define JEITA_ARB_VOTER "JEITA_ARB_VOTER"
|
||||
#define MOISTURE_VOTER "MOISTURE_VOTER"
|
||||
#define HVDCP2_ICL_VOTER "HVDCP2_ICL_VOTER"
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define HVDCP2_FCC_VOTER "HVDCP2_FCC_VOTER"
|
||||
#endif
|
||||
#define AICL_THRESHOLD_VOTER "AICL_THRESHOLD_VOTER"
|
||||
#define USBOV_DBC_VOTER "USBOV_DBC_VOTER"
|
||||
#define CHG_TERMINATION_VOTER "CHG_TERMINATION_VOTER"
|
||||
@@ -78,32 +95,199 @@ enum print_reason {
|
||||
#define MAIN_FCC_VOTER "MAIN_FCC_VOTER"
|
||||
#define DCIN_AICL_VOTER "DCIN_AICL_VOTER"
|
||||
#define WLS_PL_CHARGING_VOTER "WLS_PL_CHARGING_VOTER"
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define OTG_VOTER "OTG_VOTER"
|
||||
#endif
|
||||
#define ICL_CHANGE_VOTER "ICL_CHANGE_VOTER"
|
||||
#define OVERHEAT_LIMIT_VOTER "OVERHEAT_LIMIT_VOTER"
|
||||
#define TYPEC_SWAP_VOTER "TYPEC_SWAP_VOTER"
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define SW_DISABLE_DC_VOTER "SW_DISABLE_DC_VOTER"
|
||||
#define CLASSA_QC_FCC_VOTER "CLASSA_QC_FCC_VOTER"
|
||||
#define QC_A_CP_ICL_MAX_VOTER "QC_A_CP_ICL_MAX_VOTER"
|
||||
#define JEITA_VOTER "JEITA_VOTER"
|
||||
#define AFTER_FFC_VOTER "AFTER_FFC_VOTER"
|
||||
#define BATT_VERIFY_VOTER "BATT_VERIFY_VOTER"
|
||||
#define BBC_CHARGER_VOTER "BBC_CHARGER_VOTER"
|
||||
#define QC2_UNSUPPORTED_VOTER "QC2_UNSUPPORTED_VOTER"
|
||||
#define THERMAL_FCC_OVERRIDE_VOTER "THERMAL_FCC_OVERRIDE_VOTER"
|
||||
/* use for QC3P5 */
|
||||
#define QC3P5_VOTER "QC3P5_VOTER"
|
||||
#define FCC_MAX_QC3P5_VOTER "FCC_MAX_QC3P5_VOTER"
|
||||
|
||||
/* thermal micros */
|
||||
#define MAX_TEMP_LEVEL 16
|
||||
/* defined for distinguish qc class_a and class_b */
|
||||
#define VOL_THR_FOR_QC_CLASS_AB 12400000
|
||||
#define COMP_FOR_LOW_RESISTANCE_CABLE 100000
|
||||
#define QC_CLASS_A_CURRENT_UA 3600000
|
||||
#define HVDCP_CLASS_A_MAX_UA 2500000
|
||||
#define HVDCP_CLASS_A_FOR_CP_UA 1900000
|
||||
#define MAX_PULSE 38
|
||||
#define MAX_PLUSE_COUNT_ALLOWED 30
|
||||
#define HIGH_NUM_PULSE_THR 12
|
||||
#endif
|
||||
|
||||
#define BOOST_BACK_STORM_COUNT 3
|
||||
#define WEAK_CHG_STORM_COUNT 8
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define MAX_QC3P5_PLUSE_COUNT_ALLOWED 230
|
||||
#define QC3P5_DP_RAPIDLY_TUNE_ALLOWED 120
|
||||
#define QC3P5_DP_RAPIDLY_TUNE_PULSE 10
|
||||
|
||||
/* defined for qc2_unsupported */
|
||||
#define QC2_UNSUPPORTED_UA 1800000
|
||||
/* defined for HVDCP2 */
|
||||
#define HVDCP2_CURRENT_UA 1400000
|
||||
/* defined for un_compliant Type-C cable */
|
||||
#define CC_UN_COMPLIANT_START_DELAY_MS 700
|
||||
#endif
|
||||
|
||||
#define VBAT_TO_VRAW_ADC(v) div_u64((u64)v * 1000000UL, 194637UL)
|
||||
|
||||
#define ITERM_LIMITS_PMI632_MA 5000
|
||||
#define ITERM_LIMITS_PM8150B_MA 10000
|
||||
#define ADC_CHG_ITERM_MASK 32767
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define BAT_TEMP_COLD 0
|
||||
#define BAT_TEMP_TOO_HOT 580
|
||||
#endif
|
||||
|
||||
#define SDP_100_MA 100000
|
||||
#define SDP_CURRENT_UA 500000
|
||||
#define CDP_CURRENT_UA 1500000
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define DCP_CURRENT_UA 1600000
|
||||
#define HVDCP_START_CURRENT_UA 1000000
|
||||
#define HVDCP_CURRENT_UA 2800000
|
||||
#else
|
||||
#define DCP_CURRENT_UA 1500000
|
||||
#define HVDCP_CURRENT_UA 3000000
|
||||
#endif
|
||||
#define TYPEC_DEFAULT_CURRENT_UA 900000
|
||||
#define TYPEC_MEDIUM_CURRENT_UA 1500000
|
||||
#define TYPEC_HIGH_CURRENT_UA 3000000
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define HVDCP3P5_40W_CURRENT_UA 4000000
|
||||
#define PD_UNVERIFED_CURRENT 4800000
|
||||
#define FLOAT_CHARGER_UA 1000000
|
||||
|
||||
/* used for bq charge pump solution */
|
||||
#define MAIN_CHG_SUSPEND_VOTER "MAIN_CHG_SUSPEND_VOTER"
|
||||
#define PD_VERIFED_VOTER "PD_VERIFED_VOTER"
|
||||
#define WIRELESS_BY_USB_IN_VOTER "WIRELESS_BY_USB_IN_VOTER"
|
||||
|
||||
#define ADC_CHG_TERM_MASK 32767
|
||||
#endif
|
||||
#define DCIN_ICL_MIN_UA 100000
|
||||
#define DCIN_ICL_MAX_UA 1500000
|
||||
#define DCIN_ICL_STEP_UA 100000
|
||||
#define ROLE_REVERSAL_DELAY_MS 500
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
/* six pin new battery step charge micros */
|
||||
#define MAX_STEP_ENTRIES 3
|
||||
#define MAX_COUNT_OF_IBAT_STEP 2
|
||||
#define TAPER_DECREASE_FCC_UA 100000
|
||||
#define TAPER_SLOWDECREASE_FCC_UA 50000
|
||||
#define TAPER_IBAT_TRH_HYS_UA 50000
|
||||
#define MIN_TAPER_FCC_THR_UA 2500000
|
||||
#define SECOND_FFC_TERM_CURRENT_DIFF 98
|
||||
|
||||
#define STEP_CHG_DELAYED_MONITOR_MS 10000
|
||||
#define STEP_CHG_DELAYED_QUICK_MONITOR_MS 2000
|
||||
#define STEP_CHG_DELAYED_SLOWQUICK_MONITOR_MS 1000
|
||||
#define STEP_CHG_DELAYED_START_MS 100
|
||||
#define VBAT_FOR_STEP_MIN_UV 4300000
|
||||
#define VBAT_FOR_STEP_HYS_UV 20000
|
||||
#define WARM_VFLOAT_UV 4100000
|
||||
|
||||
#define MAIN_CHG_SUSPEND_ICL 50000
|
||||
#define MAIN_ICL_MIN 100000
|
||||
#define MAIN_ICL_MIN_VOTER "MAIN_ICL_MIN_VOTER"
|
||||
#define SIX_PIN_VFLOAT_VOTER "SIX_PIN_VFLOAT_VOTER"
|
||||
#define NON_FFC_VFLOAT_VOTER "NON_FFC_VFLOAT_VOTER"
|
||||
#define SW_CONN_THERM_VOTER "SW_CONN_THERM_VOTER"
|
||||
|
||||
#define QC3P5_CHARGER_ICL 2000000
|
||||
|
||||
#ifndef CONFIG_FUEL_GAUGE_BQ27Z561
|
||||
#define ESR_WORK_VOTER "ESR_WORK_VOTER"
|
||||
#define ESR_WORK_TIME_2S 2000
|
||||
#define ESR_WORK_TIME_97S 97000
|
||||
|
||||
enum esr_work_status {
|
||||
ESR_CHECK_FCC_NOLIMIT,
|
||||
ESR_CHECK_FCC_LIMITED,
|
||||
};
|
||||
#endif
|
||||
|
||||
#define REPORT_SOC_DECIMAL_MS 100
|
||||
|
||||
#define RECHARGE_SOC_THR 99
|
||||
|
||||
/* cutoff voltage threshold */
|
||||
#define CUTOFF_VOL_THR 3400000
|
||||
#define CUTOFF_VOL_HYS 50000
|
||||
|
||||
/* wdog bark timer */
|
||||
#define BARK_TIMER_LONG 128
|
||||
#define BARK_TIMER_NORMAL 16
|
||||
|
||||
/* notify qcom step charge callback func interval time */
|
||||
#define NOTIFY_STEP_CALLBACK_MS 2000
|
||||
|
||||
/* wireless thermal related */
|
||||
#define ADAPTER_NONE 0x00
|
||||
#define ADAPTER_SDP 0x01
|
||||
#define ADAPTER_CDP 0x02
|
||||
#define ADAPTER_DCP 0x03
|
||||
#define ADAPTER_QC2 0x05
|
||||
#define ADAPTER_QC3 0x06
|
||||
#define ADAPTER_PD 0x07
|
||||
#define ADAPTER_AUTH_FAILED 0x08
|
||||
#define ADAPTER_XIAOMI_QC3 0x09
|
||||
#define ADAPTER_XIAOMI_PD 0x0a
|
||||
#define ADAPTER_ZIMI_CAR_POWER 0x0b
|
||||
#define ADAPTER_XIAOMI_PD_40W 0x0c
|
||||
#define ADAPTER_XIAOMI_PD_50W 0x0e
|
||||
#define ADAPTER_XIAOMI_PD_60W 0x0f
|
||||
#define ADAPTER_VOICE_BOX 0x0d
|
||||
|
||||
/* defined for charger type recheck */
|
||||
#define CHARGER_RECHECK_DELAY_MS 30000
|
||||
#define TYPE_RECHECK_TIME_5S 5000
|
||||
#define TYPE_RECHECK_COUNT 3
|
||||
|
||||
/* define for reverse state of wireless charging */
|
||||
#define REVERSE_GPIO_STATE_UNSET 0
|
||||
#define REVERSE_GPIO_STATE_START 1
|
||||
#define REVERSE_GPIO_STATE_END 2
|
||||
|
||||
enum hvdcp3_type {
|
||||
HVDCP3_NONE = 0,
|
||||
HVDCP3_CLASSA_18W,
|
||||
HVDCP3_CLASSB_27W,
|
||||
HVDCP3P5_CLASSA_18W,
|
||||
HVDCP3P5_CLASSB_27W,
|
||||
};
|
||||
|
||||
enum quick_charge_type {
|
||||
QUICK_CHARGE_NORMAL = 0,
|
||||
QUICK_CHARGE_FAST,
|
||||
QUICK_CHARGE_FLASH,
|
||||
QUICK_CHARGE_TURBE,
|
||||
QUICK_CHARGE_MAX,
|
||||
};
|
||||
|
||||
struct quick_charge {
|
||||
enum power_supply_type adap_type;
|
||||
enum quick_charge_type adap_cap;
|
||||
};
|
||||
#endif
|
||||
|
||||
enum smb_mode {
|
||||
PARALLEL_MASTER = 0,
|
||||
PARALLEL_SLAVE,
|
||||
@@ -295,11 +479,23 @@ enum icl_override_mode {
|
||||
SW_OVERRIDE_USB51_MODE,
|
||||
/* ICL other than USB51 */
|
||||
SW_OVERRIDE_HC_MODE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
/* add NO CC MODE*/
|
||||
SW_OVERRIDE_NO_CC_MODE,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* EXTCON_USB and EXTCON_USB_HOST are mutually exclusive */
|
||||
static const u32 smblib_extcon_exclusive[] = {0x3, 0};
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
/* six pin battery data struct */
|
||||
struct six_pin_step_data {
|
||||
u32 vfloat_step_uv;
|
||||
u32 fcc_step_ua;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct smb_regulator {
|
||||
struct regulator_dev *rdev;
|
||||
struct regulator_desc rdesc;
|
||||
@@ -385,8 +581,14 @@ struct smb_charger {
|
||||
struct smb_chg_freq chg_freq;
|
||||
int otg_delay_ms;
|
||||
int weak_chg_icl_ua;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int thermal_fcc_override;
|
||||
#endif
|
||||
u32 sdam_base;
|
||||
bool pd_not_supported;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool batt_verified;
|
||||
#endif
|
||||
|
||||
/* locks */
|
||||
struct mutex smb_lock;
|
||||
@@ -403,11 +605,29 @@ struct smb_charger {
|
||||
struct power_supply *usb_psy;
|
||||
struct power_supply *dc_psy;
|
||||
struct power_supply *bms_psy;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct power_supply *bbc_psy;
|
||||
struct power_supply_desc usb_psy_desc;
|
||||
#endif
|
||||
struct power_supply *usb_main_psy;
|
||||
struct power_supply *usb_port_psy;
|
||||
struct power_supply *wls_psy;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct power_supply *idtp_psy;
|
||||
struct power_supply *wireless_psy;
|
||||
struct power_supply *wls_chip_psy;
|
||||
struct power_supply *wip_psy;
|
||||
struct power_supply *ln_psy;
|
||||
struct power_supply *cp_chip_psy;
|
||||
#endif
|
||||
struct power_supply *cp_psy;
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
struct power_supply *batt_verify_psy;
|
||||
#endif
|
||||
enum power_supply_type real_charger_type;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
enum power_supply_type wireless_charger_type;
|
||||
#endif
|
||||
|
||||
/* notifiers */
|
||||
struct notifier_block nb;
|
||||
@@ -430,6 +650,12 @@ struct smb_charger {
|
||||
struct typec_partner *typec_partner;
|
||||
struct typec_partner_desc typec_partner_desc;
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct pinctrl *smb5_pinctrl;
|
||||
struct pinctrl_state *smb5_gpio_active;
|
||||
struct pinctrl_state *smb5_gpio_suspend;
|
||||
#endif
|
||||
|
||||
/* votables */
|
||||
struct votable *dc_suspend_votable;
|
||||
struct votable *fcc_votable;
|
||||
@@ -450,6 +676,9 @@ struct smb_charger {
|
||||
struct votable *qnovo_disable_votable;
|
||||
|
||||
/* work */
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct work_struct batt_update_work;
|
||||
#endif
|
||||
struct work_struct bms_update_work;
|
||||
struct work_struct pl_update_work;
|
||||
struct work_struct jeita_update_work;
|
||||
@@ -457,9 +686,17 @@ struct smb_charger {
|
||||
struct work_struct chg_termination_work;
|
||||
struct work_struct dcin_aicl_work;
|
||||
struct work_struct cp_status_change_work;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct work_struct batt_verify_update_work;
|
||||
struct work_struct plugin_check_time_work;
|
||||
struct delayed_work fake_plug_out_check_work;
|
||||
#endif
|
||||
struct delayed_work ps_change_timeout_work;
|
||||
struct delayed_work clear_hdc_work;
|
||||
struct delayed_work icl_change_work;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct delayed_work dc_power_work;
|
||||
#endif
|
||||
struct delayed_work pl_enable_work;
|
||||
struct delayed_work uusb_otg_work;
|
||||
struct delayed_work bb_removal_work;
|
||||
@@ -467,9 +704,33 @@ struct smb_charger {
|
||||
struct delayed_work lpd_detach_work;
|
||||
struct delayed_work thermal_regulation_work;
|
||||
struct delayed_work usbov_dbc_work;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct delayed_work six_pin_batt_step_chg_work;
|
||||
#endif
|
||||
struct delayed_work pr_swap_detach_work;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct delayed_work reg_work;
|
||||
struct delayed_work thermal_setting_work;
|
||||
#ifndef CONFIG_FUEL_GAUGE_BQ27Z561
|
||||
struct delayed_work reduce_fcc_work;
|
||||
#endif
|
||||
struct delayed_work charger_type_recheck;
|
||||
struct delayed_work raise_qc3_vbus_work;
|
||||
#endif
|
||||
struct delayed_work pr_lock_clear_work;
|
||||
struct delayed_work role_reversal_check;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct delayed_work conn_therm_work;
|
||||
struct delayed_work after_ffc_chg_dis_work;
|
||||
struct delayed_work after_ffc_chg_en_work;
|
||||
struct delayed_work dc_plug_out_delay_work;
|
||||
struct delayed_work wireless_full_delay_work;
|
||||
struct delayed_work report_soc_decimal_work;
|
||||
struct delayed_work step_charge_notify_work;
|
||||
struct delayed_work cc_un_compliant_charge_work;
|
||||
struct delayed_work clean_cp_to_sw_work;
|
||||
struct delayed_work check_init_boot;
|
||||
#endif
|
||||
|
||||
struct alarm lpd_recheck_timer;
|
||||
struct alarm moisture_protection_alarm;
|
||||
@@ -490,10 +751,16 @@ struct smb_charger {
|
||||
int voltage_min_uv;
|
||||
int voltage_max_uv;
|
||||
int pd_active;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int apdo_max;
|
||||
#endif
|
||||
bool pd_hard_reset;
|
||||
bool pr_lock_in_progress;
|
||||
bool pr_swap_in_progress;
|
||||
bool early_usb_attach;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool early_dc_attach;
|
||||
#endif
|
||||
bool ok_to_pd;
|
||||
bool typec_legacy;
|
||||
bool typec_irq_en;
|
||||
@@ -504,6 +771,26 @@ struct smb_charger {
|
||||
int boost_threshold_ua;
|
||||
int system_temp_level;
|
||||
int thermal_levels;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int dc_temp_level;
|
||||
int dc_thermal_levels;
|
||||
int pps_thermal_level;
|
||||
int *thermal_mitigation_dcp;
|
||||
int *thermal_mitigation_qc2;
|
||||
int *thermal_mitigation_pd_base;
|
||||
int *thermal_mitigation_icl;
|
||||
int *thermal_fcc_qc3_normal;
|
||||
int *thermal_fcc_qc3_cp;
|
||||
int *thermal_fcc_qc3_classb_cp;
|
||||
int *thermal_fcc_pps_cp;
|
||||
int *thermal_mitigation_dc;
|
||||
int *thermal_mitigation_voice;
|
||||
int *thermal_mitigation_epp;
|
||||
int *thermal_mitigation_bpp_qc3;
|
||||
int *thermal_mitigation_bpp_qc2;
|
||||
int *thermal_mitigation_bpp;
|
||||
int *thermal_mitigation_dc_20W;
|
||||
#endif
|
||||
int *thermal_mitigation;
|
||||
int dcp_icl_ua;
|
||||
int fake_capacity;
|
||||
@@ -531,8 +818,14 @@ struct smb_charger {
|
||||
bool use_extcon;
|
||||
bool otg_present;
|
||||
bool hvdcp_disable;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool fake_hvdcp3;
|
||||
#endif
|
||||
int hw_max_icl_ua;
|
||||
int auto_recharge_soc;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int auto_recharge_vbat;
|
||||
#endif
|
||||
enum sink_src_mode sink_src_mode;
|
||||
enum power_supply_typec_power_role power_role;
|
||||
enum jeita_cfg_stat jeita_configured;
|
||||
@@ -573,8 +866,14 @@ struct smb_charger {
|
||||
int term_vbat_uv;
|
||||
int usbin_forced_max_uv;
|
||||
int init_thermal_ua;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int pd_verifed;
|
||||
#endif
|
||||
u32 comp_clamp_level;
|
||||
int wls_icl_ua;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int capacity;
|
||||
#endif
|
||||
int cutoff_count;
|
||||
bool dcin_aicl_done;
|
||||
bool hvdcp3_standalone_config;
|
||||
@@ -589,6 +888,13 @@ struct smb_charger {
|
||||
int qc2_max_pulses;
|
||||
enum qc2_non_comp_voltage qc2_unsupported_voltage;
|
||||
bool dbc_usbov;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool qc2_unsupported;
|
||||
bool no_raise_vbus_status;
|
||||
bool vbus_rising;
|
||||
bool fake_plug_out;
|
||||
bool cp_to_sw_status;
|
||||
#endif
|
||||
|
||||
/* extcon for VBUS / ID notification to USB for uUSB */
|
||||
struct extcon_dev *extcon;
|
||||
@@ -596,6 +902,9 @@ struct smb_charger {
|
||||
/* battery profile */
|
||||
int batt_profile_fcc_ua;
|
||||
int batt_profile_fv_uv;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int non_fcc_batt_profile_fv_uv;
|
||||
#endif
|
||||
|
||||
int usb_icl_delta_ua;
|
||||
int pulse_cnt;
|
||||
@@ -612,9 +921,111 @@ struct smb_charger {
|
||||
u32 irq_status;
|
||||
|
||||
/* wireless */
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int flag_dc_present;
|
||||
int power_good_en;
|
||||
int fake_dc_on;
|
||||
int fake_dc_flag;
|
||||
bool en_bq_flag;
|
||||
int64_t rpp;
|
||||
int64_t cep;
|
||||
int64_t tx_bt_mac;
|
||||
int64_t oob_rpp_msg_cnt;
|
||||
int64_t oob_cep_msg_cnt;
|
||||
int reverse_chg_state;
|
||||
int reverse_gpio_state;
|
||||
|
||||
/* product related */
|
||||
bool support_wireless;
|
||||
bool wireless_bq;
|
||||
bool fake_usb_insertion;
|
||||
/* external gpios for charging and wireless charging ctrl */
|
||||
unsigned int ncp3902_en_gpio;
|
||||
unsigned int ncp3902_pass_en_gpio;
|
||||
/* wireless direct charging related */
|
||||
unsigned int dc_chg_gpio;
|
||||
unsigned int bq_en_gpio;
|
||||
unsigned int rx_hw_sleep_gpio;
|
||||
/* used for bq charge pump solution */
|
||||
struct usbpd *pd;
|
||||
bool use_bq_pump;
|
||||
bool ext_fg;
|
||||
bool ext_bbc;
|
||||
/* used for 6pin new battery step charge */
|
||||
bool six_pin_step_charge_enable;
|
||||
bool init_start_vbat_checked;
|
||||
struct six_pin_step_data six_pin_step_cfg[MAX_STEP_ENTRIES];
|
||||
u32 start_step_vbat;
|
||||
int trigger_taper_count;
|
||||
int index_vfloat;
|
||||
int step_soc_threshold;
|
||||
|
||||
int chg_warm_threshold;
|
||||
int chg_cool_threshold;
|
||||
#endif
|
||||
int dcin_uv_count;
|
||||
ktime_t dcin_uv_last_time;
|
||||
int last_wls_vout;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int fake_conn_temp;
|
||||
u64 entry_time;
|
||||
int entry_connector_therm;
|
||||
#ifndef CONFIG_FUEL_GAUGE_BQ27Z561
|
||||
/* reduce fcc for esr cal*/
|
||||
int esr_work_status;
|
||||
bool cp_charge_enabled;
|
||||
int charge_type;
|
||||
int charge_status;
|
||||
int batt_health;
|
||||
#endif
|
||||
/* charger type recheck */
|
||||
int recheck_charger;
|
||||
int precheck_charger_type;
|
||||
int chg_term_current_thresh_hi_from_dts;
|
||||
/* raise qc3 vbus flag */
|
||||
bool qc_class_ab;
|
||||
bool is_qc_class_a;
|
||||
bool is_qc_class_b;
|
||||
bool raise_vbus_to_detect;
|
||||
bool detect_low_power_qc3_charger;
|
||||
bool high_vbus_detected;
|
||||
bool support_ffc;
|
||||
bool qc3_raise_done;
|
||||
/* workarounds */
|
||||
bool support_conn_therm;
|
||||
int conn_detect_count;
|
||||
int vbus_disable_gpio;
|
||||
int vbus_disable;
|
||||
u64 last_ffc_remove_time;
|
||||
u64 after_raise_vbus_time;
|
||||
u64 plugin_attach_check_time;
|
||||
u64 plugin_detch_check_time;
|
||||
|
||||
bool warm_fake_charging;
|
||||
bool health_not_good;
|
||||
bool hvdcp_recheck_status;
|
||||
|
||||
/* QC3P5 related */
|
||||
bool qc3p5_supported;
|
||||
bool qc3p5_auth_complete;
|
||||
bool qc3p5_authenticated;
|
||||
bool qc3p5_authentication_started;
|
||||
bool qc3p5_dp_tune_rapidly;
|
||||
int qc3p5_power_limit_w;
|
||||
|
||||
/* workarounds */
|
||||
bool snk_debug_acc_detected;
|
||||
bool cc_un_compliant_detected;
|
||||
bool report_input_absent;
|
||||
bool batt_temp_irq_enabled;
|
||||
bool vbat_critical_low_triggered;
|
||||
|
||||
int support_second_ffc_term_current_diff;
|
||||
bool support_second_ffc_term_current;
|
||||
bool flag_second_ffc_term_current;
|
||||
|
||||
int night_chg_flag;
|
||||
#endif
|
||||
};
|
||||
|
||||
int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
|
||||
@@ -666,6 +1077,9 @@ irqreturn_t typec_state_change_irq_handler(int irq, void *data);
|
||||
irqreturn_t typec_attach_detach_irq_handler(int irq, void *data);
|
||||
irqreturn_t dcin_uv_irq_handler(int irq, void *data);
|
||||
irqreturn_t dc_plugin_irq_handler(int irq, void *data);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
irqreturn_t dc_power_on_irq_handler(int irq, void *data);
|
||||
#endif
|
||||
irqreturn_t high_duty_cycle_irq_handler(int irq, void *data);
|
||||
irqreturn_t switcher_power_ok_irq_handler(int irq, void *data);
|
||||
irqreturn_t wdog_snarl_irq_handler(int irq, void *data);
|
||||
@@ -676,10 +1090,18 @@ irqreturn_t usbin_ov_irq_handler(int irq, void *data);
|
||||
irqreturn_t sdam_sts_change_irq_handler(int irq, void *data);
|
||||
int smblib_get_prop_input_suspend(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_get_prop_battery_input_suspend(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#endif
|
||||
int smblib_get_prop_batt_present(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_get_prop_batt_capacity(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_get_prop_batt_capacity_level(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#endif
|
||||
int smblib_get_prop_batt_status(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_get_prop_batt_charge_type(struct smb_charger *chg,
|
||||
@@ -700,6 +1122,10 @@ int smblib_get_prop_batt_iterm(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_prop_input_suspend(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_set_prop_battery_input_suspend(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
#endif
|
||||
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_batt_status(struct smb_charger *chg,
|
||||
@@ -725,6 +1151,10 @@ int smblib_get_prop_voltage_wls_output(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_prop_voltage_wls_output(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_get_prop_wireless_version(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#endif
|
||||
int smblib_set_prop_dc_reset(struct smb_charger *chg);
|
||||
int smblib_get_prop_usb_present(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
@@ -775,6 +1205,9 @@ int smblib_get_prop_input_current_max(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_prop_thermal_overheat(struct smb_charger *chg,
|
||||
int therm_overheat);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_get_prop_connector_temp(struct smb_charger *chg);
|
||||
#endif
|
||||
int smblib_get_skin_temp_status(struct smb_charger *chg);
|
||||
int smblib_get_prop_vph_voltage_now(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
@@ -798,6 +1231,10 @@ int smblib_set_prop_ship_mode(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_rechg_soc_thresh(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_set_prop_rechg_vbat_thresh(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
#endif
|
||||
void smblib_suspend_on_debug_battery(struct smb_charger *chg);
|
||||
int smblib_rerun_apsd_if_required(struct smb_charger *chg);
|
||||
void smblib_rerun_apsd(struct smb_charger *chg);
|
||||
@@ -819,6 +1256,49 @@ int smblib_typec_port_type_set(const struct typec_capability *cap,
|
||||
int smblib_get_prop_from_bms(struct smb_charger *chg,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_set_prop_wireless_wakelock(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
|
||||
int smblib_set_wirless_cp_enable(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_wirless_power_good_enable(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_sw_disable_dc_en(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_tx_mac(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_rx_cr(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_bt_state(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_input_current_max(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_get_prop_wireless_version(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_prop_dc_temp_level(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_get_prop_dc_temp_level(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_prop_tx_mac(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_rx_cr(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_rx_cep(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_bt_state(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
|
||||
int smblib_set_sw_disable_dc_en(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
|
||||
int smblib_set_prop_typec_boost_otg_disable(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_prop_battery_charging_enabled(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_set_vbus_disable(struct smb_charger *chg,
|
||||
bool disable);
|
||||
#endif
|
||||
int smblib_get_iio_channel(struct smb_charger *chg, const char *propname,
|
||||
struct iio_channel **chan);
|
||||
int smblib_read_iio_channel(struct smb_charger *chg, struct iio_channel *chan,
|
||||
@@ -835,8 +1315,29 @@ void smblib_apsd_enable(struct smb_charger *chg, bool enable);
|
||||
int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val);
|
||||
int smblib_get_irq_status(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_set_prop_type_recheck(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
int smblib_get_prop_type_recheck(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_night_charging_func(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_get_quick_charge_type(struct smb_charger *chg);
|
||||
#endif
|
||||
int smblib_get_qc3_main_icl_offset(struct smb_charger *chg, int *offset_ua);
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_dp_dm_bq(struct smb_charger *chg, int val);
|
||||
int smblib_get_prop_battery_charging_enabled(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_set_fastcharge_mode(struct smb_charger *chg, bool enable);
|
||||
int smblib_get_fastcharge_mode(struct smb_charger *chg);
|
||||
struct usbpd *smb_get_usbpd(void);
|
||||
#endif
|
||||
int smblib_init(struct smb_charger *chg);
|
||||
int smblib_deinit(struct smb_charger *chg);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int smblib_get_prop_wireless_fw_version(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
#endif
|
||||
#endif /* __SMB5_CHARGER_H */
|
||||
|
||||
@@ -275,6 +275,13 @@ enum {
|
||||
HVDCP_PULSE_COUNT_MAX_QC2_INVALID = 0xC0
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define USBIN_ADAPTER_ALLOW_CFG_REG (USBIN_BASE + 0x60)
|
||||
#define USBIN_ADAPTER_ALLOW_MASK GENMASK(3, 0)
|
||||
#define USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V 0x07
|
||||
#define USBIN_ADAPTER_ALLOW_5V_TO_12V 0x0c
|
||||
#endif
|
||||
|
||||
#define USBIN_OPTIONS_1_CFG_REG (USBIN_BASE + 0x62)
|
||||
#define HVDCP_AUTH_ALG_EN_CFG_BIT BIT(6)
|
||||
#define HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT BIT(5)
|
||||
@@ -317,12 +324,24 @@ enum {
|
||||
|
||||
/* DCIN Interrupt Bits */
|
||||
#define DCIN_PLUGIN_RT_STS_BIT BIT(4)
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define DCIN_PON_RT_STS_BIT BIT(6)
|
||||
#endif
|
||||
|
||||
#define DCIN_CMD_IL_REG (DCIN_BASE + 0x40)
|
||||
#define DCIN_SUSPEND_BIT BIT(0)
|
||||
#define DCIN_EN_OVERRIDE_BIT BIT(1)
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define DCIN_EN_BIT BIT(2)
|
||||
#endif
|
||||
#define DCIN_EN_MASK GENMASK(2, 1)
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define DCIN_CMD_PULLDOWN_REG (DCIN_BASE + 0x45)
|
||||
#define DCIN_PULLDOWN_EN_BIT BIT(0)
|
||||
#define DCIN_MID_PULLDOWN_BIT BIT(1)
|
||||
#endif
|
||||
|
||||
#define DCIN_CMD_PON_REG (DCIN_BASE + 0x45)
|
||||
#define DCIN_PON_BIT BIT(0)
|
||||
#define MID_CHG_BIT BIT(1)
|
||||
@@ -344,6 +363,11 @@ enum {
|
||||
#define SNK_RP_3P0_BIT BIT(1)
|
||||
#define SNK_RP_SHORT_BIT BIT(0)
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define TYPE_C_SNK_DEBUG_ACC_STATUS_REG (TYPEC_BASE + 0x07)
|
||||
#define SNK_DEBUG_ACC_RPSTD_PRSTD_BIT BIT(0)
|
||||
#endif
|
||||
|
||||
#define TYPE_C_SRC_STATUS_REG (TYPEC_BASE + 0x08)
|
||||
#define DETECTED_SNK_TYPE_MASK GENMASK(4, 0)
|
||||
#define SRC_HIGH_BATT_BIT BIT(5)
|
||||
@@ -355,6 +379,9 @@ enum {
|
||||
|
||||
#define TYPE_C_STATE_MACHINE_STATUS_REG (TYPEC_BASE + 0x09)
|
||||
#define TYPEC_ATTACH_DETACH_STATE_BIT BIT(5)
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define TYPEC_ATTACHWAIT_SRC 0x05
|
||||
#endif
|
||||
|
||||
#define TYPE_C_MISC_STATUS_REG (TYPEC_BASE + 0x0B)
|
||||
#define TYPEC_WATER_DETECTION_STATUS_BIT BIT(7)
|
||||
@@ -376,6 +403,12 @@ enum {
|
||||
#define U_USB_FMB2_BIT BIT(1)
|
||||
#define U_USB_FLOAT2_BIT BIT(0)
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define TYPE_C_DEBUG_ACC_SNK_CFG (TYPEC_BASE + 0x4A)
|
||||
#define TYPEC_DEBUG_ACC_SNK_SEL_ICL BIT(2)
|
||||
#define TYPEC_DEBUG_ACC_SNK_DIS_AICL BIT(3)
|
||||
#endif
|
||||
|
||||
#define TYPE_C_MODE_CFG_REG (TYPEC_BASE + 0x44)
|
||||
#define TYPEC_TRY_MODE_MASK GENMASK(4, 3)
|
||||
#define EN_TRY_SNK_BIT BIT(4)
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "step-chg-jeita.h"
|
||||
|
||||
#define STEP_CHG_VOTER "STEP_CHG_VOTER"
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define STEP_BMS_CHG_VOTER "STEP_BMS_CHG_VOTER"
|
||||
#endif
|
||||
#define JEITA_VOTER "JEITA_VOTER"
|
||||
|
||||
#define is_between(left, right, value) \
|
||||
@@ -38,6 +41,13 @@ struct jeita_fv_cfg {
|
||||
struct range_data fv_cfg[MAX_STEP_CHG_ENTRIES];
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct cold_step_chg_cfg {
|
||||
struct step_chg_jeita_param param;
|
||||
struct range_data fcc_cfg[MAX_COLD_STEP_CHG_ENTRIES];
|
||||
};
|
||||
#endif
|
||||
|
||||
struct step_chg_info {
|
||||
struct device *dev;
|
||||
ktime_t step_last_update_time;
|
||||
@@ -48,28 +58,57 @@ struct step_chg_info {
|
||||
bool config_is_read;
|
||||
bool step_chg_cfg_valid;
|
||||
bool sw_jeita_cfg_valid;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool cold_step_chg_cfg_valid;
|
||||
#endif
|
||||
bool soc_based_step_chg;
|
||||
bool ocv_based_step_chg;
|
||||
bool vbat_avg_based_step_chg;
|
||||
bool batt_missing;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool use_bq_pump;
|
||||
bool use_bq_gauge;
|
||||
#endif
|
||||
bool taper_fcc;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
bool six_pin_battery;
|
||||
#endif
|
||||
int jeita_fcc_index;
|
||||
int jeita_fv_index;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int jeita_cold_fcc_index;
|
||||
#endif
|
||||
int step_index;
|
||||
int get_config_retry_count;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int jeita_hot_th;
|
||||
int jeita_cold_th;
|
||||
int jeita_cool_th;
|
||||
int jeita_warm_th;
|
||||
#endif
|
||||
|
||||
struct step_chg_cfg *step_chg_config;
|
||||
struct jeita_fcc_cfg *jeita_fcc_config;
|
||||
struct jeita_fv_cfg *jeita_fv_config;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct cold_step_chg_cfg *cold_step_chg_config;
|
||||
#endif
|
||||
|
||||
struct votable *fcc_votable;
|
||||
struct votable *fv_votable;
|
||||
struct votable *usb_icl_votable;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct votable *chg_disable_votable;
|
||||
struct votable *cp_disable_votable;
|
||||
#endif
|
||||
struct wakeup_source *step_chg_ws;
|
||||
struct power_supply *batt_psy;
|
||||
struct power_supply *bms_psy;
|
||||
struct power_supply *usb_psy;
|
||||
struct power_supply *dc_psy;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
struct power_supply *wls_psy;
|
||||
#endif
|
||||
struct delayed_work status_change_work;
|
||||
struct delayed_work get_config_work;
|
||||
struct notifier_block nb;
|
||||
@@ -150,6 +189,22 @@ static bool is_input_present(struct step_chg_info *chip)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
static bool is_dc_wls_available(struct step_chg_info *chip)
|
||||
{
|
||||
if (!chip->dc_psy)
|
||||
chip->dc_psy = power_supply_get_by_name("dc");
|
||||
|
||||
if (!chip->wls_psy)
|
||||
chip->wls_psy = power_supply_get_by_name("wireless");
|
||||
|
||||
if (!chip->dc_psy || !chip->wls_psy)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
int read_range_data_from_node(struct device_node *node,
|
||||
const char *prop_str, struct range_data *ranges,
|
||||
int max_threshold, u32 max_value)
|
||||
@@ -305,11 +360,23 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip)
|
||||
of_property_read_bool(profile_node, "qcom,ocv-based-step-chg");
|
||||
if (chip->ocv_based_step_chg) {
|
||||
chip->step_chg_config->param.psy_prop =
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW;
|
||||
#else
|
||||
POWER_SUPPLY_PROP_VOLTAGE_OCV;
|
||||
#endif
|
||||
chip->step_chg_config->param.prop_name = "OCV";
|
||||
chip->step_chg_config->param.rise_hys = 0;
|
||||
chip->step_chg_config->param.fall_hys = 0;
|
||||
chip->step_chg_config->param.use_bms = true;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->cold_step_chg_config->param.psy_prop =
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW;
|
||||
chip->cold_step_chg_config->param.prop_name = "OCV";
|
||||
chip->cold_step_chg_config->param.rise_hys = 100000;
|
||||
chip->cold_step_chg_config->param.fall_hys = 100000;
|
||||
chip->cold_step_chg_config->param.use_bms = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
chip->vbat_avg_based_step_chg =
|
||||
@@ -366,6 +433,55 @@ static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip)
|
||||
chip->sw_jeita_cfg_valid = false;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->cold_step_chg_cfg_valid = true;
|
||||
rc = read_range_data_from_node(profile_node,
|
||||
"qcom,cold-step-chg-ranges",
|
||||
chip->cold_step_chg_config->fcc_cfg,
|
||||
max_fv_uv, max_fcc_ma * 1000);
|
||||
if (rc < 0) {
|
||||
pr_debug("Read qcom,jeita-fv-ranges failed from battery profile, rc=%d\n",
|
||||
rc);
|
||||
chip->cold_step_chg_cfg_valid = false;
|
||||
}
|
||||
|
||||
rc = of_property_read_u32(profile_node, "qcom,jeita-too-hot",
|
||||
&chip->jeita_hot_th);
|
||||
if (rc < 0) {
|
||||
pr_err("do not use external fg and set jeita to hot to invaled\n");
|
||||
chip->jeita_hot_th = -EINVAL;
|
||||
}
|
||||
|
||||
rc = of_property_read_u32(profile_node, "qcom,jeita-too-cold",
|
||||
&chip->jeita_cold_th);
|
||||
if (rc < 0) {
|
||||
pr_err("do not use external fg and set jeita too cold to invaled\n");
|
||||
chip->jeita_cold_th = -EINVAL;
|
||||
}
|
||||
|
||||
chip->jeita_warm_th = BATT_WARM_THRESHOLD;
|
||||
rc = of_property_read_u32(profile_node, "qcom,jeita-warm-th",
|
||||
&chip->jeita_warm_th);
|
||||
if (rc < 0) {
|
||||
pr_err("do not use dtsi config and set jeita warm to invaled\n");
|
||||
}
|
||||
|
||||
chip->jeita_cool_th = BATT_COOL_THRESHOLD;
|
||||
rc = of_property_read_u32(profile_node, "qcom,jeita-cool-th",
|
||||
&chip->jeita_cool_th);
|
||||
if (rc < 0) {
|
||||
pr_err("do not use dtsi config and set jeita cool to invaled\n");
|
||||
}
|
||||
chip->use_bq_pump =
|
||||
of_property_read_bool(profile_node, "qcom,use-bq-pump");
|
||||
|
||||
chip->use_bq_gauge =
|
||||
of_property_read_bool(profile_node, "qcom,use-ext-gauge");
|
||||
|
||||
chip->six_pin_battery =
|
||||
of_property_read_bool(profile_node, "mi,six-pin-battery");
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -545,10 +661,30 @@ static int handle_step_chg_config(struct step_chg_info *chip)
|
||||
union power_supply_propval pval = {0, };
|
||||
int rc = 0, fcc_ua = 0, current_index;
|
||||
u64 elapsed_us;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int fv_uv = 0, update_now = 0;
|
||||
static int usb_present;
|
||||
|
||||
if (!is_usb_available(chip))
|
||||
return 0;
|
||||
rc = power_supply_get_property(chip->usb_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Get battery present status failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
if (pval.intval && pval.intval != usb_present)
|
||||
update_now = true;
|
||||
usb_present = pval.intval;
|
||||
#endif
|
||||
|
||||
elapsed_us = ktime_us_delta(ktime_get(), chip->step_last_update_time);
|
||||
/* skip processing, event too early */
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US && !update_now)
|
||||
#else
|
||||
if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US)
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
@@ -617,17 +753,112 @@ static int handle_step_chg_config(struct step_chg_info *chip)
|
||||
get_client_vote(chip->fcc_votable, STEP_CHG_VOTER),
|
||||
chip->taper_fcc);
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
/*bq27z561 get voltage max and current max*/
|
||||
if (chip->use_bq_gauge) {
|
||||
rc = power_supply_get_property(chip->bms_psy,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval);
|
||||
if (rc >= 0 && chip->fv_votable && pval.intval > 0)
|
||||
vote(chip->fv_votable, STEP_BMS_CHG_VOTER, true, pval.intval);
|
||||
fv_uv = pval.intval;
|
||||
|
||||
rc = power_supply_get_property(chip->bms_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_MAX, &pval);
|
||||
if (rc >= 0 && chip->fcc_votable && pval.intval > 0)
|
||||
vote(chip->fcc_votable, STEP_BMS_CHG_VOTER, false, pval.intval);
|
||||
fcc_ua = pval.intval;
|
||||
|
||||
pr_info("bms step charge fcc:%d fv:%d\n", fcc_ua, fv_uv);
|
||||
}
|
||||
#endif
|
||||
|
||||
update_time:
|
||||
chip->step_last_update_time = ktime_get();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
static int handle_fast_charge(struct step_chg_info *chip, int temp)
|
||||
{
|
||||
union power_supply_propval pval = {0, };
|
||||
static bool fast_mode_dis;
|
||||
int rc, dc_present, is_cp_en;
|
||||
int pd_authen;
|
||||
|
||||
if (is_dc_wls_available(chip)) {
|
||||
rc = power_supply_get_property(chip->dc_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT, &pval);
|
||||
if (rc < 0)
|
||||
pr_err("Couldn't get dc present rc = %d\n", rc);
|
||||
else
|
||||
dc_present = pval.intval;
|
||||
|
||||
rc = power_supply_get_property(chip->wls_psy,
|
||||
POWER_SUPPLY_PROP_WIRELESS_CP_EN, &pval);
|
||||
if (rc < 0)
|
||||
pr_err("Couldn't get cp_en rc = %d\n", rc);
|
||||
else
|
||||
is_cp_en = pval.intval;
|
||||
}
|
||||
|
||||
rc = power_supply_get_property(chip->usb_psy,
|
||||
POWER_SUPPLY_PROP_PD_AUTHENTICATION, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Get fastcharge mode status failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
pd_authen = pval.intval;
|
||||
|
||||
if (pd_authen || (dc_present && is_cp_en)) {
|
||||
if ((temp >= chip->jeita_warm_th || temp <= chip->jeita_cool_th) && !fast_mode_dis) {
|
||||
pr_err("temp:%d disable fastcharge mode\n", temp);
|
||||
pval.intval = false;
|
||||
rc = power_supply_set_property(chip->usb_psy,
|
||||
POWER_SUPPLY_PROP_FASTCHARGE_MODE, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Set fastcharge mode failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
fast_mode_dis = true;
|
||||
} else if ((temp < chip->jeita_warm_th - chip->jeita_fv_config->param.fall_hys) &&
|
||||
(temp > chip->jeita_cool_th + chip->jeita_fv_config->param.rise_hys) && fast_mode_dis) {
|
||||
pr_err("temp:%d enable fastcharge mode\n", temp);
|
||||
pval.intval = true;
|
||||
rc = power_supply_set_property(chip->usb_psy,
|
||||
POWER_SUPPLY_PROP_FASTCHARGE_MODE, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Set fastcharge mode failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
fast_mode_dis = false;
|
||||
}
|
||||
} else {
|
||||
fast_mode_dis = false;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
/* set JEITA_SUSPEND_HYST_UV to 70mV to avoid recharge frequently when jeita warm */
|
||||
#define JEITA_SUSPEND_HYST_UV 120000
|
||||
#define JEITA_HYSTERESIS_TEMP_THRED 150
|
||||
#define JEITA_SIX_PIN_BATT_HYST_UV 100000
|
||||
#define WARM_VFLOAT_UV 4100000
|
||||
#else
|
||||
#define JEITA_SUSPEND_HYST_UV 50000
|
||||
#endif
|
||||
static int handle_jeita(struct step_chg_info *chip)
|
||||
{
|
||||
union power_supply_propval pval = {0, };
|
||||
int rc = 0, fcc_ua = 0, fv_uv = 0;
|
||||
u64 elapsed_us;
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
int temp = 0, volt_now = 0, cold_fcc_ua = 0, update_now = 0;
|
||||
static bool usb_present;
|
||||
int curr_vfloat_uv, curr_vbat_uv;
|
||||
#endif
|
||||
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_SW_JEITA_ENABLED, &pval);
|
||||
@@ -646,9 +877,27 @@ static int handle_jeita(struct step_chg_info *chip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (!is_usb_available(chip))
|
||||
return 0;
|
||||
rc = power_supply_get_property(chip->usb_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Get battery present status failed, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
if (pval.intval && pval.intval != usb_present)
|
||||
update_now = true;
|
||||
usb_present = pval.intval;
|
||||
#endif
|
||||
|
||||
elapsed_us = ktime_us_delta(ktime_get(), chip->jeita_last_update_time);
|
||||
/* skip processing, event too early */
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US && !update_now)
|
||||
#else
|
||||
if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US)
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
if (chip->jeita_fcc_config->param.use_bms)
|
||||
@@ -664,16 +913,99 @@ static int handle_jeita(struct step_chg_info *chip)
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
temp = pval.intval;
|
||||
|
||||
if (chip->cold_step_chg_cfg_valid) {
|
||||
if (chip->cold_step_chg_config->param.use_bms)
|
||||
rc = power_supply_get_property(chip->bms_psy,
|
||||
chip->cold_step_chg_config->param.psy_prop, &pval);
|
||||
else
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
chip->cold_step_chg_config->param.psy_prop, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Couldn't read %s property rc=%d\n",
|
||||
chip->cold_step_chg_config->param.prop_name, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
volt_now = pval.intval;
|
||||
}
|
||||
|
||||
if (!chip->chg_disable_votable)
|
||||
chip->chg_disable_votable = find_votable("CHG_DISABLE");
|
||||
|
||||
if (!chip->cp_disable_votable)
|
||||
chip->cp_disable_votable = find_votable("CP_DISABLE");
|
||||
|
||||
/* qcom charge pump use cp_disable_voter, others do not need */
|
||||
if (!chip->use_bq_pump) {
|
||||
if (!chip->chg_disable_votable || !chip->cp_disable_votable)
|
||||
goto update_time;
|
||||
} else {
|
||||
if (!chip->chg_disable_votable)
|
||||
goto update_time;
|
||||
}
|
||||
|
||||
if(chip->jeita_hot_th >= 0 && chip->jeita_cold_th >= (-100)) {
|
||||
if (temp >= chip->jeita_hot_th ||
|
||||
temp <= chip->jeita_cold_th) {
|
||||
pr_info("sw-jeita: temp is :%d, stop charing\n", temp);
|
||||
vote(chip->chg_disable_votable, JEITA_VOTER, true, 0);
|
||||
} else {
|
||||
vote(chip->chg_disable_votable, JEITA_VOTER, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!chip->use_bq_pump) {
|
||||
if (temp <= chip->jeita_cool_th || temp >= chip->jeita_warm_th) {
|
||||
vote(chip->cp_disable_votable, JEITA_VOTER, true, 0);
|
||||
}
|
||||
else
|
||||
vote(chip->cp_disable_votable, JEITA_VOTER, false, 0);
|
||||
}
|
||||
|
||||
if (temp <= JEITA_HYSTERESIS_TEMP_THRED) {
|
||||
chip->jeita_fv_config->param.rise_hys = 5;
|
||||
chip->jeita_fv_config->param.fall_hys = 5;
|
||||
chip->jeita_fcc_config->param.rise_hys = 5;
|
||||
chip->jeita_fcc_config->param.fall_hys = 5;
|
||||
} else {
|
||||
chip->jeita_fv_config->param.rise_hys = 20;
|
||||
chip->jeita_fv_config->param.fall_hys = 20;
|
||||
chip->jeita_fcc_config->param.rise_hys = 20;
|
||||
chip->jeita_fcc_config->param.fall_hys = 20;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = get_val(chip->jeita_fcc_config->fcc_cfg,
|
||||
chip->jeita_fcc_config->param.rise_hys,
|
||||
chip->jeita_fcc_config->param.fall_hys,
|
||||
chip->jeita_fcc_index,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
temp,
|
||||
#else
|
||||
pval.intval,
|
||||
#endif
|
||||
&chip->jeita_fcc_index,
|
||||
&fcc_ua);
|
||||
if (rc < 0)
|
||||
fcc_ua = 0;
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (chip->cold_step_chg_cfg_valid == true) {
|
||||
rc = get_val(chip->cold_step_chg_config->fcc_cfg,
|
||||
chip->cold_step_chg_config->param.rise_hys,
|
||||
chip->cold_step_chg_config->param.fall_hys,
|
||||
chip->jeita_cold_fcc_index,
|
||||
volt_now,
|
||||
&chip->jeita_cold_fcc_index,
|
||||
&cold_fcc_ua);
|
||||
if (rc < 0)
|
||||
cold_fcc_ua = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!chip->fcc_votable)
|
||||
chip->fcc_votable = find_votable("FCC");
|
||||
if (!chip->fcc_votable)
|
||||
@@ -681,12 +1013,22 @@ static int handle_jeita(struct step_chg_info *chip)
|
||||
return -EINVAL;
|
||||
|
||||
vote(chip->fcc_votable, JEITA_VOTER, fcc_ua ? true : false, fcc_ua);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (chip->cold_step_chg_cfg_valid) {
|
||||
if (chip->jeita_fcc_index == 0 && chip->jeita_cold_fcc_index != 0)
|
||||
vote(chip->fcc_votable, JEITA_VOTER, cold_fcc_ua ? true : false, cold_fcc_ua);
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = get_val(chip->jeita_fv_config->fv_cfg,
|
||||
chip->jeita_fv_config->param.rise_hys,
|
||||
chip->jeita_fv_config->param.fall_hys,
|
||||
chip->jeita_fv_index,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
temp,
|
||||
#else
|
||||
pval.intval,
|
||||
#endif
|
||||
&chip->jeita_fv_index,
|
||||
&fv_uv);
|
||||
if (rc < 0)
|
||||
@@ -702,6 +1044,10 @@ static int handle_jeita(struct step_chg_info *chip)
|
||||
if (!chip->usb_icl_votable)
|
||||
goto set_jeita_fv;
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
handle_fast_charge(chip, temp);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If JEITA float voltage is same as max-vfloat of battery then
|
||||
* skip any further VBAT specific checks.
|
||||
@@ -717,13 +1063,57 @@ static int handle_jeita(struct step_chg_info *chip)
|
||||
* Suspend USB input path if battery voltage is above
|
||||
* JEITA VFLOAT threshold.
|
||||
*/
|
||||
#ifndef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (chip->jeita_arb_en && fv_uv > 0) {
|
||||
#else
|
||||
if (fv_uv > 0) {
|
||||
#endif
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW, &pval);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
if (rc < 0) {
|
||||
pr_err("Get battery voltage failed, rc = %d\n", rc);
|
||||
goto set_jeita_fv;
|
||||
}
|
||||
curr_vbat_uv = pval.intval;
|
||||
|
||||
if (!chip->six_pin_battery) {
|
||||
if ((curr_vbat_uv > fv_uv) && (temp >= chip->jeita_warm_th))
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, true, 0);
|
||||
else if (curr_vbat_uv < (fv_uv - JEITA_SUSPEND_HYST_UV))
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, false, 0);
|
||||
} else {
|
||||
curr_vfloat_uv = get_effective_result(chip->fv_votable);
|
||||
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_CHARGE_TYPE, &pval);
|
||||
if (rc < 0) {
|
||||
pr_err("Get charge type failed, rc = %d\n", rc);
|
||||
goto set_jeita_fv;
|
||||
}
|
||||
|
||||
if (curr_vfloat_uv != WARM_VFLOAT_UV) {
|
||||
if (curr_vbat_uv > fv_uv + JEITA_SIX_PIN_BATT_HYST_UV) {
|
||||
if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER && fv_uv == WARM_VFLOAT_UV)
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, true, 0);
|
||||
} else if (curr_vbat_uv < (fv_uv - JEITA_SUSPEND_HYST_UV)) {
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, false, 0);
|
||||
}
|
||||
} else {
|
||||
if (curr_vbat_uv > fv_uv) {
|
||||
if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER && fv_uv == WARM_VFLOAT_UV)
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, true, 0);
|
||||
} else if (curr_vbat_uv < (fv_uv - JEITA_SUSPEND_HYST_UV)) {
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!rc && (pval.intval > fv_uv))
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, true, 0);
|
||||
else if (pval.intval < (fv_uv - JEITA_SUSPEND_HYST_UV))
|
||||
vote(chip->usb_icl_votable, JEITA_VOTER, false, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
set_jeita_fv:
|
||||
@@ -873,7 +1263,13 @@ int qcom_step_chg_init(struct device *dev,
|
||||
|
||||
chip->step_chg_config = devm_kzalloc(dev,
|
||||
sizeof(struct step_chg_cfg), GFP_KERNEL);
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->cold_step_chg_config = devm_kzalloc(dev,
|
||||
sizeof(struct cold_step_chg_cfg), GFP_KERNEL);
|
||||
if (!chip->step_chg_config || !chip->cold_step_chg_config)
|
||||
#else
|
||||
if (!chip->step_chg_config)
|
||||
#endif
|
||||
return -ENOMEM;
|
||||
|
||||
chip->step_chg_config->param.psy_prop = POWER_SUPPLY_PROP_VOLTAGE_NOW;
|
||||
@@ -881,6 +1277,13 @@ int qcom_step_chg_init(struct device *dev,
|
||||
chip->step_chg_config->param.rise_hys = 100000;
|
||||
chip->step_chg_config->param.fall_hys = 100000;
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->cold_step_chg_config->param.psy_prop = POWER_SUPPLY_PROP_VOLTAGE_NOW;
|
||||
chip->cold_step_chg_config->param.prop_name = "VBATT";
|
||||
chip->cold_step_chg_config->param.rise_hys = 100000;
|
||||
chip->cold_step_chg_config->param.fall_hys = 100000;
|
||||
#endif
|
||||
|
||||
chip->jeita_fcc_config = devm_kzalloc(dev,
|
||||
sizeof(struct jeita_fcc_cfg), GFP_KERNEL);
|
||||
chip->jeita_fv_config = devm_kzalloc(dev,
|
||||
@@ -890,12 +1293,22 @@ int qcom_step_chg_init(struct device *dev,
|
||||
|
||||
chip->jeita_fcc_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP;
|
||||
chip->jeita_fcc_config->param.prop_name = "BATT_TEMP";
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->jeita_fcc_config->param.rise_hys = 20;
|
||||
chip->jeita_fcc_config->param.fall_hys = 20;
|
||||
#else
|
||||
chip->jeita_fcc_config->param.rise_hys = 10;
|
||||
chip->jeita_fcc_config->param.fall_hys = 10;
|
||||
#endif
|
||||
chip->jeita_fv_config->param.psy_prop = POWER_SUPPLY_PROP_TEMP;
|
||||
chip->jeita_fv_config->param.prop_name = "BATT_TEMP";
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
chip->jeita_fv_config->param.rise_hys = 20;
|
||||
chip->jeita_fv_config->param.fall_hys = 20;
|
||||
#else
|
||||
chip->jeita_fv_config->param.rise_hys = 10;
|
||||
chip->jeita_fv_config->param.fall_hys = 10;
|
||||
#endif
|
||||
|
||||
INIT_DELAYED_WORK(&chip->status_change_work, status_change_work);
|
||||
INIT_DELAYED_WORK(&chip->get_config_work, get_config_work);
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
#ifndef __STEP_CHG_H__
|
||||
#define __STEP_CHG_H__
|
||||
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
#define MAX_STEP_CHG_ENTRIES 6
|
||||
#define MAX_COLD_STEP_CHG_ENTRIES 2
|
||||
#define BATT_COOL_THRESHOLD 150
|
||||
#define BATT_WARM_THRESHOLD 450
|
||||
#else
|
||||
#define MAX_STEP_CHG_ENTRIES 8
|
||||
#endif
|
||||
|
||||
struct step_chg_jeita_param {
|
||||
u32 psy_prop;
|
||||
|
||||
@@ -107,6 +107,10 @@ enum {
|
||||
POWER_SUPPLY_DP_DM_FORCE_9V = 14,
|
||||
POWER_SUPPLY_DP_DM_FORCE_12V = 15,
|
||||
POWER_SUPPLY_DP_DM_CONFIRMED_HVDCP3P5 = 16,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_DP_DM_RAISE_VOLT_DONE = 17,
|
||||
POWER_SUPPLY_DP_DM_RAISE_VOLT_START = 18,
|
||||
#endif
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -208,6 +212,13 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
|
||||
POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
|
||||
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_SHUTDOWN_DELAY,
|
||||
POWER_SUPPLY_PROP_SHUTDOWN_DELAY_ENABLE,
|
||||
POWER_SUPPLY_PROP_SOC_DECIMAL,
|
||||
POWER_SUPPLY_PROP_SOC_DECIMAL_RATE,
|
||||
POWER_SUPPLY_PROP_COLD_THERMAL_LEVEL,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_TEMP,
|
||||
POWER_SUPPLY_PROP_TEMP_MAX,
|
||||
POWER_SUPPLY_PROP_TEMP_MIN,
|
||||
@@ -232,6 +243,12 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_CHARGE_ENABLED,
|
||||
POWER_SUPPLY_PROP_SET_SHIP_MODE,
|
||||
POWER_SUPPLY_PROP_REAL_TYPE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_HVDCP3_TYPE,
|
||||
POWER_SUPPLY_PROP_FAKE_HVDCP3,
|
||||
POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
|
||||
POWER_SUPPLY_PROP_QUICK_CHARGE_POWER,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_CHARGE_NOW_RAW,
|
||||
POWER_SUPPLY_PROP_CHARGE_NOW_ERROR,
|
||||
POWER_SUPPLY_PROP_CAPACITY_RAW,
|
||||
@@ -241,7 +258,14 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_STEP_CHARGING_STEP,
|
||||
POWER_SUPPLY_PROP_PIN_ENABLED,
|
||||
POWER_SUPPLY_PROP_INPUT_SUSPEND,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_BATTERY_INPUT_SUSPEND,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_INPUT_VOLTAGE_VRECT,
|
||||
POWER_SUPPLY_PROP_RX_IOUT,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM,
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
|
||||
@@ -266,6 +290,11 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_BOOST_CURRENT,
|
||||
POWER_SUPPLY_PROP_SAFETY_TIMER_ENABLE,
|
||||
POWER_SUPPLY_PROP_CHARGE_DONE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_HIZ_MODE,
|
||||
POWER_SUPPLY_PROP_USB_CURRENT_NOW,
|
||||
POWER_SUPPLY_PROP_USB_VOLTAGE_NOW,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_FLASH_ACTIVE,
|
||||
POWER_SUPPLY_PROP_FLASH_TRIGGER,
|
||||
POWER_SUPPLY_PROP_FORCE_TLIM,
|
||||
@@ -283,11 +312,17 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_TYPEC_MODE,
|
||||
POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION, /* 0: N/C, 1: CC1, 2: CC2 */
|
||||
POWER_SUPPLY_PROP_TYPEC_POWER_ROLE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_TYPEC_BOOST_OTG_DISABLE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_TYPEC_SRC_RP,
|
||||
POWER_SUPPLY_PROP_PD_ALLOWED,
|
||||
POWER_SUPPLY_PROP_PD_ACTIVE,
|
||||
POWER_SUPPLY_PROP_PD_IN_HARD_RESET,
|
||||
POWER_SUPPLY_PROP_PD_CURRENT_MAX,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_APDO_MAX,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_PD_USB_SUSPEND_SUPPORTED,
|
||||
POWER_SUPPLY_PROP_CHARGER_TEMP,
|
||||
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
|
||||
@@ -300,6 +335,11 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_PARALLEL_MODE,
|
||||
POWER_SUPPLY_PROP_DIE_HEALTH,
|
||||
POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_CONNECTOR_TEMP,
|
||||
POWER_SUPPLY_PROP_VBUS_DISABLE,
|
||||
POWER_SUPPLY_PROP_ARTI_VBUS_ENABLE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_CTM_CURRENT_MAX,
|
||||
POWER_SUPPLY_PROP_HW_CURRENT_MAX,
|
||||
POWER_SUPPLY_PROP_PR_SWAP,
|
||||
@@ -309,13 +349,34 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_PD_VOLTAGE_MAX,
|
||||
POWER_SUPPLY_PROP_PD_VOLTAGE_MIN,
|
||||
POWER_SUPPLY_PROP_SDP_CURRENT_MAX,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_DC_THERMAL_LEVELS,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_CONNECTOR_TYPE,
|
||||
POWER_SUPPLY_PROP_PARALLEL_BATFET_MODE,
|
||||
POWER_SUPPLY_PROP_PARALLEL_FCC_MAX,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_WIRELESS_VERSION,
|
||||
POWER_SUPPLY_PROP_WIRELESS_FW_VERSION,
|
||||
POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
|
||||
POWER_SUPPLY_PROP_WIRELESS_CP_EN,
|
||||
POWER_SUPPLY_PROP_WIRELESS_POWER_GOOD_EN,
|
||||
POWER_SUPPLY_PROP_SW_DISABLE_DC_EN,
|
||||
POWER_SUPPLY_PROP_WIRELESS_WAKELOCK,
|
||||
POWER_SUPPLY_PROP_WIRELESS_TX_ID,
|
||||
POWER_SUPPLY_PROP_TX_ADAPTER,
|
||||
POWER_SUPPLY_PROP_TX_MAC,
|
||||
POWER_SUPPLY_PROP_RX_CR,
|
||||
POWER_SUPPLY_PROP_RX_CEP,
|
||||
POWER_SUPPLY_PROP_BT_STATE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_MIN_ICL,
|
||||
POWER_SUPPLY_PROP_MOISTURE_DETECTED,
|
||||
POWER_SUPPLY_PROP_BATT_PROFILE_VERSION,
|
||||
POWER_SUPPLY_PROP_BATT_FULL_CURRENT,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_WARM_FAKE_CHARGING,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_RECHARGE_SOC,
|
||||
POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED,
|
||||
POWER_SUPPLY_PROP_SMB_EN_MODE,
|
||||
@@ -326,7 +387,14 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_CLEAR_SOH,
|
||||
POWER_SUPPLY_PROP_FORCE_RECHARGE,
|
||||
POWER_SUPPLY_PROP_FCC_STEPPER_ENABLE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_SMB_EN_ALLOWED,
|
||||
POWER_SUPPLY_PROP_BATT_2S_MODE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_TOGGLE_STAT,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_TYPE_RECHECK,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_MAIN_FCC_MAX,
|
||||
POWER_SUPPLY_PROP_FG_RESET,
|
||||
POWER_SUPPLY_PROP_QC_OPTI_DISABLE,
|
||||
@@ -343,6 +411,9 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_FORCE_MAIN_FCC,
|
||||
POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL,
|
||||
POWER_SUPPLY_PROP_ADAPTER_CC_MODE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_NON_COMPATIBLE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_SKIN_HEALTH,
|
||||
POWER_SUPPLY_PROP_AICL_DONE,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_STEP,
|
||||
@@ -361,6 +432,68 @@ enum power_supply_property {
|
||||
POWER_SUPPLY_PROP_CP_ILIM,
|
||||
POWER_SUPPLY_PROP_IRQ_STATUS,
|
||||
POWER_SUPPLY_PROP_PARALLEL_OUTPUT_MODE,
|
||||
#ifdef CONFIG_MACH_XIAOMI_SM8250
|
||||
POWER_SUPPLY_PROP_CP_WIN_OV,
|
||||
POWER_SUPPLY_PROP_CP_PASSTHROUGH_MODE,
|
||||
POWER_SUPPLY_PROP_CP_PASSTHROUGH_CONFIG,
|
||||
POWER_SUPPLY_PROP_CP_OVP_CONFIG,
|
||||
POWER_SUPPLY_PROP_CP_OCP_CONFIG,
|
||||
POWER_SUPPLY_PROP_CP_CFLY_SS_STATUS,
|
||||
POWER_SUPPLY_PROP_TI_BATTERY_PRESENT,
|
||||
POWER_SUPPLY_PROP_TI_VBUS_PRESENT,
|
||||
POWER_SUPPLY_PROP_TI_BATTERY_VOLTAGE,
|
||||
POWER_SUPPLY_PROP_TI_BATTERY_CURRENT,
|
||||
POWER_SUPPLY_PROP_TI_BATTERY_TEMPERATURE,
|
||||
POWER_SUPPLY_PROP_TI_BUS_VOLTAGE,
|
||||
POWER_SUPPLY_PROP_TI_BUS_CURRENT,
|
||||
POWER_SUPPLY_PROP_TI_BUS_TEMPERATURE,
|
||||
POWER_SUPPLY_PROP_TI_DIE_TEMPERATURE,
|
||||
POWER_SUPPLY_PROP_TI_ALARM_STATUS,
|
||||
POWER_SUPPLY_PROP_TI_FAULT_STATUS,
|
||||
POWER_SUPPLY_PROP_TI_REG_STATUS,
|
||||
POWER_SUPPLY_PROP_TI_SET_BUS_PROTECTION_FOR_QC3,
|
||||
POWER_SUPPLY_PROP_TI_BUS_ERROR_STATUS,
|
||||
POWER_SUPPLY_PROP_FASTCHARGE_MODE,
|
||||
POWER_SUPPLY_PROP_DP_DM_BQ,
|
||||
POWER_SUPPLY_PROP_PD_AUTHENTICATION,
|
||||
POWER_SUPPLY_PROP_PASSTHROUGH_CURR_MAX,
|
||||
POWER_SUPPLY_PROP_TERMINATION_CURRENT,
|
||||
POWER_SUPPLY_PROP_FFC_TERMINATION_CURRENT,
|
||||
POWER_SUPPLY_PROP_SYS_TERMINATION_CURRENT,
|
||||
POWER_SUPPLY_PROP_FFC_SYS_TERMINATION_CURRENT,
|
||||
POWER_SUPPLY_PROP_VBATT_FULL_VOL,
|
||||
POWER_SUPPLY_PROP_FFC_VBATT_FULL_VOL,
|
||||
POWER_SUPPLY_PROP_KI_COEFF_CURRENT,
|
||||
POWER_SUPPLY_PROP_RECHARGE_VBAT,
|
||||
POWER_SUPPLY_PROP_STEP_VFLOAT_INDEX,
|
||||
POWER_SUPPLY_PROP_NIGHT_CHARGING,
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
/* battery verify properties */
|
||||
POWER_SUPPLY_PROP_ROMID,
|
||||
POWER_SUPPLY_PROP_DS_STATUS,
|
||||
POWER_SUPPLY_PROP_PAGENUMBER,
|
||||
POWER_SUPPLY_PROP_PAGEDATA,
|
||||
POWER_SUPPLY_PROP_AUTHEN_RESULT,
|
||||
POWER_SUPPLY_PROP_SESSION_SEED,
|
||||
POWER_SUPPLY_PROP_S_SECRET,
|
||||
POWER_SUPPLY_PROP_CHALLENGE,
|
||||
POWER_SUPPLY_PROP_AUTH_ANON,
|
||||
POWER_SUPPLY_PROP_AUTH_BDCONST,
|
||||
POWER_SUPPLY_PROP_PAGE0_DATA,
|
||||
POWER_SUPPLY_PROP_PAGE1_DATA,
|
||||
POWER_SUPPLY_PROP_VERIFY_MODEL_NAME,
|
||||
POWER_SUPPLY_PROP_MAXIM_BATT_CYCLE_COUNT,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_CHIP_OK,
|
||||
/* DIV 2 properties */
|
||||
POWER_SUPPLY_PROP_DIV_2_MODE,
|
||||
POWER_SUPPLY_PROP_REVERSE_CHG_MODE,
|
||||
POWER_SUPPLY_PROP_REVERSE_CHG_STATE,
|
||||
POWER_SUPPLY_PROP_REVERSE_GPIO_STATE,
|
||||
POWER_SUPPLY_PROP_RESET_DIV_2_MODE,
|
||||
POWER_SUPPLY_PROP_AICL_ENABLE,
|
||||
POWER_SUPPLY_PROP_OTG_STATE,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_FG_TYPE,
|
||||
POWER_SUPPLY_PROP_CHARGER_STATUS,
|
||||
/* Local extensions of type int64_t */
|
||||
@@ -402,6 +535,9 @@ enum power_supply_type {
|
||||
POWER_SUPPLY_TYPE_UFP, /* Type-C UFP */
|
||||
POWER_SUPPLY_TYPE_DFP, /* Type-C DFP */
|
||||
POWER_SUPPLY_TYPE_CHARGE_PUMP, /* Charge Pump */
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
POWER_SUPPLY_TYPE_BATT_VERIFY, /* battery verify */
|
||||
#endif
|
||||
};
|
||||
|
||||
enum power_supply_usb_type {
|
||||
@@ -456,6 +592,9 @@ union power_supply_propval {
|
||||
int intval;
|
||||
const char *strval;
|
||||
int64_t int64val;
|
||||
#ifdef CONFIG_BATT_VERIFY_BY_DS28E16
|
||||
unsigned char arrayval[50];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct device_node;
|
||||
|
||||
Reference in New Issue
Block a user