Commit 5fc55bc8225d5a5c13b978e3e3dbf51e6cd6a333

Authored by Ramakrishna Pallala
Committed by Anton Vorontsov
1 parent 19dd6bcd11

max17042_battery: Support CHARGE_COUNTER power supply attribute

This patch adds the support for CHARGE_COUNTER power supply attribute
to max17042/47 driver.

Note:QH(Charge Counter) register is not documented in max17042 the Spec.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>

Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff

drivers/power/max17042_battery.c
... ... @@ -113,6 +113,7 @@
113 113 POWER_SUPPLY_PROP_VOLTAGE_OCV,
114 114 POWER_SUPPLY_PROP_CAPACITY,
115 115 POWER_SUPPLY_PROP_CHARGE_FULL,
  116 + POWER_SUPPLY_PROP_CHARGE_COUNTER,
116 117 POWER_SUPPLY_PROP_TEMP,
117 118 POWER_SUPPLY_PROP_CURRENT_NOW,
118 119 POWER_SUPPLY_PROP_CURRENT_AVG,
... ... @@ -196,6 +197,13 @@
196 197 break;
197 198 case POWER_SUPPLY_PROP_CHARGE_FULL:
198 199 ret = max17042_read_reg(chip->client, MAX17042_FullCAP);
  200 + if (ret < 0)
  201 + return ret;
  202 +
  203 + val->intval = ret * 1000 / 2;
  204 + break;
  205 + case POWER_SUPPLY_PROP_CHARGE_COUNTER:
  206 + ret = max17042_read_reg(chip->client, MAX17042_QH);
199 207 if (ret < 0)
200 208 return ret;
201 209