summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2022-09-19 11:29:56 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-21 00:40:38 +0000
commit2776eb7a6294fcb360124355a7bab59aa4bc888c (patch)
tree4f97f665793c9133ff8b5681bacdd5232143d503
parentf259d9e4426beba5429c7b87ab78d160780ca946 (diff)
downloadchrome-ec-2776eb7a6294fcb360124355a7bab59aa4bc888c.tar.gz
test: virtual_battery: Manufacture Info SB ext cmd
Verify the virtual_battery code appropriately responds to a manufacture info extended smart battery spec command. BRANCH=none BUG=b:246652125 TEST=./twister --clobber -i -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: Ibc316a052b26364110b7b8a3712af1ce466cc8f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3905884 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/dts/bindings/emul/zephyr,smart-battery.yaml6
-rw-r--r--zephyr/emul/emul_smart_battery.c7
-rw-r--r--zephyr/include/emul/emul_smart_battery.h4
-rw-r--r--zephyr/test/drivers/default/src/virtual_battery.c7
4 files changed, 21 insertions, 3 deletions
diff --git a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml b/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
index 82bad83db1..4c46fd4f64 100644
--- a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
+++ b/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
@@ -153,3 +153,9 @@ properties:
required: false
default: "LION"
description: Manufacturer data. Length has to be smaller than 32 bytes.
+
+ mf-info:
+ type: string
+ required: false
+ default: "LION"
+ description: Manufacturer info. Length has to be smaller than 32 bytes.
diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c
index 9b8774d099..b3e8d62bcc 100644
--- a/zephyr/emul/emul_smart_battery.c
+++ b/zephyr/emul/emul_smart_battery.c
@@ -486,6 +486,10 @@ int sbat_emul_get_block_data(const struct emul *emul, int cmd, uint8_t **blk,
*blk = bat->mf_data;
*len = bat->mf_data_len;
return 0;
+ case SB_MANUFACTURE_INFO:
+ *blk = bat->mf_info;
+ *len = bat->mf_info_len;
+ return 0;
default:
/* Unknown command or return value is not word */
return 1;
@@ -844,6 +848,9 @@ static int sbat_emul_init(const struct emul *emul, const struct device *parent)
.dev_chem = DT_INST_PROP(n, dev_chem), \
.dev_chem_len = sizeof( \
DT_INST_PROP(n, dev_chem)) - 1, \
+ .mf_info = DT_INST_PROP(n, mf_info), \
+ .mf_info_len = sizeof( \
+ DT_INST_PROP(n, mf_info)) - 1, \
.mf_date = 0, \
.cap_alarm = 0, \
.time_alarm = 0, \
diff --git a/zephyr/include/emul/emul_smart_battery.h b/zephyr/include/emul/emul_smart_battery.h
index 4ff9d4a613..826e817992 100644
--- a/zephyr/include/emul/emul_smart_battery.h
+++ b/zephyr/include/emul/emul_smart_battery.h
@@ -119,6 +119,10 @@ struct sbat_emul_bat_data {
uint8_t mf_data[MAX_BLOCK_SIZE];
/** Manufacturer data length */
int mf_data_len;
+ /** Manufacture info */
+ uint8_t mf_info[MAX_BLOCK_SIZE];
+ /** Manufacture info length */
+ int mf_info_len;
};
/**
diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c
index 51419944f3..0e69c641a5 100644
--- a/zephyr/test/drivers/default/src/virtual_battery.c
+++ b/zephyr/test/drivers/default/src/virtual_battery.c
@@ -236,9 +236,10 @@ ZTEST_USER(virtual_battery, test_read_regs)
zassert_mem_equal(str, bat->mf_data, bat->mf_data_len, "%s != %s", str,
bat->mf_data);
- /*
- * TODO(b/247103618): Verify manufacturer info extended SB spec command
- */
+ /* At present, this command is used nowhere in our codebase. */
+ virtual_battery_read_data(SB_MANUFACTURE_INFO, &str, bat->mf_info_len);
+ zassert_mem_equal(str, bat->mf_info, bat->mf_info_len, "%s != %s", str,
+ bat->mf_info);
}
ZTEST_USER(virtual_battery, test_write_mfgacc)