diff options
author | Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> | 2022-04-20 11:06:43 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-17 09:28:59 +0000 |
commit | 8cc7f551ac8fdc6acdd5e457a87857e99a085e46 (patch) | |
tree | ce0f5d6330823e870fbd9edaf4e410f78d4b7e35 | |
parent | 1a2d2a5222f487e87ac1281aaf967cc7b2bbe006 (diff) | |
download | chrome-ec-8cc7f551ac8fdc6acdd5e457a87857e99a085e46.tar.gz |
virtual_battery: Support Battery MFG function and manufacture info
Add Battery MFG function and manufacture info (0x70)
BUG=b:228360450
BRANCH=kukui
TEST=make BOARD=damu
Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>
Change-Id: I81c73c468de170dac1ef141514cabbc30bf97536
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3595402
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
(cherry picked from commit 7d03da76a7360483a00c499532cac0c3375067c3)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3644394
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | common/virtual_battery.c | 16 | ||||
-rw-r--r-- | include/battery_smart.h | 5 | ||||
-rw-r--r-- | include/config.h | 6 |
3 files changed, 27 insertions, 0 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c index fa821ccf7f..0f07482e09 100644 --- a/common/virtual_battery.c +++ b/common/virtual_battery.c @@ -354,6 +354,12 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head, return EC_ERROR_INVAL; memcpy(dest, &str, read_len); break; + + case SB_MANUFACTURE_INFO: + if (sb_read_string(*batt_cmd_head, str, sizeof(str))) + return EC_ERROR_INVAL; + memcpy(dest, &str, MIN(read_len, sizeof(str))); + break; #endif case SB_MANUFACTURER_ACCESS: #ifdef CONFIG_BATTERY_SMART @@ -370,6 +376,16 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head, val = 0x0011; memcpy(dest, &val, bounded_read_len); break; +#ifdef CONFIG_SMART_BATTERY_OPTIONAL_MFG_FUNC + case SB_OPTIONAL_MFG_FUNC1: + case SB_OPTIONAL_MFG_FUNC2: + case SB_OPTIONAL_MFG_FUNC3: + case SB_OPTIONAL_MFG_FUNC4: + if (sb_read(*batt_cmd_head, &val)) + return EC_ERROR_INVAL; + memcpy(dest, &val, bounded_read_len); + break; +#endif default: CPRINTS("Unhandled VB reg %x", *batt_cmd_head); return EC_ERROR_INVAL; diff --git a/include/battery_smart.h b/include/battery_smart.h index 635ac8558a..243f4515e3 100644 --- a/include/battery_smart.h +++ b/include/battery_smart.h @@ -56,9 +56,14 @@ #define SB_DEVICE_NAME 0x21 #define SB_DEVICE_CHEMISTRY 0x22 #define SB_MANUFACTURER_DATA 0x23 +#define SB_OPTIONAL_MFG_FUNC1 0x3C +#define SB_OPTIONAL_MFG_FUNC2 0x3D +#define SB_OPTIONAL_MFG_FUNC3 0x3E +#define SB_OPTIONAL_MFG_FUNC4 0x3F /* Extension of smart battery spec, may not be supported on all platforms */ #define SB_PACK_STATUS 0x43 #define SB_ALT_MANUFACTURER_ACCESS 0x44 +#define SB_MANUFACTURE_INFO 0x70 /* Battery mode */ #define MODE_INTERNAL_CHARGE_CONTROLLER BIT(0) diff --git a/include/config.h b/include/config.h index 486bd9757a..80642c99c5 100644 --- a/include/config.h +++ b/include/config.h @@ -2216,6 +2216,12 @@ #undef CONFIG_I2C_VIRTUAL_BATTERY /* + * Define this configuration to support smart battery MFG function + * for virtual battery. + */ +#undef CONFIG_SMART_BATTERY_OPTIONAL_MFG_FUNC + +/* * Define this option if an i2c bus may be unpowered at a certain point during * runtime. An example could be, a sensor bus which is not needed in lower * power states so the power rail for those sensors is completely disabled. |