summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/virtual_battery.c16
-rw-r--r--include/battery_smart.h5
-rw-r--r--include/config.h6
-rw-r--r--zephyr/Kconfig.battery10
-rw-r--r--zephyr/shim/include/config_chip.h4
5 files changed, 41 insertions, 0 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c
index ae86f51d53..8e88e22bcb 100644
--- a/common/virtual_battery.c
+++ b/common/virtual_battery.c
@@ -394,6 +394,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
@@ -410,6 +416,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 9b373f7c8a..dc0679dff0 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 478e6dc708..100cd12020 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2633,6 +2633,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.
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index d069faf57e..7b3f20da38 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -247,4 +247,14 @@ config PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT
must call battery_set_fixed_battery_type() to set the fixed battery
type, during board initialization.
+if PLATFORM_EC_I2C_VIRTUAL_BATTERY
+
+config PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC
+ bool "Support smart battery optional MFG function"
+ help
+ Enable this option when need support smart battery optional commands.
+ Only make sense when PLATFORM_EC_I2C_VIRTUAL_BATTERY.
+
+endif # PLATFORM_EC_I2C_VIRTUAL_BATTERY
+
endif # PLATFORM_EC_BATTERY
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index ef6f7162f3..f11ec4c507 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -210,9 +210,13 @@
#undef CONFIG_I2C_VIRTUAL_BATTERY
#undef I2C_PORT_VIRTUAL_BATTERY
+#undef CONFIG_SMART_BATTERY_OPTIONAL_MFG_FUNC
#ifdef CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY
#define CONFIG_I2C_VIRTUAL_BATTERY
#define VIRTUAL_BATTERY_ADDR_FLAGS CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY_ADDR
+#ifdef CONFIG_PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC
+#define CONFIG_SMART_BATTERY_OPTIONAL_MFG_FUNC
+#endif
#endif
#undef CONFIG_I2C_PASSTHRU_RESTRICTED