aboutsummaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2018-12-18 16:31:39 -0800
committerSebastian Reichel <sebastian.reichel@collabora.com>2019-01-21 22:31:27 +0100
commit2a7b0a29b3752a08751ae723abf40c19435de387 (patch)
tree3cb1f3e3973c4ffe0b1de12a205838eeba669dbe /drivers/power
parent02276af2fcf809b00b1fc1aede7cae6f25849e4d (diff)
downloadlinux-stericsson-2a7b0a29b3752a08751ae723abf40c19435de387.tar.gz
drivers: power: supply: goldfish_battery: Add support for reading more properties
To comply with tests we need to support more power supply properties: POWER_SUPPLY_PROP_VOLTAGE_NOW POWER_SUPPLY_PROP_TEMP POWER_SUPPLY_PROP_CHARGE_COUNTER POWER_SUPPLY_PROP_CURRENT_NOW POWER_SUPPLY_PROP_CURRENT_AVG POWER_SUPPLY_PROP_CHARGE_FULL POWER_SUPPLY_PROP_CYCLE_COUNT POWER_SUPPLY_PROP_VOLTAGE_MAX POWER_SUPPLY_PROP_CURRENT_MAX Signed-off-by: Roman Kiryanov <rkir@google.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/goldfish_battery.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/power/supply/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c
index 382193fe63c4..ad969d9fc981 100644
--- a/drivers/power/supply/goldfish_battery.c
+++ b/drivers/power/supply/goldfish_battery.c
@@ -43,6 +43,15 @@ enum {
BATTERY_HEALTH = 0x10,
BATTERY_PRESENT = 0x14,
BATTERY_CAPACITY = 0x18,
+ BATTERY_VOLTAGE = 0x1C,
+ BATTERY_TEMP = 0x20,
+ BATTERY_CHARGE_COUNTER = 0x24,
+ BATTERY_VOLTAGE_MAX = 0x28,
+ BATTERY_CURRENT_MAX = 0x2C,
+ BATTERY_CURRENT_NOW = 0x30,
+ BATTERY_CURRENT_AVG = 0x34,
+ BATTERY_CHARGE_FULL_UAH = 0x38,
+ BATTERY_CYCLE_COUNT = 0x40,
BATTERY_STATUS_CHANGED = 1U << 0,
AC_STATUS_CHANGED = 1U << 1,
@@ -61,6 +70,12 @@ static int goldfish_ac_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_ONLINE:
val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_AC_ONLINE);
break;
+ case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_VOLTAGE_MAX);
+ break;
+ case POWER_SUPPLY_PROP_CURRENT_MAX:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_CURRENT_MAX);
+ break;
default:
ret = -EINVAL;
break;
@@ -91,6 +106,29 @@ static int goldfish_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_CAPACITY);
break;
+ case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_VOLTAGE);
+ break;
+ case POWER_SUPPLY_PROP_TEMP:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_TEMP);
+ break;
+ case POWER_SUPPLY_PROP_CHARGE_COUNTER:
+ val->intval = GOLDFISH_BATTERY_READ(data,
+ BATTERY_CHARGE_COUNTER);
+ break;
+ case POWER_SUPPLY_PROP_CURRENT_NOW:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_CURRENT_NOW);
+ break;
+ case POWER_SUPPLY_PROP_CURRENT_AVG:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_CURRENT_AVG);
+ break;
+ case POWER_SUPPLY_PROP_CHARGE_FULL:
+ val->intval = GOLDFISH_BATTERY_READ(data,
+ BATTERY_CHARGE_FULL_UAH);
+ break;
+ case POWER_SUPPLY_PROP_CYCLE_COUNT:
+ val->intval = GOLDFISH_BATTERY_READ(data, BATTERY_CYCLE_COUNT);
+ break;
default:
ret = -EINVAL;
break;
@@ -105,10 +143,19 @@ static enum power_supply_property goldfish_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_VOLTAGE_NOW,
+ POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_CHARGE_COUNTER,
+ POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_CURRENT_AVG,
+ POWER_SUPPLY_PROP_CHARGE_FULL,
+ POWER_SUPPLY_PROP_CYCLE_COUNT,
};
static enum power_supply_property goldfish_ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_VOLTAGE_MAX,
+ POWER_SUPPLY_PROP_CURRENT_MAX,
};
static irqreturn_t goldfish_battery_interrupt(int irq, void *dev_id)