Commit 73633ccb authored by Hans de Goede's avatar Hans de Goede Committed by Sebastian Reichel

power: supply: bq24190_charger: Store ichg-max and vreg-max in bq24190_dev_info

Store ichg-max and vreg-max in bq24190_dev_info once from
bq24190_get_config() and drop the bq24190_charger_get_current_max() and
bq24190_charger_get_voltage_max() helpers.

This is a preparation patch for honoring the
constant_charge_current_max_ua and constant_charge_voltage_max_uv
values from power_supply_get_battery_info().
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent a314fae3
...@@ -165,6 +165,8 @@ struct bq24190_dev_info { ...@@ -165,6 +165,8 @@ struct bq24190_dev_info {
u16 sys_min; u16 sys_min;
u16 iprechg; u16 iprechg;
u16 iterm; u16 iterm;
u32 ichg_max;
u32 vreg_max;
struct mutex f_reg_lock; struct mutex f_reg_lock;
u8 f_reg; u8 f_reg;
u8 ss_reg; u8 ss_reg;
...@@ -977,15 +979,6 @@ static int bq24190_charger_get_current(struct bq24190_dev_info *bdi, ...@@ -977,15 +979,6 @@ static int bq24190_charger_get_current(struct bq24190_dev_info *bdi,
return 0; return 0;
} }
static int bq24190_charger_get_current_max(struct bq24190_dev_info *bdi,
union power_supply_propval *val)
{
int idx = ARRAY_SIZE(bq24190_ccc_ichg_values) - 1;
val->intval = bq24190_ccc_ichg_values[idx];
return 0;
}
static int bq24190_charger_set_current(struct bq24190_dev_info *bdi, static int bq24190_charger_set_current(struct bq24190_dev_info *bdi,
const union power_supply_propval *val) const union power_supply_propval *val)
{ {
...@@ -1024,15 +1017,6 @@ static int bq24190_charger_get_voltage(struct bq24190_dev_info *bdi, ...@@ -1024,15 +1017,6 @@ static int bq24190_charger_get_voltage(struct bq24190_dev_info *bdi,
return 0; return 0;
} }
static int bq24190_charger_get_voltage_max(struct bq24190_dev_info *bdi,
union power_supply_propval *val)
{
int idx = ARRAY_SIZE(bq24190_cvc_vreg_values) - 1;
val->intval = bq24190_cvc_vreg_values[idx];
return 0;
}
static int bq24190_charger_set_voltage(struct bq24190_dev_info *bdi, static int bq24190_charger_set_voltage(struct bq24190_dev_info *bdi,
const union power_supply_propval *val) const union power_supply_propval *val)
{ {
...@@ -1109,13 +1093,15 @@ static int bq24190_charger_get_property(struct power_supply *psy, ...@@ -1109,13 +1093,15 @@ static int bq24190_charger_get_property(struct power_supply *psy,
ret = bq24190_charger_get_current(bdi, val); ret = bq24190_charger_get_current(bdi, val);
break; break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
ret = bq24190_charger_get_current_max(bdi, val); val->intval = bdi->ichg_max;
ret = 0;
break; break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
ret = bq24190_charger_get_voltage(bdi, val); ret = bq24190_charger_get_voltage(bdi, val);
break; break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
ret = bq24190_charger_get_voltage_max(bdi, val); val->intval = bdi->vreg_max;
ret = 0;
break; break;
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
ret = bq24190_charger_get_iinlimit(bdi, val); ret = bq24190_charger_get_iinlimit(bdi, val);
...@@ -1682,7 +1668,13 @@ static int bq24190_get_config(struct bq24190_dev_info *bdi) ...@@ -1682,7 +1668,13 @@ static int bq24190_get_config(struct bq24190_dev_info *bdi)
{ {
const char * const s = "ti,system-minimum-microvolt"; const char * const s = "ti,system-minimum-microvolt";
struct power_supply_battery_info *info; struct power_supply_battery_info *info;
int v; int v, idx;
idx = ARRAY_SIZE(bq24190_ccc_ichg_values) - 1;
bdi->ichg_max = bq24190_ccc_ichg_values[idx];
idx = ARRAY_SIZE(bq24190_cvc_vreg_values) - 1;
bdi->vreg_max = bq24190_cvc_vreg_values[idx];
if (device_property_read_u32(bdi->dev, s, &v) == 0) { if (device_property_read_u32(bdi->dev, s, &v) == 0) {
v /= 1000; v /= 1000;
......
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