Skip to content

Commit 826d6bb

Browse files
marcanjannau
authored andcommitted
power: supply: macsmc_power: Add cycle count and health props
Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 10b60d6 commit 826d6bb

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/power/supply/macsmc_power.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ static int macsmc_battery_get_property(struct power_supply *psy,
136136
ret = apple_smc_read_s64(power->smc, SMC_KEY(BAAC), &vs64);
137137
val->intval = vs64;
138138
break;
139+
case POWER_SUPPLY_PROP_CYCLE_COUNT:
140+
ret = apple_smc_read_u16(power->smc, SMC_KEY(B0CT), &vu16);
141+
val->intval = vu16;
142+
break;
143+
case POWER_SUPPLY_PROP_HEALTH:
144+
ret = apple_smc_read_flag(power->smc, SMC_KEY(BBAD));
145+
val->intval = ret == 1 ? POWER_SUPPLY_HEALTH_DEAD : POWER_SUPPLY_HEALTH_GOOD;
146+
ret = ret < 0 ? ret : 0;
147+
break;
139148
case POWER_SUPPLY_PROP_MODEL_NAME:
140149
val->strval = power->model_name;
141150
break;
@@ -167,6 +176,8 @@ static enum power_supply_property macsmc_battery_props[] = {
167176
POWER_SUPPLY_PROP_CHARGE_NOW,
168177
POWER_SUPPLY_PROP_TEMP,
169178
POWER_SUPPLY_PROP_CHARGE_COUNTER,
179+
POWER_SUPPLY_PROP_CYCLE_COUNT,
180+
POWER_SUPPLY_PROP_HEALTH,
170181
POWER_SUPPLY_PROP_MODEL_NAME,
171182
POWER_SUPPLY_PROP_SERIAL_NUMBER,
172183
};

0 commit comments

Comments
 (0)