summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default
Commit message (Collapse)AuthorAgeFilesLines
* charger: Move charger_state_v2.h into charge_state.hSimon Glass2023-05-112-2/+0
| | | | | | | | | | | | | | | | | | | | We don't have a v1 anymore, so the name makes no sense. Move it into the existing file. Include charge_state.h instead of v2, doing this in the same change to avoid build errors. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: Ic3e3adc45e4d002c2cd5ba8aa65e24686e01d628 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516191 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: test: Avoid using charger_state as a variableSimon Glass2023-05-113-21/+21
| | | | | | | | | | | | | | | | We have enum charge_state_v2 and used to have enum charge_state. Try to avoid using charger_state in the source except as an enum. This makes no functional change. BUG=b:218332694 TEST=CQ Change-Id: I3e53843799b7a6258cf636c11df47389b8d98123 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516190 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* adc: Reduce code size of adc commandDaisuke Nojiri2023-05-031-5/+5
| | | | | | | | | | | | | | | | This CL reduces the code size of the adc console command by removing some redundancy. BUG=None TEST=twister -T zephyr/test/drivers -s drivers.default.console_cmds Change-Id: Icd08d6b73adc25d1be0cd4a2f69ff38a65ed0ddf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4501179 Reviewed-by: Rob Barnes <robbarnes@google.com> Commit-Queue: Rob Barnes <robbarnes@google.com> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* zephyr: Add test to 100% cover bmi_set_gyro_offsetJeremy Bettis2023-04-211-0/+52
| | | | | | | | | | | | | | | | | | | Call set_offset with extreme values to exercise the clipping code. BRANCH=None BUG=b:278607671 TEST=./twister -T zephyr/test/drivers/ --coverage -s drivers.default \ -- --test=bmi160::test_bmi_gyr_set_offset_min_max &&\ lcov --list-full-path -l twister-out/coverage.info | \ awk '/accelgyro_bmi_common.c/ {print $2, $3}' Change-Id: I3c3ca9ea638e6bb45e3d737019f34d71831a855e Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4454188 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* retimer: Use common console command for all RetimersVijay Hiremath2023-04-191-9/+9
| | | | | | | | | | | | | | BUG=b:278138274 BRANCH=none TEST=Tested on ADL-RVP, retimer console command works ./twister -T zephyr/test/drivers ./twister -T zephyr/test/drivers -s drivers.default ./firmware_builder.py --metrics /tmp/tmp_pc1rc15 build Change-Id: Idaec9b41f550ad6aafa34400e95ebf00b9c11348 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426790 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* zephyr: Fix uninitialized variableJeremy Bettis2023-04-181-1/+1
| | | | | | | | | | | | | | | | | | The test was causing inconsistent code coverage due to calling set_offset with an uninitialized variable. BRANCH=None BUG=b:278607671 TEST=Ran test several times Change-Id: I779096eb0b90deb040b50b1015bbffcf22fc0583 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4437750 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* accel_list2dw12: Set high perf mode for ODR >= 50zKornel Dulęba2023-04-171-3/+3
| | | | | | | | | | | | | | | | | | | Until recently we're used it only as lid accel, where no significant precision is required. However in Winterhold we want to use it for body detection. In order to reduce the noise and make it usable for that purpose we need to set it into "high performance" power mode. ODR is used to recognize the sensor purpose. For lid accel it's set to 12.5Hz, assume that if it's at least 50Hz the high performance is wanted. BUG=b:262680246 BRANCH=none TEST=Set ODR to 50Hz, verify high performance mode is on Change-Id: I8c4decc93d2f2cfcc074cf2399f5cb582eb72696 Signed-off-by: Kornel Dulęba <korneld@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4379149 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* zephyr: Support PLATFORM_EC_CMD_POWERINDEBUG flagKnox Chiou2023-04-111-0/+1
| | | | | | | | | | | | | | | | | | | Support PLATFORM_EC_CMD_POWERINDEBUG flag for `powerindebug` on zephyr. BUG=b:272185086 BRANCH=none TEST=zmake build geralt TEST=disable flag and check powerindebug Signed-off-by: Knox Chiou <knoxchiou@google.com> Change-Id: I89af4161b6bcc351e750d2716e0cc594cfe74814 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4383291 Tested-by: Knox Chiou <knoxchiou@chromium.org> Commit-Queue: Knox Chiou <knoxchiou@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Knox Chiou <knoxchiou@chromium.org>
* zephyr: Add `test_` prefix to ZTEST function namesAl Semjonovs2023-04-079-54/+56
| | | | | | | | | | | | | | Twister parsing fails when `test_` prefix is missing from the test name. BUG=None BRANCH=NONE TEST=./twister -T zephyr/test Change-Id: Ic7148a66c761eaf45619b4e764e5aac9b869092c Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409346 Reviewed-by: Keith Short <keithshort@chromium.org>
* bma4xx: emulator and driver testsPeter Marheine2023-03-172-0/+461
| | | | | | | | | | | | | | | | | | | | This implements an emulator and tests for the accel_bma4xx driver using that emulator in the drivers.default test binary. One change to the driver itself is made to fix an overread during interrupt processing (which is not harmful but is slightly inefficient) and a function is marked __maybe_unused so the driver builds successfully when not using interrupts. BUG=b:256047664 TEST=twister -ciC -s drivers/drivers.default -- --test="bma4xx::*" BRANCH=none LOW_COVERAGE_REASON=Some aspects of emulator functionality are not currently exercised. Change-Id: I2765f768c1f5f3651893dfedd1c04cd15cb7fa86 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4310762 Reviewed-by: Eric Yilun Lin <yllin@google.com>
* zephyr: power_button: convert to the input APIFabio Baltieri2023-03-151-1/+3
| | | | | | | | | | | | | | | | | Convert the shim button driver to use the input APIs for the debounced state, use gpio_pin_get_dt() for the signal level one. BUG=b:268200726 BRANCH=none TEST=./twister, cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Cq-Depend: chromium:4339704 Change-Id: Ie4c3729709af7690332bc91aea2131a51aed184e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4329528 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* tcpci: test: add get_vbus_voltage testEric Yilun Lin2023-03-132-0/+59
| | | | | | | | | | | | | | | | Add the test for TCPCI get_vbus_voltage API. BUG=b:272664811 TEST=./twister -c -i -T zephyr/test/drivers BRANCH=none Change-Id: I5b26e1e0d43225b4318694d3e76d2133905013e2 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4328914 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Auto-Submit: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* zephyr: make bc1.2 optionalTing Shen2023-02-242-0/+60
| | | | | | | | | | | | | | | | For devices that don't support bc1.2, the code should not depend on anything related to usb_charge module (e.g. bc12_ports) BUG=b:269989432 TEST=zmake build --all BRANCH=none Change-Id: I6be47485bbd606f93a581d1638b3402337233b7c Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4274111 Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* Remove CONFIG_HOST_EVENT64Tim Van Patten2023-02-211-4/+0
| | | | | | | | | | | | | | | | | | | The config option CONFIG_HOST_EVENT64 has been unconditionally enabled since 2017. This CL removes the option entirely, to clarify that 64 bit host event support is enabled by default. BRANCH=none BUG=b:261141172 TEST=Manually build and flash, verify device boots TEST=ectool version Change-Id: I806c12b8e69955dd19d32ad96587050fd189bea4 Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4255275 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Rob Barnes <robbarnes@google.com>
* zephyr/test: Update tests to use EC CMD APICaveh Jalali2023-02-1610-220/+138
| | | | | | | | | | | | | | | | This refactors the unit tests to use the EC host command API. Calls to the generic host_command_process(...) are replaced with type-checked host command API calls that perform the same operation. BRANCH=none BUG=b:258110734 TEST='./twister -v -T zephyr/test' passes Change-Id: I1b925a04271dd50c3c7c0a3481cd30ba762b1561 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4172828 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr/test: Move console_cmd_crash to separate testRob Barnes2023-02-102-35/+0
| | | | | | | | | | | | | | | | The console_cmd_crash test needs CONFIG_ASSERT_TEST set. Moving console_cmd_crash to be stand alone under drivers so this flag is not polluting any other tests. BUG=b:268638354 BRANCH=None TEST=Pass driver unit tests Change-Id: I5ee5de583b61c77cc483d41dc32c5a4eb0bf9585 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4240330 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Obsolete AMODE commandsDiana Z2023-02-071-19/+0
| | | | | | | | | | | | | | | The AMODE host commands were created to support GFU mode, which we do not support in TCPMv2. Move these host commands to a TCPMv1 only file and remove references to them from the unit tests. BRANCH=None BUG=b:267562375 TEST=./twister -T ./zephyr/test Change-Id: I7bafcd8eded1f8eca4082560172aee91ebd7ff24 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4221975 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* raa489000: never report ACOK when sourcing VBUSPeter Marheine2023-02-061-0/+12
| | | | | | | | | | | | | | | | | | | | | | This chip sometimes ACOK when sourcing VBUS because the ACOK status bit actually indicates whether VBUS is above approximately 3.6V and the charger is not overcurrent or over-temperature, though it also seems to report ACOK correctly when the port comes up as a source rather than going through a PRS. This change makes raa489000_is_acok return a correct value (not-OK) in all situations when sourcing VBUS. BUG=b:263691951,b:262663436 TEST=On Nivviks, `hibernate` now correctly hibernates following fast role swap from sink to source on port C0 (with C1 disconnected), where previously it refused to hibernate with the "AC on, skip hibernate" message. BRANCH=nissa Change-Id: I314988d7dfcc8b4d576224f934cd5dc693e7f54f Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4222772 Reviewed-by: Adam Mills <adamjmills@google.com> Reviewed-by: Arthur Lin <arthur.lin@lcfc.corp-partner.google.com>
* zephyr: test: Unmask Accept message after PRS testAbe Levkoy2023-02-011-0/+3
| | | | | | | | | | | | | | | | After changing how the partner handles Accept for a Power Role Swap test, restore the default behavior. Avoid disturbing future tests that depend on the partner receiving Accept. BUG=b:267369382 TEST=twister -s zephyr/test/drivers/drivers.default (with DRS test) BRANCH=none Change-Id: I5ed3eee62889f321d1350f3f2ee763d1b5f0f781 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211270 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Al Semjonovs <asemjonovs@google.com>
* tcpci: allow get_chip_info callers to update the cachePeter Marheine2023-01-222-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some drivers massage retrieved chip info in assorted ways (usually because the chips misbehave), but it's both confusing and inefficient how that interacts with cached chip info because the consuming driver needs to always interpose itself between possibly-cached values and its caller, usually requiring another layer of caching. This adds a new tcpci_get_chip_info_mutable() function that works like tcpci_get_chip_info(), but the caller can provide a function that modifies the cached data in order to do any required massaging. A callback is used rather than an output pointer to give the implementation freedom to change its behavior more, such as by adding locking to prevent the latent concurrency bugs that currently lurk in it. This also fixes a bug in the previous implementation where partial data would be cached if an error occurred in reading certain TCPC registers. BUG=b:244502337 TEST=make buildall; zmake build -a; twister BRANCH=none Change-Id: Ia3dcac109eb22bf0326e3fd1722aa64fe9f73f50 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179431 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* shim/src/watchdog: Add support for watchdog helperPatryk Duda2023-01-191-16/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Watchdog helper is used to print a warning along with useful debugging information before hardware watchdog will reset SOC. Zephyr provides counter based watchdog which is very similar to watchdog helper from EC. This patch adds support for using multiple watchdogs simultaneously. One of the watchdogs will be counter based, the other will be hardware based (e.g. IWDG on STM32). Watchdog tests was modified to address the problem with allocating new counter channel every time watchdog_init() is called while there is no way to free them. BUG=b:239712345 BRANCH=none TEST=Add 'zephyr,counter-watchdog' node to DTS. Use 'waitms' command to check if a warning from watchdog based counter is triggered. TEST=./twister -i -T zephyr/test/drivers \ --test external/platform/ec/zephyr/test/drivers/drivers.default Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I66b5474d7e65978791450c2fd62dd3d345cd474a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116769 Tested-by: Patryk Duda <patrykd@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* zephyr:test: Correct port80 suite nameAl Semjonovs2023-01-181-1/+1
| | | | | | | | | | | | | | | ZTEST suite for port80 console command went to port80 host command suite. Correcting for console command suite. BUG=None BRANCH=NONE TEST=./twister -c -T zephyr/test Change-Id: I3e31a8a9d92f1dcc0402981b9cdf4551f05b18c3 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4178238 Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* TCPMv2: Add SOP minor revision to EC_CMD_TYPEC_STATUSJameson Thies2023-01-181-0/+18
| | | | | | | | | | | | | | | | | | | | EC_CMD_TYPEC_STATUS is used to send data about USB-C partners and cables to the kernel where it can then be exposed to userspace. Currently, EC_CMD_TYPEC_STATUS only assigns major PD revision to sop_revision causing the minor revision to appear as "0" regardless of the devices actual minor PD revision. This CL adds minor revision assignment to EC_CMD_TYPEC_STATUS so that it can be correctly reported by the kernel. BUG=b:261736720 BRANCH=None TEST="cat /sys/class/typec/port0-partner/usb_power_delivery_revision" for USB PD 2.0, 3.0 and 3.1 devices. Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: I8c1858d6e6d577628b373d16f9aabdfd15a0e3c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4163826 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Add coverage for gpio-keys power_button.cAl Semjonovs2023-01-171-0/+17
| | | | | | | | | | | | | | | | | | Enable gpio-keys power button to exercise tests for board specific code. BUG=None BRANCH=NONE TEST=zmake build --coverage herobrine ./twister -v -i --coverage -p native_posix -p unit_testing genhtml -q -s --branch-coverage -o build/zephyr/coverage_rpt/ twister-out/coverage.info build/zephyr/herobrine/output/zephyr.info Change-Id: I79901e458f1e7fc48806779b05e80cc58a5a83e5 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159985 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr:test: Split console command tests into its own suite.Al Semjonovs2023-01-172-41/+47
| | | | | | | | | | | | | | | | Create a new test suite for console commands. Current default test suite takes excessive time to complete leading to increasing the timeout times. BUG=None BRANCH=None TEST=./twister -T zephyr/test Change-Id: Idb453b0b8f7cc9a61265ac287310772f1b8f24a2 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159984 Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: make the test emulator's PD revision configurableJameson Thies2023-01-131-0/+3
| | | | | | | | | | | | | | | | This CL updates the tcpci partner emulator to have an internal variable define how it responds to Get_Revision, instead of hardcoding it's RMDO to 0x31000000 (USBPD 3.1). BUG=b:236868370 BRANCH=None TEST=./twister -p native_posix -p unit_testing Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: Ib212383ce2a29c87f7284a971b2ad96cce6b68c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159990 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* syv682x: cached force discharge configEric Yilun Lin2023-01-131-2/+10
| | | | | | | | | | | | | | | | | | | | syv682x vbus discharge function is getting called from ppc_dev_is_connected to reset the discharge config many times. We cached the force discharge config to reduce the i2c traffics on IT81202 i2c ports. BUG=none TEST=i2c traffic reduces. FRS is working. BRANCH=none Change-Id: Iebae413d8f6621b8c99dc28c744220f54d420062 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4160813 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Eric Yilun Lin <yllin@google.com>
* Default charger current derating to 5%Peter Marheine2023-01-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not derating seems like a common pitfall that can cause problems with some chargers, so set a reasonably conservative default. 5% is chosen as the most common derating factor used among boards today (counting occurrences in source code, so this may undercount 5% occurrences because several projects set 5% at the project rather than board-level): 1. 38 x 5% 2. 23 x 4% 3. 6 x 10% 3. 2 x 3% 4. 1 x 2% Boards that currently configure this setting are modified only to continue building without warnings regardless of whether they use the new default value in order to signal that they were explicitly configured. BUG=b:260774380 TEST=make buildall / zmake build -a BRANCH=none Change-Id: I017849d38572fbc48090ae1fa2c539b808e426f9 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4109651 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* SBS: Make battery_get_params clear flags selectivelyDaisuke Nojiri2023-01-101-0/+17
| | | | | | | | | | | | | | | | | | | | | | | Currently, battery_get_params clear all flags in batt.flags. This patch makes the function clear only the flags which are explicitly set or unset by battery_get_params. With this change, the charger task can add a flag to batt.flags. There isn't yet functionality change by this patch. BUG=b:263921114 BRANCH=None TEST=run-battery_get_params_smart run-sbs_charging_v2 TEST=./twister -i --toolchain host -s \ external/platform/ec/zephyr/test/drivers/drivers.default Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I5708ab6de81bc0a7c28961b13960fd89460b2e1c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4136966 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Bob Moragues <moragues@chromium.org>
* zephyr: Reset battfake after every testDaisuke Nojiri2023-01-091-1/+7
| | | | | | | | | | | | | | | | This patch makes smart battery tests disable battfake after each test. BUG=None BRANCH=None TEST=./twister -i --toolchain host -s \ external/platform/ec/zephyr/test/drivers/drivers.default Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I1869fa848fcd52d1ea8731d256fb3b72e741e51f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4143800 Commit-Queue: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* zephyr: named-gpios: remove DT_PATH usagesFabio Baltieri2023-01-039-13/+13
| | | | | | | | | | | | | | | | Replace a bunch of DT_PATH usages with some common macros to access the named-gpios node based on the DT compatible. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib99820051b5a55b68915e3b29071ee5f7e45ebfb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114286 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* shim/src/gpio: Add save/restore GPIO controller port configure functionJosh-Tsai2022-12-282-0/+75
| | | | | | | | | | | | | | | | | | | | | | We need to save the IO expander GPIO status before the device reset, and restore the status after the device is reset completely. create the function to save and restore the port configure BRANCH=None BUG=b:260534665 TEST=zmake build winterhold TEST=IO expander GPIOs status will not clear after tcpc reset TEST=./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test/drivers/drivers.default Change-Id: Ic35e7e412792a56fde670de252887a9bdb557b36 Signed-off-by: Josh-Tsai <josh_tsai@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4115054 Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: ec-console: remove DT_PATH usagesFabio Baltieri2022-12-231-1/+0
| | | | | | | | | | | | | | | | Use a compatible lookup to find the ec-console node, add check for duplicate nodes, drop a redundant explicit setting (it defaults to y). BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ie2920843e2315a866bb0244b86bfd1e2d5d24b5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116775 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* zephyr/test/drivers: Move flash test to separate directoryPatryk Duda2022-12-222-545/+0
| | | | | | | | | | | | | | | | | | Moving flash tests to separate directory will allow to create a variant of these tests with different options enabled. BUG=b:239712345 BRANCH=none TEST=./twister -v -T zephyr/test/drivers/ --test \ external/platform/ec/zephyr/test/drivers/drivers.flash Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ifa8f350a27abe73d87794f6a4dcc13e34c7b6092 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4118761 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com>
* TCPMV2: Handle errors in pe_send_alert_runJameson Thies2022-12-161-0/+54
| | | | | | | | | | | | | | | | | | | | | | If the EC tries to send 2 alert messages very close to each other (~30ms), it will fail with a message discarded error on the second Alert. Because pe_send_alert_run does not check for this case, it prevents the TCPMV2 PE from returning to PE_SNK_Ready. This CL updates pe_send_alert_run to look for protocol errors and discarded messages, and send a soft reset in either case. This allows the PE to return to PE_SNK_Ready. BUG=b:260912784 TEST=Tested by adding EC command to send 2 Alerts very quickly, and confirmed that if the second alert fails the Chromebook resends it. Also, "make try_build_boards", "make runhosttests" and zephyr tests. BRANCH=None Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: I5cc0920a0f910c67e988a3dbf8ac0c3c611c386b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4068497 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* BB retimer: Add condition to set 'DP CONNECTION' bitjohnwc_yeh2022-12-131-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | Set 'DP CONNECTION' bit when mux_state gets HPD event only on the ports with HDMI/DP card It will increase BBR power consumption, so set 'DP CONNECTION' bit only when mux_state gets HPD event only on the ports with HDMI/DP card. BUG=b:233975818 BRANCH=None TEST=Test on Banshee, when only hdmi card 'DP CONNECTION' bit is 0. Enter console command bb 1 r 4 =0x403, plug in hdmi monitor bb 1 r 4 =0x8503. Run ./twister -T zephyr/test/drivers Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Change-Id: I87b2a4379e66e08830c556d703390a7fb96d3258 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050320 Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Boris Mittelberg <bmbm@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* zephyr: leds: select PLATFORM_EC_LED_DT automaticallyFabio Baltieri2022-12-081-1/+0
| | | | | | | | | | | | | | | | Select PLATFORM_EC_LED_DT automatically when the LED policy node is find in the devicetree. Drop the remaining LED DT options from the config files. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ia406abed7e9ca36a2952c59d34daa15a9db76c0e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054627 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: test: Make get_panic_data_write mockableTristan Honscheid2022-11-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The version of get_panic_data_write() that currently gets compiled in is controlled by an `#ifdef CONFIG_BOARD_NATIVE_POSIX` block, which means that the actual implementation used in device builds (over 30 SLOCs) is unreachable in testing, in favor of a stub that directly returns the pdata_ptr pointer. This CL removes the stub native posix version of the function and makes the real version test_mockable. Then, all test binaries that were relying on the removed stub definition are supplied with a mocked version of get_panic_data_write() that behaves the same way the stub did by returning pdata_ptr directly. This frees a new test binary to test the actual implementation. BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I8228acb0147b3b3843d302c272d8715d925fddd5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052121 Commit-Queue: Aaron Massey <aaronmassey@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Tristan Honscheid <honscheid@google.com> Auto-Submit: Tristan Honscheid <honscheid@google.com>
* tcpm_header: add test for tcpc_has_frs_control from flagsClayton Whitelaw2022-11-291-0/+14
| | | | | | | | | | | | | | | | This function previously had no coverage for the case when TCPC_FLAGS_CONTROL_FRS was set. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: I1b8d902fc0551388fcb12200e9c85a1f62ed7209 Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063190 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* tcpm_header: add test for tcpm_dump_registersClayton Whitelaw2022-11-291-0/+17
| | | | | | | | | | | | | | | | | | This function previously had no coverage for the case where standard registers should be dumped. To support this test, mark tcpc_dump_std_registers as test_mockable. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: Id7bbba6f77c1684a7eeafb1be1f990fb9176e16b Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062461 Commit-Queue: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com>
* tcpm_header: add test for tcpm_get_chip_info unimplementedClayton Whitelaw2022-11-291-0/+6
| | | | | | | | | | | | | | | This function previously had no coverage for this particular path. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: Ia09dff83a8cc9d54b93e1158d834d091feaa512c Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4061756 Reviewed-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tcpm_header: add test for tcpc_get_bist_test_mode unimplementedClayton Whitelaw2022-11-291-0/+11
| | | | | | | | | | | | | | | This function previously had no coverage this particular path. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: I7fef8ab28251c2658fba8162d1077d2e78a9479f Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4061754 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Yuval Peress <peress@google.com>
* Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMITPeter Marheine2022-11-294-8/+8
| | | | | | | | | | | | | | | | | | | "Default input current" is not a very clear name, so rename this option to better express its use as a default value that is set in the charger. This is made possible by splitting other uses into CHARGER_MIN_INPUT_CURRENT_LIMIT, making the only use for CHARGER_INPUT_CURRENT be as a default. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=isl9241 and sm5803 currently lack emulators Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ia9c1df9061825b15477466e85343afeb2a371288 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025404 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpm_header: add tests for tcpm_set_frs_enableClayton Whitelaw2022-11-291-0/+27
| | | | | | | | | | | | | | | | | | | | This function had no coverage previously. Added tests for both cases where the driver does and does not implement these functions. Since the function is conditionally included, guard the tests by checking the same configuration. BUG=none TEST=twister, verify lines are now covered BRANCH=none Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Change-Id: I287642975e05b7331333b7016af8e571c9e28676 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052580 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* tabletmode: Correctly handle HW orientation changingTim Van Patten2022-11-281-26/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the tabletmode is being forced by 'tabletmode on' or 'tabletmode off', the actual HW orientation can still change between tablet and clamshell mode. When 'tabletmode reset' is issued, the device should behave correctly based on the current HW orientation. This also updates the test drivers.default.tablet_set_mode to fix spelling errors and adds comments to explain the various zassert_equal() values being checked. BRANCH=none BUG=b:256015402 TEST=./twister -v -i --coverage -p native_posix -p unit_testing \ -s zephyr/test/drivers/drivers.host_cmd ./twister -v -i --coverage -p native_posix -p unit_testing \ -s zephyr/test/drivers/drivers.default TEST='tabletmode on' in clamshell mode, convert DUT to tablet mode, 'tabletmode reset', verify DUT is in tablet mode. Change-Id: I1039bda7790e0623b013db01e673fe43fa7d8fc8 Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4006302 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* motion_sense: avoid possible invalid memory accessBoris Mittelberg2022-11-281-0/+16
| | | | | | | | | | | | | | | | Returning SENSOR_CONFIG_MAX will cause out of bound read. Return one of the legal values. BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I1d2b407cb42da8b6fa78fb61be39d05ea1d64401 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032916 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Ricardo Quesada <ricardoq@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* test: i2c_passthru: Verify CONFIG_I2C_PASSTHRU_RESTRICTEDKeith Short2022-11-241-2/+121
| | | | | | | | | | | | | | | | Verify I2C passthru commands are rejected when the CONFIG_I2C_PASSTHRU_RESTRICTED option is enabled. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: If6a5e024d91a65d87362025da6c1bc0e70b212f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048915 Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* tcpm_header: add missing RESET_FAKE callsClayton Whitelaw2022-11-231-0/+3
| | | | | | | | | | | | | | | Each mock should be reset before each test to guarantee its state. That was missing from some of these fakes. BUG=none BRANCH=none TEST=twister Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Change-Id: Ie10fe951d07d278147c4fda2c46da5c922eb8af3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052765 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: test: Bring virtual_battery_handler() to 100% coverageTristan Honscheid2022-11-231-0/+145
| | | | | | | | | | | | | | | | Cover all remaining code paths in virtual_battery_handler() in common/virtual_battery.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: Ib510b7c76eca7daf8e9824c486afd391ad1b5d87 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4036107 Commit-Queue: Aaron Massey <aaronmassey@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tcpm_header: add more driver call-through testsClayton Whitelaw2022-11-231-6/+67
| | | | | | | | | | | | | | | | | | | | | | These functions call the driver's implementation only if present. Added tests for both cases where the driver does and does not implement these functions. Functions tested: - tcpm_debug_accessory - tcpm_debug_detach - tcpm_hard_reset_reinit BUG=none TEST=twister, verify lines are now covered BRANCH=none Signed-off-by: Clayton Whitelaw <cawhitelaw@google.com> Change-Id: I26e1cdb74f1ed3f08065a301081561a764322bc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048912 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com>