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-04-25 09:29:26 +0000 |
commit | 48244ca29a8cb18530162f1fd17c003bcbc1abd4 (patch) | |
tree | 84243b0c82a09a6a44feeb7c79cd04d020f05193 | |
parent | c67a30cf4f30c48d08b684c449cb1092db09cebf (diff) | |
download | chrome-ec-48244ca29a8cb18530162f1fd17c003bcbc1abd4.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/+/3601921
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
-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 29abe65f32..286fbd68b5 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -322,6 +322,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 35b3d502ce..856b16e732 100644 --- a/include/battery.h +++ b/include/battery.h @@ -368,6 +368,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'. */ |