Skip to content

Commit 5e08536

Browse files
committed
power: supply: macsmc_power: Add cycle count and health props
Signed-off-by: Hector Martin <[email protected]>
1 parent 4d782bf commit 5e08536

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
@@ -138,6 +138,15 @@ static int macsmc_battery_get_property(struct power_supply *psy,
138138
ret = apple_smc_read_s64(power->smc, SMC_KEY(BAAC), &vs64);
139139
val->intval = vs64;
140140
break;
141+
case POWER_SUPPLY_PROP_CYCLE_COUNT:
142+
ret = apple_smc_read_u16(power->smc, SMC_KEY(B0CT), &vu16);
143+
val->intval = vu16;
144+
break;
145+
case POWER_SUPPLY_PROP_HEALTH:
146+
ret = apple_smc_read_flag(power->smc, SMC_KEY(BBAD));
147+
val->intval = ret == 1 ? POWER_SUPPLY_HEALTH_DEAD : POWER_SUPPLY_HEALTH_GOOD;
148+
ret = ret < 0 ? ret : 0;
149+
break;
141150
case POWER_SUPPLY_PROP_MODEL_NAME:
142151
val->strval = power->model_name;
143152
break;
@@ -169,6 +178,8 @@ static enum power_supply_property macsmc_battery_props[] = {
169178
POWER_SUPPLY_PROP_CHARGE_NOW,
170179
POWER_SUPPLY_PROP_TEMP,
171180
POWER_SUPPLY_PROP_CHARGE_COUNTER,
181+
POWER_SUPPLY_PROP_CYCLE_COUNT,
182+
POWER_SUPPLY_PROP_HEALTH,
172183
POWER_SUPPLY_PROP_MODEL_NAME,
173184
POWER_SUPPLY_PROP_SERIAL_NUMBER,
174185
};

0 commit comments

Comments
 (0)