smb-lib: smb138x-charger: add parallel current to parallel psy
The measured battery current can be read from the parallel slave charger. Expose this through the CURRENT_NOW property in the parallel power supply. Change-Id: Icd717147adc018a076a72bd5ce1a52a765f34f7b Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
This commit is contained in:
parent
7d74a7b9f3
commit
42d047fcee
3 changed files with 26 additions and 0 deletions
|
@ -1749,6 +1749,22 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
|
|||
return rc;
|
||||
}
|
||||
|
||||
/************************
|
||||
* PARALLEL PSY GETTERS *
|
||||
************************/
|
||||
|
||||
int smblib_get_prop_slave_current_now(struct smb_charger *chg,
|
||||
union power_supply_propval *pval)
|
||||
{
|
||||
if (IS_ERR_OR_NULL(chg->iio.batt_i_chan))
|
||||
chg->iio.batt_i_chan = iio_channel_get(chg->dev, "batt_i");
|
||||
|
||||
if (IS_ERR(chg->iio.batt_i_chan))
|
||||
return PTR_ERR(chg->iio.batt_i_chan);
|
||||
|
||||
return iio_read_channel_processed(chg->iio.batt_i_chan, &pval->intval);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* INTERRUPT HANDLERS *
|
||||
**********************/
|
||||
|
@ -2440,6 +2456,8 @@ static void smblib_iio_deinit(struct smb_charger *chg)
|
|||
iio_channel_release(chg->iio.usbin_i_chan);
|
||||
if (!IS_ERR_OR_NULL(chg->iio.usbin_v_chan))
|
||||
iio_channel_release(chg->iio.usbin_v_chan);
|
||||
if (!IS_ERR_OR_NULL(chg->iio.batt_i_chan))
|
||||
iio_channel_release(chg->iio.batt_i_chan);
|
||||
}
|
||||
|
||||
int smblib_init(struct smb_charger *chg)
|
||||
|
|
|
@ -103,6 +103,7 @@ struct smb_iio {
|
|||
struct iio_channel *temp_max_chan;
|
||||
struct iio_channel *usbin_i_chan;
|
||||
struct iio_channel *usbin_v_chan;
|
||||
struct iio_channel *batt_i_chan;
|
||||
};
|
||||
|
||||
struct smb_charger {
|
||||
|
@ -301,6 +302,9 @@ int smblib_set_prop_typec_power_role(struct smb_charger *chg,
|
|||
int smblib_set_prop_pd_active(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
|
||||
int smblib_get_prop_slave_current_now(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
|
||||
int smblib_init(struct smb_charger *chg);
|
||||
int smblib_deinit(struct smb_charger *chg);
|
||||
#endif /* __SMB2_CHARGER_H */
|
||||
|
|
|
@ -395,6 +395,7 @@ static enum power_supply_property smb138x_parallel_props[] = {
|
|||
POWER_SUPPLY_PROP_INPUT_SUSPEND,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_MAX,
|
||||
POWER_SUPPLY_PROP_CURRENT_MAX,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW,
|
||||
POWER_SUPPLY_PROP_CHARGER_TEMP,
|
||||
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
|
||||
};
|
||||
|
@ -431,6 +432,9 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
|
|||
rc = smblib_get_charge_param(chg, &chg->param.fcc,
|
||||
&val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CURRENT_NOW:
|
||||
rc = smblib_get_prop_slave_current_now(chg, val);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGER_TEMP:
|
||||
rc = smblib_get_prop_charger_temp(chg, val);
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue