summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv2: Print VID/PID only when presentDiana Z2020-11-121-1/+4
| | | | | | | | | | | | | | | | Not all partners will reply to DiscoverIdentity, so only print out their VID/PID combination when the VID is non-zero. BRANCH=None BUG=None TEST=on drawcia, plug in a charger which does not reply to DiscoverIdentity and verify it doesn't print Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I1ea114794ada20b68cb6f902b085a2fd02650912 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2535216 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* i2c_master: Add i2cxfer raw commandJan Dabros2020-11-121-1/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GL3590 USB3.1 hub has i2c interface, which behaves different from majority of i2c slaves. While write operation is the same, this chip doesn't support repeated-start sequence for reads. New command allows to create i2c frames in a more flexible way. User may specify how many (if any) bytes to write and then how many bytes to read. Since the raw option is for debugging and won't be commonly used, do not include it by default to save space on flash - use #define CONFIG_CMD_I2C_XFER_RAW built with the raw option. For now, it will be defined only for servo_v4p1. BUG=b:150323106 BRANCH=master TEST=buildall. Verify that reading i2c data from non-gl3590 devices is not affected by this change. For usual write16 (0x0201) at offset 0x4 from device 0x24: i2cxfer raw 1 0x24 0 0x4 0x1 0x2. When reading from GL3590 device, two operations will be required: i2cxfer raw 1 0x50 0 0x10 i2cxfer raw 1 0x50 8 Signed-off-by: Jan Dabros <jsd@semihalf.com> Change-Id: Ifd9ee5184490eb8de383c9468b0152e6f993d7c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505780 Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org>
* ioexpander: Fix type error in command_ioex_getRob Barnes2020-11-121-13/+14
| | | | | | | | | | | | | | | | | | | | enum ioex_signal is a uint16. It gets cast to an int32 in command_ioex_get. When find_ioex_by_name returns -1, it gets interpreted as 65535, not -1. Return IOEX_SIGNAL_END from find_ioex_by_name instead of -1. Minor cleanup to make it more clear that enum ioex_signal is not an int. BUG=b:172599383 BRANCH=Zork TEST='ioexget foo' does not crash Change-Id: I92922591b6a657a1d2a0840c3d361a8a909895fb Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533671 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* motion_sense: Make change in range permanentGwendal Grignou2020-11-124-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
* tcpmv2: Don't trigger BC1.2 detect if role doesn't changeKeith Short2020-11-121-12/+29
| | | | | | | | | | | | | | | | | | | Don't trigger BC12 client detect or BC1.2 host mode if the data role hasn't changed. This fixes issues seen with some CDP hosts that drop VBUS if BC1.2 client detect is restarted. BUG=b:158708115 BRANCH=firmware-volteer-13521.B-master TEST=Connect laptop CDP to Volteer. CDP falls back to SDP but remains stable instead of looping on BC1.2 detect. TEST=Connect desktop CDP to Volteer, verify 7.5W charging. TEST=Connect DCP to Volteer, verify 7.5W charging. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ifd0ee379a0d5894894d13fb1a64b4dec2e77ec9e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2529809 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Revert "crc8: rename crc8 to cros_crc8 to to avoid zephyr conflict"Jett Rink2020-11-117-30/+29
| | | | | | | | | | | | | | | Something slipped through CQ coverage. Need to figure out, but in the mean time, revert the 3 CLs that seemed to have caused the issue. BRANCH=none BUG=chromium:1147953 TEST=none This reverts commit befe5a9c78ff4e75db7c5cda801688c8976e95f3. Change-Id: I14e82f33646b6574b1b3da13783143e3a29d417b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533357
* tree: rename strtoul to strtoull since it is 64-bitJett Rink2020-11-113-3/+5
| | | | | | | | | | | | | | | A long is 32-bit, but a long long is 64-bit. The function name should be strtoull if it is returning 64 bits of data. BRANCH=none BUG=b:172592963 TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I04c40f9256ed37eb1cf9b6bd1b0ef0320fe49b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2530874 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* crc8: rename crc8 to cros_crc8 to to avoid zephyr conflictJett Rink2020-11-117-29/+30
| | | | | | | | | | | | | | | | | Zephyr already provides a robust implementation for crc8, but it conflicts with platform/ec's name of crc8. Rename platform/ec to use cros_crc8 instead since it is a special case of zephyr crc8 implementation. BRANCH=none BUG=b:168032589 TEST=builds. Just a rename Change-Id: Idf312098cb921c8e10dcb48c5eb297801af2df8a Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527810 Reviewed-by: Yuval Peress <peress@chromium.org>
* Add EC_CMD_BATTERY_GET_STATIC v1 for zorkPeter Marheine2020-11-102-15/+46
| | | | | | | | | | | | | | | | | | | | | | | | Some zork variants have battery model names that differ only beyond the 7th character, which cannot be differentiated with the current limitation of 8 characters per battery string. Introduce a new hostcmd version that allows longer battery strings and enable it on Zork. Because allowing longer strings through the host memory map is more difficult and not required (because getting the full longer string is mostly only useful for servicing), the host memory map is unchanged. ectool is updated to use hostcmd (rather than memory map) if the new command version is available, in order to take advantage of it. BUG=b:171854783 TEST=ectool battery prints longer strings when supported by the EC; a hacked EC on morphius can return 11 characters of text. An EC running older firmware still works with a new ectool. BRANCH=zork Change-Id: I63d20d4f690b6945cb1d423aafaf55dafc039211 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519243 Reviewed-by: Edward Hill <ecgh@chromium.org>
* zephyr: add stub host events implementationJack Rosenthal2020-11-091-29/+32
| | | | | | | | | | | | | | | | Include host_command.c and host_event_commands.c so that we get some basic definitions to get things compiling. Since we don't have CONFIG_HOSTCMD_ESPI enabled yet, this is really just pulling in stub definitions. BUG=b:172678200 BRANCH=none TEST=compiles for volteer Cq-Depend: chromium:2523466 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ic293f80d30ecf9534ff935b73aa4ca42614a77be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523381
* Zephyr: add more compliant implementation for irq_(un)lockYuval Peress2020-11-082-1/+33
| | | | | | | | | | | | | | | | | | This change replaces the stubbed irq_(un)lock static functions defined in task.h with new functions that behave more like the Zephyr implementation of irq_(un)lock functions. This should make the migration from interrupt_(dis|en)able to Zephyr more seamless. BRANCH=none BUG=b:172060699 TEST=Added unit tests, make runtests -j, and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ia7ad2b8d7d411a11699353bf5d3cc36a261fad14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511720
* Add chip-specific shim along with i2c moduleYuval Peress2020-11-081-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change accomplishes 2 things: 1. It refactors the zephyr/shim directory to structure around chip specific compilation. In this example, we're focusing on npcx7m6fb which is used in volteer but others can be added easily. 2. It shims the common/i2c_master.c by providing an alternate implementation of i2c_xfer_unlocked that calls down to the Zephyr API i2c_write_read instead of the chip specific i2c_xfer_no_retry or chip_i2c_xfer_with_notify. The shim layer is made possible by the addition of zephyr/shim/include/i2c/i2c.h which adds a functions that needs to be implemented per chip (npcx7 family in this case) and allows us to map the current port int which is defined in chip/${CHIP}/registers.h (chip/npcx/registers-npcx7.h in our case). This function (i2c_get_device_for_port) maps the platform/ec port int to a const struct device * which is needed in the Zephyr I2C APIs. BRANCH=none BUG=b:171302975 TEST=clean_build.sh projects/experimental/volteer/ and make BOARD=eve Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I210f4758337bf384d0d6f103eef8b89126887d11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504285 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* common:i2c: Migrate interrupt_(dis|en)able calls to irq_(un|)lockYuval Peress2020-11-081-5/+7
| | | | | | | | | | | | | | | | | This change migrates interrupt_disable -> irq_lock and interrupt_enable -> irq_unlock. BRANCH=none BUG=b:172060699 TEST=make runtests -j, and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ia5d872d8b9fcabc23a859350cf3bf121597d84af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2517629 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* zephyr: Enable the '8042' commandSimon Glass2020-11-071-20/+18
| | | | | | | | | | | | | | | | | | | | | | | | | This is used to provide information about the keyboard operation. Enable this command and its subcommands. Note that in ECOS these subcommands are also top-level commands, but this is not the case in Zephyr, since it seems unnecessary. Note also that changing these to console sub-commands may end up making FAFT testing more difficult since the invocation on the EC UART would be different. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos Run on volteer and try out '8042 kbd', etc. Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ia11092af350247ac98681485a9ddd309c7192272 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523452 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Revert "topology: Add USB2 & USB3 connectivity info to tcpc_config_t"caveh jalali2020-11-061-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f5121aa5b762a68e9e2bca3c4c132cb2ffc9cfdb. Reason for revert: feature no longer used BRANCH=none BUG=b:153941950 TEST=buildall passes Original change's description: > topology: Add USB2 & USB3 connectivity info to tcpc_config_t > > Intel SoC needs which USB2/3 ports are assigned to which Type-C ports. > This patch adds USB2 and USB3 port numbers to tcpc_config_t so that > EC_CMD_LOCATE_CHIP can return it to the host. > > Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> > > BUG=b/134614710 > BRANCH=none > TEST=TBD > > Change-Id: I10206dde4d71ac6e40a71c65333db4edd3c81e7a > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1669880 > Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> > Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Tested-by: Daisuke Nojiri <dnojiri@chromium.org> > Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> > Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Bug: b/134614710 Change-Id: Ibd60e7e3d59e11734a3a08917be3daaae7fb569d Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427440 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* common: body_detection: modify variance updating formulaChing-Kang Yen2020-11-061-6/+6
| | | | | | | | | | | | | | | Modify the variance formula to speed up body detection. BRANCH=None BUG=b:123434029 TEST=make buildall; TEST=make BOARD=ampton, re-flash the DUT, see if the body detection works Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Ib444abb6bdfbc637539103d563b515817865acc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2452133 Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* zephyr: Allow keyboard_8042 to build with zephyrSimon Glass2020-11-061-5/+30
| | | | | | | | | | | | | | | | | Make a few changes so that this file can build. It does not work yet. BUG=b:167405015 BRANCH=none TEST=make BOARD=volteer zmake configure .../zephyr-chrome/projects/experimental/volteer \ -B /tmp/z/cos zmake build /tmp/z/cos See there are no errors Change-Id: If68cc8e4541f513013481bde859fbe2f4681a0bc Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521358 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* TCPMv2: Update 'pdcable' console commandAyushee2020-11-061-0/+26
| | | | | | | | | | | | | | | This patchset adds information about cable's Thunderbolt mode response. BUG=b:129990370 BRANCH=none TEST=EC command "pdcable <port>" prints out the information about the cable. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I485fb767009242636332e19ed7d211dbcc837b27 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2515063 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Update sending cable information to the hostAyushee2020-11-061-8/+8
| | | | | | | | | | | | | | | | If the type of cable is Active or if it is a Linear re-driver cable, set the Bit 0: Active/Passive cable of control_flags in the usb_pd_control host command to 1 BUG=b:156749387 BRANCH=None TEST=Able to set bit 0 when an active/LRD cable is connected Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Icde9a905a0456702c26f91bb8a3175a3b1aff9b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2470210 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add support for linear re-driver cablesAyushee2020-11-064-61/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The linear re-driver cables enumerate as passive cables in the Discover mode SOP' response from the cable. But they have Active/Passive bit (B25) in the discover mode SOP' response set. Hence, if the cable is LRD, the port enters Thunderbolt mode SOP' before entering USB and it also sets the cable as active in the mux and retimer setting. USB4 PD flow for LRD cables: Is Discover mode SOP' B25? ----- N ----- Enter USB4 SOP with Gen 2 cable speed | y | Enter TBT SOP' | Enter USB4 SOP as per cable speed. TBT PD flow for LRD cables: Is Discover mode SOP' B25? ----- N ----- Enter TBT SOP | y | Enter TBT SOP' | Enter TBT SOP This CL also updates the retimer setting and Enter USB Data object for USB4 according to the type of cable detected (LRD/Active/passive) BUG=b:156749387 BRANCH=None TEST=With Linear re-driver cable, 1. Able to enter USB4 mode 2. Able to enter Thunderbolt mode 3. Able to exit and re-enter USB4 on reboot 4. Able to exit and re-enter Thunderbolt mode on reboot Change-Id: Ie5258f792e13a205dea71fc9f06b1d8987ec9194 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2470209 Reviewed-by: Tanu Malhotra <tanu.malhotra@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* Revert "motion_sense: set sensor data rate to 0, when sensors are being ↵Gwendal Grignou2020-11-061-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | powered off" We can not change the ODR when the sensors are marked as not active. They may not be powered on and can not be touched. This reverts commit 89b87b5004252bd6f6fa6c019a63a4a1dd157600. Reason for revert: <INSERT REASONING HERE> Original change's description: > motion_sense: set sensor data rate to 0, when sensors are being powered off > > when sensors are being powered off, we should set sensor data rate to 0, > to prevent the motion sense task from being unable to enter the idle > state because the collect rate is not equal to 0. > > BUG=b:170703322 > BRANCH=master > TEST=make buildall pass, and test cerise power consumption meet spec in > DC S5 state > > Signed-off-by: Mike Lee <mike5@huaqin.corp-partner.google.com> > Change-Id: Iae66f87aee1889b460fd598b1962be658c74ddab > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505392 > Reviewed-by: Cheng-Hao Yang <chenghaoyang@chromium.org> > Reviewed-by: Ting Shen <phoenixshen@chromium.org> BRANCH=master BUG=b:170703322 TEST=compile Change-Id: Ieb8566614249fc2efdce5993291ceb98bab429f8 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519428
* common: body: Use IS_ENABLEDGwendal Grignou2020-11-061-11/+11
| | | | | | | | | | | BUG=chromium:1140877 BRANCH=none TEST=buildall Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Iac63ec83258d1194d2b035c1dd67b6f915d37c16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2489462 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* motion_lid: Add IS_ENABLED()Gwendal Grignou2020-11-061-31/+43
| | | | | | | | | | | | | Add IS_ENABLED() instead of #ifdef when possible. BUG=chromium:1140877 BRANCH=none TEST=buildall Change-Id: I644e8ceb066a83531632709a59b29b257f259929 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2489460 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* common: motion: add IF_ENABLED()Gwendal Grignou2020-11-061-237/+205
| | | | | | | | | | | | | | | Split some defines when necessary, add IF_ENABLED to common/motion_sense.c. Find small setting errors in some boards along the way. BUG=chromium:1140877 BRANCH=none TEST=buildall Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I77ff528a16809088a986a2cc707aff8ae7df3906 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488939 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* motion: Use empty CONFIG_ variable to use IS_ENABLED()Gwendal Grignou2020-11-062-3/+3
| | | | | | | | | | | | | | | | Split information in a boolean variable and another variable that contains a property. For instance, CONFIG_GESTURE_SENSOR_DOUBLE_TAP becomes: CONFIG_GESTURE_SENSOR_DOUBLE_TAP : boolean variable CONFIG_GESTURE_TAP_SENSOR : property that contains the sensor number. BUG=chromium:1140877 BRANCH=none TEST=buildall Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I27ba462f8a12b14882104b9f983f2dc17f917314 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488937
* motion: orientation: update interfaceGwendal Grignou2020-11-063-43/+53
| | | | | | | | | | | | | | Enabling orientation sensor would not compile anymore. Fix interface by replacing macros with functions. BUG=chromium:718919 BRANCH=none TEST=Compile when enabled on grunt and eve. Change-Id: Ic5d6992d040cde79ef3f691db494804e160b7650 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2491266 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* TCPMv2: Correct battery index detectionDiana Z2020-11-051-19/+35
| | | | | | | | | | | | | | | | | | The battery index is located in the first byte after the extended header, which is not passed up to the PE layer. Additionally, the PRL will start copying the message from byte 0 so correct the extended message population. Add condition to fill in a valid response if the battery is not currently present, and correct the battery status response initialization. BRANCH=None BUG=b:161837550 TEST=with GRL-C2, invalid battery index tests pass Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I65ebe56f197b9822a42463f8d9dfb42b34c1ffe1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357517 Reviewed-by: Jett Rink <jettrink@chromium.org>
* BB retimer: Update USB4 related bitsAyushee2020-11-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | This CL updates the following bits: Bit 4: USB3 bit - If active cable V3, according to Discover Idenitity SOP response, Product VDO 2 B5. else set to 1 Bit 16: Thunderbolt support - According to B3:B5 of Discover Identity SOP response. Bit 19: VPro Support - If host is vPro capable and according to Discover Mode SOP response B26/B31. This CL also updates the thunderbolt related bits for the retimer if the thunderbolt mode SOP' and SOP'' is entered. BUG=b:156749387 BRANCH=None TEST=Able to update the retimer bits on entering USB4 mode Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic083001dee73d854379f1f3dfd85bebe5ee6ef5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473597 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpmv2: ifdef cleanup with IS_ENABLEDDenis Brockus2020-11-056-293/+312
| | | | | | | | | | | | | | | | | | | | | | | | Remove as many #if preprocessor statements as possible without allowing the code to grow when it is compiled. Verified against the sizes built on current ToT and this CL on that ToT ~/trunk/src/platform/ec $ make newsizes Compared 699 of 699 files. File sizes are unchanged. BUG=b:172208011 BRANCH=none TEST=verify TCPMv2 functionality Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib7d6a41b418f0683d3f7a14236b377073f346010 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2515279 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Allow alternate mode reentryAbe Levkoy2020-11-052-4/+9
| | | | | | | | | | | | | | When the EC is waiting for the AP to direct it to enter alternate modes, allow the AP to direct an Exit Mode followed by another Enter Mode. BUG=b:168030639 TEST=Exit and reenter DP and TBT alt modes BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I9edf0ca0a787ed025de2d5a5403d4225a6683e3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518612 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Remove unnecessary bracesAbe Levkoy2020-11-051-2/+1
| | | | | | | | | | | BUG=none TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ia9ae2cf5092530013df1da080c03d1dfc7bf7678 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518611 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add support for USB4 active cableAyushee2020-11-056-47/+232
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB4 PD flow for active cables: Structured VDM version (cable revision)-- <2.0 -------->| | | >=2.0 | | | VDO version---- <1.3 -------> Modal op? -- N --| (B21:23 of | | Discover ID SOP'- y | Active cable VDO1) | | | TBT SVID? -- N --| >=1.3 | | | y | Cable USB4 support? - N | | | | Gen4 cable? - N - Skip USB4 mode entry y Skip USB4 | | mode entry | Enter USB4 y (SOP',SOP'',SOP) | | |<---- NAK ----- Enter mode TBT SOP'<---| | | | | ACK | | | | |<---- NAK ----- Enter mode TBT SOP'' | | | | Exit TBT mode SOP ACK | | | | ACK/NAK Enter USB4 mode | | SOP | Exit TBT mode SOP'' | | | ACK/NAK | | | Exit TBT mode SOP' | | | ACK/NAK | | | |--------Retry done? ---- N ------------| | y | Skip USB4 mode entry The CL also checks if the port is VCONN source before sending Enter USB SOP' and SOP'' messages and requests for a vconn swap is it isn't In case of reboot, the port sends exit Thunderbolt mode SOP' and SOP'' and skips sending exit Thunderbolt mode for SOP, since it didn't enter Thunderbolt mode SOP prior to reboot. Note: 1. This is only applicable when the port enters USB4 mode SOP and Thunderbolt mode with the cable plug. 2. It is a temporary behaviour until data reset feature is in place (b/141363146) BUG=b:156749387 BRANCH=None TEST=1.Able to enter into USB4 with active cable. 2.Able to exit Thunderbolt mode SOP' and SOP'' on reboot and re-enter into USB4 mode with active cable. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I828c7ca0fd9b7b1025f13bcc86c511692b9f9895 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432868 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* COIL: Rename CONFIG_I2C_PERIPHERALDiana Z2020-11-051-1/+1
| | | | | | | | | | | | | Rename CONFIG_I2C_PERIPHERAL and related comments. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I3f148e976f3a4d6a1dc6c58686368c056290d5d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* COIL: Rename CONFIG_I2C_CONTROLLERDiana Z2020-11-054-4/+4
| | | | | | | | | | | | | Rename CONFIG_I2C_CONTROLLER and related comments. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ied6a1829bf54a5c9a32e6772982a4b8aa31aaf23 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Correct PE_VDM_Response name stringAbe Levkoy2020-11-051-1/+1
| | | | | | | | | | | | | | PE_VDM_RESPONSE isn't a superstate. BUG=none TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I3450f4eb0d12bd71187932b453bbb7ebeade7f48 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2517780 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* motion_sense: set sensor data rate to 0, when sensors are being powered offMike Lee2020-11-041-1/+3
| | | | | | | | | | | | | | | | | when sensors are being powered off, we should set sensor data rate to 0, to prevent the motion sense task from being unable to enter the idle state because the collect rate is not equal to 0. BUG=b:170703322 BRANCH=master TEST=make buildall pass, and test cerise power consumption meet spec in DC S5 state Signed-off-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Change-Id: Iae66f87aee1889b460fd598b1962be658c74ddab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505392 Reviewed-by: Cheng-Hao Yang <chenghaoyang@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* tcpmv2: Move "Allow_List" print to USBPD channelKeith Short2020-11-041-1/+3
| | | | | | | | | | | | | | | | | Move the allow_list not found message from the CONSOLE to the USBPD channel. This allows the message to be disabled during tests. BUG=none BRANCH=none TEST=make buildall TEST=Run "chan 0" and connect a charger that isn't in the allow list to volteer. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I395a701ee955200ad183dcb7da64d662d3611a4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518730 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* OCPC: Average and filter resistance calculationsAseda Aboagye2020-11-031-5/+59
| | | | | | | | | | | | | | | | | | | | | It's been seen that the resistance calculations can vary quite a bit during the charging cycle. In order to reduce this variance, this CL has the OCPC module take the running mean and use that at the combined resistance value. Additionally, values that are outside of a 6 standard deviation window are discarded. BUG=b:170974274 BRANCH=None TEST=Build and flash waddledee, enable OCPC debug logging and plot combined resistance over time as DUT charges in suspend. Verify that combined resistance does not vary significantly. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I2ccb9ccbc0b98455e78249d47f8692828f1a15e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508853 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* OCPC: Calculate resistance in suspendAseda Aboagye2020-11-031-1/+2
| | | | | | | | | | | | | | | | | | | | Currently our resistance calculations are only made when the system is charging in S5 or lower. We can perform these calculations when the system is in suspend as well since the power consumption is low. Additionally, it's very possible that a user may not charge in G3 for a very long time if at all. BUG=b:170975872 BRANCH=None TEST=Build and flash waddledoo, suspend DUT, charge from sub board, verify that resistance is being calculated. Change-Id: I882eae0014f5c7986e5997872f4a9e004f82ee9d Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508851 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* tcpmv2: extended unlocked exception to battery removalJett Rink2020-11-021-1/+1
| | | | | | | | | | | | | | | | When the battery is removed and that is also tied to write protect, allow EFS2 device to get a higher power contract even if the EC-CR50 communication failed. BRANCH=none BUG=b:168521645 TEST=morphius is able to boot to recovery screen with battery unplugged Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Idcc80beeb0364264adcb21e2eaf2c44e366460f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2493104 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Replace I2C_GET_ADDR with I2C_STRIP_FLAGSYuval Peress2020-11-022-2/+2
| | | | | | | | | | | | | | | | | The new I2C_STRIP_FLAGS macro was added to avoid conflict with Zephyr's macro. This CL performs the migration to that new API. BRANCH=none BUG=b:172067439 TEST=make runtests -j and built for various boards: eve, volteer, arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet Change-Id: I0583b647435db96ec268f186252b367bdc4118a6 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511097 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* atomic: rename atomic_read_clear to atomic_clearDawid Niedzwiecki2020-11-028-12/+12
| | | | | | | | | | | | | | | | | Rename atomic_read_clear to atomic_clear to be consistent with the rest of the atomic functions, which return the previous value of the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I2588971bd7687879a28ec637cf5f6c3d27d393f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505143 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* System: shutdown chipset before enter hibernateSue Chen2020-11-022-15/+23
| | | | | | | | | | | | | | | | | Pressing Alt + h + Volume Up cannot enter hibernate on lazor. The DUT would boot up immediately. To ensure the KB hibernate successfully, the AP needs fully shutdown before hibernating. BUG=b:171731177 BRANCH=none TEST=Pressing Alt+h+VolumeUp can enter hibernate in S0, and can wake up by plugging AC, pressing power button. make buildall -j2 Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I3c09c0d339ebbaab33635a283fd57bac61ebf08f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2497371 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* common/mock: Make sure mocks are only in the test buildTom Hughes2020-10-3116-1/+64
| | | | | | | | | | | BRANCH=none BUG=b:171370392 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1517a7080bd4853918ffc7127d44e1955d925789 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2510455 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Hard Reset to only disable ADD if Vbus dropsDenis Brockus2020-10-301-3/+4
| | | | | | | | | | | | | | | | | | If the sourcing partner does not leave Safe5V on Hard Reset then AutoDischargeDisconnect should not be disabled. BUG=b:170325888 BRANCH=zork TEST=SuzyQ should work Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ie191b0529b1f33bdaca09643b5a44af034935539 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2509977 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Add allow_list for partners that didn't set UP but should haveDenis Brockus2020-10-301-3/+6
| | | | | | | | | | | | | | | | | | Added three additional monitors and renamed the defines to tell what the PID is. BUG=b:171013724 BRANCH=zork TEST=connect new devices and make sure they source us Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Iaf18d6aaad40ff5ac8d8bb57bc2568a9256712bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2509974 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* Zephyr: refactor i2c components to avoid name collisions with zephyrYuval Peress2020-10-301-19/+26
| | | | | | | | | | | | | | | | | This change prepares the i2c module for shimming (in the next CL) by avoiding name conflicts with zephyr's. It also does some minor formatting changes using clang-format. BRANCH=none BUG=b:171302975 TEST=build platform/ec boards volteer and eve Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I5f53384eb5819d39acc68669c0c40ff211815f63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2509976 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* include/config.h: Replace CONFIG_FP_SENSOR with CONFIG_FINGERPRINT_MCUTom Hughes2020-10-301-0/+4
| | | | | | | | | | | | | | | | CONFIG_FP_SENSOR was only enabled for RW, but we need a way to know whether the board is a fingerprint MCU when in RO as well. "FINGERPRINT_MCU" is a bit more generic than FP_SENSOR. We still only build the matching-related code for RW. BRANCH=none BUG=b:171370392 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I808faa7a16522791cfb4eb9cc2e163d9eb994804 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508860 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* Revert "hack: temporarily work around TX_COMPLETE failure"Ken Lu2020-10-301-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bf411187b05aab57a9eb23c9a5b54f32b45aa2da. Reason for revert: PS8815 A1 firmware 0x0c fixes the TX_COMPLETE failure Original change's description: > hack: temporarily work around TX_COMPLETE failure > > After we removed the retry logic in the PRL layer, we uncovered an issue > that was being masked. On Delbin, the state machine is not receiving > that the PD messages (namely Request) is being sent successfully. We get > neither success or failure within 100ms. We still need to figure out and > fix this the root cause. > > This change just assumes that any sent PD traffic is successful after > 100ms (instead of a failure) for Delbin boards only. > > There is an upcoming build for Delbin that we will have power on > issues if we don't add some kind of power work around. This patch will > not allow the USB PD stack on Delbin to work properly in all scenarios; > this patch only aims to ensure that we can get power to the device to > test other non-PD functionality. > > This CL should be reverted within a two week time frame. > > BUG=b:164154200 > TEST=Delbin can power on > > Signed-off-by: Jett Rink <jettrink@chromium.org> > Change-Id: If6dce35dfd78ee3a70e6216a7b6bf62d3ded5646 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376477 > Reviewed-by: Keith Short <keithshort@chromium.org> > Commit-Queue: Anson Tseng <ansontseng@google.com> > Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com> BUG: b:164154200 BRANCH=firmware-volteer-13521.B Change-Id: If475ba52dd3f128848ad263a34ebb9ce50b93bfb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505389 Tested-by: Ken Lu <ken_lu@pegatron.corp-partner.google.com> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Ken Lu <ken_lu@pegatron.corp-partner.google.com>
* morphius: Wait 500ms before allowing DP event to cause resume.Edward Hill2020-10-302-3/+4
| | | | | | | | | | | | | | | | | Turning off the MST hub in S3 (via IOEX_HDMI_DATA_EN_DB) causes a VDM:Attention that immediately wakes us back up from S3. Wait 500ms after S3 entry before setting EC_MKBP_EVENT_DP_ALT_MODE_ENTERED in pd_notify_dp_alt_mode_entry(). BUG=b:167949458 BRANCH=zork TEST=powerd_dbus_suspend with display connected to MST hub DB Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I0d90d0a5130403b9aca1057725509814cac0d545 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2506424 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>