power: smb-lib: Move to SW based step-charging
Remove the HW SOC-based step-charging logic and enable SW based step-charging. The SW based step-charging uses the periodic WD bark IRQ to notify the battery properties. The bark-time can be changes using the property 'qcom,wd-bark-time-secs' 'qcom,step-charging-enable' enables the feature. Change-Id: Ib162f3eb3f98a4e7f144bedc8c8cea40fbf6137a Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
This commit is contained in:
parent
859d453ac5
commit
cb900325e7
5 changed files with 83 additions and 385 deletions
|
@ -85,21 +85,6 @@ Charger specific properties:
|
|||
maximum charge current in mA for each thermal
|
||||
level.
|
||||
|
||||
- qcom,step-soc-thresholds
|
||||
Usage: optional
|
||||
Value type: Array of <u32>
|
||||
Definition: Array of SOC threshold values, size of 4. This should be a
|
||||
flat array that denotes the percentage ranging from 0 to 100.
|
||||
If the array is not present, step charging is disabled.
|
||||
|
||||
- qcom,step-current-deltas
|
||||
Usage: optional
|
||||
Value type: Array of <s32>
|
||||
Definition: Array of delta values for charging current, size of 5, with
|
||||
FCC as base. This should be a flat array that denotes the
|
||||
offset of charging current in uA, from -3100000 to 3200000.
|
||||
If the array is not present, step charging is disabled.
|
||||
|
||||
- io-channels
|
||||
Usage: optional
|
||||
Value type: List of <phandle u32>
|
||||
|
@ -182,6 +167,18 @@ Charger specific properties:
|
|||
Definition: Specifies the deglitch interval for OTG detection.
|
||||
If the value is not present, 50 msec is used as default.
|
||||
|
||||
- qcom,step-charging-enable
|
||||
Usage: optional
|
||||
Value type: bool
|
||||
Definition: Boolean flag which when present enables step-charging.
|
||||
|
||||
- qcom,wd-bark-time-secs
|
||||
Usage: optional
|
||||
Value type: <u32>
|
||||
Definition: WD bark-timeout in seconds. The possible values are
|
||||
16, 32, 64, 128. If not defined it defaults to 64.
|
||||
|
||||
|
||||
=============================================
|
||||
Second Level Nodes - SMB2 Charger Peripherals
|
||||
=============================================
|
||||
|
@ -217,9 +214,6 @@ pmi8998_charger: qcom,qpnp-smb2 {
|
|||
|
||||
dpdm-supply = <&qusb_phy0>;
|
||||
|
||||
qcom,step-soc-thresholds = <60 70 80 90>;
|
||||
qcom,step-current-deltas = <500000 250000 150000 0 (-150000)>;
|
||||
|
||||
qcom,chgr@1000 {
|
||||
reg = <0x1000 0x100>;
|
||||
interrupts = <0x2 0x10 0x0 IRQ_TYPE_NONE>,
|
||||
|
|
|
@ -4,6 +4,6 @@ obj-$(CONFIG_SMB1351_USB_CHARGER) += battery.o smb1351-charger.o pmic-voter.o
|
|||
obj-$(CONFIG_MSM_BCL_CTL) += msm_bcl.o
|
||||
obj-$(CONFIG_MSM_BCL_PERIPHERAL_CTL) += bcl_peripheral.o
|
||||
obj-$(CONFIG_BATTERY_BCL) += battery_current_limit.o
|
||||
obj-$(CONFIG_QPNP_SMB2) += battery.o qpnp-smb2.o smb-lib.o pmic-voter.o storm-watch.o
|
||||
obj-$(CONFIG_QPNP_SMB2) += step-chg-jeita.o battery.o qpnp-smb2.o smb-lib.o pmic-voter.o storm-watch.o
|
||||
obj-$(CONFIG_SMB138X_CHARGER) += battery.o smb138x-charger.o smb-lib.o pmic-voter.o storm-watch.o
|
||||
obj-$(CONFIG_QPNP_QNOVO) += battery.o qpnp-qnovo.o
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <linux/power_supply.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/qpnp/qpnp-revid.h>
|
||||
#include <linux/regulator/driver.h>
|
||||
#include <linux/regulator/of_regulator.h>
|
||||
|
@ -122,87 +123,6 @@ static struct smb_params v1_params = {
|
|||
.max_u = 1575000,
|
||||
.step_u = 25000,
|
||||
},
|
||||
.step_soc_threshold[0] = {
|
||||
.name = "step charge soc threshold 1",
|
||||
.reg = STEP_CHG_SOC_OR_BATT_V_TH1_REG,
|
||||
.min_u = 0,
|
||||
.max_u = 100,
|
||||
.step_u = 1,
|
||||
},
|
||||
.step_soc_threshold[1] = {
|
||||
.name = "step charge soc threshold 2",
|
||||
.reg = STEP_CHG_SOC_OR_BATT_V_TH2_REG,
|
||||
.min_u = 0,
|
||||
.max_u = 100,
|
||||
.step_u = 1,
|
||||
},
|
||||
.step_soc_threshold[2] = {
|
||||
.name = "step charge soc threshold 3",
|
||||
.reg = STEP_CHG_SOC_OR_BATT_V_TH3_REG,
|
||||
.min_u = 0,
|
||||
.max_u = 100,
|
||||
.step_u = 1,
|
||||
},
|
||||
.step_soc_threshold[3] = {
|
||||
.name = "step charge soc threshold 4",
|
||||
.reg = STEP_CHG_SOC_OR_BATT_V_TH4_REG,
|
||||
.min_u = 0,
|
||||
.max_u = 100,
|
||||
.step_u = 1,
|
||||
},
|
||||
.step_soc = {
|
||||
.name = "step charge soc",
|
||||
.reg = STEP_CHG_SOC_VBATT_V_REG,
|
||||
.min_u = 0,
|
||||
.max_u = 100,
|
||||
.step_u = 1,
|
||||
.set_proc = smblib_mapping_soc_from_field_value,
|
||||
},
|
||||
.step_cc_delta[0] = {
|
||||
.name = "step charge current delta 1",
|
||||
.reg = STEP_CHG_CURRENT_DELTA1_REG,
|
||||
.min_u = 100000,
|
||||
.max_u = 3200000,
|
||||
.step_u = 100000,
|
||||
.get_proc = smblib_mapping_cc_delta_to_field_value,
|
||||
.set_proc = smblib_mapping_cc_delta_from_field_value,
|
||||
},
|
||||
.step_cc_delta[1] = {
|
||||
.name = "step charge current delta 2",
|
||||
.reg = STEP_CHG_CURRENT_DELTA2_REG,
|
||||
.min_u = 100000,
|
||||
.max_u = 3200000,
|
||||
.step_u = 100000,
|
||||
.get_proc = smblib_mapping_cc_delta_to_field_value,
|
||||
.set_proc = smblib_mapping_cc_delta_from_field_value,
|
||||
},
|
||||
.step_cc_delta[2] = {
|
||||
.name = "step charge current delta 3",
|
||||
.reg = STEP_CHG_CURRENT_DELTA3_REG,
|
||||
.min_u = 100000,
|
||||
.max_u = 3200000,
|
||||
.step_u = 100000,
|
||||
.get_proc = smblib_mapping_cc_delta_to_field_value,
|
||||
.set_proc = smblib_mapping_cc_delta_from_field_value,
|
||||
},
|
||||
.step_cc_delta[3] = {
|
||||
.name = "step charge current delta 4",
|
||||
.reg = STEP_CHG_CURRENT_DELTA4_REG,
|
||||
.min_u = 100000,
|
||||
.max_u = 3200000,
|
||||
.step_u = 100000,
|
||||
.get_proc = smblib_mapping_cc_delta_to_field_value,
|
||||
.set_proc = smblib_mapping_cc_delta_from_field_value,
|
||||
},
|
||||
.step_cc_delta[4] = {
|
||||
.name = "step charge current delta 5",
|
||||
.reg = STEP_CHG_CURRENT_DELTA5_REG,
|
||||
.min_u = 100000,
|
||||
.max_u = 3200000,
|
||||
.step_u = 100000,
|
||||
.get_proc = smblib_mapping_cc_delta_to_field_value,
|
||||
.set_proc = smblib_mapping_cc_delta_from_field_value,
|
||||
},
|
||||
.freq_buck = {
|
||||
.name = "buck switching frequency",
|
||||
.reg = CFG_BUCKBOOST_FREQ_SELECT_BUCK_REG,
|
||||
|
@ -236,7 +156,6 @@ static struct smb_params pm660_params = {
|
|||
},
|
||||
};
|
||||
|
||||
#define STEP_CHARGING_MAX_STEPS 5
|
||||
struct smb_dt_props {
|
||||
int usb_icl_ua;
|
||||
int dc_icl_ua;
|
||||
|
@ -244,14 +163,13 @@ struct smb_dt_props {
|
|||
int wipower_max_uw;
|
||||
int min_freq_khz;
|
||||
int max_freq_khz;
|
||||
u32 step_soc_threshold[STEP_CHARGING_MAX_STEPS - 1];
|
||||
s32 step_cc_delta[STEP_CHARGING_MAX_STEPS];
|
||||
struct device_node *revid_dev_node;
|
||||
int float_option;
|
||||
int chg_inhibit_thr_mv;
|
||||
bool no_battery;
|
||||
bool hvdcp_disable;
|
||||
bool auto_recharge_soc;
|
||||
int wd_bark_time;
|
||||
};
|
||||
|
||||
struct smb2 {
|
||||
|
@ -273,6 +191,11 @@ module_param_named(
|
|||
#define MICRO_1P5A 1500000
|
||||
#define MICRO_P1A 100000
|
||||
#define OTG_DEFAULT_DEGLITCH_TIME_MS 50
|
||||
#define MIN_WD_BARK_TIME 16
|
||||
#define DEFAULT_WD_BARK_TIME 64
|
||||
#define BITE_WDOG_TIMEOUT_8S 0x3
|
||||
#define BARK_WDOG_TIMEOUT_MASK GENMASK(3, 2)
|
||||
#define BARK_WDOG_TIMEOUT_SHIFT 2
|
||||
static int smb2_parse_dt(struct smb2 *chip)
|
||||
{
|
||||
struct smb_charger *chg = &chip->chg;
|
||||
|
@ -284,27 +207,13 @@ static int smb2_parse_dt(struct smb2 *chip)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
chg->step_chg_enabled = true;
|
||||
chg->step_chg_enabled = of_property_read_bool(node,
|
||||
"qcom,step-charging-enable");
|
||||
|
||||
if (of_property_count_u32_elems(node, "qcom,step-soc-thresholds")
|
||||
!= STEP_CHARGING_MAX_STEPS - 1)
|
||||
chg->step_chg_enabled = false;
|
||||
|
||||
rc = of_property_read_u32_array(node, "qcom,step-soc-thresholds",
|
||||
chip->dt.step_soc_threshold,
|
||||
STEP_CHARGING_MAX_STEPS - 1);
|
||||
if (rc < 0)
|
||||
chg->step_chg_enabled = false;
|
||||
|
||||
if (of_property_count_u32_elems(node, "qcom,step-current-deltas")
|
||||
!= STEP_CHARGING_MAX_STEPS)
|
||||
chg->step_chg_enabled = false;
|
||||
|
||||
rc = of_property_read_u32_array(node, "qcom,step-current-deltas",
|
||||
chip->dt.step_cc_delta,
|
||||
STEP_CHARGING_MAX_STEPS);
|
||||
if (rc < 0)
|
||||
chg->step_chg_enabled = false;
|
||||
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)
|
||||
chip->dt.wd_bark_time = DEFAULT_WD_BARK_TIME;
|
||||
|
||||
chip->dt.no_battery = of_property_read_bool(node,
|
||||
"qcom,batteryless-platform");
|
||||
|
@ -989,7 +898,6 @@ static enum power_supply_property smb2_batt_props[] = {
|
|||
POWER_SUPPLY_PROP_TEMP,
|
||||
POWER_SUPPLY_PROP_TECHNOLOGY,
|
||||
POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED,
|
||||
POWER_SUPPLY_PROP_STEP_CHARGING_STEP,
|
||||
POWER_SUPPLY_PROP_CHARGE_DONE,
|
||||
POWER_SUPPLY_PROP_PARALLEL_DISABLE,
|
||||
POWER_SUPPLY_PROP_SET_SHIP_MODE,
|
||||
|
@ -1047,9 +955,6 @@ static int smb2_batt_get_prop(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED:
|
||||
val->intval = chg->step_chg_enabled;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_STEP_CHARGING_STEP:
|
||||
rc = smblib_get_prop_step_chg_step(chg, val);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
||||
rc = smblib_get_prop_batt_voltage_now(chg, val);
|
||||
break;
|
||||
|
@ -1163,6 +1068,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
|
|||
vote(chg->fcc_votable, BATT_PROFILE_VOTER, false, 0);
|
||||
}
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED:
|
||||
chg->step_chg_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);
|
||||
|
@ -1203,6 +1111,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
case POWER_SUPPLY_PROP_RERUN_AICL:
|
||||
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
|
||||
case POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
|
@ -1330,73 +1239,6 @@ static int smb2_init_vconn_regulator(struct smb2 *chip)
|
|||
/***************************
|
||||
* HARDWARE INITIALIZATION *
|
||||
***************************/
|
||||
static int smb2_config_step_charging(struct smb2 *chip)
|
||||
{
|
||||
struct smb_charger *chg = &chip->chg;
|
||||
int rc = 0;
|
||||
int i;
|
||||
|
||||
if (!chg->step_chg_enabled)
|
||||
return rc;
|
||||
|
||||
for (i = 0; i < STEP_CHARGING_MAX_STEPS - 1; i++) {
|
||||
rc = smblib_set_charge_param(chg,
|
||||
&chg->param.step_soc_threshold[i],
|
||||
chip->dt.step_soc_threshold[i]);
|
||||
if (rc < 0) {
|
||||
pr_err("Couldn't configure soc thresholds rc = %d\n",
|
||||
rc);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < STEP_CHARGING_MAX_STEPS; i++) {
|
||||
rc = smblib_set_charge_param(chg, &chg->param.step_cc_delta[i],
|
||||
chip->dt.step_cc_delta[i]);
|
||||
if (rc < 0) {
|
||||
pr_err("Couldn't configure cc delta rc = %d\n",
|
||||
rc);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
rc = smblib_write(chg, STEP_CHG_UPDATE_REQUEST_TIMEOUT_CFG_REG,
|
||||
STEP_CHG_UPDATE_REQUEST_TIMEOUT_40S);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev,
|
||||
"Couldn't configure soc request timeout reg rc=%d\n",
|
||||
rc);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
rc = smblib_write(chg, STEP_CHG_UPDATE_FAIL_TIMEOUT_CFG_REG,
|
||||
STEP_CHG_UPDATE_FAIL_TIMEOUT_120S);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev,
|
||||
"Couldn't configure soc fail timeout reg rc=%d\n",
|
||||
rc);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/*
|
||||
* enable step charging, source soc, standard mode, go to final
|
||||
* state in case of failure.
|
||||
*/
|
||||
rc = smblib_write(chg, CHGR_STEP_CHG_MODE_CFG_REG,
|
||||
STEP_CHARGING_ENABLE_BIT |
|
||||
STEP_CHARGING_SOURCE_SELECT_BIT |
|
||||
STEP_CHARGING_SOC_FAIL_OPTION_BIT);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't configure charger rc=%d\n", rc);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err_out:
|
||||
chg->step_chg_enabled = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int smb2_config_wipower_input_power(struct smb2 *chip, int uw)
|
||||
{
|
||||
int rc;
|
||||
|
@ -1572,7 +1414,7 @@ static int smb2_init_hw(struct smb2 *chip)
|
|||
{
|
||||
struct smb_charger *chg = &chip->chg;
|
||||
int rc;
|
||||
u8 stat;
|
||||
u8 stat, val;
|
||||
|
||||
if (chip->dt.no_battery)
|
||||
chg->fake_capacity = 50;
|
||||
|
@ -1720,11 +1562,27 @@ static int smb2_init_hw(struct smb2 *chip)
|
|||
return rc;
|
||||
}
|
||||
|
||||
/* configure step charging */
|
||||
rc = smb2_config_step_charging(chip);
|
||||
if (rc < 0) {
|
||||
dev_err(chg->dev, "Couldn't configure step charging rc=%d\n",
|
||||
rc);
|
||||
val = (ilog2(chip->dt.wd_bark_time / 16) << BARK_WDOG_TIMEOUT_SHIFT) &
|
||||
BARK_WDOG_TIMEOUT_MASK;
|
||||
val |= BITE_WDOG_TIMEOUT_8S;
|
||||
rc = smblib_masked_write(chg, SNARL_BARK_BITE_WD_CFG_REG,
|
||||
BITE_WDOG_DISABLE_CHARGING_CFG_BIT |
|
||||
BARK_WDOG_TIMEOUT_MASK | BITE_WDOG_TIMEOUT_MASK,
|
||||
val);
|
||||
if (rc) {
|
||||
pr_err("Couldn't configue WD config rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* enable WD BARK and enable it on plugin */
|
||||
rc = smblib_masked_write(chg, WD_CFG_REG,
|
||||
WATCHDOG_TRIGGER_AFP_EN_BIT |
|
||||
WDOG_TIMER_EN_ON_PLUGIN_BIT |
|
||||
BARK_WDOG_INT_EN_BIT,
|
||||
WDOG_TIMER_EN_ON_PLUGIN_BIT |
|
||||
BARK_WDOG_INT_EN_BIT);
|
||||
if (rc) {
|
||||
pr_err("Couldn't configue WD config rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1944,9 +1802,8 @@ static int smb2_determine_initial_status(struct smb2 *chip)
|
|||
smblib_handle_usb_source_change(0, &irq_data);
|
||||
smblib_handle_chg_state_change(0, &irq_data);
|
||||
smblib_handle_icl_change(0, &irq_data);
|
||||
smblib_handle_step_chg_state_change(0, &irq_data);
|
||||
smblib_handle_step_chg_soc_update_request(0, &irq_data);
|
||||
smblib_handle_batt_temp_changed(0, &irq_data);
|
||||
smblib_handle_wdog_bark(0, &irq_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1968,18 +1825,15 @@ static struct smb_irq_info smb2_irqs[] = {
|
|||
},
|
||||
[STEP_CHG_STATE_CHANGE_IRQ] = {
|
||||
.name = "step-chg-state-change",
|
||||
.handler = smblib_handle_step_chg_state_change,
|
||||
.wake = true,
|
||||
.handler = NULL,
|
||||
},
|
||||
[STEP_CHG_SOC_UPDATE_FAIL_IRQ] = {
|
||||
.name = "step-chg-soc-update-fail",
|
||||
.handler = smblib_handle_step_chg_soc_update_fail,
|
||||
.wake = true,
|
||||
.handler = NULL,
|
||||
},
|
||||
[STEP_CHG_SOC_UPDATE_REQ_IRQ] = {
|
||||
.name = "step-chg-soc-update-request",
|
||||
.handler = smblib_handle_step_chg_soc_update_request,
|
||||
.wake = true,
|
||||
.handler = NULL,
|
||||
},
|
||||
/* OTG IRQs */
|
||||
[OTG_FAIL_IRQ] = {
|
||||
|
@ -2098,7 +1952,8 @@ static struct smb_irq_info smb2_irqs[] = {
|
|||
},
|
||||
[WDOG_BARK_IRQ] = {
|
||||
.name = "wdog-bark",
|
||||
.handler = NULL,
|
||||
.handler = smblib_handle_wdog_bark,
|
||||
.wake = true,
|
||||
},
|
||||
[AICL_FAIL_IRQ] = {
|
||||
.name = "aicl-fail",
|
||||
|
@ -2338,18 +2193,18 @@ static int smb2_probe(struct platform_device *pdev)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = smblib_init(chg);
|
||||
if (rc < 0) {
|
||||
pr_err("Smblib_init failed rc=%d\n", rc);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = smb2_parse_dt(chip);
|
||||
if (rc < 0) {
|
||||
pr_err("Couldn't parse device tree rc=%d\n", rc);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = smblib_init(chg);
|
||||
if (rc < 0) {
|
||||
pr_err("Smblib_init failed rc=%d\n", rc);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* set driver data before resources request it */
|
||||
platform_set_drvdata(pdev, chip);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "smb-lib.h"
|
||||
#include "smb-reg.h"
|
||||
#include "battery.h"
|
||||
#include "step-chg-jeita.h"
|
||||
#include "storm-watch.h"
|
||||
|
||||
#define smblib_err(chg, fmt, ...) \
|
||||
|
@ -102,35 +103,6 @@ unlock:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int smblib_get_step_cc_delta(struct smb_charger *chg, int *cc_delta_ua)
|
||||
{
|
||||
int rc, step_state;
|
||||
u8 stat;
|
||||
|
||||
if (!chg->step_chg_enabled) {
|
||||
*cc_delta_ua = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't read BATTERY_CHARGER_STATUS_1 rc=%d\n",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
step_state = (stat & STEP_CHARGING_STATUS_MASK) >>
|
||||
STEP_CHARGING_STATUS_SHIFT;
|
||||
rc = smblib_get_charge_param(chg, &chg->param.step_cc_delta[step_state],
|
||||
cc_delta_ua);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get step cc delta rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int smblib_get_jeita_cc_delta(struct smb_charger *chg, int *cc_delta_ua)
|
||||
{
|
||||
int rc, cc_minus_ua;
|
||||
|
@ -149,7 +121,7 @@ static int smblib_get_jeita_cc_delta(struct smb_charger *chg, int *cc_delta_ua)
|
|||
}
|
||||
|
||||
rc = smblib_get_charge_param(chg, &chg->param.jeita_cc_comp,
|
||||
&cc_minus_ua);
|
||||
&cc_minus_ua);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get jeita cc minus rc=%d\n", rc);
|
||||
return rc;
|
||||
|
@ -402,28 +374,6 @@ int smblib_set_charge_param(struct smb_charger *chg,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int step_charge_soc_update(struct smb_charger *chg, int capacity)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
rc = smblib_set_charge_param(chg, &chg->param.step_soc, capacity);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Error in updating soc, rc=%d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = smblib_write(chg, STEP_CHG_SOC_VBATT_V_UPDATE_REG,
|
||||
STEP_CHG_SOC_VBATT_V_UPDATE_BIT);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg,
|
||||
"Couldn't set STEP_CHG_SOC_VBATT_V_UPDATE_REG rc=%d\n",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int smblib_set_usb_suspend(struct smb_charger *chg, bool suspend)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -1804,30 +1754,6 @@ int smblib_get_prop_batt_temp(struct smb_charger *chg,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int smblib_get_prop_step_chg_step(struct smb_charger *chg,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
int rc;
|
||||
u8 stat;
|
||||
|
||||
if (!chg->step_chg_enabled) {
|
||||
val->intval = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't read BATTERY_CHARGER_STATUS_1 rc=%d\n",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
val->intval = (stat & STEP_CHARGING_STATUS_MASK) >>
|
||||
STEP_CHARGING_STATUS_SHIFT;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
|
@ -2932,28 +2858,17 @@ static int smblib_recover_from_soft_jeita(struct smb_charger *chg)
|
|||
* USB MAIN PSY GETTERS *
|
||||
*************************/
|
||||
int smblib_get_prop_fcc_delta(struct smb_charger *chg,
|
||||
union power_supply_propval *val)
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
int rc, jeita_cc_delta_ua, step_cc_delta_ua, hw_cc_delta_ua = 0;
|
||||
|
||||
rc = smblib_get_step_cc_delta(chg, &step_cc_delta_ua);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get step cc delta rc=%d\n", rc);
|
||||
step_cc_delta_ua = 0;
|
||||
} else {
|
||||
hw_cc_delta_ua = step_cc_delta_ua;
|
||||
}
|
||||
int rc, jeita_cc_delta_ua = 0;
|
||||
|
||||
rc = smblib_get_jeita_cc_delta(chg, &jeita_cc_delta_ua);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get jeita cc delta rc=%d\n", rc);
|
||||
jeita_cc_delta_ua = 0;
|
||||
} else if (jeita_cc_delta_ua < 0) {
|
||||
/* HW will take the min between JEITA and step charge */
|
||||
hw_cc_delta_ua = min(hw_cc_delta_ua, jeita_cc_delta_ua);
|
||||
}
|
||||
|
||||
val->intval = hw_cc_delta_ua;
|
||||
val->intval = jeita_cc_delta_ua;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3134,57 +3049,6 @@ irqreturn_t smblib_handle_chg_state_change(int irq, void *data)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
irqreturn_t smblib_handle_step_chg_state_change(int irq, void *data)
|
||||
{
|
||||
struct smb_irq_data *irq_data = data;
|
||||
struct smb_charger *chg = irq_data->parent_data;
|
||||
|
||||
smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);
|
||||
|
||||
if (chg->step_chg_enabled)
|
||||
rerun_election(chg->fcc_votable);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
irqreturn_t smblib_handle_step_chg_soc_update_fail(int irq, void *data)
|
||||
{
|
||||
struct smb_irq_data *irq_data = data;
|
||||
struct smb_charger *chg = irq_data->parent_data;
|
||||
|
||||
smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);
|
||||
|
||||
if (chg->step_chg_enabled)
|
||||
rerun_election(chg->fcc_votable);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
#define STEP_SOC_REQ_MS 3000
|
||||
irqreturn_t smblib_handle_step_chg_soc_update_request(int irq, void *data)
|
||||
{
|
||||
struct smb_irq_data *irq_data = data;
|
||||
struct smb_charger *chg = irq_data->parent_data;
|
||||
int rc;
|
||||
union power_supply_propval pval = {0, };
|
||||
|
||||
smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);
|
||||
|
||||
if (!chg->bms_psy) {
|
||||
schedule_delayed_work(&chg->step_soc_req_work,
|
||||
msecs_to_jiffies(STEP_SOC_REQ_MS));
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
rc = smblib_get_prop_batt_capacity(chg, &pval);
|
||||
if (rc < 0)
|
||||
smblib_err(chg, "Couldn't get batt capacity rc=%d\n", rc);
|
||||
else
|
||||
step_charge_soc_update(chg, pval.intval);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
irqreturn_t smblib_handle_batt_temp_changed(int irq, void *data)
|
||||
{
|
||||
struct smb_irq_data *irq_data = data;
|
||||
|
@ -4095,10 +3959,15 @@ irqreturn_t smblib_handle_wdog_bark(int irq, void *data)
|
|||
struct smb_charger *chg = irq_data->parent_data;
|
||||
int rc;
|
||||
|
||||
smblib_dbg(chg, PR_INTERRUPT, "IRQ: %s\n", irq_data->name);
|
||||
|
||||
rc = smblib_write(chg, BARK_BITE_WDOG_PET_REG, BARK_BITE_WDOG_PET_BIT);
|
||||
if (rc < 0)
|
||||
smblib_err(chg, "Couldn't pet the dog rc=%d\n", rc);
|
||||
|
||||
if (chg->step_chg_enabled)
|
||||
power_supply_changed(chg->batt_psy);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -4181,22 +4050,6 @@ static void bms_update_work(struct work_struct *work)
|
|||
power_supply_changed(chg->batt_psy);
|
||||
}
|
||||
|
||||
static void step_soc_req_work(struct work_struct *work)
|
||||
{
|
||||
struct smb_charger *chg = container_of(work, struct smb_charger,
|
||||
step_soc_req_work.work);
|
||||
union power_supply_propval pval = {0, };
|
||||
int rc;
|
||||
|
||||
rc = smblib_get_prop_batt_capacity(chg, &pval);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get batt capacity rc=%d\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
step_charge_soc_update(chg, pval.intval);
|
||||
}
|
||||
|
||||
static void clear_hdc_work(struct work_struct *work)
|
||||
{
|
||||
struct smb_charger *chg = container_of(work, struct smb_charger,
|
||||
|
@ -4729,7 +4582,6 @@ int smblib_init(struct smb_charger *chg)
|
|||
INIT_WORK(&chg->bms_update_work, bms_update_work);
|
||||
INIT_WORK(&chg->rdstd_cc2_detach_work, rdstd_cc2_detach_work);
|
||||
INIT_DELAYED_WORK(&chg->hvdcp_detect_work, smblib_hvdcp_detect_work);
|
||||
INIT_DELAYED_WORK(&chg->step_soc_req_work, step_soc_req_work);
|
||||
INIT_DELAYED_WORK(&chg->clear_hdc_work, clear_hdc_work);
|
||||
INIT_WORK(&chg->otg_oc_work, smblib_otg_oc_work);
|
||||
INIT_WORK(&chg->vconn_oc_work, smblib_vconn_oc_work);
|
||||
|
@ -4751,6 +4603,13 @@ int smblib_init(struct smb_charger *chg)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = qcom_step_chg_init(chg->step_chg_enabled);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't init qcom_step_chg_init rc=%d\n",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = smblib_create_votables(chg);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't create votables rc=%d\n",
|
||||
|
@ -4785,7 +4644,6 @@ int smblib_deinit(struct smb_charger *chg)
|
|||
cancel_work_sync(&chg->bms_update_work);
|
||||
cancel_work_sync(&chg->rdstd_cc2_detach_work);
|
||||
cancel_delayed_work_sync(&chg->hvdcp_detect_work);
|
||||
cancel_delayed_work_sync(&chg->step_soc_req_work);
|
||||
cancel_delayed_work_sync(&chg->clear_hdc_work);
|
||||
cancel_work_sync(&chg->otg_oc_work);
|
||||
cancel_work_sync(&chg->vconn_oc_work);
|
||||
|
@ -4797,6 +4655,7 @@ int smblib_deinit(struct smb_charger *chg)
|
|||
cancel_delayed_work_sync(&chg->bb_removal_work);
|
||||
power_supply_unreg_notifier(&chg->nb);
|
||||
smblib_destroy_votables(chg);
|
||||
qcom_step_chg_deinit();
|
||||
qcom_batt_deinit();
|
||||
break;
|
||||
case PARALLEL_SLAVE:
|
||||
|
|
|
@ -190,9 +190,6 @@ struct smb_params {
|
|||
struct smb_chg_param dc_icl_div2_mid_hv;
|
||||
struct smb_chg_param dc_icl_div2_hv;
|
||||
struct smb_chg_param jeita_cc_comp;
|
||||
struct smb_chg_param step_soc_threshold[4];
|
||||
struct smb_chg_param step_soc;
|
||||
struct smb_chg_param step_cc_delta[5];
|
||||
struct smb_chg_param freq_buck;
|
||||
struct smb_chg_param freq_boost;
|
||||
};
|
||||
|
@ -287,7 +284,6 @@ struct smb_charger {
|
|||
struct work_struct rdstd_cc2_detach_work;
|
||||
struct delayed_work hvdcp_detect_work;
|
||||
struct delayed_work ps_change_timeout_work;
|
||||
struct delayed_work step_soc_req_work;
|
||||
struct delayed_work clear_hdc_work;
|
||||
struct work_struct otg_oc_work;
|
||||
struct work_struct vconn_oc_work;
|
||||
|
@ -384,9 +380,6 @@ int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev);
|
|||
irqreturn_t smblib_handle_debug(int irq, void *data);
|
||||
irqreturn_t smblib_handle_otg_overcurrent(int irq, void *data);
|
||||
irqreturn_t smblib_handle_chg_state_change(int irq, void *data);
|
||||
irqreturn_t smblib_handle_step_chg_state_change(int irq, void *data);
|
||||
irqreturn_t smblib_handle_step_chg_soc_update_fail(int irq, void *data);
|
||||
irqreturn_t smblib_handle_step_chg_soc_update_request(int irq, void *data);
|
||||
irqreturn_t smblib_handle_batt_temp_changed(int irq, void *data);
|
||||
irqreturn_t smblib_handle_batt_psy_changed(int irq, void *data);
|
||||
irqreturn_t smblib_handle_usb_psy_changed(int irq, void *data);
|
||||
|
@ -424,9 +417,6 @@ int smblib_get_prop_batt_current_now(struct smb_charger *chg,
|
|||
union power_supply_propval *val);
|
||||
int smblib_get_prop_batt_temp(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
int smblib_get_prop_step_chg_step(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);
|
||||
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
|
||||
|
@ -506,7 +496,7 @@ int smblib_set_prop_charge_qnovo_enable(struct smb_charger *chg,
|
|||
void smblib_suspend_on_debug_battery(struct smb_charger *chg);
|
||||
int smblib_rerun_apsd_if_required(struct smb_charger *chg);
|
||||
int smblib_get_prop_fcc_delta(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
union power_supply_propval *val);
|
||||
int smblib_icl_override(struct smb_charger *chg, bool override);
|
||||
int smblib_dp_dm(struct smb_charger *chg, int val);
|
||||
int smblib_rerun_aicl(struct smb_charger *chg);
|
||||
|
|
Loading…
Add table
Reference in a new issue