Support wireless power source as charger input.
sgm415x: Support wireless power source as charger input. Change-Id: Iad9cd8526aa1697b9d749264b27e1d0db06e0ac0 Reviewed-on: https://gerrit.mot.com/2417538 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
1 parent
c99b4911b9
commit
ee381ff374
2 files changed
+44
-1
No files matched your search
@@ -1816,6 +1816,14 @@ static int sgm4154x_parse_dt(struct sgm4154x_device *sgm)
|
||||
sgm->init_data.ilim < SGM4154x_IINDPM_I_MIN_uA)
|
||||
return -EINVAL;
|
||||
|
||||
ret = device_property_read_u32(sgm->dev,
|
||||
"wls-current-limit-microamp",
|
||||
&sgm->init_data.wlim);
|
||||
if (ret)
|
||||
sgm->init_data.wlim = SGM4154x_IINDPM_I_MIN_uA;
|
||||
|
||||
pr_info("wireless input current limit: %duA\n", sgm->init_data.wlim);
|
||||
|
||||
irq_gpio = of_get_named_gpio(sgm->dev->of_node, "sgm,irq-gpio", 0);
|
||||
if (!gpio_is_valid(irq_gpio))
|
||||
{
|
||||
@@ -2271,6 +2279,25 @@ static int sgm4154x_charger_get_chg_info(void *data, struct mmi_charger_info *ch
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_wls_online(struct sgm_mmi_charger *chg)
|
||||
{
|
||||
int rc;
|
||||
union power_supply_propval val;
|
||||
|
||||
if (!chg->wls_psy)
|
||||
return 0;
|
||||
|
||||
rc = power_supply_get_property(chg->wls_psy,
|
||||
POWER_SUPPLY_PROP_ONLINE, &val);
|
||||
if (rc < 0) {
|
||||
pr_err("Error wls online rc = %d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pr_debug("wireless online is %d", val.intval);
|
||||
return val.intval;
|
||||
}
|
||||
|
||||
static int sgm4154x_charger_config_charge(void *data, struct mmi_charger_cfg *config)
|
||||
{
|
||||
int rc;
|
||||
@@ -2522,7 +2549,12 @@ 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) {
|
||||
curr_in_limit = 0;
|
||||
if (is_wls_online(chg) && chg->sgm->init_data.wlim) {
|
||||
curr_in_limit = chg->sgm->init_data.wlim;
|
||||
pr_info("wireless is on, set current limit to %d", curr_in_limit);
|
||||
} else {
|
||||
curr_in_limit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (chg->sgm->ilim != curr_in_limit) {
|
||||
@@ -2782,6 +2814,15 @@ static int sgm4154x_mmi_charger_init(struct sgm_mmi_charger *chg)
|
||||
pr_info("%s power supply is found\n", chg->fg_psy_name);
|
||||
}
|
||||
|
||||
if (!chg->wls_psy) {
|
||||
chg->wls_psy = power_supply_get_by_name("wireless");
|
||||
if (!chg->wls_psy) {
|
||||
pr_err("wireless power supply found\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_info("wireless power supply is found\n");
|
||||
}
|
||||
|
||||
if (chg->driver) {
|
||||
pr_info("sgm4154x_mmi_charger has already registered\n");
|
||||
return 0;
|
||||
|
||||
@@ -221,6 +221,7 @@
|
||||
struct sgm4154x_init_data {
|
||||
u32 ichg; /* charge current */
|
||||
u32 ilim; /* input current */
|
||||
u32 wlim; /* wireless input current */
|
||||
u32 vreg; /* regulation voltage */
|
||||
u32 iterm; /* termination current */
|
||||
u32 iprechg; /* precharge current */
|
||||
@@ -287,6 +288,7 @@ struct sgm_mmi_charger {
|
||||
u32 chrg_taper_cnt;
|
||||
const char *fg_psy_name;
|
||||
struct power_supply *fg_psy;
|
||||
struct power_supply *wls_psy;
|
||||
int ichg_polority;
|
||||
|
||||
int paired_ichg;
|
||||
|
||||
Reference in new issue
Block a user