Commit 0a872b7
chgstv2: Add battery sustainer
This patch adds the battery sustainer. Given a target SoC by the host,
the sustainer will try to keep the SoC stay close within the range
near the target.
The diagram below shows how the sustainer uses the charge mode to
charge or discharge the battery as the SoC moves near the target:
T-d% T%
----------|----------------------|-----------
charge normally charge normally/slowly
(mode=NORMAL)
... ----> +--------------------->
| |
<----------------------+ <----- ...
discharge naturally discharge normally
(mode=IDLE) (mode=DISCHARGE)
When AC is unplugged, the sustainer is disabled. Currently, the
sustainer requires CONFIG_CHARGER_DISCHARGE_ON_AC.
> chgstate
state_of_charge = 69%
chg_ctl_mode = NORMAL
manual_voltage = -1
manual_current = -1
Battery sustainer = off (-1% ~ -1%)
> chgstate sustain 70 72
state_of_charge = 69%
chg_ctl_mode = NORMAL
manual_voltage = -1
manual_current = -1
Battery sustainer = on (70% ~ 72%)
> battfake 71
> chgstate
state_of_charge = 71%
chg_ctl_mode = NORMAL
> battfake 73
> chgstate
state_of_charge = 73%
chg_ctl_mode = DISCHARGE
manual_voltage = -1
manual_current = -1
> battfake 71
> chgstate
state_of_charge = 71%
chg_ctl_mode = IDLE
manual_voltage = 0
manual_current = 0
Unplug AC and EC keeps running.
> chgstate
state_of_charge = 73%
chg_ctl_mode = DISCHARGE
manual_voltage = -1
manual_current = -1
Replug AC.
> chgstate
state_of_charge = 73%
chg_ctl_mode = DISCHARGE
manual_voltage = 0
manual_current = 0
BUG=b:188457962
BRANCH=None
TEST=Atlas. See the description above.
Change-Id: I62b4e8bc9517900a5a32d2f35369c645fa8a60c3
Signed-off-by: Daisuke Nojiri <[email protected]>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929347
Reviewed-by: Vincent Palatin <[email protected]>1 parent 7d875de commit 0a872b7
1 file changed
+47
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
1123 | 1127 | | |
1124 | 1128 | | |
1125 | 1129 | | |
| |||
1180 | 1184 | | |
1181 | 1185 | | |
1182 | 1186 | | |
1183 | | - | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
1184 | 1190 | | |
1185 | 1191 | | |
1186 | 1192 | | |
| |||
1667 | 1673 | | |
1668 | 1674 | | |
1669 | 1675 | | |
1670 | | - | |
| 1676 | + | |
1671 | 1677 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
1675 | 1681 | | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
1679 | | - | |
1680 | | - | |
1681 | | - | |
1682 | | - | |
1683 | | - | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
1684 | 1686 | | |
1685 | | - | |
1686 | | - | |
1687 | | - | |
| 1687 | + | |
1688 | 1688 | | |
1689 | | - | |
1690 | | - | |
1691 | | - | |
1692 | | - | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
1693 | 1709 | | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
| 1710 | + | |
1699 | 1711 | | |
1700 | 1712 | | |
1701 | | - | |
1702 | | - | |
1703 | | - | |
1704 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1705 | 1717 | | |
1706 | 1718 | | |
1707 | 1719 | | |
| |||
1720 | 1732 | | |
1721 | 1733 | | |
1722 | 1734 | | |
1723 | | - | |
| 1735 | + | |
1724 | 1736 | | |
1725 | 1737 | | |
1726 | 1738 | | |
| |||
1865 | 1877 | | |
1866 | 1878 | | |
1867 | 1879 | | |
1868 | | - | |
| 1880 | + | |
1869 | 1881 | | |
1870 | 1882 | | |
1871 | 1883 | | |
| |||
2988 | 3000 | | |
2989 | 3001 | | |
2990 | 3002 | | |
2991 | | - | |
| 3003 | + | |
2992 | 3004 | | |
2993 | 3005 | | |
2994 | 3006 | | |
| |||
3001 | 3013 | | |
3002 | 3014 | | |
3003 | 3015 | | |
3004 | | - | |
| 3016 | + | |
3005 | 3017 | | |
3006 | 3018 | | |
3007 | 3019 | | |
| |||
0 commit comments