summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIkjoon Jang <ikjn@chromium.org>2021-03-10 12:43:17 +0800
committerCommit Bot <commit-bot@chromium.org>2021-09-11 01:19:56 +0000
commit12266aa3326520452f6754a075c39dd5c0e823ea (patch)
tree41245ced22c581b2b7615fcad733f1156260b4a8
parent836efc3c35afe0eef890f25b7e82a32d6f645e3d (diff)
downloadchrome-ec-12266aa3326520452f6754a075c39dd5c0e823ea.tar.gz
virtual_battery: add a few more properties
Recent version of kernel sbs-battery driver has properties currently unsupported by EC.This patch adds 4 more properties to remove annoying error messages from console: "power_supply sbs-12-000b: driver failed to report xxx" in kernel, "[3927380.033752 Unhandled VB reg 1b" in EC console. New properties added : - SB_AVERAGE_CURRENT(0xb): involves i2c transaction - SB_MAX_ERROR(0xc): returns a constant 3% - SB_CHARGING_CURRENT(0x14), SB_CHARGING_VOLTAGE(0x15): returns existing battery params BRANCH=none BUG=b:170921599 TEST=read properties from sbs sysfs knobs (current_avg capacity_error_margin constant_charge_current_max constant_charge_voltage_max) Change-Id: I681006899969da8466730eda155df935af22994f Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2747559 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> (cherry picked from commit ed5f46d3a7d931f6f2aed9ccfc2edbb4f0fb6576) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3153586 Commit-Queue: Brian Norris <briannorris@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org>
-rw-r--r--common/virtual_battery.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c
index 29e6e8ec7d..c2ebd35afd 100644
--- a/common/virtual_battery.c
+++ b/common/virtual_battery.c
@@ -244,6 +244,18 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
return EC_ERROR_BUSY;
memcpy(dest, &(curr_batt->current), bounded_read_len);
break;
+ case SB_AVERAGE_CURRENT:
+ /* This may cause an i2c transaction */
+ val = battery_get_avg_voltage();
+ if (val < 0)
+ return val;
+ memcpy(dest, &val, bounded_read_len);
+ break;
+ case SB_MAX_ERROR:
+ /* report as 3% to make kernel happy */
+ val = BATTERY_LEVEL_SHUTDOWN;
+ memcpy(dest, &val, bounded_read_len);
+ break;
case SB_FULL_CHARGE_CAPACITY:
if (curr_batt->flags & BATT_FLAG_BAD_FULL_CAPACITY ||
curr_batt->flags & BATT_FLAG_BAD_VOLTAGE)
@@ -304,6 +316,18 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
return EC_ERROR_INVAL;
memcpy(dest, &val, bounded_read_len);
break;
+ case SB_CHARGING_CURRENT:
+ if (curr_batt->flags & BATT_FLAG_BAD_DESIRED_CURRENT)
+ return EC_ERROR_BUSY;
+ val = curr_batt->desired_current;
+ memcpy(dest, &val, bounded_read_len);
+ break;
+ case SB_CHARGING_VOLTAGE:
+ if (curr_batt->flags & BATT_FLAG_BAD_DESIRED_VOLTAGE)
+ return EC_ERROR_BUSY;
+ val = curr_batt->desired_voltage;
+ memcpy(dest, &val, bounded_read_len);
+ break;
case SB_MANUFACTURE_DATE:
/* This may cause an i2c transaction */
if (!battery_manufacture_date(&year, &month, &day)) {