Confusion regarding power devices: upower thinks the charger is a battery?
On Librem 5 Birch the upower -e
command shows the following four devices:
purism@pureos:~$ upower -e
/org/freedesktop/UPower/devices/line_power_tps6598x_source_psy_0_003f
/org/freedesktop/UPower/devices/battery_max170xx_battery
/org/freedesktop/UPower/devices/battery_bq25890_charger
/org/freedesktop/UPower/devices/DisplayDevice
That is different compared to other computers I tried it on, a few laptops and a PinePhone (Mobian), on all of those upower -e
lists only three devices: one battery, one line_power, and one DisplayDevice.
The last one, "DisplayDevice", seems to always exist but not be a device on its own but more like a clone of one of the other devices.
On the Librem 5 there is one "line_power" device but then there are two different devices starting with "battery", there is both "battery_max170xx_battery" and "battery_bq25890_charger".
The upower -d
command shows the following:
purism@pureos:~$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_tps6598x_source_psy_0_003f
native-path: tps6598x-source-psy-0-003f
power supply: yes
updated: Tue Mar 9 10:51:19 2021 (9792 seconds ago)
has history: no
has statistics: no
line-power
warning-level: none
online: yes
icon-name: 'ac-adapter-symbolic'
Device: /org/freedesktop/UPower/devices/battery_max170xx_battery
native-path: max170xx_battery
power supply: yes
updated: Tue Mar 9 13:33:20 2021 (71 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: fully-charged
warning-level: none
energy: 6.7815 Wh
energy-empty: 0 Wh
energy-full: 6.7848 Wh
energy-full-design: 6.6 Wh
energy-rate: 0.00447592 W
voltage: 4.16328 V
percentage: 99%
temperature: 37.9 degrees C
capacity: 100%
technology: lithium-ion
icon-name: 'battery-full-charged-symbolic'
Device: /org/freedesktop/UPower/devices/battery_bq25890_charger
native-path: bq25890-charger
vendor: Texas Instruments
model: BQ25895
power supply: yes
updated: Tue Mar 9 13:34:14 2021 (17 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: fully-charged
warning-level: none
energy: 0 Wh
energy-empty: 0 Wh
energy-full: 0 Wh
energy-full-design: 0 Wh
energy-rate: 0 W
voltage: 4.124 V
percentage: 0%
capacity: 100%
icon-name: 'battery-full-charged-symbolic'
Device: /org/freedesktop/UPower/devices/DisplayDevice
power supply: yes
updated: Tue Mar 9 13:31:20 2021 (192 seconds ago)
has history: no
has statistics: no
battery
present: yes
state: fully-charged
warning-level: none
energy: 6.7815 Wh
energy-full: 6.7848 Wh
energy-rate: 0.00447592 W
percentage: 99.9514%
icon-name: 'battery-full-charged-symbolic'
Daemon:
daemon-version: 0.99.10
on-battery: no
lid-is-closed: no
lid-is-present: no
critical-action: PowerOff
From the above it looks like upower thinks the "bq25890-charger" device is a battery. This seems wrong, a charger is not a battery?
The three devices (ignoring DisplayDevice) exist under /sys/devices/platform/soc@0/30800000.bus/
in the following places:
/sys/devices/platform/soc@0/30800000.bus/30a20000.i2c/i2c-0/0-003f/power_supply/tps6598x-source-psy-0-003f
/sys/devices/platform/soc@0/30800000.bus/30a50000.i2c/i2c-3/3-0036/power_supply/max170xx_battery
/sys/devices/platform/soc@0/30800000.bus/30a50000.i2c/i2c-3/3-006a/power_supply/bq25890-charger
and bq25890-charger
also exists in three more places under /sys/:
/sys/class/power_supply/bq25890-charger
/sys/bus/i2c/drivers/bq25890-charger
/sys/module/bq25890_charger/drivers/i2c:bq25890-charger
I think that on the Librem 5 upower should only list one battery device, is that correct or is there some reason why it is legitimate to consider the bq25890-charger device as a "battery"?
Why would upower think that the bq25890-charger device is a battery, where does that information come from?
If upower gets confused by this and makes wrong decisions about the charging state, then this may be related to https://source.puri.sm/Librem5/linux-next/-/issues/250 -- for example it looks like upower goes through its list of devices and it may decide that the overall state is "charging" if it finds one "battery" device in such a state, then if there is a false "battery" device that could maybe lead to upower showing a "charging" state even though the real battery is discharging.