Skip to content

Commit 8ce6ee4

Browse files
committed
power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support
Expose averaged current information, which is part of the SBS standard and should be supported by all batteries. Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 79bcd5a commit 8ce6ee4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/power/supply/sbs-battery.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ enum {
2525
REG_MANUFACTURER_DATA,
2626
REG_TEMPERATURE,
2727
REG_VOLTAGE,
28-
REG_CURRENT,
28+
REG_CURRENT_NOW,
29+
REG_CURRENT_AVG,
2930
REG_MAX_ERR,
3031
REG_CAPACITY,
3132
REG_TIME_TO_EMPTY,
@@ -92,8 +93,10 @@ static const struct chip_data {
9293
SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535),
9394
[REG_VOLTAGE] =
9495
SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000),
95-
[REG_CURRENT] =
96+
[REG_CURRENT_NOW] =
9697
SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767),
98+
[REG_CURRENT_AVG] =
99+
SBS_DATA(POWER_SUPPLY_PROP_CURRENT_AVG, 0x0B, -32768, 32767),
97100
[REG_MAX_ERR] =
98101
SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, 0x0c, 0, 100),
99102
[REG_CAPACITY] =
@@ -142,6 +145,7 @@ static enum power_supply_property sbs_properties[] = {
142145
POWER_SUPPLY_PROP_CYCLE_COUNT,
143146
POWER_SUPPLY_PROP_VOLTAGE_NOW,
144147
POWER_SUPPLY_PROP_CURRENT_NOW,
148+
POWER_SUPPLY_PROP_CURRENT_AVG,
145149
POWER_SUPPLY_PROP_CAPACITY,
146150
POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN,
147151
POWER_SUPPLY_PROP_TEMP,
@@ -324,7 +328,7 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
324328
{
325329
int ret;
326330

327-
ret = sbs_read_word_data(client, sbs_data[REG_CURRENT].addr);
331+
ret = sbs_read_word_data(client, sbs_data[REG_CURRENT_NOW].addr);
328332
if (ret < 0)
329333
return ret;
330334

@@ -521,6 +525,7 @@ static void sbs_unit_adjustment(struct i2c_client *client,
521525
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
522526
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
523527
case POWER_SUPPLY_PROP_CURRENT_NOW:
528+
case POWER_SUPPLY_PROP_CURRENT_AVG:
524529
case POWER_SUPPLY_PROP_CHARGE_NOW:
525530
case POWER_SUPPLY_PROP_CHARGE_FULL:
526531
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
@@ -699,6 +704,7 @@ static int sbs_get_property(struct power_supply *psy,
699704
case POWER_SUPPLY_PROP_CYCLE_COUNT:
700705
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
701706
case POWER_SUPPLY_PROP_CURRENT_NOW:
707+
case POWER_SUPPLY_PROP_CURRENT_AVG:
702708
case POWER_SUPPLY_PROP_TEMP:
703709
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
704710
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:

0 commit comments

Comments
 (0)