summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/virtual_battery.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/virtual_battery.c b/common/virtual_battery.c
index e9d1c2811d..ef33a4c67a 100644
--- a/common/virtual_battery.c
+++ b/common/virtual_battery.c
@@ -177,6 +177,7 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
int write_len)
{
int val;
+ int year, month, day;
/*
* We cache battery operational mode locally for both read and write
* commands. If MODE_CAPACITY bit is set, battery capacity will be
@@ -300,6 +301,20 @@ int virtual_battery_operation(const uint8_t *batt_cmd_head,
return EC_ERROR_INVAL;
memcpy(dest, &val, bounded_read_len);
break;
+ case SB_MANUFACTURE_DATE:
+ /* This may cause an i2c transaction */
+ if (!battery_manufacture_date(&year, &month, &day)) {
+ /* Encode in Smart Battery Spec format */
+ val = ((year - 1980) << 9) + (month << 5) + day;
+ } else {
+ /*
+ * Return 0 on error. The kernel is unhappy with
+ * returning an error code.
+ */
+ val = 0;
+ }
+ memcpy(dest, &val, bounded_read_len);
+ break;
case SB_MANUFACTURER_ACCESS:
/* No manuf. access reg access allowed over VB interface */
return EC_ERROR_INVAL;