summaryrefslogtreecommitdiff
path: root/driver/charger
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2023-02-22 16:33:40 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-20 19:29:11 +0000
commit312f806c07106e61b5b19489999ca627b3e722b2 (patch)
treef6f1ad9aefed8917034a611af0c1d74a8307d7f6 /driver/charger
parent5320de037e67eb119f11c1cbb7a62faa089909c6 (diff)
downloadchrome-ec-312f806c07106e61b5b19489999ca627b3e722b2.tar.gz
Reland "zephyr/tests: emulator and tests for sm5803"
This is a reland of commit fd2415cda6a261b92390aad04829f46f33ffc9e6, with sleeps in test_lpm increased from 4 to 10 seconds. This seems to fix the flakiness that was observed, verified with no failures over 8 CQ builds. Original change's description: > zephyr/tests: emulator and tests for sm5803 > > This implements an emulator and some tests for the SM5803 charger. The > current tests do not exercise the driver as comprehensively as intended, > but those will be added in a later change. > > One discovered bug in the driver is fixed, where some interrupts were > disabled immediately after being enabled. > > BUG=b:242544165 > TEST=twister -ciC -s drivers/drivers.sm5803 > BRANCH=nissa > > Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 > Reviewed-by: Tristan Honscheid <honscheid@google.com> BUG=b:242544165,b:278890420 TEST=`bb add chromeos/cq/firmware-zephyr-cov-cq -commit https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846` 8 times, verified success for all builds. Change-Id: Ifd0d486a45be2242023e6efba6457e7907aaedd2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Tested-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'driver/charger')
-rw-r--r--driver/charger/sm5803.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index 57b1a0330f..ec7132fb35 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -44,7 +44,7 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
#define UNKNOWN_DEV_ID -1
-static int dev_id = UNKNOWN_DEV_ID;
+test_export_static int dev_id = UNKNOWN_DEV_ID;
static const struct charger_info sm5803_charger_info = {
.name = CHARGER_NAME,
@@ -435,7 +435,7 @@ enum ec_error_list sm5803_vbus_sink_enable(int chgnum, int enable)
* Track and store whether we've initialized the charger chips already on this
* boot. This should prevent us from re-running inits after sysjumps.
*/
-static bool chip_inited[CHARGER_NUM];
+test_export_static bool chip_inited[CHARGER_NUM];
#define SM5803_SYSJUMP_TAG 0x534D /* SM */
#define SM5803_HOOK_VERSION 1
@@ -734,15 +734,13 @@ static void sm5803_init(int chgnum)
SM5803_TINT_MIN_LEVEL);
/*
- * Configure VBAT_SNSP high interrupt to fire after thresholds are set.
+ * Configure VBAT_SNSP high and TINT interrupts to fire after
+ * thresholds are set.
*/
rv |= main_read8(chgnum, SM5803_REG_INT2_EN, &reg);
- reg |= SM5803_INT2_VBATSNSP;
+ reg |= SM5803_INT2_VBATSNSP | SM5803_INT2_TINT;
rv |= main_write8(chgnum, SM5803_REG_INT2_EN, reg);
- /* Configure TINT interrupts to fire after thresholds are set */
- rv |= main_write8(chgnum, SM5803_REG_INT2_EN, SM5803_INT2_TINT);
-
/*
* Configure CHG_ENABLE to only be set through I2C by setting
* HOST_MODE_EN bit (all other register bits are 0 by default)