Commit Graph

791 Commits

Author SHA1 Message Date
Abe Levkoy 4c6709899b tcpci: Base retry count on active PD rev
Retry twice when operating at PD 3.0 and thrice when operating at PD
2.0. Provide a TCPM-agnostic interface to get the number of retries.

BUG=b:173025773,b:173025737
TEST=Pass TD.PD.LL.E3 Soft Reset Usage and TD.PD.LL.E4 Hard Reset Usage
BRANCH=firmware-volteer-13521.B-master

Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I422447718f1bfc9a9d4f8ffc5b284723a5332833
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578201
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
2020-12-15 15:39:20 +00:00
Abe Levkoy 0a561def48 mock: Clean up TCPMv2 mocks
Place mock functions in the mock libraries corresponding to the layers
of the real implementations. Broadly, move towards one layer of the TCPM
stack as a UUT, with mocks for the other layers as needed. There should
be a one-to-one correspondence between real modules and mock modules.
usb_pd_mock.c does not correspond to any real implementation module or
TCPM stack layer, so remove it and move its contents to the layers
corresponding to their real implementations.

Also clean up some redundant or misplaced mocks inside tests.

BUG=b:153071799,b:173791979
TEST=make buildall
BRANCH=none

Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: Ic44df8675de2b9f1f8c7669cd97dcdc296bf107f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2578200
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
2020-12-15 15:39:18 +00:00
Dawid Niedzwiecki f96f176c30 task_set_event: remove the wait argument
There is an option in the task_set_event function which force
the calling task to wait for an event. However, the option is never
used thus remove it.

This also will help in the Zephyr migration process.

BUG=b:172360521
BRANCH=none
TEST=make buildall

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
2020-12-14 19:59:09 +00:00
Peter Marheine 23fc8c22f1 cortex-m mpu: support configuring regions with difficult alignment
The existing configuration code assumes that provided addresses are
at least as aligned as the requested size, which is not true on
NPCX797WC (and likely others) where RAM regions are only 64k-aligned
but have larger sizes (like 256k).

Use a new greedy approach to configuring the MPU which handles these
situations corrently: for any given request take the largest possible
chunk from the bottom of the memory region (subject to size and address
alignment). Maximize the space by aggressively using MPU subregions-
this means that in many well-aligned situations this algorithm selects a
larger region than the requested size and enables one subregion, but in
more difficult situations it is capable of enabling subregions with more
exotic positions.

BUG=b:169276765
BRANCH=zork
TEST=With a test harness to print out computed configurations, manually
     verified the correctness of a variety taken from real chip
     configurations (request first, MPU region(s) indented):
     0x20000000 size 0x1000 # stm32f03x
         0x20000000 size 0x8000 srd fe
     0x20000000 size 0x2000 # stm32f03x
         0x20000000 size 0x10000 srd fe
     0x20000000 size 0x2800 # stm32l100
         0x20000000 size 0x4000 srd e0
     0x20000000 size 0x4000 # stm32f412
         0x20000000 size 0x20000 srd fe
        0x80000 size 0xc000 # it8320
            0x80000 size 0x20000 srd f8
     0xff200000 size 0xa0000 # ish5p4
         0xff200000 size 0x100000 srd e0
     0x200b0000 size 0x20000 # npcx797wb
         0x20080000 size 0x80000 srd e7
     0x10070000 size 0x40000 # npcx797wb
         0x10000000 size 0x80000 srd 7f
         0x10080000 size 0x80000 srd f8
     0x200c0000 size 0x10000 # npcx796f
         0x20080000 size 0x80000 srd ef
     0x10090000 size 0x30000 # npcx796f
         0x10080000 size 0x80000 srd f1
     0x10090000 size 0x20
         0x10090000 size 0x100 srd fe

     Further verified MPU configuration with the new algorithm succeeds
     on Dalboz, and test/mpu.c passes on Dragonclaw.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: I71d8e2b37c7e20fc7a39166b90eea0b7f7ebcf43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2434601
Reviewed-by: Edward Hill <ecgh@chromium.org>
2020-12-11 04:08:50 +00:00
Diana Z bc64c3cbed TCPMv2: Add source and sink cap PD APIs for TC-only use
Stub out returns of 0 and NULL for the source and sink cap pd_ APIs if
a board is not using the PE layer.

BRANCH=None
BUG=None
TEST=make -j buildall

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I32e74f3f29aacdf47aca9bc9d0664a4d799da3b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2585749
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
2020-12-11 00:46:16 +00:00
Diana Z 3bedcf29e8 TCPMv2: Check fixed PDO for relevant flags
Have the pd_ functions which query fixed PDO flags retrieve the fixed
PDO themselves, rather than going through stored TC flags.  This reduces
the liklihood of problems with the flags getting out of sync, and
reflects our future goal of being able to provide the AP with the PDOs
directly for decision-making.

BRANCH=dedede
BUG=b:173166474
TEST=on waddledoo, perform many DUT-DUT connections and verify that the
other DUT will always show up as DR power and data in the "ectool usbpd"
output

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I4dd46f5ef4156377d11169545a541b11e60a2cf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2576453
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
2020-12-10 21:58:42 +00:00
Yuval Peress 6f0894886e common:online_calibration: Spoof sensor data
This change allows the `accelspoof` ec command to also
override the calibration data (bypassing the calibration
module). This config flag should be used when testing
layers above the EC (kernel and up)'s handling of the
calibration values.

BRANCH=none
BUG=none
TEST=Built on eve and added unit tests.
TEST=make run-online_calibration_spoof -j

Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I4735b9613c152af5559661a91565b05635d6495e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2494986
2020-12-08 19:06:07 +00:00
Denis Brockus 00932fb745 genvif: add more Component SOP_Discovery fields
BUG=b:172293518
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I6deeecc36505eb4f7261d04eae2c9ff419fa0296
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2567171
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
2020-12-02 13:35:35 +00:00
Edward Hill 6f2aa2eeb1 usbc: Wake PD task on PE TX and RX
Wake the PD task from pe_message_received(), pe_message_sent(), and
pe_report_error() to avoid having to wait USBC_EVENT_TIMEOUT.

BUG=none
BRANCH=none
TEST=make run-usb_pe_drp

Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: I2fd1465796224507e1eb64ea20572165918d5bf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2564818
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
2020-12-01 18:19:47 +00:00
Edward Hill e6f16fe408 test: Add test_send_caps_error_before_connected to usb_pe_drp
Add a test for the other half of handling an error on sending
source capabilities. Before connection, PE_SRC_Send_Capabilities
goes to PE_SRC_Discovery on send error. Once connected, to goes
to PE_Send_Soft_Reset.

BUG=b:161835483
BRANCH=none
TEST=make run-usb_pe_drp

Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: I92df9159286536bdda76e5b8530494c6aa368af1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2553344
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-12-01 18:19:42 +00:00
Edward Hill 725de7c472 test: Improve test_send_caps_error in usb_pe_drp
Better mock tx and rx messages, add sop type.

BUG=b:161835483 b:173791979
BRANCH=none
TEST=make run-usb_pe_drp

Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: If1f91b6385d6841d662a8a6262af6382645da92e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2553343
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-12-01 18:19:40 +00:00
Gwendal Grignou 2d723bc996 motion_sense: Stop collection when sensor is powered down
Set collection_rate to 0 when sensor is not in initialized state anymore.
It will prevent the motion_sense task to be neededlessly scheduled.
Export wait_us to be tested.

BUG=b:170703322
BRANCH=kukui
TEST=unit test

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: I1dc4c7a07ff30fa10997ef87784114c725f100d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2520297
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Reviewed-by: Yuval Peress <peress@chromium.org>
2020-12-01 02:37:52 +00:00
Denis Brockus 63153bdc5e TCPMv2: AP resume should consider Src->Snk swap
TCPMv1 used PD_FLAGS_CHECK_PR_ROLE and
pd_check_pr_role() to accomplish this. This was
missing from TCPMv2.

In the TCPMv2 implementation, policy
pd_can_source_from_device was added to put the
logic in one place to detect if the PDO for a
partner device can and should be the source

Using this policy the AP resume code will check
to see if an already attached partner that we
are sinking from should be sinking from us instead.

BUG=b:169299049
BRANCH=zork
TEST=verify DRP phone will swap back to SNK on AP resume

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I8e584446445c8ee2e1c91973a58a04405cdf9e1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2555865
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
2020-11-25 17:45:51 +00:00
Gwendal Grignou 4a399faf37 test: motion: Update test to match motion_sense
Put sensors in forced mode, since interrupts are not generated in test
mode.
Remove unnecessary task wakeup, since motion sense are sending them.
Fix comments and remove empty code.

BUG=b:170703322
BRANCH=kukui
TEST=unittest

Change-Id: Ic9096998a29cebeb47bed5cc2c148b7743f6c78f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523295
Reviewed-by: Yuval Peress <peress@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
2020-11-23 05:57:46 +00:00
Denis Brockus 9b056a8aba genvif: Type_C_Is_Alt_Mode_Adapter only when valid
some refactoring for does_respond_to_discov_sop_xxx
and is_usb_pd_supported was added to make the common
code available for other uses as well

BUG=b:172434299
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I36c7df53e61734fcbdd176e3ea292a3f8914fdf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2550309
Tested-by: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
2020-11-20 23:54:28 +00:00
Denis Brockus 5f57405065 genvif: host/device data only if enabled
Some device data is only valid if Device_Supports_USB_Data
in the Upstream Facing Port Fields group.

Some host data is only valid if Host_Supports_USB_Data
in Downstream Facing Port Fields

BUG=b:172441959,b:172438944
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I41edde27d9cc6fb49934e0d176efc90540a9faee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2550308
Tested-by: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
2020-11-20 23:54:26 +00:00
Diana Z c98936e40a TCPMv2: Store and report sink caps
Copy sink caps for later reference, and report them up to the AP in the
TYPEC_STATUS host command return.  This also moves the location of the
DPM set for sink caps, to be symmetrical between source and sink inits.

Set the old unit tests to clear all DPM requests.  New PE tests will
correctly handle our startup sequence, but the old tests may have
erratic behavior based on how many states run before the connection is
forced over to READY.

BRANCH=None
BUG=b:160009733,b:168862110
TEST=on drawcia, verify sink capabilities match those from PD traces
with several docks and dongles

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Iadc6ef4c7364d7c709878a75fd5e707a965f77f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2540390
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
2020-11-20 18:43:53 +00:00
Diana Z 30a9f90a09 TCPMv2: Always probe sink caps
This commit adds the ability to always probe the partner for sink
capabilities, and re-names the state to reflect that sources may use it
now too.  This also fixes some issues in the state to get sink
capabilities, including correcting the message detection and soft
resetting with the SOP* of the unexpected message.

This also updates the unit tests to expect a Get_Sink_Caps message as a
part of typical startup.

BRANCH=None
BUG=b:168862110,b:160009733
TEST=on drawcia, observe sink caps are requested from source and sink
partners

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I5da3adc17ccec71f6cad9e8f152b9570ec99691d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2540389
Reviewed-by: Keith Short <keithshort@chromium.org>
2020-11-20 17:43:24 +00:00
Denis Brockus 7f9807dc0d genvif: Device_Speed/Host_Speed default to USB 3.2 GEN 1x1
Since this is the most common correct answer, I am changing
the default from USB 2 to USB 3.2 GEN 1x1

BUG=b:172441959,b:172438944
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I758ec7ec0df2f285466d83ddb0dcfa8cc98efa55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2547192
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
2020-11-19 18:34:23 +00:00
Denis Brockus 07f5ec6691 genvif: component for all ports with Port_Label
BUG=b:172450627
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: Idcc65ad2ec7fda48d39a6319e6adf226765e37bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2545141
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
2020-11-19 00:48:03 +00:00
Denis Brockus 73b90bcbad genvif: add unit test for genvif and genvif override
Any of the following will run the test from platform/ec
    make buildall
    make runtests
    make run-genvif_test

The following will run the test from platform/ec/test/genvif
    make clean test

BUG=b:173219559
BRANCH=none
TEST=make buildall

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: Ic5594ae96d040adc332c2afc8fa8a8eb8b373882
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2542745
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
2020-11-17 20:53:44 +00:00
Ching-Kang Yen b0f1017dd7 common: motion_sense: Add spoofing activity
make spoof command able to spoof activity state:
ectool motionsense spoof -- NUM activity ACT [EN] [0/1]

This commit also remove unused parameter |sensor_num| from
list_activities, set_activity, get_activity in ectool.

BRANCH=None
BUG=b:123434029
TEST=buildall
TEST=ectool motionsense spoof 4 activity 4 1 0
     ectool motionsense spoof 4 activity 4
     ectool motionsense get_activity 4
     ectool motionsense spoof 4 activity 4 1 1
     ectool motionsense get_activity 4
     ectool motionsense spoof 4 activity 4 0
     ectool motionsense get_activity 4
     ectool motionsense spoof 4 activity 4 1
     ectool motionsense get_activity 4

Signed-off-by: Ching-Kang Yen <chingkang@chromium.org>
Change-Id: I819c156ae7fe50c5cf6216d0f44012d192fb528e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2477393
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2020-11-13 06:29:13 +00:00
Jett Rink ba63fbd08d zephyr: forward cros_crc8 to zephyrs crc8 impl
Shim in support for crc8 used in CBI, I2C, and other
applications within platform/ec

BRANCH=none
BUG=b:168032589
TEST=add unit test for platform/ec and zephyr based
     CRC8 approaches and verify they both pass.

Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: I9b6112cb83dab81a44a1ac020d4efb1b7bb1df5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532692
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
2020-11-13 00:27:45 +00:00
Jett Rink 9263a4f135 crc32: rename test crc32->crc to allow for crc8
Instead of creating a new test for crc8, just make the existing crc32
test more generic.

BRANCH=none
BUG=none
TEST=none

Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: Ie630d4991d4e2c7dc441842c39d63fc0281ac809
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532690
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
2020-11-13 00:27:29 +00:00
Gwendal Grignou d28c10498c motion_sense: Make change in range permanent
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>
2020-11-12 03:23:26 +00:00
Jett Rink e50f47c5d2 Revert "crc32: rename test crc32->crc to allow for crc8"
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 5ec269c5a7.

Change-Id: I90f812cd4d4f83ea05d34740541db0076abce392
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533356
Tested-by: Rajat Jain <rajatja@google.com>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-11-11 19:36:24 +00:00
Jett Rink 90caed85bc Revert "zephyr: forward cros_crc8 to zephyrs crc8 impl"
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 22ee9a3467.

Change-Id: I5617e39204a7c05001363d5780fa2f52e3e1ea05
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533355
2020-11-11 19:30:15 +00:00
Jett Rink e2dfdb09d9 tree: rename strtoul to strtoull since it is 64-bit
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>
2020-11-11 18:37:36 +00:00
Jett Rink 22ee9a3467 zephyr: forward cros_crc8 to zephyrs crc8 impl
Shim in support for crc8 used in CBI, I2C, and other
applications within platform/ec

BRANCH=none
BUG=b:168032589
TEST=add unit test for platform/ec and zephyr based
     CRC8 approaches and verify they both pass.

Change-Id: Ib609f98596c4edc6e6f0d01b6242e62a1f95ad72
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527811
Reviewed-by: Yuval Peress <peress@chromium.org>
2020-11-11 16:59:49 +00:00
Jett Rink 5ec269c5a7 crc32: rename test crc32->crc to allow for crc8
Instead of creating a new test for crc8, just make the existing crc32
test more generic.

BRANCH=none
BUG=none
TEST=none

Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: I459e9b721a6cc0d94cef8c0d93102ad372095c34
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527493
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-11-11 16:59:45 +00:00
Yicheng Li 6cd9c9b453 test: Add 3072-byte key test case for rsa test
This is so that the unittest can be built for a board that actually
uses 3072-byte RSA in RW signature verification, and run on-device.
E.g. `build --BOARD=hatch_fp test-rsa`

BRANCH=none
BUG=b:169256204
TEST=make -j buildall
TEST=make BOARD=bloonchipper test-rsa3, flash to Dragonclaw,
     rwsig verify OK, test passes.

Change-Id: I1e67f05b76b53d96fe508832a94e9af5ad896d4d
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2429392
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-11-11 02:01:45 +00:00
Yuval Peress c47740eca1 Zephyr: add more compliant implementation for irq_(un)lock
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
2020-11-08 19:31:12 +00:00
Diana Z 899412aaf6 COIL: Rename CONFIG_I2C_CONTROLLER
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>
2020-11-05 01:28:37 +00:00
Dawid Niedzwiecki ba9f1a8dd1 test: fix stm32_rtc compilation error
After the atomic functions change, there is a compilation error of
test-stm32_rtc. Remove volatile qualifier, because it is not needed for
atomic functions - 'rtc_fired' is changed only by them.

BUG=b:172079887
BRANCH=none
TEST=make BOARD=bloonchipper test-stm32f_rtc

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I38c48697b0ce1b639dcf767d939bb8dcf1215f79
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2512205
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-11-03 10:19:01 +00:00
Dawid Niedzwiecki 7106989353 atomic: rename atomic_read_clear to atomic_clear
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>
2020-11-02 10:17:27 +00:00
Tom Hughes 8dcad3805d test/fpsensor: Add test for checking protocol info
Note that the "fpsensor_uart_ro" test is broken at this point due to
b/171370392 and will be fixed in a followup commit.

BRANCH=none
BUG=b:171370392
TEST=Using dragonclaw v0.2 and servo_micro:
     ./test/run_device_tests.py -t fpsensor_uart_ro
     ./test/run_device_tests.py -t fpsensor_uart_rw
     ./test/run_device_tests.py -t fpsensor_spi_ro
     ./test/run_device_tests.py -t fpsensor_spi_rw

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I00cb5dd975fefe577381f1889e88aad000c8ba57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508859
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
2020-10-30 20:27:24 +00:00
Tom Hughes a6ec60c2f3 test/fpsensor: Run the fpsensor test on device
BRANCH=none
BUG=b:171370392
TEST=Using dragonclaw v0.2 and servo_micro:
     ./test/run_device_tests.py -t fpsensor

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Idc24d9bdd5574ca7099e97e86e3b49011844380c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2507951
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
2020-10-30 20:27:19 +00:00
Tom Hughes 27797ea91d test/fpsensor: Add missing RUN_TEST macro
The RUN_TEST macro is needed to perform the bookeeping on failures for
the tests that are run.

BRANCH=none
BUG=b:171370392
TEST=make buildall -j

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I8b74c8ee39fd95391417267993e186eb2056456d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508858
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
2020-10-30 20:27:17 +00:00
Dawid Niedzwiecki a05f7b9f46 tree: Use new atomic_* implementation
It is done as a part of porting to Zephyr.
Since the implementation of atomic functions is done for all architectures
use atomic_* instead of deprecated_atomic_*.

Sometimes there was a compilation error "discards 'volatile' qualifier"
due to dropping "volatile" in the argument of the functions, thus
some pointers casts need to be made. It shouldn't cause any issues,
because we are sure about generated asm (store operation will be
performed).

BUG=b:169151160
BRANCH=none
TEST=buildall

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949
Tested-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-10-27 09:35:49 +00:00
Paul Fagerburg ce87da13c5 test: Allow EC unit test to use Ztest API
Provide a translation layer in test_utils.h for the Zephyr zassert
macros to map onto EC's TEST_ASSERT macros. With a little bit of
duplicated-but-not-quite-duplicated code (test_main vs. run_test)
and some extra macros for the return type of the test cases, the
tests can build for either the EC framework (by default) or the
Zephyr Ztest framework (#ifdef CONFIG_ZEPHYR).

Update the unit test documentation to explain why (and a brief
"how") developers should use the Ztest API for new unit tests.

BUG=b:168032590
BRANCH=none
TEST=`TEST_LIST_HOST=base32 make runhosttests`

Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: I26e60788c1468e44fed565dd31162759c7587ea6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2492527
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
2020-10-23 03:51:47 +00:00
Abe Levkoy f420b2073e TCPMv2: Avoid VCONN-Source discovery failure
Remove redundant checks for VCONN Source in pe_attempt_port_discovery
(which prevent discovery from running). Allow pe_vdm_send_request to
attempt to become VCONN Source if necessary. Make the checks in the VDM
request child states more complete (not just checking for VCONN Source).

BUG=b:170662791
TEST=Attach Tapex Creek board; observed successful discovery
BRANCH=none

Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: Id7d3a1b82d1029f69b3e05b845632e7237524bc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486303
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-10-21 00:09:30 +00:00
Gwendal Grignou 512823a8aa common: online_calibration: Fix compilation issue
- Fix compilation error: sizeof() of an input array
was not calculated properly.
- Fix calling convention: use sensor pointer instead of
sensor number
- Use common formula to calculate sensor number.

BUG=none
BRANCH=none
TEST=compile, unittest, load on eve with online calibration added.

Change-Id: I06ff30eb5710cbe8f91c939b2ccc084c20a37847
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486304
Reviewed-by: Yuval Peress <peress@chromium.org>
2020-10-20 20:15:03 +00:00
Ayushee 913b68e8e4 TBT:Add support for exit mode SOP'/SOP'' on chipset transition
When chipset is transitioning to a new state or on sysjump, the EC
re-negotiates to enter an alternate mode on booting up.

This commit adds support for exiting Thunderbolt mode for SOP' and SOP''
for active cable on chipset transition and also moves all the alternate
mode exit rotines to their respective files.

It also delays deleting the SVID data until after the EXIT_MODE message
has ACKed and avoids pd_dfp_exit_mode() from changing the alternate
mode's internal states.

This commit also makes sure that the mux is set to safe state before
exiting the alternate mode and it is reconfigured according to the
port's current data role on receiving ACK/NAK from the cable/port
partner.

BUG=b:151169925, b:159717794
BRANCH=none
TEST=On reboot, able to exit and re-enter into DisplayPort mode,
     Thunderbolt mode with passive cable and thunderbolt mode with
     active cable.

Change-Id: If1e48e9f31cd678e23fe89bd3494551b5d1a78f1
Signed-off-by: Ayushee <ayushee.shah@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415082
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-10-14 20:33:10 +00:00
Tom Hughes 063c4877b2 test/run_device_tests.py: Disable STM32F-specific test on icetower
Icetower is an STM32H743 device, so this test does not compile.

BRANCH=none
BUG=b:170432597
TEST=On Icetower v0.1 connected via servo_micro:
     ./test/run_device_tests.py -b dartmonkey

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Iaff85c24649ee50101441c9a75c57bd10b605c51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462159
Reviewed-by: Yicheng Li <yichengli@chromium.org>
2020-10-09 23:43:56 +00:00
Tom Hughes 4afe356a38 test/run_device_tests.py: Check for ASSERTION_FAILURE
Count an instance of ASSERTION_FAILURE as a test failure. There was a
bug where the rollback tests correctly hit the data access violation,
but then went into a boot loop due to hitting an ASSERTION_FAILURE. We
now check the all the logs for failures.

BRANCH=none
BUG=b:170147314
TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region0
TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region1
TEST=./test/run_device_tests.py -b bloonchipper

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Iebe980af38383d6e71f46f799314e6275f047336
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462544
Reviewed-by: Yicheng Li <yichengli@chromium.org>
2020-10-09 23:34:47 +00:00
Tom Hughes f645ba8208 test/run_device_tests.py: Fix rollback region addresses for dartmonkey
BRANCH=none
BUG=b:170147314, b:170432597
TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region0
TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region1

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: If1ff057165c462716820b783a8ef1dac7994fde1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462543
Reviewed-by: Yicheng Li <yichengli@chromium.org>
2020-10-09 04:04:48 +00:00
Tom Hughes eadfb75ab5 test/utils.c: Adjust expected speedup for STM32H743
BRANCH=none
BUG=b:158580909, b:170432597
TEST=On Icetower v0.1 connected to servo_micro:
     ./test/run_device_tests.py -b dartmonkey -t utils

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: If5dcd7ade6397611b40b9c7a6f9560402a11c042
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2459229
Reviewed-by: Edward Hill <ecgh@chromium.org>
2020-10-09 04:04:43 +00:00
Jack Rosenthal ffb3d81118 common: include config.h from console.h
console.h currently relies on many config options to selectively
define macros.  It does not currently include config.h, which means
these config options are not guaranteed to be defined by this point.
We will need this for Zephyr as well.

There were a few configuration header files which implicitly relied on
the ording of including console.h to bring in stdint.h at some point.
We explicitly include what we use here to fix that.

BUG=b:167590251
BRANCH=none
TEST=build passes

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: Ia005577a2579962ee8b14c61930f37fe28bc8f5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427088
Reviewed-by: Yuval Peress <peress@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2020-09-29 20:55:43 +00:00
Jack Rosenthal d4be394be0 tree: rename atomic_* functions to deprecated_atomic_*
We will move to an API compatible with Zephyr's API.  See the bug for
complete rationale and plan.

BUG=b:169151160
BRANCH=none
TEST=buildall

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507
Tested-by: Dawid Niedźwiecki <dn@semihalf.com>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2020-09-29 16:30:59 +00:00
Tom Hughes 01b7d964e5 fpsensor: Fix buffer check to account for overflow
BRANCH=none
BUG=b:144957935
TEST=make buildall

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I1b4fa0a715869ccc37e48d75316ef52c367aa64a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417529
Reviewed-by: Craig Hesling <hesling@chromium.org>
2020-09-25 18:35:25 +00:00