diff options
author | Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> | 2022-04-20 08:24:24 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-16 07:22:46 +0000 |
commit | e2b1b2bd8509555095385538a1a1b64dc5b4c2a4 (patch) | |
tree | 982e04c831106b90b19b3b39942fa15f48ddbb2e | |
parent | 3589d895838dc6a9e4883ff61fc0a69ca2881dd4 (diff) | |
download | chrome-ec-e2b1b2bd8509555095385538a1a1b64dc5b4c2a4.tar.gz |
virtual battery: Write manufacturer access command
Add battery command manufacturer data
BUG=b:228360450
BRANCH=kukui
TEST=make buildall
Run command "ectool i2cwrite 16 2 0x16 0x00 0x0001" on damu.
Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>
Change-Id: Ic560c76cf6ccffecf0f35f4d8d8d7abaa0a6bce2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3595399
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
(cherry picked from commit 197da82322401ec38a181b28fb00ff37e647440b)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3644558
Commit-Queue: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com>
Reviewed-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com>
Tested-by: Jacky Wang <jacky5_wang@pegatron.corp-partner.google.com>
-rw-r--r-- | common/virtual_battery.c | 9 | ||||
-rw-r--r-- | driver/battery/smart.c | 5 | ||||
-rw-r--r-- | include/battery.h | 8 |
3 files changed, 21 insertions, 1 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c index 19241d3ee0..fa821ccf7f 100644 --- a/common/virtual_battery.c +++ b/common/virtual_battery.c @@ -356,7 +356,14 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head, break; #endif case SB_MANUFACTURER_ACCESS: - /* No manuf. access reg access allowed over VB interface */ +#ifdef CONFIG_BATTERY_SMART + if ((write_len >= 2) && (write_len <= 3)) { + val = batt_cmd_head[1] | batt_cmd_head[2] << 8; + /* This may cause an i2c transaction */ + if (!battery_manufacturer_access(val)) + return EC_SUCCESS; + } +#endif return EC_ERROR_INVAL; case SB_SPECIFICATION_INFO: /* v1.1 without PEC, no scale factor to voltage and current */ diff --git a/driver/battery/smart.c b/driver/battery/smart.c index 9a53cb6cc6..a74ae7c9bf 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -323,6 +323,11 @@ int battery_manufacturer_data(char *data, int size) return sb_read_string(SB_MANUFACTURER_DATA, data, size); } +int battery_manufacturer_access(int cmd) +{ + return sb_write(SB_MANUFACTURER_ACCESS, cmd); +} + int battery_get_avg_current(void) { int current; diff --git a/include/battery.h b/include/battery.h index 3576299a77..f32b202d33 100644 --- a/include/battery.h +++ b/include/battery.h @@ -379,6 +379,14 @@ int battery_manufacturer_date(int *year, int *month, int *day); int battery_manufacturer_data(char *data, int size); /** + * Write battery manufacturer access. + * + * @param cmd Destiation for battery manufacturer access command. + * @retun non-zeor if error. + */ +int battery_manufacturer_access(int cmd); + +/** * Report the absolute difference between the highest and lowest cell voltage in * the battery pack, in millivolts. On error or unimplemented, returns '0'. */ |