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>
This commit is contained in:
Roman Kiryanov 2018-12-18 16:31:39 -08:00 committed by Sebastian Reichel
parent 02276af2fc
commit 2a7b0a29b3
1 changed files with 47 additions and 0 deletions

View File

@ -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)