Project

General

Profile

Actions

Issue #2125

open
DC

Report battery % / charging

Issue #2125: Report battery % / charging

Added by Denis 'GNUtoo' Carikli almost 6 years ago. Updated almost 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
09/14/2020
Due date:
% Done:

0%

Estimated time:
Resolution:
Device:
Galaxy S 3 (I9300), Unknown
Grant:
Type of work:
C programming

VS Updated by Victor Shilin over 5 years ago Actions #1

The battery driver needs to use VF SOC register in order to report the charge percentage correctly (the following patch by Wolfgang Wiedmeyer made this work on Replicant 11: https://github.com/fourkbomb/linux/commit/7da07efcb2efc5df8fd7ab0be01a7b0b7a483998).
The charger driver reports "Discharging" (in the status sysfs node) even when the cable is connected (the "online" sysfs node, however, is showing the value "1").
I tried to force the "status" node to return "Charging" instead (whenever the "online" node reports value "1"), but this didn't help (need to investigate how exactly the healthd service detects charging).

KH Updated by Kurtis Hanna over 5 years ago Actions #2

Not sure if this helps at all, but here is a max17047 related commit from upstream that was added a few months ago. https://patchwork.kernel.org/project/linux-samsung-soc/patch/20201210212534.216197-3-krzk@kernel.org/

_R Updated by _I3^ RELATIVISM over 5 years ago Actions #3

  • Type of work C programming added

VS Updated by Victor Shilin over 5 years ago Actions #4

healthd service detected device charging after setting the charger driver type from POWER_SUPPLY_TYPE_BATTERY to POWER_SUPPLY_TYPE_MAINS:
https://github.com/Midas-Mainline/android_kernel_samsung_smdk4412/commit/f91cadd693f173d671f15a6d9386dcb2a033f5b2

Not sure if this the correct way to resolve the issue, though.
smdk4412 kernel instead use "samsung_fake_battery" driver to create "usb" and "ac" power supplies:
https://github.com/LineageOS/android_kernel_samsung_smdk4412/blob/lineage-17.0/drivers/power/samsung_fake_battery.c#L339

KH Updated by Kurtis Hanna about 5 years ago Actions #5

It looks like postmarketOS has recently been trying to solve this issue, but have run up against some issues: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/2423

KH Updated by Kurtis Hanna almost 5 years ago Actions #6

This patch, which is a v2 of an old Wolfgang patch, was just submitted upstream which claims to cause the i9300 to provide an accurate State of Charge value at all times. https://lore.kernel.org/linux-pm/20210919200735.142862-2-henrik@grimler.se/T/

HG Updated by Henrik Grimler almost 5 years ago Actions #7

For the record: the v2 of Wolfgangs patch is needed since RepSOC does not return anything reasonable for i9300/i9305, since it does not have a current sense resistor. We also need the POWER_SUPPLY_TYPE_BATTERY->POWER_SUPPLY_TYPE_MAINS patch mentioned above for the UI to show something reasonable (otherwise the device think there are two power sources it seems). Together with some other Replicant patches [1] the battery can be charged and % reported correctly (but there are some quirks that stills needs to be worked out, data transfer to the phone does not seem to be possible while it is charging for example).

[1] https://gitlab.com/postmarketOS/pmaports/-/tree/ed1e314287aebc6c9f7e623411880fba7afece65/main/linux-postmarketos-exynos4

Actions

Also available in: PDF Atom