[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241208-cros_charge-control-v2-v1-3-8d168d0f08a3@weissschuh.net>
Date: Sun, 08 Dec 2024 15:59:28 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Thomas Weißschuh <thomas@...ssschuh.net>,
Benson Leung <bleung@...omium.org>, Guenter Roeck <groeck@...omium.org>,
Sebastian Reichel <sre@...nel.org>, Tzung-Bi Shih <tzungbi@...nel.org>
Cc: Thomas Koch <linrunner@....net>,
Sebastian Reichel <sebastian.reichel@...labora.com>,
chrome-platform@...ts.linux.dev, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Thomas Weißschuh <linux@...ssschuh.net>,
stable@...r.kernel.org
Subject: [PATCH 3/3] power: supply: cros_charge-control: hide start
threshold on v2 cmd
ECs implementing the v2 command will not stop charging when the end
threshold is reached. Instead they will begin discharging until the
start threshold is reached, leading to permanent charge and discharge
cycles. This defeats the point of the charge control mechanism.
Avoid the issue by hiding the start threshold on v2 systems.
Instead on those systems program the EC with start == end which forces
the EC to reach and stay at that level.
v1 does not support thresholds and v3 works correctly,
at least judging from the code.
Reported-by: Thomas Koch <linrunner@....net>
Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
Cc: stable@...r.kernel.org
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
drivers/power/supply/cros_charge-control.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
index 108b121db4423187fb65548396fb9195b8801006..9b0a7500296b4d7eb8cd53153e148926bb98aec1 100644
--- a/drivers/power/supply/cros_charge-control.c
+++ b/drivers/power/supply/cros_charge-control.c
@@ -139,6 +139,10 @@ static ssize_t cros_chctl_store_threshold(struct device *dev, struct cros_chctl_
return -EINVAL;
if (is_end_threshold) {
+ /* Start threshold is not exposed, use fixed value */
+ if (priv->cmd_version == 2)
+ priv->current_start_threshold = val == 100 ? 0 : val;
+
if (val < priv->current_start_threshold)
return -EINVAL;
priv->current_end_threshold = val;
@@ -234,12 +238,10 @@ static umode_t cros_chtl_attr_is_visible(struct kobject *kobj, struct attribute
{
struct cros_chctl_priv *priv = cros_chctl_attr_to_priv(attr, n);
- if (priv->cmd_version < 2) {
- if (n == CROS_CHCTL_ATTR_START_THRESHOLD)
- return 0;
- if (n == CROS_CHCTL_ATTR_END_THRESHOLD)
- return 0;
- }
+ if (n == CROS_CHCTL_ATTR_START_THRESHOLD && priv->cmd_version < 3)
+ return 0;
+ else if (n == CROS_CHCTL_ATTR_END_THRESHOLD && priv->cmd_version < 2)
+ return 0;
return attr->mode;
}
--
2.47.1
Powered by blists - more mailing lists