Skip to content

Commit

Permalink
Revert Power: Drivers
Browse files Browse the repository at this point in the history
Changes in..
            Fix Charging speed
            Fix Charging disconnected at 46c
            Fix Charging Heat
            Add dynamic-fv-ranges
  • Loading branch information
negrroo committed May 15, 2020
1 parent 29f7d4b commit e8d8f99
Show file tree
Hide file tree
Showing 13 changed files with 395 additions and 30 deletions.
5 changes: 5 additions & 0 deletions arch/arm64/boot/dts/qcom/batterydata-e10-atl-4000mAh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ qcom,e10_atl_4000mah {
101 150 4400000
151 450 4400000
451 600 4100000>;
qcom,dynamic-fv-ranges = <0 100 4400000
101 200 4380000
201 300 4360000
301 400 4340000
401 500 4340000>;
qcom,checksum = <0xA0E7>;
qcom,gui-version = "PMI8998GUI - 2.0.0.58";
qcom,fg-profile-data = [
Expand Down
5 changes: 5 additions & 0 deletions arch/arm64/boot/dts/qcom/batterydata-e10-cos-4000mAh.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ qcom,e10_cos_4000mah {
101 150 4400000
151 450 4400000
451 600 4100000>;
qcom,dynamic-fv-ranges = <0 100 4400000
101 200 4380000
201 300 4360000
301 400 4340000
401 500 4340000>;
qcom,checksum = <0x0920>;
qcom,gui-version = "PMI8998GUI - 2.0.0.58";
qcom,fg-profile-data = [
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/qcom/beryllium-p0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
qcom,fcc-cool-temp-delta = <1960000>;
qcom,auto-recharge-soc;
qcom,sw-jeita-enable;
qcom,dynamic-fv-enable;
qcom,thermal-mitigation
= <1800000 1600000 1400000 1200000 1000000 1000000 1000000>;
qcom,thermal-mitigation-dcp
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/qcom/sdm845-pcie.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@
qcom,vreg-cx-voltage-level = <RPMH_REGULATOR_LEVEL_MAX
RPMH_REGULATOR_LEVEL_NOM 0>;

qcom,l1-supported;
qcom,l1ss-supported;
qcom,aux-clk-sync;

Expand Down
36 changes: 32 additions & 4 deletions drivers/power/reset/msm-poweroff.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -45,19 +45,24 @@
#define SCM_WDOG_DEBUG_BOOT_PART 0x9
#define SCM_DLOAD_FULLDUMP 0X10
#define SCM_EDLOAD_MODE 0X01
#define SCM_EDLOAD_PCI_MODE 0X04
#define SCM_DLOAD_CMD 0x10
#define SCM_DLOAD_MINIDUMP 0X20
#define SCM_DLOAD_BOTHDUMPS (SCM_DLOAD_MINIDUMP | SCM_DLOAD_FULLDUMP)

#define BOOT_CONFIG_SHIFT 3

static int restart_mode;
static void *restart_reason;
static bool scm_pmic_arbiter_disable_supported;
static bool scm_deassert_ps_hold_supported;
/* Download mode master kill-switch */
static void __iomem *msm_ps_hold;
static void __iomem *boot_config;
static phys_addr_t tcsr_boot_misc_detect;
static void scm_disable_sdi(void);
static bool force_warm_reboot;
static bool early_pcie_init_enable;

#ifdef CONFIG_QCOM_DLOAD_MODE
/* Runtime could be only changed value once.
Expand Down Expand Up @@ -186,7 +191,10 @@ static void enable_emergency_dload_mode(void)
mb();
}

ret = scm_set_dload_mode(SCM_EDLOAD_MODE, 0);
if (early_pcie_init_enable)
ret = scm_set_dload_mode(SCM_EDLOAD_PCI_MODE, 0);
else
ret = scm_set_dload_mode(SCM_EDLOAD_MODE, 0);
if (ret)
pr_err("Failed to set secure EDLOAD mode: %d\n", ret);
}
Expand Down Expand Up @@ -288,8 +296,7 @@ static void msm_restart_prepare(const char *cmd)
* Kill download mode if master-kill switch is set
*/

set_dload_mode(download_mode &&
(in_panic || restart_mode == RESTART_DLOAD));
set_dload_mode(false);
#endif

if (qpnp_pon_check_hard_reset_stored()) {
Expand All @@ -303,6 +310,10 @@ static void msm_restart_prepare(const char *cmd)
(cmd != NULL && cmd[0] != '\0'));
}

#ifdef CONFIG_QCOM_PRESERVE_MEM
need_warm_reset = true;
#endif

if (force_warm_reboot)
pr_info("Forcing a warm reset of the system\n");

Expand Down Expand Up @@ -585,6 +596,7 @@ static int msm_restart_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct resource *mem;
struct device_node *np;
uint32_t read_val;
int ret = 0;

#ifdef CONFIG_QCOM_DLOAD_MODE
Expand Down Expand Up @@ -682,6 +694,22 @@ static int msm_restart_probe(struct platform_device *pdev)
if (mem)
tcsr_boot_misc_detect = mem->start;


early_pcie_init_enable = 0;
mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "boot-config");
if (mem) {
boot_config = devm_ioremap_resource(dev, mem);
if (IS_ERR(boot_config)) {
pr_err("unable to ioremap boot config offset\n");
return PTR_ERR(boot_config);
}

read_val = __raw_readl(boot_config);

/* Bit 3 of the BOOT_CONFIG is used as the PCIe_EARLY_INIT_EN */
early_pcie_init_enable = (read_val >> BOOT_CONFIG_SHIFT) & 1;
}

pm_power_off = do_msm_poweroff;
arm_pm_restart = do_msm_restart;

Expand Down
3 changes: 3 additions & 0 deletions drivers/power/supply/power_supply_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,14 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(ctm_current_max),
POWER_SUPPLY_ATTR(hw_current_max),
POWER_SUPPLY_ATTR(real_type),
POWER_SUPPLY_ATTR(hvdcp3_type),
POWER_SUPPLY_ATTR(quick_charge_type),
POWER_SUPPLY_ATTR(dc_adapter),
POWER_SUPPLY_ATTR(pr_swap),
POWER_SUPPLY_ATTR(cc_step),
POWER_SUPPLY_ATTR(cc_step_sel),
POWER_SUPPLY_ATTR(sw_jeita_enabled),
POWER_SUPPLY_ATTR(dynamic_fv_enabled),
POWER_SUPPLY_ATTR(pd_voltage_max),
POWER_SUPPLY_ATTR(pd_voltage_min),
POWER_SUPPLY_ATTR(sdp_current_max),
Expand Down
4 changes: 3 additions & 1 deletion drivers/power/supply/qcom/qpnp-fg-gen3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,9 @@ static int fg_charge_full_update(struct fg_chip *chip)
msoc, bsoc, chip->health, chip->charge_status,
chip->charge_full);
if (chip->charge_done && !chip->charge_full) {
if (msoc >= 99 && chip->health == POWER_SUPPLY_HEALTH_GOOD) {
if (msoc >= 99 && (chip->health == POWER_SUPPLY_HEALTH_GOOD
|| chip->health == POWER_SUPPLY_HEALTH_COOL
|| chip->health == POWER_SUPPLY_HEALTH_WARM)) {
fg_dbg(chip, FG_STATUS, "Setting charge_full to true\n");
chip->charge_full = true;
/*
Expand Down
27 changes: 26 additions & 1 deletion drivers/power/supply/qcom/qpnp-smb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ static int smb2_parse_dt(struct smb2 *chip)
chg->wireless_support = of_property_read_bool(node,
"qcom,wireless-support");

chg->dynamic_fv_enabled = of_property_read_bool(node,
"qcom,dynamic-fv-enable");

rc = of_property_read_u32(node, "qcom,wd-bark-time-secs",
&chip->dt.wd_bark_time);
if (rc < 0 || chip->dt.wd_bark_time < MIN_WD_BARK_TIME)
Expand Down Expand Up @@ -457,11 +460,13 @@ static int smb2_parse_dt(struct smb2 *chip)

rc = of_property_read_u32(node, "qcom,otg-deglitch-time-ms",
&chg->otg_delay_ms);
if (rc < 0)
if (rc < 0) {
chg->otg_delay_ms = OTG_DEFAULT_DEGLITCH_TIME_MS;

rc = of_property_read_u32(node, "qcom,fcc-low-temp-delta",
&chip->dt.jeita_low_cc_delta);
}

if (rc < 0)
chip->dt.jeita_low_cc_delta = DEFAULT_CRITICAL_JEITA_CCOMP;
chg->jeita_ccomp_low_delta = chip->dt.jeita_low_cc_delta;
Expand Down Expand Up @@ -500,6 +505,7 @@ static enum power_supply_property smb2_usb_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_MAX,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
POWER_SUPPLY_PROP_PD_CURRENT_MAX,
POWER_SUPPLY_PROP_CURRENT_MAX,
POWER_SUPPLY_PROP_TYPE,
Expand All @@ -515,6 +521,7 @@ static enum power_supply_property smb2_usb_props[] = {
POWER_SUPPLY_PROP_CTM_CURRENT_MAX,
POWER_SUPPLY_PROP_HW_CURRENT_MAX,
POWER_SUPPLY_PROP_REAL_TYPE,
POWER_SUPPLY_PROP_HVDCP3_TYPE,
POWER_SUPPLY_PROP_PR_SWAP,
POWER_SUPPLY_PROP_PD_VOLTAGE_MAX,
POWER_SUPPLY_PROP_PD_VOLTAGE_MIN,
Expand Down Expand Up @@ -583,6 +590,15 @@ static int smb2_usb_get_prop(struct power_supply *psy,
else
val->intval = chg->real_charger_type;
break;
case POWER_SUPPLY_PROP_HVDCP3_TYPE:
if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3)
val->intval = HVDCP3_CLASSA_18W;
else
val->intval = HVDCP3_NONE;
break;
case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
val->intval = smblib_get_quick_charge_type(chg);
break;
case POWER_SUPPLY_PROP_TYPEC_MODE:
if (chg->connector_type == POWER_SUPPLY_CONNECTOR_MICRO_USB)
val->intval = POWER_SUPPLY_TYPEC_NONE;
Expand Down Expand Up @@ -1314,6 +1330,7 @@ static enum power_supply_property smb2_batt_props[] = {
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED,
POWER_SUPPLY_PROP_SW_JEITA_ENABLED,
POWER_SUPPLY_PROP_DYNAMIC_FV_ENABLED,
POWER_SUPPLY_PROP_CHARGE_DONE,
POWER_SUPPLY_PROP_PARALLEL_DISABLE,
POWER_SUPPLY_PROP_SET_SHIP_MODE,
Expand Down Expand Up @@ -1388,6 +1405,9 @@ static int smb2_batt_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_SW_JEITA_ENABLED:
val->intval = chg->sw_jeita_enabled;
break;
case POWER_SUPPLY_PROP_DYNAMIC_FV_ENABLED:
val->intval = chg->dynamic_fv_enabled;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
val->intval = get_client_vote(chg->fv_votable,
BATT_PROFILE_VOTER);
Expand Down Expand Up @@ -1527,6 +1547,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
chg->sw_jeita_enabled = !!val->intval;
}
break;
case POWER_SUPPLY_PROP_DYNAMIC_FV_ENABLED:
chg->dynamic_fv_enabled = !!val->intval;
break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
chg->batt_profile_fcc_ua = val->intval;
vote(chg->fcc_votable, BATT_PROFILE_VOTER, true, val->intval);
Expand Down Expand Up @@ -1582,6 +1605,8 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
case POWER_SUPPLY_PROP_SW_JEITA_ENABLED:
case POWER_SUPPLY_PROP_DIE_HEALTH:
case POWER_SUPPLY_PROP_DC_THERMAL_LEVELS:
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
return 1;
default:
break;
Expand Down
Loading

0 comments on commit e8d8f99

Please sign in to comment.