summaryrefslogtreecommitdiff
path: root/common/virtual_battery.c
diff options
context:
space:
mode:
authorMichael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>2022-04-13 13:25:54 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-14 10:31:39 +0000
commit4efe01202e6c8e5681c953732ebf3ada539c8804 (patch)
tree6881f036b4c5bf9d840b78beb9e74a9630d7ab8b /common/virtual_battery.c
parentd1c5c1c0d5b74bb011a9f76d3a89d90ea3373275 (diff)
downloadchrome-ec-4efe01202e6c8e5681c953732ebf3ada539c8804.tar.gz
virtual_battery: Return manufacturer data
Add battery command manufacturer data BUG=b:228360450 BRANCH=kukui TEST=make buildall Run command "ectool i2cxfer 2 0x0b 0x05 0x23" on damu Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> Change-Id: Iab93801e28b0d6f32cb257c19573e6dfbdc3c3bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3583910 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'common/virtual_battery.c')
-rw-r--r--common/virtual_battery.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c
index db7e34ced6..33e014d68e 100644
--- a/common/virtual_battery.c
+++ b/common/virtual_battery.c
@@ -187,6 +187,9 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
{
int val;
int year, month, day;
+#ifdef CONFIG_BATTERY_SMART
+ char str[32];
+#endif
/*
* We cache battery operational mode locally for both read and write
* commands. If MODE_CAPACITY bit is set, battery capacity will be
@@ -382,6 +385,16 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
}
memcpy(dest, &val, bounded_read_len);
break;
+#ifdef CONFIG_BATTERY_SMART
+ case SB_MANUFACTURER_DATA:
+ if (read_len > ARRAY_SIZE(str))
+ return EC_ERROR_INVAL;
+ /* This may cause an i2c transaction */
+ if (battery_manufacturer_data(str, ARRAY_SIZE(str)))
+ return EC_ERROR_INVAL;
+ memcpy(dest, &str, read_len);
+ break;
+#endif
case SB_MANUFACTURER_ACCESS:
/* No manuf. access reg access allowed over VB interface */
return EC_ERROR_INVAL;