summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* lis2dw: enable the low noise configurationJosh Tsai2023-04-262-0/+8
| | | | | | | | | | | | | | | | | | | | Enable the low noise configuration at Control register 6 bit3. BRANCH=None BUG=b:262680246 TEST=use i2c read_byte command to check the low noise bit is set Change-Id: I19e519d9de69eaaac276027b1ab5bb9f80757eb1 Signed-off-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4359354 Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Kornel Dulęba <korneld@google.com> Reviewed-by: Kornel Dulęba <korneld@google.com> Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> (cherry picked from commit 9da35bc68bdd8af9e4e9e9c4a6b2f19eef6dac78) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4465589 Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
* accel_list2dw12: Set high perf mode for ODR >= 50zKornel Dulęba2023-04-261-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> (cherry picked from commit 8b50c762dc2df4d14e7aff4838e2490419be7913) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4465588 Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
* common: Move pse driver into driver placeDavid Huang2023-03-202-0/+212
| | | | | | | | | | | | | | Since there are more projects using this driver. Move it into driver place. BUG=b:273191751 BRANCH=None TEST=make buildall -j Change-Id: I50e2cb480a551ce19722edc2b6f70824f4b9147e Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4335461 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* bma4xx: emulator and driver testsPeter Marheine2023-03-171-3/+3
| | | | | | | | | | | | | | | | | | | | 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/emul: Add ANX7483 emulatorRobert Zieba2023-03-161-7/+9
| | | | | | | | | | | | | Add ANX7483 emulator and associated tests. BRANCH=none BUG=b:247151116 TEST=Ran tests Change-Id: Idd56a90e58c6d482556d92446aa0659a6a1b8105 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4322379 Reviewed-by: Diana Z <dzigterman@chromium.org>
* zephyr/emul: Add PS8811 emulatorRobert Zieba2023-03-161-0/+5
| | | | | | | | | | | | | Add emulator for the PS8811 retimer and associated tests. BRANCH=none BUG=b:247151116 TEST=Ran tests Change-Id: I65153b9c7cd2b597c1ebcc0371a96d34740c8a81 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4313466 Reviewed-by: Diana Z <dzigterman@chromium.org>
* Zephyr: Correct Temp sensor F75303 read methond.Logan_Liao2023-03-152-82/+44
| | | | | | | | | | | | | | | | This patch correct F75303 read fail on zephyr. BUG=b:269786658 BRANCH=none TEST=test markarth console that temps show right value. Change-Id: I315d80e2166d0b5f4d69f4e671846abe52fccbba Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290094 Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com>
* frostflow: Modify charger frequence for power consumption.Logan_Liao2023-03-151-0/+48
| | | | | | | | | | | | | | | | | | To avoid charger enter CCM mode, modify isl9241 frequence to 600kHz from 1020kHz in S5. BUG=b:271704154 BRANCH=none TEST=power team test power consumption is lower than 1020kHz. Change-Id: I9906f2795582c2c8e4a63a674404c0e5a5dfbc96 Signed-off-by: Logan_Liao <Logan_Liao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333276 Reviewed-by: SamSP Liu <samsp_liu2@compal.corp-partner.google.com> Tested-by: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Chao Gui <chaogui@google.com> Commit-Queue: Logan Liao <logan_liao@compal.corp-partner.google.com> Reviewed-by: Logan Liao <logan_liao@compal.corp-partner.google.com>
* ec: Add yet more #line directivesJeremy Bettis2023-03-141-0/+6
| | | | | | | | | | | | | | | | | | There are more files that are reporting incorrect coverage due to the gcc preprocessor getting off by a line. BRANCH=None BUG=b:272518464 TEST=Ran coverage build Change-Id: I8b0fa21702c7fd3611c57af68b59ea70f605861f Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4334214 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* anx7447: replace anx7447_get_vbus_voltageEric Yilun Lin2023-03-141-21/+5
| | | | | | | | | | | | | | | | | Replace the function to use the generic TCPCI API instead. BUG=b:272664811 TEST=1. ./twister -T zephyr/test/drivers 2. test steelix C0 anx3447 port, and VBUS reporting is correct BRANCH=none Change-Id: I5916ed6f010d863d003c9fb1d981c7817f495206 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333419 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Auto-Submit: Eric Yilun Lin <yllin@google.com> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* tcpci: add tcpci_get_vbus_voltage_no_checkEric Yilun Lin2023-03-141-4/+9
| | | | | | | | | | | | | | | | | | | The function is identical to get_vbus_voltage but without checking the DEV_CAP_1. This is a refactor for some TCPCI (e.g. ANX7447) support VBUS sensing, but doesn't report it in DEV_CAP_1. BUG=b:272664811 TEST=./twister -T zephyr/test/drivers BRANCH=none Change-Id: Ic66fc1dd86eea363f82388453c0181f35bfc5ae6 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333418 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* anx7447: drop unused anx7447 functionsEric Yilun Lin2023-03-142-49/+0
| | | | | | | | | | | | | | | | The functions are replaced by the TCPCI calls. BUG=b:272664811 TEST=zmake testall BRANCH=none Change-Id: I9ebf5216c7cdd0134afe8d3be35b0a518e2e7d8d Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333417 Tested-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Eric Yilun Lin <yllin@google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Reviewed-by: Sung-Chi Li <lschyi@chromium.org>
* tcpm: anx7406: add PD anx7406 supportXin Ji2023-03-133-0/+512
| | | | | | | | | | | | | | | | | Add ANX7406 tcpci driver, support external retimer control. PD 20V@3A Request, DP Alt mode. Disable low power mode. BUG=b:212509565 BRANCH=none TEST=1. Verify DP Alt mode. 2. Verify PD charging. Change-Id: I0d82349578eb6a6f9c938fb4b9e33b94853a4d04 Signed-off-by: Xin Ji <xji@analogix.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3460777 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* rt1739: implement set_vbus_source_current_limitTing Shen2023-03-132-4/+31
| | | | | | | | | | | | | | | | | Implements set_vbus_source_current_limit and initialize source ocp level to a proper limit based on RP config. BUG=b:271942294 TEST=On geralt, `i2c read_byte i2c@f01cc0 0x70 0x25` returns 0x12 BRANCH=none LOW_COVERAGE_REASON=early bringup Change-Id: I583ec6101939410e29bf0a537637263ac5780dd6 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4323579 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org>
* bma4xx: avoid undefined results in ODR conversionsPeter Marheine2023-03-132-15/+84
| | | | | | | | | | | | | | | | | | | | | | | When small values were given to BMA4_ODR_TO_REG, the result would be undefined because it would end up doing __fls(0) which is documented to be undefined. Large values could also behave incorrectly, though the result is defined. This change reimplements BMA4_ODR_TO_REG and BMA4_REG_TO_ODR in a way that is rigorously proven to be correct and has similar expected runtime cost. This was discovered while implementing tests for the driver; the new implementation passes the tests where the old one would modify unintended bits of the ACCEL_CONFIG register if small values were passed to set_data_rate. BUG=b:256047664 TEST=bma4xx test suite now passes BRANCH=none Change-Id: I11764652e096881eb9118a25b032755405c165f6 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4322781 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* servo_v4p1: Add mechanism to enable/disable USB3 to DUTŁukasz Hajec2023-03-092-2/+4
| | | | | | | | | | | | | | | | | | This CL disables USB3 to DUT by default. It overwrites TUSB1064 usb_mux set method to always prevent or allow using USB3 mode in this mux/switch. This CL also adds console command (and needed backed) that can be used to enable/disable USB3 to DUT. BUG=b:254857085 b:263573379 BRANCH=none TEST=build and flash servo FW test functionality using Lazor board Change-Id: Idcb47369b7b0352a21666e7a46ddcc56b6e1063a Signed-off-by: Łukasz Hajec <hajec@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4236345 Reviewed-by: Jan Dabros <dabros@google.com>
* driver/wpc/cps8100.c: Add support of CPS8200 firmware updateDerek Huang2023-03-083-38/+535
| | | | | | | | | | | | | | | | | | | | | | | This patch adds cps8200_update_open, cps8200_update_write and cps8200_update_close functions which allow the host updater (e.g. ectool) to update firmware of cps8200 via I2C. Example: localhost ~ # ectool pchg 0 update 0x3 0x0 /path/to/image.bin Opened update session (port=0 ver=0x3 bsize=128): 0x0 /path/to/image.bin Writing /path/to/image.bin (33980 bytes) ************************************************************** Firmware was updated successfully (CRC32=0xfe43d401). BUG=b:195708351 BRANCH=none TEST=ectool pchg 0 update 0x3 0x0 ./CPS8200_A0_40_V3_CRCBEA6.bin Change-Id: I4e17a308714c94dc2b9335943536a732297b86fc Signed-off-by: Derek Huang <derekhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4105947 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* fpsensor: Utilize a common set of CPRINT functionsBobby Casey2023-03-035-16/+5
| | | | | | | | | | | | | | Replace multiple copies of CPRINTF and CPRINTS with the common version from fpsensor_utils.h. BRANCH=none BUG=none TEST=compare_builds passes Change-Id: I2ed5dfcee9b2cf3bebe18e449556856e11c4666b Signed-off-by: Bobby Casey <bobbycasey@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4283702 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* driver/fingerprint: Rename fpsensor.hBobby Casey2023-03-031-3/+3
| | | | | | | | | | | | | | | To reduce confusion and the possibility of accidentally including include/fpsensor.h rather than driver/fingerprint/fpsensor.h, rename the driver include file to driver/fingerprint/fpsensor_driver.h. BRANCH=none BUG=none TEST=compare_builds.sh passes Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Id908311e05d2ab06b0a817ed6fb3001b2e6815c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4283700 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fingerprint/elan: Add _ELAN suffix to ELAN macrosBobby Casey2023-03-033-17/+23
| | | | | | | | | | | | | | | | | This commit builds successfully but is not testable without an elan sensor on an icetower board. This commit is based on http://crrev.com/c/2727971, which was reverted in http://crrev.com/c/2810517 BRANCH=none BUG=b:264457390 TEST=build dartmonkey target modified to use elan sensor Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Ifca9113e82deaf96a262256fab5aa48f2cdb2c61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273189 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fingerprint/elan: Resolve elan compilation issuesBobby Casey2023-03-033-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Resolve compilation failure due to ec_commands.h not being included. Resolve link failures for init_trng and exit_trng in the elan configuration. This has likely been failing since trng was refactored in http://crrev.com/c/3738978 but went unnoticed because there are no targets actively building elan FPMCU. Remove unnecessary includes of endian.h, which caused compilation errors because "builtins/" is no longer in the FPMCU include path. This commit is based on http://crrev.com/c/2727971, which was reverted in http://crrev.com/c/2810517 Note: This commit builds successfully but is not testable without an elan sensor on an icetower board. BRANCH=none BUG=b:264457390 TEST=build dartmonkey target modified to use elan sensor Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Ied6b2b2ffaa649c320b0170be241d8aaea53eb2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273188 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* driver/fingerprint: Add _FPC suffix to FPC macrosBobby Casey2023-03-038-59/+70
| | | | | | | | | | | | | | | This commit is based on http://crrev.com/c/2727971, which was reverted in http://crrev.com/c/2810517 BRANCH=none BUG=b:264457390 TEST=test/run_device_tests.py -b bloonchipper TEST=test/run_device_tests.py -b dartmonkey Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Ife7373d366228a7940b87b036be1bb7c2a1cf770 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273187 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* zephyr: enable elan touchpad driverTing Shen2023-03-031-0/+16
| | | | | | | | | | | | | | | | This CL enables the Elan touchpad driver and touchpad task on zephyr EC, with minimal changes to make the code compilable. BUG=b:269989432 TEST=Add a touchpad node on krabby and verify it buildable. BRANCH=none Change-Id: I4b723ed2230f54d3dc597cdc30605fcfa4d4e0a3 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4149991 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com>
* fpsensor: Rename fpsensor_private.h to fpsensor_utils.hBobby Casey2023-03-021-1/+1
| | | | | | | | | | | | | | | | Rename fpsensor_private.h as it does not contain any private interfaces and is included by non-private source files. BRANCH=none BUG=none TEST=make BOARD=bloonchipper TEST=make BOARD=dartmonkey TEST=make run-fpsensor_crypto Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I4f9233c8c7b5ffdf84fdd0c11c3166dd65f4a913 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4273186 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* Reduce AP communication failure spamTim Van Patten2023-03-022-4/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When communication with the AP is unavailable (not in S0, dead, etc.), the EC spams these logs to the console: 23-02-28 12:11:54.993 [53.641200 RMI: Unexpected command value in out bound message] 23-02-28 12:11:55.004 [53.642300 STT: Failed to write SOC temp rv:1] 23-02-28 12:11:55.008 [54.653200 RMI: Unexpected command value in out bound message] 23-02-28 12:11:56.023 [54.654500 STT: Failed to write SOC temp rv:1] 23-02-28 12:11:56.027 [55.663800 RMI: Unexpected command value in out bound message] 23-02-28 12:11:57.042 [55.665500 STT: Failed to write SOC temp rv:1] The actual content of the message is ignored by developers, and the messages are instead interpreted to indicate that communication with the AP is currently down. For nooglers and external developers, this can lead to confusion and wasted time mis-attributing the log messages to a different/separate error. This CL removes the STT log message, and instead relies on sb_rmi_mailbox_xfer() to log a single message when there is an AP communication failure. The flag is reset when the AP communication is restore. BRANCH=none BUG=b:271142544 TEST=tast run <IP> crash.WatchdogCrash, verify only a single error log TEST=Load known bad AP FW onto DUT (whiterun, R113-15367.0.0) where suspend/resume fails, close then open lid, validate EC logs are not spammed Change-Id: Iad08dbef64738d1a1f2d676fd47fbe7e66201e5e Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4298592 Reviewed-by: Rob Barnes <robbarnes@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* isl9241: Prevent isl9241_nvdc_to_bypass from locking control3 mutex twiceDaisuke Nojiri2023-02-181-7/+18
| | | | | | | | | | | | | | | | | | | isl9241_nvdc_to_bypass locks control3 mutex and calls isl9241_get_vsys_voltage, which tries to lock the same mutex. This deadlocks whatever task calling isl9241_nvdc_to_bypass. This patch makes isl9241_nvdc_to_bypass call an internal version of isl9241_get_vsys_voltage, which skips mutex lock. BUG=b:266742386 BRANCH=None TEST=Agah Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I690dd0011f05f7488be6566146b7863bf747d9e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4261958 Reviewed-by: Jes Klinke <jbk@chromium.org> Tested-by: Jes Klinke <jbk@chromium.org>
* power/amd_x86: Add support for STB dumpingRobert Zieba2023-02-162-0/+92
| | | | | | | | | | | | | | | | Skyrim supports dumping the contents of the SoCs smart-trace buffer when triggered externally. The contents of the STB can be useful in debugging S0i3 suspend failures. Add support for triggering an STB dump when the SoC hangs during S0i3 entry/exit. BRANCH=none BUG=b:246770811 TEST=Ran on skyrim DUT Change-Id: Ie18c6072a77f6dd306a46d7f76bd345b4f9e75a7 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4220248 Reviewed-by: Diana Z <dzigterman@chromium.org>
* cps8100.c/ctn730.c: board_get_pchg_count() retun pchg_countben chen2023-02-152-2/+2
| | | | | | | | | | | | | | | | | | Using board_get_pchg_count() to determined pchg_count at runtime. BUG=b:267700817 BRANCH=None TEST=make BOARD PASS Cq-Depend:chromium:4248823 Cq-Depend:chromium:4218552 Change-Id: I844bf2615bd04da38ff658b987fc205f69ceca5e Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4248459 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Derek Huang <derekhuang@google.com>
* geralt: disable bc1.2Ting Shen2023-02-142-0/+8
| | | | | | | | | | | | | | | | Remove CONFIG_USB_CHARGER and hide related driver code inside #ifdef. BUG=b:267989266 TEST=no USB_CHG task in `kernel thread` BRANCH=none LOW_COVERAGE_REASON=early bringup Change-Id: Iebd80267f64149fde148a436212c9998824c6564 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4248932 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* CPS8100: create header fileScott Chao2023-02-141-0/+15
| | | | | | | | | | | | | This CL created the header file and also add the driver declaration. BUG=b:268581418 BRANCH=none TEST=make buildall Change-Id: I08df700f4aff4c5cbe5ccd1345652263feab36f3 Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4238095 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* it8xxx2: micro-optimize SHA256 computationPeter Marheine2023-02-091-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hash performance is a significant contributor to EC boot-up time, so it's valuable to optimize the computation of firmware hashes. This change improves RW image hashing performance on Nereid, reducing time taken for `hash rw` on the console by about 15ms on average (from 1263ms to 1244ms for 384kB of data). This primarily replaces the byte swapping in SHA256_update with an inline assembly version that saves 6 instructions per word of data hashed. Calling htobe32() turns into a call into libgcc's __bswapsi2 which does implement an efficient swap, but spends several instructions reloading constant values used by the function and incurs function call overhead. This inline version saves 4 instructions by allowing the constants to be kept in registers through the entire SHA256_update (effectively hoisting the constant loads outside the loop), and 2 more in procedure call overhead. SHA256_chip_calculation is also optimized slightly: declaring the hash_ctrl local as volatile forces it to be allocated a stack slot and the read value be written to the stack (then ignored), which is unnecessary because the macro referring to the SHA1HASHCTRLR register is already a volatile read. Removing the unneeded qualifier saves 3 instructions between stack adjustment that is no longer needed (because the function now operates only on values that fit in registers) and the unneeded store that is now removed. BUG=b:260762509 TEST=`hash 0xbfffc 32` has the same value before and after this change, with manual verification that the 32 bytes of memory at 0x800bfffc are unchanged between the two builds (`md 0x800bfffc 32`). BRANCH=nissa LOW_COVERAGE_REASON=uncovered line can only run on actual hardware, not native_posix where coverage is gathered Change-Id: I99fcb2278518f6a57046985ef03a58ebb2f307a1 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4235298 Reviewed-by: Adam Mills <adamjmills@google.com>
* ppc/rt1739: implement dead battery bootTing Shen2023-02-082-3/+35
| | | | | | | | | | | | | | | | | | | | If rt1739 seems to be the only power source of the system, don't turn off its HV sink path. BUG=b:267412033 TEST=Verify that PPC is able to supply power in follow scenarios: 1) power on without battery 2) sysjump without battery 3) ec reset without battery BRANCH=none LOW_COVERAGE_REASON=early bringup Change-Id: I13d291edfc78f6e1491b3c4a0d8e2e661925004d Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4225988 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org>
* TCPMv2: Gate DP module support on a CONFIGDiana Z2023-02-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Add a CONFIG option to gate DP mode support within the embedded controller. By default, turn the DP module off if the AP is controlling the VDMs for mode entry. For modules which do not implement the DP config option, the header now defines stubs for DP specific functions to use. This obsoletes some of the stub functions from older unit tests. BRANCH=None BUG=b:266714542 TEST=on skyrim, compile with DP disabled and observe 3162 bytes saved, run zmake compare-builds -a and util/compare_build.sh -b all, ./twister -T ./zephyr/test passes (note: ECOS compare builds needed all assert statements removed to pass, as they grab the line number, zephyr compare builds passed before HC mode entry was revamped) Change-Id: I9619eb5d34e418f1972c4bf16d4cf9c8d551eac5 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4201454 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* it8xxx2: modify pd registers for it81202/it81302 CxRuibin Chang2023-02-072-2/+17
| | | | | | | | | | | | | | | Part of pd HW module changes in chip it81202/it81302 Cx version, so I modify pd registers and config for pd driver. BRANCH=none BUG=b:267415408 TEST=we re-work tentacruel to it81202Cx, then it can go to ready state with adapter, dongle and dock. Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Change-Id: Ibd8460fe14588b762d92a785a92c4bd2b587140f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4225334 Reviewed-by: Eric Yilun Lin <yllin@google.com>
* raa489000: never report ACOK when sourcing VBUSPeter Marheine2023-02-061-1/+22
| | | | | | | | | | | | | | | | | | | | | | 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>
* rt1739: fix ppc_dump output channelEric Yilun Lin2023-02-031-4/+11
| | | | | | | | | | | | | | | | | | | | | | | console commands should not use any channel. BUG=none TEST=ppc_dump 0 0 1 2 3 4 5 6 7 8 9 A B C D E F 00: 39 17 14 46 00 00 00 00 00 00 00 00 00 01 00 00 10: 80 E0 60 00 05 C0 00 00 40 00 00 10 00 00 00 23 20: 11 00 37 03 06 32 7F 91 00 10 00 07 08 00 80 96 30: 32 02 00 F1 09 04 0F 00 0F 03 08 0F 00 00 00 00 40: 64 00 00 02 00 00 31 31 00 00 10 00 1D 01 00 00 50: 22 13 49 5A 00 00 00 00 00 00 00 00 00 00 00 00 60: 00 01 BRANCH=none Change-Id: If39b754147316e8cb52ac7b2c4ad5523a4ecfde5 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4216996 Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* raa489000: support AC_PRESENT_CONTROL without OCPCPeter Marheine2023-02-011-5/+9
| | | | | | | | | | | | | | | | | | | The comparator inversion logic for the RAA489000 is relevant regardless of whether a given system uses an OCPC charger topology or something else; include the code even when OCPC is disabled so single-charger boards can use this feature. BUG=b:262663436,b:263691951 TEST=On pujjo (which does not use OCPC), GSC console now shows AC status bounce from off to on and back off as expected when a charger is disconnected from a hub that does not support fast role swap. BRANCH=nissa LOW_COVERAGE_REASON=AC_PRESENT_CONTROL is not currently tested Change-Id: Ib7c00fcc9644e79ccff62f519764b4fef5d1898a Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211348 Reviewed-by: Adam Mills <adamjmills@google.com>
* Zephyr: Add configs for F75303matt_wang2023-01-302-6/+99
| | | | | | | | | | | | | | | | | | The F75303 driver needs a Kconfig, and needs to build in zephyr. Add support to the device tree parsing and definition for the F75303 i2c temperature sensors. LOW_COVERAGE_REASON=no emulator for the F75303. b:266089368 BUG=b:262409595 BRANCH=none TEST=build the project that using the F75303 success.(mushu nami markarth) Change-Id: Id769718fbcda3e4213c50c90c9c7918bc0a31a43 Signed-off-by: matt_wang <matt_wang@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4142061 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Chao Gui <chaogui@google.com> Reviewed-by: Chao Gui <chaogui@google.com>
* RAA489000: support modify OCP level margintony.tang2023-01-301-0/+5
| | | | | | | | | | | | | support modify OCP level margin BUG=b:263996465 BRANCH=none TEST=zmake build pujjo Change-Id: I53a88053b0d1fee80b0e53c0e6bd7ece671b3c67 Signed-off-by: tony.tang <tony.tang@lcfc.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4154456 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* charger/isl9238c: Add BUCK_PHASE_VOLTAGE configjohnwc_yeh2023-01-302-0/+8
| | | | | | | | | | | | | | | | Adjusts the phase comparator threshold offset for forward buck and buck-boost. LOW_COVERAGE_REASON=No isl9238c emulator BUG=b:265862821 BRANCH=none TEST=fix charger stuck in CCM problem and S5 power consumption can meet < 0.5W criteria. Change-Id: Idc10c266e97c104f221eabc51b28c6c243ce17be Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179434 Reviewed-by: Diana Z <dzigterman@chromium.org>
* raa489000: Support AC_PRESENT when OTG modeAndrew McRae2023-01-232-0/+64
| | | | | | | | | | | | | | | | | | Flip the comparator inverter output when the charger chip is running in OTG mode so that the AC_PRESENT signal is correctly generated. The AC_PRESENT relies on the ACOK signal, but during OTG mode, ACOK is on when the charger is sourcing power to the port, so AC_PRESENT should be off. BUG=b:263691951 TEST=Verify with nivviks that AC_PRESENT is generated correctly BRANCH=none Change-Id: I004b8caaa63a902dd54288840c044bbe920e1347 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179436 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* tcpci: allow get_chip_info callers to update the cachePeter Marheine2023-01-221-40/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tcpci: handle tcpc tx discarded eventScott Chao2023-01-181-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | In Revision 2.0, Version 1.3 USB Type-C® Port Controller Interface Specification 4.7.1. If the transmission was discarded due to an incoming received message, the TCPC sets the TransmitSOP*MessageDiscarded bit in the ALERT register. In the old process, TCPM will always send soft reset if TCPC did not set TransmitSOP*MessageSuccessful. It will cause the pending message be cleared. For example, when TCPC get ATTENTION from USB-C dock and TCPM send GET_SINK_CAP to TCPC at the same time. The TCPC will set TransmitSOP*MessageDiscarded and TCPM will send soft reset and cause TCPM did not get ATTENTION message. BUG=b:265247056 BRANCH=none TEST=make sure dock can display. TEST=make buildall TEST=./twister -v -T zephyr/test Change-Id: I2597894c1f7abceea3c352ba1066d270d2d01ba0 Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4160814 Reviewed-by: Diana Z <dzigterman@chromium.org>
* syv682x: cached force discharge configEric Yilun Lin2023-01-131-1/+15
| | | | | | | | | | | | | | | | | | | | 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>
* clang-format: reformat few files with the current llvm releaseFabio Baltieri2023-01-111-1/+1
| | | | | | | | | | | | | | | | Looks like the current llvm release changes the clang-format output for few files, which is currently breaking CI and blocking any merging. Rerun clang-format -i on the affected files. BRANCH=none BUG=b:265098403 TEST=./util/check_clang_format.py Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ife808c4f24d9c2469d2addda8af209c695cee1e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4154893 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Alexander Hartl <alexanderhartl@google.com>
* SBS: Make battery_get_params clear flags selectivelyDaisuke Nojiri2023-01-101-21/+31
| | | | | | | | | | | | | | | | | | | | | | | 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>
* anx7483: extending LFPS_TIMER registerjohnwc_yeh2023-01-092-0/+22
| | | | | | | | | | | | | | | | Modify LFPS_TIMER to prevent going USB SLUMBER state too early. LOW_COVERAGE_REASON=no emulator for the ANX7483 exists BUG=b:254402716 BRANCH=none TEST=zmake build xivu Change-Id: I578e5b4b8ab5a3b75e2597f47c1b88b3ec7bacd1 Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4142058 Reviewed-by: SamSP Liu <samsp_liu2@compal.corp-partner.google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrew McRae <amcrae@google.com>
* zephyr/test/drivers: add it8xxx2_hw_sha256 testDino Li2023-01-061-0/+16
| | | | | | | | | | | | | | | | Verify that the hardware sha256 registers are configured as we want. BRANCH=none BUG=b:263259072 TEST=./twister -v -T zephyr/test/drivers/ \ --test external/platform/ec/zephyr/test/drivers/drivers.it8xxx2_hw_sha256 ./twister -v -i -T zephyr/test/drivers Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: Ie0c92f0fbdf709c1d1776a0fefe27bc6756d64d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4127644 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* usb_mux: Only send virtual mux state if changedAndrew McRae2023-01-041-2/+9
| | | | | | | | | | | | | | | | | | Only send the virtual mux status to the host if the mux status has changed, and is not zero. This avoids any false events waking up the host if there are changes on the port. BUG=b:262338992 TEST=Verify on nirwen that AP suspends after hub is unplugged. BRANCH=none Change-Id: I15ba40fe978c2f8773b179962de95904bee6b620 Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4128262 Reviewed-by: Sam McNally <sammc@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tree: Replace "unsigned" with "unsigned int"Andrea Grandi2023-01-041-10/+10
| | | | | | | | | | | | | | | | | Fix checkpatch error: > Prefer 'unsigned int' to bare use of 'unsigned' BUG=b:262047616 TEST=./util/compare_build.sh -b all -j 120 => MATCH BRANCH=none Change-Id: Ibf82332a1e1ea0a0a03d3993336e24883e495e05 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126483 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>