summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: i2c: protect physical portDino Li2021-07-221-0/+14
| | | | | | | | | | | | | | | | | | If i2c devices are connected to the same port, they should use the same mutex_lock() index. So the new transaction won't break the ongoing transaction. BRANCH=none BUG=b:189855648 TEST=Enable CONFIG_SMBUS_PEC and voltage regulator function on asurada. No i2c transaction is broken. Change-Id: Ib848e3c2e60b99ce66ad5fd2fc7095f90820a15d Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010920 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* retimer: clear unused mux bitsli feng2021-07-191-0/+7
| | | | | | | | | | | | | | | | | | | | During retimer firmware update, EC passes mux value to Coreboot/kernel. Coreboot/kernel checks mux value to know if PD port is NDA, or if port connection is set to what retimer firmware update sequence expects. Some bits of mux value are not used by Coreboot/kernel. This patch clears unused bits; and keeps alternate mode bits and safe mode bit in the mux value. BUG=none BRANCH=none TEST=On ADL RVP, verified NDA port retimer firmware update working. TEST=On Voxel DVT, verified NDA port retimer firmware update working with both Chromium solution and upstream solution. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I1becc09a0f5c5d4e1fb845c5fe33fa748d44bd4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010482 Reviewed-by: Keith Short <keithshort@chromium.org>
* ALT-DP: Don't send DP_ATTENTION until after DP_CONFIGScott Collyer2021-07-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This CL adds a new variable to the hpd state that enables the pd policy layer to inform the hpd->DP_ATTENTION converter that at least one DP_CONFIG message has been received. This control is used to make sure that DP_ATTENTION messages aren't sent prior the DFP_D being configured for DP port mode. Some port partners may get confused if DP_ATTENTION is sent prior to either DP_CONFIG or DP_STATUS. BRANCH=quiche BUG=b:192051705 TEST=verifed on kasumi (grunt) that the display is extended correctly following usbc hotplug events. Previously, this case was failing 1 out of 3-4 times. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I80d576de7fc0075be2b1a838d1ed764ae7828e8e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3035785 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* chgstv2: Move battery validate code to battery.cDaisuke Nojiri2021-07-151-0/+2
| | | | | | | | | | | | | | This patch moves the code validating battery parameters to battery.c. There is no functionality change. BUG=None BRANCH=None TEST=buildall Change-Id: I1706c4b504565b52964391077894665b4e5d1a86 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3007375 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fuel Gauge: Add interface for optional sleep supportDiana Z2021-07-141-0/+15
| | | | | | | | | | | | | | | Some fuel gauges may support a "sleep" mode which will enable lower power consumption in some states. Set up a structure for this along with an API which boards may use to call it. BRANCH=None BUG=b:186774653 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I155702bfb50a7353c7728445d60ecf853e39e4c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2967037 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bmi160: bmi260: Minor driver fixesTomasz Michalec2021-07-141-4/+4
| | | | | | | | | | | | | | | | | | | Fix three issues with BMI160 and BMI260 drivers: - get/set acclerometer/gyroscope offset will return error on failed read of offset register - BMI160 calibration function returns error when setting range fail - Invalid temperature is properly recognized by driver BUG=none BRANCH=none TEST=run zmake drivers test Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I545c0a931227ef7efc000ec97c1f6297a48e6d1a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3027039 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Add BMI260 emulatorTomasz Michalec2021-07-141-0/+4
| | | | | | | | | | | | | | Add extension to support BMI260 model. BUG=b:184856157 BRANCH=none TEST=none Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Iaffebdb5279001d085fd56868e81318528380380 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2997364 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: Add BMI160 emulatorTomasz Michalec2021-07-144-0/+1184
| | | | | | | | | | | | | | | | | | | | | Add BMI emulator which is emulated device on i2c bus. Emulated accelerometer and gyroscope properties are defined through device tree, but they can be changed in runtime through BMI emulator API. It allows to set custom handlers for write and read messages to emulate more complex scenarios or malfunctioning device. BMI emulator is designed to implement support for different BMI models as an extension to common emulator code. BUG=b:184856157 BRANCH=none TEST=none Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I63e9d3aca98c8923372437f7a66257a4c82817f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2977559 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* cbi: Introduce CONFIG_CBI_GPIOPhilip Chen2021-07-142-0/+19
| | | | | | | | | | | | | | | | | | | For the boards where SKU_ID/BRD_ID comes from the strapping pins on EC, this new config enables AP to ask EC for those hardware configs using the CBI host command `EC_CMD_GET_CROS_BOARD_INFO`. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=Enabled CONFIG_CBI_GPIO for lazor and manually verified with `ectool cbi get`. Change-Id: I7ec9097bab96d2076d9d42db2d003460db000113 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3002452 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* TCPC: add flag to disable debug accessory controlBoris Mittelberg2021-07-131-0/+2
| | | | | | | | | | | | | | | | | The NCT38xx TCPC takes over the GPIO we otherwise use to control the Burnside Bridge on Brya P1 devices. To get the BB out of reset we add the flag to tcpc_config structure to take the control back to TCPM. BRANCH=none BUG=b:191516281 TEST=running deployment in the lab; running FAFT PD test Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I73ddf26964cc6363640ddd80fbcbf353704d3198 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3016406 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* qcom: Deprecate AP_RST_REQ in SC7280Wai-Hong Tam2021-07-131-0/+2
| | | | | | | | | | | | | | | Add guards to deprecate the AP_RST_REQ power signal. The AP_RST_REQ is power signal only valid in SC7180. BRANCH=None BUG=b:187980397, b:148246695 TEST=Built all the Chromium EC images and Zephyr EC images. TEST=Modify a board to use the SC7280 CONFIG. Change-Id: I0b12889dd2549665d2c2d6bfc06fddd9b9357175 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2993210 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: Generalize system_get_board_version()Philip Chen2021-07-121-0/+5
| | | | | | | | | | | | | | | | | | Extend system_get_board_version() to support not only AP-sourced SKU ID but also EC-sourced SKU ID, whose getter function can be customized per board. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=zmake testall Change-Id: I764868d6472fb66480a43d028e5a79933b10117d Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3017602 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* zephyr: add InvenSense sensorsKeith Short2021-07-121-0/+1
| | | | | | | | | | | | | | | | Add Kconfig options for the InvenSense sensor drivers ICM426xx and ICM42607. This also creates config option for CONFIG_ACCELGYRO_ICM42607 which was missed when the driver was first created (CL:2822268). BUG=b:193195946 BRANCH=none TEST=zmake testall TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I422071e749ee2e8ed3ac1997aa886ee78395d37e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3015867 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* syv682x: Fix name for option to disable CC passthroughKeith Short2021-07-101-2/+3
| | | | | | | | | | | | | | | | | | | | | Change the name to disable CC passthrough on the SVY682x PPC from CONFIG_SYV682X_NO_CC to CONFIG_USBC_PPC_SYV682X_NO_CC to match the naming convention of other PPC options. This also corrects a non-fatal error in the firmware-eq CQ about a new ad-hoc EC config option. BUG=b:193195946 BRANCH=none TEST=zmake testall TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I66abcdddb7735f210fa25ed7c8b5760d8d626026 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3015866 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>
* driver: bmi3xx: Add support for BMI323 sensorBhanu Prakash Maiya2021-07-092-0/+3
| | | | | | | | | | | | | | | | | | | | | BMI323 is one of BMI3XX series accel sensor series. Adding defines, driver from Bosch APIs based initial patches submitted by Bosch team members in crrev/c/2966530. BRANCH=none BUG=b:178398789 TEST=Accel implementation tested on Guybrush EC commands: > accelinfo > acceldata Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@chromium.org> Change-Id: I9fa9d80aa25231261994adb4ef0ac5d71ac2f81a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2984740 Reviewed-by: Diana Z <dzigterman@chromium.org> Auto-Submit: Bhanu Prakash Maiya <bhanumaiya@google.com> Commit-Queue: Bhanu Prakash Maiya <bhanumaiya@google.com> Tested-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* system: Clean up system_get_board_version()Philip Chen2021-07-092-20/+10
| | | | | | | | | | | | | | | | | | | Refactor system_get_board_version() a bit so that we can remove CONFIG_BOARD_VERSION_CUSTOM and CONFIG_BOARD_VERSION from config.h. BRANCH=None BUG=b:186264627 TEST=make buildall -j TEST=zmake testall Cq-Depend: chromium:3015243 Change-Id: Id5ab809493c297b7d330ea13dcd6934ec00042a6 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3004112 Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* zephyr: switch to using shell_*, not printkDawid Niedzwiecki2021-07-091-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reimplement the printf functions for Zephyr to use shell_* functions instead of printk. The main differences are: -UART output is buffered by the shell layer. The size of the buffer should be adjusted per board (SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE) -The shell uses non-blocking UART FIFO operations while printk waits actively for every sent byte. -The shell prints can not be split by the other shell prints so it should increase the quality of the output. However the shell_* functions can not be used in interrupts, so use printk instead which can divide the shell output. The output may be messy for boards that have a lot of prints in interrupts e.g. volteer. EC uses unusual print format e.g. "%pT" to print a timestamp, so use the CrosEC's vfnprintf function and then pass the generated string to the shell_* print. Use the sprintf function for that purpose. Long term, the EC codebase should switch to a usual print format, so shell_* can be used directly and not 2 versions of vfnprintf. This change should also help to pass tests that wait for a certain pattern on output e.g. ECBootTime. BUG=b:191724484, b:178033156 BRANCH=none TEST=Verify the console output works Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ifaed2093ab8c43038c7d3e0ded1449a93f7f7da5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2988194 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv2: Add new override function for getting default RpScott Collyer2021-07-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | This CL addes a new overridable function typec_get_default_current_limit_rp() which is used in place of CONFIG_USB_PD_PULLUP to retrieve the correct Rp value to reflect the current limit. This functionality is required for boards which are not per port symmetric. Unless this function if overridden in a board/basebard specific file, there is no change in functionality from present design. BUG=b:191793195 BRANCH=quiche TEST=verfied on Gingerbread that Rp = 3.0A is selected for C0 and Rp = 1.5A is selected for port C1. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I9ec9daa563f6b4f551b4890ae7a56767f7c26764 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2980435 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* console: use functions to check console channelsDawid Niedzwiecki2021-07-081-0/+17
| | | | | | | | | | | | | | | | Create a function to check if a console channel is disabled. It allows checking a channel outside the console_output.c, which is needed in Zephyr. BUG=b:191724484 BRANCH=none TEST=Check if console channels works Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I9ab38c17c66373c3a38f45c8080c8166a2a9d09f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3001270 Reviewed-by: Keith Short <keithshort@chromium.org>
* NCT3807: Set up correct FRS enableDiana Z2021-07-071-0/+3
| | | | | | | | | | | | | | | | | | | | | The NCT3807 requires a few steps for FRS enablement. Specifically: - Zero out VBUS_SINK_DISCONNECT_THRESHOLD - Enable FRS interrupt (already done in TCPCI code) - Set FRS enable to 1 Note that it should not use the TCPCI specification method of clearing AutoDischargeDisconnect as soon as FRS is set. This results in the CC lines immediately reading as Open. BRANCH=None BUG=b:183586640,b:192012189 TEST=on guybrush C0, confirm FRS can execute successfully with WooHubs, HooToo, and Moshi Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ida0d33ae9ce4b8660615a0b9f3064cf90f5ae3bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2987598 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* chgstv2: Clean up CONFIG_CHARGER_PROFILE_OVERRIDEDaisuke Nojiri2021-07-061-11/+0
| | | | | | | | | | | | This also cleans up CHARGE_STATE_DEBUG. BUG=None BRANCH=None TEST=buildall Change-Id: Idb18118100eece9029051625b4b32bdf09fdd553 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929344
* System: Add SYSTEM_IN_MANUAL_RECOVERY flagDaisuke Nojiri2021-07-052-1/+20
| | | | | | | | | | | | | | | | | | This patch adds SYSTEM_IN_MANUAL_RECOVERY, which indicates the system is in recovery mode. It's set when EC_HOST_EVENT_KEYBOARD_RECOVERY is set and cleared when the system shuts down (not when the host event flag is cleared). BUG=b:188242794 BRANCH=None TEST=Verify sysinfo command prints 'Recovery: yes' in recovery screen. TEST=Verify sysinfo command prints 'Recovery: no' after shutting down from recovery screen. Change-Id: I357e25fa4072cb4549dbe2c6bd476b0a93ccbb38 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3001190
* cbi: Add cbi_get_cache_status()Philip Chen2021-07-031-0/+5
| | | | | | | | | | | | | | | | Implement a new API cbi_get_cache_status() for us to probe CBI cache status in unit tests and anywhere else. BRANCH=None BUG=b:186264627 TEST=make buildall -j Signed-off-by: Philip Chen <philipchen@google.com> Change-Id: Ibe3af7df4f04abe2d65b31f2d604dbb6044e5863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3002448 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* DP Altmode DFP: Add `mfallow` commandudaykiran2021-07-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The USB Type-C Altmode allows for protocols other than USB to be transferred over a USB connection. Chromebooks use this functionality to transfer DisplayPort on USB signals. This is achieved through USB-PD handshake through SVDMs to discover, configure, and to enter or exit Alt modes. When DisplayPort as an Alt Mode is enabled, allowable functionalities are: -- SS and high speed USB functionality and two-lane DP. -- HS USB functionality and 4-lane DP. Chromebooks honor Multifunction bit set in the DPStatus message sent by a dock. However, for development purposes we would like to have control to honor the MF bit or ignore it, there by achieving 2-lane DP vs 4-lane DP functionality. 4-lane DP functionality is required to test higher resolution monitors such as 4k60. BUG=b:181365633 BRANCH=none TEST=make BOARD, tested on G5 dock with kindred. Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Icc25f339a78d1423b094d2acf9d586721ec2df46 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2939383 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cbi: Remove cbi_eeprom.hPhilip Chen2021-07-022-16/+2
| | | | | | | | | | | | | | | | Move the declaration of cbi_config to cros_board_info.h so that we can get rid of cbi_eeprom.h. BRANCH=None BUG=b:186264627 TEST=make buildall -j Change-Id: I6780542c6428090117d879945d901fe82ce999f4 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3002446 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* system: Rename reset_flags used in system_encode_save_flagsDaisuke Nojiri2021-07-011-2/+2
| | | | | | | | | | | | | | | | | There is a variable named reset_flags, which is shared by all code in system.c. system_encode_save_flags gives its parameter the same name. This patch renames the local variable to remove the confusion. There is no functionality change. BUG=None BRANCH=None TEST=buildall Change-Id: I9838d8d4c77e3a266731a840c70a77ddf1cefb25 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2998512 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Typec: Add disconnected status eventDiana Z2021-07-011-0/+1
| | | | | | | | | | | | | | Add an event bit to represent that the port has been disconnected. BRANCH=None BUG=b:188330043 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia0975cae66d81a3ef066e62632d8cd0b453b9a3a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2983991 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Prashant Malani <pmalani@chromium.org>
* battery: Set host's low battery shutdown SoC to 4%Daisuke Nojiri2021-07-011-4/+4
| | | | | | | | | | | | | | | Currently, the host's low battery shutdown SoC is 3% by default but most boards are configured to 4%. This patch changes the default value to 4% so that we require only minority boards to customize it. BUG=b:191837893, b:189737806 BRANCH=None TEST=Storo using battfake EC command. Change-Id: I69ed5d8cc8c0d1e321d79c5eae26a9c21624a4ea Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2998509 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: Add argument check in BMA2x2 driverTomasz Michalec2021-06-301-0/+1
| | | | | | | | | | | | | | set_range and set_data_rate functions of BMA2x2 driver should check input values to not set values outside of range supported by device. BUG=none BRANCH=none TEST=makeall Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Ie9650975e00a99e86a5229ee200dab24be536076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953222 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: Add BMA255 emulatorTomasz Michalec2021-06-301-0/+154
| | | | | | | | | | | | | | | | | Add BMA255 emulator which is emulated device on i2c bus. Emulated accelerometer properties are defined through device tree, but they can be changed in runtime through BMA255 emulator API. It allows to set custom handlers for write and read messages to emulate more complex scenarios or malfunctioning device. BUG=b:184855546 BRANCH=none TEST=none Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I4def7fcc54edbf9cb346fda0f21f647a5ad5f8d5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2933301 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* battery: Set host's low battery shutdown SoC to 3%Daisuke Nojiri2021-06-292-5/+8
| | | | | | | | | | | | | | | | | | | | | | | Currently, the host's low battery shutdown SoC is 2%. This is the same as EC's low battery shutdown threshold. The EC waits for 30 secs before it triggers the low battery shutdown and powerd reads the SoC every 30 secs. Thus, in most cases powerd can shut down the system gracefully but these delays can be configured differently and the system may be too busy to process all shutdown tasks within 30 secs. This patch increases the host's shutdown SoC to 3%. This will further guarantee that powerd will be given enough time to do everything for a proper shutdown. It also avoids deeply discharging the battery, which is bad for the battery health. BUG=b:191837893 BRANCH=None TEST=Altas using battfake EC command. Change-Id: I3ab23205b400a1a326a60b8f9501611c027183b2 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994747 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_mux: Remove disconnect latch flagAyushee Shah2021-06-291-18/+0
| | | | | | | | | | | | | | With dark resume enabled, disconnect latch flag is obsolete BUG=None BRANCH=None TEST=Swapping Type C devices in s0ix works Signed-off-by: Ayushee Shah <ayushee.shah@intel.com> Change-Id: Ica1b55f820f5b3fff5b7dabf88ca57ac0993f246 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2846417 Reviewed-by: Madhusudanarao Amara <madhusudanarao.amara@intel.corp-partner.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* cbi: Separate CBI EEPROM driver from CBI protocolPhilip Chen2021-06-292-4/+57
| | | | | | | | | | | | | | | | | Factor out the physical storage driver (cbi_eeprom.c) from the CBI data/protocol layer (cbi.c), setting up the groundwork to support more options of CBI sources. BRANCH=None BUG=b:186264627 TEST=make buildall -j Change-Id: Ic30a6f789970dd6723cf70d4e852ddb7161f796f Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2965848 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* driver: bma4xx: Add support for BMA422 sensorBhanu Prakash Maiya2021-06-282-0/+3
| | | | | | | | | | | | | | | | | | | | | | | BMA422 is one of BMA4XX series accel sensor series. Adding defines, driver from Bosch APIs based initial patches submitted by Bosch team members in crrev/c/2894333. Reference code can be found on https://github.com/BoschSensortec/BMA423-Sensor-API. BRANCH=none BUG=b:178400750 TEST=Accel implementation tested on Guybrush EC commands: > accelinfo > acceldata Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@chromium.org> Change-Id: I8117283e54980379989fb01f68c29b7d6c501eca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2981465 Tested-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Auto-Submit: Bhanu Prakash Maiya <bhanumaiya@google.com> Commit-Queue: Rob Barnes <robbarnes@google.com> Reviewed-by: Rob Barnes <robbarnes@google.com>
* tcpm: Do not include gpio.hCaveh Jalali2021-06-261-3/+2
| | | | | | | | | | | | | | | This removes the inclusion of gpio.h from tcpm.h. There's really nothing GPIO related in this file. BRANCH=none BUG=b:192010784 TEST=buildall passes Change-Id: Ia244e36f6137e2c170089ab0e08db7c1902b7e15 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2987160 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Boris Mittelberg <bmbm@google.com>
* TCPM: Add new LPM bypass TCPC accessorsCaveh Jalali2021-06-251-0/+24
| | | | | | | | | | | | | | | | | | | | This adds a set of light-weight TCPC register access functions for special cases where the caller arranges for the TCPC to be accessible and the complexity of fully taking a TCPC out of LPM mode is not desirable. A typical use case is for alert service routines to be able to peek at a TCPCs alert register to determine if further processing is requested. BRANCH=none BUG=b:191531291 TEST=buildall passes Change-Id: Ib5c9add95f04be311315808168b070793b51cb24 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2986601 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* stm32: rename CONFIG_STM32_SPI1_MASTER to …CONTROLLERHarry Cutts2021-06-251-3/+3
| | | | | | | | | | | | | In line with OSHWA terminology. BUG=b:181607131 TEST=make -j BOARD=hammer BRANCH=none Change-Id: I6d212e60d5aceb8497f00520b693006cc1af2d45 Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2981123 Reviewed-by: caveh jalali <caveh@chromium.org>
* chgstv2: Refactor charger_discharge_on_acDaisuke Nojiri2021-06-251-0/+2
| | | | | | | | | | | | | | | This patch makes charger_discharge_on_ac call board_discharge_on_ac. It also makes set_chg_ctrl_mode call charger_discharge_on_ac. This makes sense since when the charge control mode changes, discharge-on-ac also needs to be enabled or disabled. BUG=b:188457962 BRANCH=none TEST=make runhosttests Change-Id: I65ec09f580afc987cc86f4c60c15c1f90ead6c3c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2986848
* Update EC_CMD_CHARGE_CONTROL to version 2Daisuke Nojiri2021-06-252-1/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Version 2 of EC_CMD_CHARGE_CONTROL can control battery sustainer. It allows the host to set the upper and lower thresholds between which the EC tries to keep the battery state of charge. Version 2 of EC_CMD_CHARGE_CONTROL also supports 'GET' request. It allows the host to query the current charge control settings. localhost ~ # ectool chargecontrol Charge mode = NORMAL (0) Battery sustainer = off (-1% ~ -1%) localhost ~ # ectool chargecontrol normal 66 66 Charge state machine is in normal mode with sustainer enabled. localhost ~ # ectool chargecontrol Charge mode = NORMAL (0) Battery sustainer = on (66% ~ 66%) localhost ~ # ectool chargecontrol normal Charge state machine is in normal mode. BUG=b:188457962 BRANCH=none TEST=Atlas. See above. Change-Id: I81ec62172b4f159c46334fc0f940a2adae3f2b8a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929340 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* SenderResponseTimer: offset with TCPC transmit success timestampudaykiran2021-06-252-0/+9
| | | | | | | | | | | | | | | | | | | | | | The SenderResponseTimer shall be used by the sender's policy engine to ensure that a message requesting a response is responded to within a bounded time. Which is 24Msec to 30 Msec. However, delays associated TCPC I2C, PE, and PRL layers make hard reset response time greater 30Msec. This CL address the delay associated with TCPC. When TCPC transmit success is reported by TCPC upon receiving the GoodCRC, time stamp is recorded. Another time stamp is recorded just before starting SenderResponseTimer and offsetting PD_T_SENDER_RESPONSE. BUG=b:182439366 BRANCH=none TEST=checked with GRL compliance tester. Noted that total response time is in the middle of the expected time of 24ms to 30ms. This fix achieved response time about 27.675ms Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Id2ddcdd90eed8b3d66ade3d16877004871a21de8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2971078 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPCI: add ALERT_NONECaveh Jalali2021-06-241-0/+1
| | | | | | | | | | | | | | | This adds the TCPC_REG_ALERT_NONE constant to explicitly checking if the alert register has no alerts pending. BRANCH=none BUG=b:191531291 TEST=buildall passes Change-Id: If2d2166fbc422f071a394125fbdbe14cf20f54bc Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2986599 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* chgstv2: Unify power-on and shutdown battery thresholdsDaisuke Nojiri2021-06-231-40/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, power-on battery SoC and shutdown battery SoC are independently configured by each board. This patch will unify the setting as follows: CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 2 (don't boot if soc < 2%) CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2 (shutdown if soc <= 2%) BATTERY_LEVEL_SHUTDOWN = 3 (shutdown if soc < 3%) CONFIG_BATTERY_EXPORT_DISPLAY_SOC = Y (removed) CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC = 1 This allows us to show the low battery alert whenever we can because EC doesn't inhibit power-on even if it knows the host would immediately shut down. With CONFIG_BATTERY_EXPORT_DISPLAY_SOC, boards will start using the CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2% as the low battery threshold (and the SoC will be agreed between the EC and Powerd). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 1 will keep the same threshold. This is for avoiding degrading the UX by increasing the power-on threshold (even though a question that 1% may not be enough for soft sync to finish consistently remains to be answered). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON > 2 will have a lower threshold but we think 2% is enough to finish the software sync. A lower threshold also improves the UX by showing the low battery alert in the situation where otherwise the system would leave the user uninformed by not responding to a power button press. BUG=b:191837893 BRANCH=None TEST=buildall Change-Id: If6ff733bc181f929561a3fffb8a84e760668ce37 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2981468 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mt8192: move power_signal to includeDenis Brockus2021-06-221-0/+16
| | | | | | | | | | | | | | | | | | enum power_signal was duplicated in a few places and really belonged in an include file. This has been created as include/power/mt8192.h BUG=b:180980668 BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ibdcecc73feffcfa6d5b72fa8ef503f1802e14925 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2980811 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* bb_retimer: cleanup: Change the power handler func name & paramsVijay Hiremath2021-06-181-5/+5
| | | | | | | | | | | | | | Changed the power handler function name from bb_retimer_power_handle() to bb_retimer_power_enable() and on_off param to enable. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ifad4c71a5d76b4841ea369a991160e221c051ec5 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2973375 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: update snprintf signature to be compatible with zephyr 2.6Yuval Peress2021-06-181-2/+3
| | | | | | | | | | | | | | | | Also update the tests for printf since the documentation makes no guarantee about negative size values. BRANCH=none BUG=b:190731415 TEST=build brya TEST=make run-printf Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I5e773362f1f30a1beb95284e589e49db3a1d8800 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2970989 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* KB800x: Add DriverEric Herrmann2021-06-181-0/+4
| | | | | | | | | | | | | Add KB800x driver. Add config options to Kconfig. BUG=b:168930682 TEST=On Volteer, check USB4, TBT3, DPMF, DP, and USB3 functionality BRANCH=none Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Change-Id: Ic71b0d4236037522455a0561ba87fd9a874a4968 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2930581 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: add check for zephyr versionYuval Peress2021-06-171-0/+9
| | | | | | | | | | | BRANCH=none BUG=none TEST=(see next CL, added check to shim/src/gpio.c and tested the build) Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I2e53a1531e02aebc3648282c9fcbc2bacd7aa0b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2970986 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* PCHG: Fuzz PCHG and ctn730 driverDaisuke Nojiri2021-06-171-0/+3
| | | | | | | | | | | | | | | | This patch adds a fuzz test for PCHG and ctn730 driver. With the given corpus, the test currently reaches all the normal mode states. BUG=b:190841496 BRANCH=trogdor TEST=make run-pchg_fuzz TEST=pchg_fuzz.exe -seed=1 -runs=1000000 -dict=fuzz/pchg_fuzz.corpus Change-Id: I6eedbbbdbf3396dfa2b98ca302e16d142ea251d5 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2956076
* ec_commands: Add EC_HOST_EVENT_NONERob Barnes2021-06-161-5/+5
| | | | | | | | | | | | | | | ACPI requires event 0 to represent no event. Add EC_HOST_EVENT_NONE=0 to host_event_code to improve readability when there's no event. BUG=b:184074997 TEST=Build and boot guybrush BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: I04690dd98b0e5b8ee9e002279b238c500e364398 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2964955 Reviewed-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* util: Add function to convert binary first base3 numberWai-Hong Tam2021-06-161-0/+31
| | | | | | | | | | | | | | | | | | | | | | Add an util function to convert a ternary bit array (each element is either 0, 1, or 2) to a non-standard ternary number system where the first 2^n natural numbers are represented as they would be in a binary system (without any Z digits) and the following 3^n-2^n numbers use the remaining ternary representations in the normal ternary system order (skipping the values that were already used up). This function is useful for converting BOARd ID, which is initially used a binary and later decided to switch to tri-state after some revisions have already been built. BRANCH=Trogdor BUG=b:190250108 TEST=make runhosttests Change-Id: I853a04f3b28eb54c61855251dc5232c7e6994fef Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2964389 Reviewed-by: Julius Werner <jwerner@chromium.org>