Skip to content

Commit 33088c0

Browse files
committed
power: supply: generic-adc-battery: add temperature support
Another typical thing to monitor via an ADC line is the battery temperature. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
1 parent 9489d1b commit 33088c0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/power/supply/generic-adc-battery.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum gab_chan_type {
3030
GAB_VOLTAGE = 0,
3131
GAB_CURRENT,
3232
GAB_POWER,
33+
GAB_TEMP,
3334
GAB_MAX_CHAN_TYPE
3435
};
3536

@@ -40,7 +41,8 @@ enum gab_chan_type {
4041
static const char *const gab_chan_name[] = {
4142
[GAB_VOLTAGE] = "voltage",
4243
[GAB_CURRENT] = "current",
43-
[GAB_POWER] = "power",
44+
[GAB_POWER] = "power",
45+
[GAB_TEMP] = "temperature",
4446
};
4547

4648
struct gab {
@@ -77,6 +79,7 @@ static const enum power_supply_property gab_dyn_props[] = {
7779
POWER_SUPPLY_PROP_VOLTAGE_NOW,
7880
POWER_SUPPLY_PROP_CURRENT_NOW,
7981
POWER_SUPPLY_PROP_POWER_NOW,
82+
POWER_SUPPLY_PROP_TEMP,
8083
};
8184

8285
static bool gab_charge_finished(struct gab *adc_bat)
@@ -115,6 +118,8 @@ static int gab_get_property(struct power_supply *psy,
115118
return read_channel(adc_bat, GAB_CURRENT, &val->intval);
116119
case POWER_SUPPLY_PROP_POWER_NOW:
117120
return read_channel(adc_bat, GAB_POWER, &val->intval);
121+
case POWER_SUPPLY_PROP_TEMP:
122+
return read_channel(adc_bat, GAB_TEMP, &val->intval);
118123
default:
119124
return -EINVAL;
120125
}

0 commit comments

Comments
 (0)