Commit 4a4748f2 authored by Marek Vasut's avatar Marek Vasut Committed by Sebastian Reichel

power: supply: bq25890: Add support for setting IINLIM

Let user set input current limit via sysfs. This is useful in case there
are multiple chargers connected to the device, each of which with its own
arbitrary maximum current which it can provide, some of which may provide
more than the default 500mA. In that case, userspace can listen for plug
events generated by each charger and adjust the current limit accordingly,
e.g. to permit battery to charge faster.

Note that the IINLIM is reset every time the bq25890 is disconnected from
a charger, so the userspace must adjust the limit repeatly on every plug
event.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 04f7c7df
...@@ -613,6 +613,33 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, ...@@ -613,6 +613,33 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
return 0; return 0;
} }
static int bq25890_power_supply_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{
struct bq25890_device *bq = power_supply_get_drvdata(psy);
u8 lval;
switch (psp) {
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
lval = bq25890_find_idx(val->intval, F_IINLIM);
return bq25890_field_write(bq, F_IINLIM, lval);
default:
return -EINVAL;
}
}
static int bq25890_power_supply_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{
switch (psp) {
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
return true;
default:
return false;
}
}
/* On the BQ25892 try to get charger-type info from our supplier */ /* On the BQ25892 try to get charger-type info from our supplier */
static void bq25890_charger_external_power_changed(struct power_supply *psy) static void bq25890_charger_external_power_changed(struct power_supply *psy)
{ {
...@@ -874,6 +901,8 @@ static const struct power_supply_desc bq25890_power_supply_desc = { ...@@ -874,6 +901,8 @@ static const struct power_supply_desc bq25890_power_supply_desc = {
.properties = bq25890_power_supply_props, .properties = bq25890_power_supply_props,
.num_properties = ARRAY_SIZE(bq25890_power_supply_props), .num_properties = ARRAY_SIZE(bq25890_power_supply_props),
.get_property = bq25890_power_supply_get_property, .get_property = bq25890_power_supply_get_property,
.set_property = bq25890_power_supply_set_property,
.property_is_writeable = bq25890_power_supply_property_is_writeable,
.external_power_changed = bq25890_charger_external_power_changed, .external_power_changed = bq25890_charger_external_power_changed,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment