From 771b693157b92049820f5161a0bf74d19de14e0b Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Wed, 15 Jul 2020 08:51:55 -0700 Subject: virtual_battery: Return manufacture date Newer kernels seem to request the date and if we don't have something here we get constant spam on the EC console saying "Unhandled VB reg 1b". Let's return the manufacture date in the Smart Battery Spec format, or 0 on error. BUG=b:160784792 TEST=No more spam. BRANCH=none Change-Id: I38e75d467d722b7f14ec74ec38ec68cebe6c8ed9 Signed-off-by: Douglas Anderson Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300459 --- common/virtual_battery.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; -- cgit v1.2.1