mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-12 07:37:31 -04:00
Support input voltage limit for wireless charger
Support input voltage limit for wireless charger separately so as to load different input voltage limit for wired and wireless charger input. Change-Id: Ifab8e2ee36c0f549be4fb348396e4fadb6e650d6 Signed-off-by: Yonghua Yan <yanyh2@motorola.com> Reviewed-on: https://gerrit.mot.com/2516665 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: litong <litong20@motorola.com> Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
2d74d85400
commit
555d409161
2 changed files with 41 additions and 9 deletions
|
|
@ -583,6 +583,8 @@ static int sgm4154x_set_input_volt_lim(struct sgm4154x_device *sgm, int vindpm)
|
|||
vindpm > SGM4154x_VINDPM_V_MAX_uV)
|
||||
return -EINVAL;
|
||||
|
||||
sgm->vlim = vindpm;
|
||||
|
||||
temp = sgm4154x_get_vindpm_offset_os(sgm);
|
||||
if (0 == temp)
|
||||
offset = 3900000; //uv
|
||||
|
|
@ -1389,6 +1391,7 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
int ret;
|
||||
//static int charge_type_old = 0;
|
||||
int curr_in_limit = 0;
|
||||
u32 volt_in_limit = 0;
|
||||
static int prev_in_limit = 0;
|
||||
bool state_changed = false;
|
||||
struct sgm4154x_state state;
|
||||
|
|
@ -1465,6 +1468,8 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
dev_err(sgm->dev, "DPDM detecte not done\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
volt_in_limit = sgm->init_data.vlim;
|
||||
#if defined(__SGM41542_CHIP_ID__)|| defined(__SGM41516D_CHIP_ID__)
|
||||
switch(sgm->state.chrg_type) {
|
||||
case SGM4154x_USB_SDP:
|
||||
|
|
@ -1499,7 +1504,8 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
if (is_wls_online(sgm)) {
|
||||
pr_err("SGM4154x charger type: Wireless\n");
|
||||
sgm->state.chrg_type = SGM4154x_WLS_TYPE;
|
||||
curr_in_limit = sgm->init_data.wlim;
|
||||
curr_in_limit = sgm->init_data.wls_ilim;
|
||||
volt_in_limit = sgm->init_data.wls_vlim;
|
||||
break;
|
||||
} else {
|
||||
pr_err("SGM4154x charger type: default\n");
|
||||
|
|
@ -1514,6 +1520,12 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
sgm4154x_enable_charger(sgm);
|
||||
}
|
||||
|
||||
if (volt_in_limit != sgm->vlim) {
|
||||
dev_info(sgm->dev, "Update: volt_in_limit = %d\n",
|
||||
volt_in_limit);
|
||||
sgm4154x_set_input_volt_lim(sgm, volt_in_limit);
|
||||
}
|
||||
|
||||
if ((!sgm->use_ext_usb_psy || !sgm->usb) &&
|
||||
prev_in_limit != curr_in_limit) {
|
||||
dev_info(sgm->dev, "Update: curr_in_limit = %d\n",
|
||||
|
|
@ -1889,6 +1901,16 @@ static int sgm4154x_parse_dt(struct sgm4154x_device *sgm)
|
|||
sgm->init_data.vlim < SGM4154x_VINDPM_V_MIN_uV)
|
||||
return -EINVAL;
|
||||
|
||||
ret = device_property_read_u32(sgm->dev,
|
||||
"wls-input-voltage-limit-microvolt",
|
||||
&sgm->init_data.wls_vlim);
|
||||
if (ret)
|
||||
sgm->init_data.wls_vlim = SGM4154x_VINDPM_DEF_uV;
|
||||
|
||||
if (sgm->init_data.wls_vlim > SGM4154x_VINDPM_V_MAX_uV ||
|
||||
sgm->init_data.wls_vlim < SGM4154x_VINDPM_V_MIN_uV)
|
||||
return -EINVAL;
|
||||
|
||||
ret = device_property_read_u32(sgm->dev,
|
||||
"input-current-limit-microamp",
|
||||
&sgm->init_data.ilim);
|
||||
|
|
@ -1900,12 +1922,12 @@ static int sgm4154x_parse_dt(struct sgm4154x_device *sgm)
|
|||
return -EINVAL;
|
||||
|
||||
ret = device_property_read_u32(sgm->dev,
|
||||
"wls-current-limit-microamp",
|
||||
&sgm->init_data.wlim);
|
||||
"wls-input-current-limit-microamp",
|
||||
&sgm->init_data.wls_ilim);
|
||||
if (ret)
|
||||
sgm->init_data.wlim = SGM4154x_IINDPM_I_MIN_uA;
|
||||
sgm->init_data.wls_ilim = SGM4154x_IINDPM_I_MIN_uA;
|
||||
|
||||
pr_info("wireless input current limit: %duA\n", sgm->init_data.wlim);
|
||||
pr_info("wireless input current limit: %duA\n", sgm->init_data.wls_ilim);
|
||||
|
||||
irq_gpio = of_get_named_gpio(sgm->dev->of_node, "sgm,irq-gpio", 0);
|
||||
if (!gpio_is_valid(irq_gpio))
|
||||
|
|
@ -2384,6 +2406,7 @@ static int sgm4154x_charger_config_charge(void *data, struct mmi_charger_cfg *co
|
|||
bool low_load_en;
|
||||
static int prev_paired_load = PAIRED_LOAD_OFF;
|
||||
int curr_in_limit = chg->sgm->ilim;
|
||||
int volt_in_limit = chg->sgm->init_data.vlim;
|
||||
|
||||
/* Monitor vbat and ibat for OVP and OCP */
|
||||
if (chg->batt_info.batt_mv >= chg->sgm->vbat_ovp_threshold) {
|
||||
|
|
@ -2543,12 +2566,19 @@ static int sgm4154x_charger_config_charge(void *data, struct mmi_charger_cfg *co
|
|||
if (curr_in_limit > chg->sgm->init_data.ilim)
|
||||
curr_in_limit = chg->sgm->init_data.ilim;
|
||||
} else if (chg->chg_info.chrg_present && chg->chg_info.chrg_type == SGM4154x_WLS_TYPE) {
|
||||
curr_in_limit = chg->sgm->init_data.wlim;
|
||||
pr_debug("wireless is on, set current limit to %d", curr_in_limit);
|
||||
curr_in_limit = chg->sgm->init_data.wls_ilim;
|
||||
volt_in_limit = chg->sgm->init_data.wls_vlim;
|
||||
pr_debug("wireless is on, curr_in_limit=%d, volt_in_limit=%d\n",
|
||||
curr_in_limit, volt_in_limit);
|
||||
} else {
|
||||
curr_in_limit = 0;
|
||||
}
|
||||
|
||||
if (chg->sgm->vlim != volt_in_limit) {
|
||||
pr_info("volt_in_limit=%d\n", volt_in_limit);
|
||||
sgm4154x_set_input_volt_lim(chg->sgm, volt_in_limit);
|
||||
}
|
||||
|
||||
if (chg->sgm->ilim != curr_in_limit) {
|
||||
sgm4154x_set_input_curr_lim(chg->sgm, curr_in_limit);
|
||||
pr_info("ibus_limit=%d, ibus_adc=%d, curr=%d\n",
|
||||
|
|
|
|||
|
|
@ -223,11 +223,12 @@
|
|||
struct sgm4154x_init_data {
|
||||
u32 ichg; /* charge current */
|
||||
u32 ilim; /* input current */
|
||||
u32 wlim; /* wireless input current */
|
||||
u32 wls_ilim; /* wireless input current */
|
||||
u32 vreg; /* regulation voltage */
|
||||
u32 iterm; /* termination current */
|
||||
u32 iprechg; /* precharge current */
|
||||
u32 vlim; /* minimum system voltage limit */
|
||||
u32 vlim; /* minimum input voltage limit for wired charger*/
|
||||
u32 wls_vlim; /* minimum input voltage limit for wireless charger*/
|
||||
u32 max_ichg;
|
||||
u32 max_vreg;
|
||||
u32 vrechg;
|
||||
|
|
@ -353,6 +354,7 @@ struct sgm4154x_device {
|
|||
|
||||
u32 ichg; /* charge current */
|
||||
u32 ilim; /* input current */
|
||||
u32 vlim; /* input voltage */
|
||||
u32 vreg; /* regulation voltage */
|
||||
int user_ichg; /* user charge current */
|
||||
int user_ilim; /* user input current */
|
||||
|
|
|
|||
Loading…
Reference in a new issue