summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-07-15 14:38:30 -0700
committerCommit Bot <commit-bot@chromium.org>2021-09-11 01:19:39 +0000
commit357bd977d1bdc5dd61a2a1fcc6f08ee6f97de6d0 (patch)
tree96829ca2544f255000c6320e2285763bd9bf45d0
parent5935d7e39fd7c8647970f3dfefeb11b81002f994 (diff)
downloadchrome-ec-357bd977d1bdc5dd61a2a1fcc6f08ee6f97de6d0.tar.gz
battery: Fix obtaining battery manufacture date
* Fix the typo: should be SB_MANUFACTURE_DATE (manufacture without r) * Fix the register, i.e. SB_MANUFACTURE_DATE, not SB_SPECIFICATION_INFO * Fix the format parsing. The LSB of year is bit-9, not bit-8. BRANCH=None BUG=b:160784792 TEST=With the later CL, checked the manufacture date. Change-Id: I5b5f2bfefec4bbe700bb1ec0d9d6048123f4ad16 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300688 Reviewed-by: Douglas Anderson <dianders@chromium.org> (cherry picked from commit a5a82418126ee6cadff69d9487c43edc1ccea097) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3154563 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Brian Norris <briannorris@chromium.org> Tested-by: Brian Norris <briannorris@chromium.org>
-rw-r--r--driver/battery/smart.c10
-rw-r--r--include/battery_smart.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/driver/battery/smart.c b/driver/battery/smart.c
index 743ebc1ee1..2c67de9030 100644
--- a/driver/battery/smart.c
+++ b/driver/battery/smart.c
@@ -251,16 +251,16 @@ test_mockable int battery_manufacture_date(int *year, int *month, int *day)
int rv;
int ymd;
- rv = sb_read(SB_SPECIFICATION_INFO, &ymd);
+ rv = sb_read(SB_MANUFACTURE_DATE, &ymd);
if (rv)
return rv;
/* battery date format:
- * ymd = day + month * 32 + (year - 1980) * 256
+ * ymd = day + month * 32 + (year - 1980) * 512
*/
- *year = (ymd >> 8) + 1980;
- *month = (ymd & 0xff) / 32;
- *day = (ymd & 0xff) % 32;
+ *year = (ymd >> 9) + 1980;
+ *month = (ymd >> 5) & 0xf;
+ *day = ymd & 0x1f;
return EC_SUCCESS;
}
diff --git a/include/battery_smart.h b/include/battery_smart.h
index 1cbcf295f1..713a1059a1 100644
--- a/include/battery_smart.h
+++ b/include/battery_smart.h
@@ -50,7 +50,7 @@
#define SB_DESIGN_CAPACITY 0x18
#define SB_DESIGN_VOLTAGE 0x19
#define SB_SPECIFICATION_INFO 0x1a
-#define SB_MANUFACTURER_DATE 0x1b
+#define SB_MANUFACTURE_DATE 0x1b
#define SB_SERIAL_NUMBER 0x1c
#define SB_MANUFACTURER_NAME 0x20
#define SB_DEVICE_NAME 0x21