Commit Graph

1826 Commits

Author SHA1 Message Date
Rong Chang
ec98dbfb35 stm32f09x: fix flash protection offset
STM32F091VC has 32 flash protection sectors (31 x 4KB + 1 x 132KB),
which doesn't fit the layout requirement in config_std_internal_flash.h.
This CL hardcodes the layout and flash bank mapping.

BUG=chrome-os-partner:62372
BUG=chromium:694972
TEST=load on elm and manually enable write protect using flashrom
       # flashrom -p ec:dev=0 --wp-enable
     check ec console write protect option bytes, bank 31 is writable
       > rw 0x1ffff808
         read 0x1ffff808 = 0xff00ff00
       > rw 0x1ffff80c
         read 0x1ffff80c = 0x7f80ff00
BRANCH=oak

Change-Id: I23dcf87bfbcd2f37e97a87e94847dce1ea1d343c
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/446176
2017-02-27 16:56:24 -08:00
Shawn Nematbakhsh
6ba124a81b hostcmd: Remove EC_CMD_VBNV_CONTEXT handler for most boards
Most boards do not keep VBNV storage on the EC, so leave out the host
command handler by default.

BUG=chromium:693210
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ia202ec7d73d1804d8430fe7516cc783afd86e89a
Reviewed-on: https://chromium-review.googlesource.com/446716
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2017-02-25 16:34:15 -08:00
Shawn Nematbakhsh
23bc38414a pd: Store PD active state in battery-backed memory
Our previous idea to cut Rd for many reset cases cannot work if cr50
consistently resets the EC by asserting the reset pin shortly after
power-on. Therefore, make a decision based upon whether battery-backed
memory indicates we previously negotiated a PD power contract as a sink.
If we previously did not negotiate a contract, or if power was removed
from the device (causing battery-backed memory to wipe) then we can
assume that we don't have an active power contract.

BUG=chrome-os-partner:62952
BRANCH=reef
TEST=On reef, run "cutoff" on the console, reattach AC, and verify
device successfully wakes. Also verify Rp is dropped on console 'reboot'
and F3 + power from RW.

Change-Id: Ie300b9589cac6be7a69b77678bea6b1b6b25578c
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/443356
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-25 14:23:20 -08:00
Nicolas Boichat
2dcfd2446c flash: Add ROLLBACK flash region, that can be protected separately
ROLLBACK region will be used to store rollback information, and
can be protected independently of RW (it can only be protected when
RO is protected, though).

This is only supported on stm32f0 currently.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=on hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW+RB protected
     flashwp noall; reboot => only RO protected
     flashwp rw; reboot => only RO+RW protected
     flashwp rb; reboot => RO+RW+RB protected
     flashwp norb; reboot => RO+RW protected
     flashwp all; reboot => RO+RW+RB protected
     flashwp norw; reboot => RO+RB protected
TEST=on reef, rb/norb commands not available

Change-Id: I45ffc66d91cf3699ecff025e5114c59a73dc8274
Reviewed-on: https://chromium-review.googlesource.com/430519
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-25 08:36:41 -08:00
Shawn Nematbakhsh
f0b564b4a0 system: Add generic bbram read / write routines
Add generic routines to read or write a byte to battery-backed RAM, and
implement vbnvcontext get/set using these routines.

BUG=chrome-os-partner:62952
BRANCH=reef
TEST=On reef, with subsequent commit, run "cutoff" on the console,
reattach AC, and verify device successfully wakes. Also verify Rp is
dropped on console 'reboot' and F3 + power from RW.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I14691923f2e5198e901b6b5199e92c58c68cd18d
Reviewed-on: https://chromium-review.googlesource.com/444444
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-24 15:23:24 -08:00
Nicolas Boichat
83cf8d0a7a flash: Add EC_FLASH_PROTECT_RW_[AT_BOOT|NOW] flags
The idea of this flag is to be able to protect/unprotect only the
RW portion of the flash. In the (usual) case where ALL=RO+RW, with
no other region, this makes no difference compared to the existing
EC_FLASH_PROTECT_ALL_* flag, and this flag may not be supported.

This is necessary for futher work, where a ROLLBACK region is added,
so that RW/ROLLBACK can be protected/unprotected individually.

Only support for stm32f0 is added, as this is the target for hammer.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=build and flash hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW protected
     flashwp noall; reboot => only RO protected
     flashwp rw/norw not available
TEST=enable CONFIG_FLASH_PROTECT_RW
     build and flash hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW protected
     flashwp noall; reboot => only RO protected
     flashwp rw; reboot => RO+RW protected
     flashwp norw; reboot => only RO protected
TEST=build and flash reef (npcx)
     flashinfo => RO+RW not protected
     flashwp true => RO protected
     flashwp all; flashinfo => all_now displayed
     reboot => RO protected
     flashwp rw/norw not available

Change-Id: Ica6f499cf2e8a9345b08ef52c915655a983ffe3c
Reviewed-on: https://chromium-review.googlesource.com/442265
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-23 19:06:16 -08:00
Vincent Palatin
0d858f1544 curve25519: strip-down, build and test
Keep only the most compact version of the curve25519 code
and remove the remaining unused code for easier compilation.
Do the minimal changes to make it compile in the EC code base,
there should be no real functional changes.

Re-use the wording from BoringSSL include/openssl/curve25519.h for the
header.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:62991
TEST=run x25519 on host (ie 'make run-x25519')
and the STM32L4 target:
make BOARD=eve_fp PROJECT=x25519 TEST_BUILD=y
./util/flash_ec --board=eve_fp --image=build/eve_fp/x25519.bin
execute 'runtest' in the console.

Change-Id: I13dbe453eff39b461effb1b3ffa549afc1749fef
Reviewed-on: https://chromium-review.googlesource.com/444187
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Adam Langley <agl@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-23 16:02:03 -08:00
Vincent Palatin
bff020fc6b util: add constant-time memcmp
Import from vboot_reference the constant-time memcmp implementation
for safer usage in cryptography code.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:62991
TEST=run curve25519 test

Change-Id: I9c4c61e15912c978e13b6cc002af879c8ae8f630
Reviewed-on: https://chromium-review.googlesource.com/446098
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-23 16:02:02 -08:00
Vincent Palatin
4cbf0cc358 stm32: add TRNG support
Add a driver for the STM32 True Random Number Generator.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:62991
TEST=adhoc on STM32L, craft console command and generate/dump
buffers of random numbers.

Change-Id: Ie7ce890cfc36a3b9a277715b17051e3e42fdfc96
Reviewed-on: https://chromium-review.googlesource.com/445777
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-23 11:36:21 -08:00
Aseda Aboagye
d7303404a5 cr50: Make sure TPM wipe only clears TPM data.
Previously, wiping the TPM would wipe all of NvMem, however, it really
should only clear the TPM's NvMem space.  This commit adds a function to
clear a given NvMem user's space and makes the TPM only clear its space.

BUG=chrome-os-partner:61597
BRANCH=None
TEST=Add code for using nvmem vars, create a test variable, add a user
to snappy, unlock the console, verify that the user is no longer present
on the system and the test nvmem var still exists.
TEST=make -j buildall

Change-Id: Ic98baa5166a1ef9ae76e910b1b9ab100300e947f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/445803
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-23 01:19:07 -08:00
Sam Hurst
fe89f7f5c7 ec:Correct ACPI host commands
All host commands must be 4-digit uppercase hex digits.
The current ACPI host commands are defined as follows:
   #define EC_CMD_ACPI_READ 0x80
   #define EC_CMD_ACPI_WRITE 0x81
   #define EC_CMD_ACPI_BURST_ENABLE 0x82
   #define EC_CMD_ACPI_BURST_DISABLE 0x83
   #define EC_CMD_ACPI_QUERY_EVENT 0x84

BUG=chrome-os-partner:63190
TEST=make -j buildall
    100bd248 R __host_cmd_0x00000x0080
    100bd254 R __host_cmd_0x00000x0081
    100bd260 R __host_cmd_0x00000x0082
    100bd26c R __host_cmd_0x00000x0083
    100bd278 R __host_cmd_0x00000x0084
BRANCH=none

Change-Id: I48ad9c179454eb237018377023bae10a79c7799e
Reviewed-on: https://chromium-review.googlesource.com/445809
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-22 18:25:14 -08:00
Nicolas Boichat
30cc21b932 rwsig: Put key/signature at the end of RO/RW sections
Current code puts key at the end of the first half of flash, which
may not match the actual RO section size (e.g., it might be PSTATE,
not RO). This makes sure the key to be at the end of RO section, and
signature at the end of RW section, no matter the actual layout
being used.

However, the (deprecated) usbpd1 image type assumes that flash is
equally split between RO and RW, so we do not change that.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=make BOARD=hammer -j && deploy
TEST=make BOARD=hoho -j && \
         futility show --type usbpd1 build/hoho/ec.bin

Change-Id: Ia02e927f9128d6ec3d0b780c28312e0d18835d72
Reviewed-on: https://chromium-review.googlesource.com/426100
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-22 03:29:28 -08:00
Philip Chen
551e56ea06 mkbp: Support devices having buttons but no keyboard
If we turn on CONFIG_KEYBOARD_PROTOCOL_MKBP on devices
without keyscan task, we'll see a few compile errors
due to dependencies on keyscan.
This is the fix.

BUG=chrome-os-partner:62987
BRANCH=none
TEST=make buildall -j

Change-Id: Ib0dd1570f0e1a2de084cf1c5f75b8e3ad1cb301a
Reviewed-on: https://chromium-review.googlesource.com/443745
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/444946
Commit-Ready: Philip Chen <philipchen@chromium.org>
2017-02-21 16:07:40 -08:00
Scott
8cef7bab3b driver: Add polling mode support to Si114x ALS sensor
Eve P1 is missing the ALS_INT_L signal and so needs to poll the
Si114x. This CL adds a new config option CONFIG_ALS_SI114X_POLLING
that when defined uses a deferred callback to trigger the motion
sensor event that reads sensor registers. The deferred callback uses a
8 msec delay which is ~2x longer than the time required by the sensor
to complete the measurement.

BUG=chrome-os-partner:61470
BRANCH=none
TEST=On Eve verify that light sensor measurments are present with the
'accelinfo on 1000' command.

Change-Id: I212bebf2ceacbac87ccb0734cc4990dbc349b028
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/440377
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-02-20 14:28:02 -08:00
Aseda Aboagye
114f5cee5a g: extension: Add a whitelist for vendor commands.
The USB FW upgrade endpoint should really only accept vendor commands
required to perform the firmware update.  This commit adds a whitelist
that is checked whenever a vendor command is received over this
endpoint.

The allowed commands over USB are the following:

 - EXTENSION_POST_RESET
 - VENDOR_CC_IMMEDIATE_RESET (only for dev images)

There is also functionality to have a whitelist for vendor commands that
come over the TPM interface.

BUG=chrome-os-partner:62815
BRANCH=None
TEST=Flash Cr50 with image containing this change.  Verify that an
upgrade over USB to newer image works.
TEST=Try using usb_updater to send a vendor command that's not in the
whitelist.  Verify that the vendor command is dropped.

Change-Id: I71f8ba090a1cc6c9e7c30ce0dd3c25259e8f292f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/443447
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-18 17:26:59 -08:00
Aseda Aboagye
4ed4044329 cr50: Decrement retry counter on manual reboots.
Currently, manually triggered reboots cause the retry counter to be
incremented.  However, if the system is responsive enough to process the
reboot commands from either the console or TPM vendor command, we can
assume that the image is "ok".  This commit changes the Cr50 behaviour
to decrement the retry counter when a reboot is issued on the console or
the TPM vendor command is received.

BUG=chrome-os-partner:62687
BRANCH=None
TEST=Flash cr50. Flash an older image in the other slot. Enter the
reboot command on the console over 10 times and verify that retry
counter never exceeds RW_BOOT_MAX_RETRY_COUNT and older image is never
executed.

CQ-DEPEND=CL:444264

Change-Id: Ic35bdc63c4141834584a00a7ecceab2abe8dfc21
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/443330
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-18 17:26:59 -08:00
Shawn Nematbakhsh
2062c99cd2 cleanup: Move chip/g-specific system() prototypes to system_chip.h
BUG=chromium:693148
BRANCH=None
TEST=`make buildall -j`

Change-Id: I7a758e6b5a04721d0422cfe8b767d85abddb1ad2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/444264
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-18 17:26:59 -08:00
Nicolas Boichat
07eccbb414 rwsig: Add support for rwsig image types
usbpd1 futility image type is deprecated and should not be used for
new designs. This adds proper support for rwsig image type.

Key and signatures are added at linker stage step (futility cannot
directly create such signed images). Thanks to VB21 header, rwsig.c
can now tell how many bytes of the RW image need to be
cryptographically verified, and ensure that the rest is blank (0xff).

BRANCH=none
BUG=chromium:690773
TEST=make BOARD=hammer; flash, RW image is verified correctly.
TEST=make runtests -j
TEST=For the rest of the tests:
     Change config option to CONFIG_RWSIG_TYPE_RWSIG
TEST=make BOARD=hammer; flash, hammer still verifies correctly.
TEST=cp build/hammer/ec.RW.bin build/hammer/ec.RW.bin.orig;
     futility sign --type rwsig --prikey build/hammer/key.vbprik2 \
        build/hammer/ec.RW.bin
     diff build/hammer/ec.RW.bin build/hammer/ec.RW.bin.orig
     => Same file
TEST=Add CONFIG_CMD_FLASH, flashwrite 0x1e000, reboot, EC does
     not verify anymore.
TEST=dump_fmap build/hammer/ec.bin shows KEY_RO and SIG_RW at
     correct locations.

Change-Id: I50ec828284c2d1eca67fa8cbddaf6f3b06606c82
Reviewed-on: https://chromium-review.googlesource.com/441546
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-17 04:09:37 -08:00
Vincent Palatin
7a9b35ac70 Add eve_fp board
Eve FP MCU is using the STM32L442 microcontroller.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:62893
TEST=make BOARD=eve_fp
run it on Nucleo-L432KC (STM32L432KC is mostly the same MCU without AES)

Change-Id: I18dc57e9bf262c36283f8c835a2d4320bc5ee837
Reviewed-on: https://chromium-review.googlesource.com/442467
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-02-17 01:47:29 -08:00
Gwendal Grignou
484ef12119 motion: Add opt3001 as a motion sensor
Use the motion sensor to manage ALS as well.
The current interface (via memmap) is preserved, but
we can also access the sensor via cros ec sensor stack and
send the ALS information to ARC++.

BUG=chrome-os-partner:59423
BRANCH=reef
CQ-DEPEND=CL:424217
TEST=Check the sensor is working via ACPI sensor and
cros ec sensor. Check ARC++ sees the sensors.

Change-Id: Iaf608370454ad582691b72b471ea87b511863a78
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424323
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-02-16 18:03:59 -08:00
Nadim Taha
69c3fc2378 builtin: Expands string.h / stdint.h
Declares UINT8_MAX, INT8_MAX and defines strnlen(), strncpy(), strncmp() &
memchr(). Needed by a module I'm integrating into cr51.

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

Change-Id: I894b0297216df1b945b36fc77cd3bc5c4ef8aa2b
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/436786
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-17 01:46:31 +00:00
Daisuke Nojiri
4d6eb1bc01 pdchipinfo: Add option to force renewal
This change adds an option to pdchipinfo command to force ec to get
the version from the chip instead of the cache (if it's available).

This option will be used after firmware update, which makes the cache
value stale.

BUG=chrome-os-partner:62383
BRANCH=none
TEST=Run ectool as follows:
localhost ~ # /tmp/ectool pdchipinfo 0 on
vendor_id: 0xaaaa
product_id: 0x3429
device_id: 0xad
fw_version: 0x15
localhost ~ # /tmp/ectool pdchipinfo 1 on
EC result 2 (ERROR)

Change-Id: Icefe96d7fc1208b991a4caa13aaf4f04052edba7
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/441271
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-14 17:28:16 -08:00
Daisuke Nojiri
c9ea4bddbc pdchipinfo: Increase compatibility of fw_version
The firmware version formats may vary chip to chip. fw_version field is
changed to a union of a 8 byte string and an 64-bit integer.

BUG=chrome-os-partner:62383
BRANCH=none
TEST=ectool pdchipinfo 0/1 on Electro

Change-Id: Id51e66c44338a09ed897ee61f54cd6a394400e63
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/441270
2017-02-14 17:28:15 -08:00
Gwendal Grignou
d910997f6a lis2dh: code cleanup
Make FIFO a stack variable to save static memory,
Remove auto_inc argument, always set
Remove constant for rate 0.
Force board to declare sensor private data.
Avoid name collision in stm_mems_common
Include stm_mems_common.h in accel_lis2dh.h, caller only need to
include accel_lis2dh.h.

BUG=none
BRANCH=none
TEST=Compile with discovery_stmems board.

Change-Id: Id52b54dd4ec3cf217247c5511ad5a506067ad293
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/441144
Tested-by: mario tesi <mario.tesi@st.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: mario tesi <mario.tesi@st.com>
2017-02-13 21:15:16 -08:00
Shawn Nematbakhsh
1a736ed954 kevin / gru: Reduce SRAM footprint
Remove console commands and add CONFIG options to reduce RAM usage.

BUG=chrome-os-partner:54099
BRANCH=gru
TEST=Verify charge_ramp CONFIG + task builds for gru.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2d7bc77d1fc032c6cb75eb1ec8d13dacb676658d
Reviewed-on: https://chromium-review.googlesource.com/437662
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-02-13 18:25:51 -08:00
Nicolas Boichat
8c12f0a53f flash: Pass more precise parameter to flash_[physical_]protect_at_boot
In preparation for adding the rollback protection block, pass
EC_FLASH_PROTECT_RO/ALL_AT_BOOT to flash_[physical_]protect_at_boot,
instead of an enumeration no protection/RO/ALL.

This will later allow us to protect/unprotect the rollback region only,
by adding a EC_FLASH_PROTECT_ROLLBACK_AT_BOOT flag.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=Build hammer with CONFIG_CMD_FLASH command, so that write protection
     can be checked with flasherase/flashwrite.
TEST=On hammer (stm32f072):
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp rw; reboot => RO+RW protected
     flashwp norw; reboot => only RO protected
TEST=On reef (npcx):
     deassert WP, flashwp false; flashinfo => RO+RW not protected
     flashwp true => only RO protected
     reboot => only RO protected
     flashwp rw => RO+RW protected
     reboot => only RO protected

Change-Id: Iec96a7377baabc9100fc59de0a31505095a3499f
Reviewed-on: https://chromium-review.googlesource.com/430518
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-12 21:05:11 -08:00
Daisuke Nojiri
c51e0b2f75 PD: Remove CONFIG_USB_PD_TCPC_FW_VERSION
This removes CONFIG_USB_PD_TCPC_FW_VERSION.
board_print_tcpc_fw_version is removed since it's no longer called.
PD chip info is printed in usb_pd_protocol.c.

BUG=none
BRANCH=none
TEST=buildall. Boot Electro, verify chip info is printed.

Change-Id: I2ff860c2a1b17ceea124644ba8feb356b9cca2eb
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/434911
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-11 15:04:42 -08:00
Shawn Nematbakhsh
eb2e38ec56 console: Add non-verbose print config option
Shorten certain long prints and reduce the precision of timestamp prints
when CONFIG_CONSOLE_VERBOSE is undef'd.

BUG=chromium:688743
BRANCH=gru
TEST=On kevin, cold reset the EC, boot to OS, and verify cros_ec.log
contains all data since sysjump and is < 2K bytes (~1500 bytes).

Change-Id: Ia9390867788d0ab3087f827b0296107b4e9d4bca
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/438932
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-11 13:06:38 -08:00
Vijay Hiremath
f30a8cf686 charger_profile: support multiple battery voltage range thresholds
Current fast charge assumes only one battery voltage threshold range for
charger profile override. However we have multiple battery voltage
threshold ranges for few batteries hence added a code which can consider
multiple battery threshold ranges and choose respective charge profile.

BUG=chrome-os-partner:62653
BRANCH=none
TEST=Manually tested on Electro. Manipulate smp_cos4870 & sonycorp
     battery voltage & temperature ranges and observed correct charge
     profile is selected.

Change-Id: Icddc047e608cc8f63cd0c19be716e0f7908ca715
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/438804
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-02-10 19:02:55 -08:00
Daisuke Nojiri
4ff544a573 Add host command to get PD chip information
This patch adds a host command to get PD chip info.

For PS8751, tcpci_get_chip_info will fail if the chip is in
low power mode. It can be woken up by reading a random register
first then wait for 10ms.

This code doesn't have the wake-up read to avoid 10ms delay.
Instead, we call this function immediately after the chip is
initialized because it'll gurantee the chip is awake.

Once it's called, the chip info will be stored in cache, which
can be accessed by tcpc_get_chip_info without worrying about
chip states.

localhost ~ # ectool pdchipinfo 0
vendor_id: 0xaaaa
product_id: 0x3429
device_id: 0xad
fw_version: 0x15

localhost ~ # ectool pdchipinfo 1
vendor_id: 0x1da0
product_id: 0x8751
device_id: 0x1
fw_version: 0x37

BUG=chrome-os-partner:62383
BRANCH=none
TEST=ectool pdchipinfo 0/1. make buildall

Change-Id: I3f1667d00ce1826936d90882ada1df6ed6b0ea37
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/433166
2017-02-09 22:50:50 -08:00
Furquan Shaikh
4ce529e25a chip/npcx/espi: Handle global reset events asserting eSPI_Reset#
In case there is a sudden power loss to PCH, then there are no eSPI VW
messages sent from the PCH to EC indicating power state transition into
S5. Instead, the eSPI compatibility spec defines such events as global
reset events. For global reset events, eSPI_Reset# signal is asserted
without SLP_SUS# being asserted. This acts as an indication to the EC
that there was a global reset event.

Add a callback chipset_handle_espi_reset_assert that takes any necessary
action whenever eSPI_Reset# pin is asserted. On skylake, it would check
if power button was being pressed and release the button.

BUG=chrome-os-partner:62014
BRANCH=None
TEST=Verified that apshutdown works as expected.

Change-Id: I409afa0d00faca55ae3aa577743cedac58d4d877
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/438935
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-02-09 20:48:47 -08:00
Mario Tesi
8db50ce410 driver: accel: Add acc driver basics and FIFO for LIS2DH/LIS2DH12
Add driver for acc sensor ST lis2dh/lis2dh12
    Support interrupt management for FIFO watermark
    Starting to share common code with other devices
    like lsm6dsm/lsm6dsl (acc/gyro) or new lis2mdl (mag)
    TODO: Add all embedded functions support (click,
    tap and so on)

    BUG=none
    BRANCH=master
    TEST=Tested on discovery BOARD with sensor connected on
    EC i2c master bus. Added motion sense task on discovery
    board task list, added gpio info in board configuration
    file and tested with motion sense console commands. Data
    for acc seems ok: can successfully change ODR and
    full scale range. Also FIFO and interrupt tested
    Device tested is lis2dh (lis2dh12 simply differs for low
    pin count but share the same registers)

Change-Id: I16abeac3f139a604094b38d8d8b857a62c93a242
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Reviewed-on: https://chromium-review.googlesource.com/412700
Commit-Ready: mario tesi <mario.tesi@st.com>
Tested-by: mario tesi <mario.tesi@st.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-02-09 03:10:22 -08:00
Nadim Taha
c0feba66a2 common/spi_nor: Differential erase support
If CONFIG_SPI_NOR_SMART_ERASE is defined will read the sector/block
to be erased first and only initiate the erase operation if not
already in an erased state. The read operation (performed in
CONFIG_SPI_NOR_MAX_READ_SIZE chunks) is aborted early if a
non "0xff" byte is encountered.

Reduced erase time of a mostly erased EEPROM from 44s to 20s (16MB
Winbond part) / 1m22s to 40s (32MB Macronix part) @24MHz.

BUG=None
BRANCH=None
TEST=Built all targets. Successfully flashed various EEPROM images.

Change-Id: I369b1fcf72140663b8dbce5a469ebad27f7571ec
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/437988
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-09 05:04:56 +00:00
Vadim Bendebury
a3e8ea92ff cr50: consolidate chip shutdown and resume events
There is no point in keeping in one file multiple hooks task callbacks
to handle chipset shutdown and resume conditions.

Also, the policy of disabling deep sleep needs to be decided in the
board level hooks.

BRANCH=none
BUG=chrome-os-partner:59007
TEST=ran reef through 200 cycles of suspend/resume

Change-Id: I4d30cd04b986b243a5bea44c6978a5f82f8f62a7
Reviewed-on: https://chromium-review.googlesource.com/437729
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Trybot-Ready: Vadim Bendebury <vbendeb@chromium.org>
2017-02-07 02:44:43 +00:00
Vadim Bendebury
a9db319dd4 cr50: rework sleep state and tpm reset triggers
The cr50 needs to be aware of the power state of the system and of the
moment when the AP is reset, because this is when the TPM needs to be
reset too.

Arm and x86 platforms provide different hints in these cases.

In case of x86 there is a single signal cr50 can rely on: PLT_RST_L.
This active low signal is asserted when the system is going into any
power state deeper than s0ix. The cr50 can fall into deep sleep when
PLT_RST_L is asserted, and has to wake up and reset the TPM when this
signal is deasserted. There could be other wake triggers, but the tpm
should not be reset unless PLT_RST_L is inactive. It is also important
not to fall into deep sleep when PLT_RST_L is pulsed to reboot the
system.

In case of ARM there are two separate signals. Deasserting SYS_RST_L
signal is the trigger to reset the TPM, The GPIO_DETECT_AP going low
for a duration of time is the indication of the AP going into some
kind of sleep mode. The ARM case requires more clarification.

This adds run time configuration of the the sleep state control input.
Once the input turns low, the CHIPSET_SHUTDOWN signal is sent and deep
sleep mode is enabled. Again, this will require adjustment for ARM
platforms.

The wake from deep sleep state is controlled by the wake pins as
before, but by level instead of edge. This makes sure that in case the
trigger for deep sleep goes away while deep sleep preparation is under
way, the device resumes immediately instead of getting stuck missing
the edge.

The TPM_RST_ input is now triggering interrupts on deassertion
- this is the moment when the TPM needs to be reset. The ISR is being
renamed accordingly.

The processing previously happening inside the ISR is being moved into
a deferred function running on the hooks task context.

There is no need to invoke TPM reset related functions from the PMU
wake up ISR anymore.

BRANCH=none
BUG=chrome-os-partner:59007
TEST=as follows:

  1. make buildall -j succeeds

  2. started on Reef, still in progress after 100 iterations, early to
  call

   suspend_stress_test --suspend_min 40 --suspend_max 45 \
      --wake_max 15 wake_min 10

  (note that reef does not fall into s3 any more, so the test does not
  verify H1 deep sleep)

  3. modified the target to fall into s3 during the test and
  successfully repeated it for 100 iterations

  4. tried battery disconnect a few times and observe successful boot.

Change-Id: Ica06ec0d363b53eede3be327404ff5807fa3a610
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/436865
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-02-07 02:44:19 +00:00
Sam Hurst
edf46467b9 cleanup: Remove charge_state_v1
All boards have been transitioned to charge_state_v2.c
So charge_state_v1.c, HOOK_CHARGE_STATE_CHANGE, and
CONFIG_CHARGER_TIMEOUT_HOURS can be removed

BUG=chrome-os-partner:36272
TEST=make -j buildall
BRANCH=none

Change-Id: I3f20c5198ea75185f9894deb792575a1be31432a
Reviewed-on: https://chromium-review.googlesource.com/435467
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-06 14:50:32 -08:00
Scott
2e0df8b6c6 cr50: Have INAs and I2Cm enabled when rdd is attached
The INAs are only used for development and testing
purposes. Therefore, the 3.3V rail to the INAs is off by default and
the I2Cm module is not enabled. Enabling INA power and connecting the
I2Cm module was done at the beginning of each USB to I2C request. The
problem with this approach is that INA measurments didn't always
succeed due to not enough time for the INAs to initialize.

Rather than add some arbitrary delay, it is better to tie the INAs to
when rdd is attached/detached. It is only when rdd is attached that
the INAs will be accessed, so there is no need to enable/disable for
each individual I2C transaction.

This CL ties the enabling/disabling of the INA and I2Cm module to the
rdd state. This change makes the previous use of
usb_i2c_board_enable() and usb_i2c_board_disable() obslete.

BRANCH=none
BUG=chrome-os-partner:62375
TEST=manual
Connect servo with suzyq connected:
sudo servod -p 0x5014 -b eve -c eve_r0_inas.xml
Then execute single INA reads dut-control pp3300_dx_edp_mv and verify
that it returns meaningful numbers. Without this CL single reads via
dut-control would always return 0.

Change-Id: I799552bfd0701efd1828a0d720ac2a6cedee5ca1
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/436864
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-02-06 14:50:31 -08:00
Vijay Hiremath
d536724cf5 motion_sense: Defer switching the sensors rate if in S3
During shutdown sequence sensor rails can be powered down asynchronously
to the EC hence EC cannot interlock the sensor states with the power down
states. To avoid this issue, defer switching the sensors rate with a
configurable delay if in S3. By the time deferred function is serviced,
if the chipset is in S5 we can back out from switching the sensor rate.

BUG=chrome-os-partner:61489
BRANCH=none
TEST=Manually tested on Electro. Put the device in S5 and observed
     no I2C errors printed on EC the console.

Change-Id: I40b75ebbf0d05fafffdfd535962423c3960fafbf
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/433338
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-02-02 19:09:52 -08:00
Shawn Nematbakhsh
f08109522d charge_ramp: Specify port number in board_is_vbus_too_low()
charge_ramp needs to make a decision based upon the VBUS level on one
specific port - the port that is ramping. The VBUS level on any other
charge ports (if present) is not relevant.

BUG=chrome-os-partner:54099
BRANCH=reef, gru
TEST=With subsequent patches, verify charge_ramp success with a variety
of BC1.2 chargers.

Change-Id: Ie0a51a577e2b7491222560cd08dd5321ff3b7975
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/435561
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-02 19:09:52 -08:00
Sam Hurst
275cdfa556 usb pd:Correct the USB PD SinkWaitCap and PSHardReset timer values
Values should be as follows:
tTypeCSinkWaitCap: 310 to 620ms
tPSHardReset: 25 to 35ms
Current values are:
tTypeCSinkWaitCap (PD_T_SINK_WAIT_CAP): 240ms
tPSHardReset (PD_T_PS_HARD_RESET): 15ms

BUG=chromium:686122
TEST=manual testing on kevin along with make -j buildall
	- used a kevin to send a hard reset to uut
		> pd 0 hard
		C0 st36
		C0 st37
		34725 ms <-- time it took hard reset to execute
		C0 HARD RST TX

	- used a kevin, operating as source, that does not send
	  source caps to test a uut operating as a sink.
		C0 st6
		C0 st36
		613266 ms <-- time sink waited for source cap

	- plugged in charger and logged pd negotiation
		[1510.574091 event set 0x00200000]
		C0 st15
		C0 st3
		[1510.845115 event set 0x08000000]
		C0 st6
		Req C0 [1] 5000mV 3000mA
		[1510.945827 New chg p0]
		C0 st7
		[1510.949953 CL: pC0 st8
		0 s0 i500 v15000]
		[1510.954055 event set 0x00200000]
		[C0 st9
		1511.061285 event set 0x00400000]
		[1511.064752 CL: p0 s0 i3000 v5000]
		[Req C0 [3] 15000mV 3000mA
		1511.067538 event set 0x00200000]
		C0 st7
		C0 st8
		[1511.077896 CL: p0 s0 i500 v5000]
		[1511.079048 event set 0x00200000]
		C0 st9
		[1511.275448 CL: p0 s0 i3000 v15000]
		[1511.276913 event set 0x00200000]
		Req C0 [3] 15000mV 3000mA
		[1511.445719 CL: p0 s0 i500 v15000]
		[1511.446117 event set 0x00200000]
		C0 st7
		C0 st8
		C0 st9
		[1511.565730 CL: p0 s0 i3000 v15000]
		[1511.566566 event set 0x00200000]
		[1511.812205 event set 0x00400000]
		[1513.274941 event set 0x00200000]
		[1529.324670 Battery 90% / 0h:29 to full]
BRANCH=none

Change-Id: I6e80637cfc50dcfc431feb0e473ec22f408d6f1a
Reviewed-on: https://chromium-review.googlesource.com/434103
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-01 14:29:23 -08:00
Vadim Bendebury
11704ae6e9 Revert "version: Store image size data in version struct"
This is a dependency of the uderlyaing patch which breaks header
composition of g chip based boards.

This reverts commit 7cbb815732.

Change-Id: I4d94647cf5cb09fd338e5a581c956df6b5d83081
Reviewed-on: https://chromium-review.googlesource.com/435551
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-01 06:36:18 +00:00
Sam Hurst
1e9971abab ec:Correct EC_CMD_HOST_EVENT_GET_WAKE_MASK value
All host commands must be 4-digit uppercase hex digits.
EC_CMD_HOST_EVENT_GET_WAKE_MASK is currently defined as 0x008d

BUG=chrome-os-partner:62518
TEST=make -j buildall
	100bcffc R __host_cmd_0x00000x0087
	100bd008 R __host_cmd_0x00000x008C
	100bd014 R __host_cmd_0x00000x008D
	100bd020 R __host_cmd_0x00000x008F
	100bd02c R __host_cmd_0x00000x0092
BRANCH=none

Change-Id: If2460efa7453e8007514b10dd9a973120006c7e1
Reviewed-on: https://chromium-review.googlesource.com/435581
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-31 21:58:50 -08:00
Sam Hurst
ca0d5aba6b ec: delete auron and rambi boards
These boards have been succeeded by newer boards.

BUG=chromium:686106
TEST=make -j buildall
CQ-DEPEND=CL:434909
BRANCH=none

Change-Id: I2c964c1fdd7f8bbc5dab07caa88864847ba4e312
Reviewed-on: https://chromium-review.googlesource.com/434540
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-31 21:58:36 -08:00
Shawn Nematbakhsh
7cbb815732 version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now
renamed to image_data). This will allow us to more efficiently determine
the size of an image in a follow-up CL.

Note that compatibility is broken for old ROs that do not include this
CL.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that stored image size matches
output of system_get_image_used() for both RO and RW images.
BRANCH=None

Change-Id: I49ea5fc27a7f11f66daba485a87d0dfe7d0c770f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/427408
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-01-30 16:48:40 -08:00
Vadim Bendebury
cf8c12e139 cr50: vendor command to report tpm state
This vendor command allows the host to retrieve the internal TPM
state. The first version of the command will return the failure
information collected during assert, if it ever happened, retry
counter value and the maximum retry counter value to be able to detect
if TPM is in lockout.

The structure is packed, it is serialized before being sent to the
host.

BRANCH=none
BUG=chrome-os-partner:60555
TEST=when running on a reef with a depthcharge image capable of
     displaying TPM state on errors observed state information added
     to the recovery screen text display.

Change-Id: I9d37f7a971013ce802f63218d43697fab68276c9
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/430952
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2017-01-28 12:28:39 -08:00
Mary Ruthven
39a41bd665 tpm: rename tpm_reset to tpm_reset_request
tpm_reset just requests a tpm reset it doesn't reset the tpm. Rename the
function to reflect that.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I6f4763b5de578a8cf263b2fac98fad3af2c25d65
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/434245
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-01-28 01:52:16 -08:00
Vadim Bendebury
79a1e2072d nvmem: do not use malloc for cached buffer
With introduction of encryption it is becoming impossible to read
NVMEM contents directly from flash. Decrypting the contents each time
there is a read request creates a significant performance hit. NVMEM
needs to be rearchitecture such that there is no need to run
decryption each time NVMEM read is performed.

This patch does just that, implementation details are described in the
header comment in common/nvmem.c.

To reduce memory impact the size of NVMEM is being decreased from 16K
to 12K. This is acceptable because eviction objects stored in NVMEM
serialized now, which dramatically reduces NVMEM size requirements.
The TPM2 NVMEM size definition must be kept in sync.

Another optimization this change introduces is bypassing writing into
the flash if NVMEM contents did not change, which is verified by
examining the hash of the cached storage.

A test is added to verify that the new commit scheme works as
expected, and the nvmem test is re-introduced to the list of test ran
on each 'make buildall'.

CQ-DEPEND=CL:433839
BRANCH=none
BUG=chrome-os-partner:62260,chrome-os-partner:62421
BUG=chrome-os-partner:62437
TEST=ran the following tests, all succeeded
     make buildall -j
     TEST_LIST_HOST=nvmem make runtests
     tcg test suite
     corp enroll on reef, reboot a few times, verify that enrollment sticks

Change-Id: I177daa3ceb4fd7aac299ca26b4506b863e31b946
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/433184
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-28 01:52:09 -08:00
Scott
58e18da39f servo_v4: pd: Added Device Test System support
- Modified src attach state to enable vbus when debug accessory is
detected.

- servo_v4 has two pd ports, but each port requires a different default
power role. Port 0 can only ever be a SNK, but port 1 which acts is
intended to be a DTS port should default to a SRC so it can be be a
source debug accessory. It may also act as a sink debug accessory, but
is not intended to toggle automatically but will swap roles if
necessary via pd role swap messaging.

- Add hook for ccd enable/disable for DTS mode

BUG=chrome-os-partner:61878
BRANCH=servo
TEST=Manual Verfied that can still build servo_v4 project. All changes
in this CL are contingent on config option CONFIG_USB_PD_DTS being enabled.

Change-Id: Iab968b6fbdfc8f2d155c4f8618921b32f313b9ec
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/428308
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-26 23:16:40 -08:00
Sam Hurst
17515de32c pd: support gotoMin and giveBack
In Sink mode, on the receipt of a GotoMin message,
reduce the current consumption to some minimum level.

BUG=chrome-os-partner:33688
TEST=Manual testing
	Used a Kevin, with test routine, to test GotoMin feature
	on another Kevin unit.

	Test routine:
		 if (!strcasecmp(argv[2], "gm")) {
		    ccprintf("send goto min\n");
		    send_control(port, PD_CTRL_GOTO_MIN);
		    send_control(port, PD_CTRL_PS_RDY);
		}

	Kevin with GotoMin feature:
		# ectool usbpdpower 0
		Port 0: SNK DRP PD 4277mV / 3000mA, max 5000mV / 3000mA / 15000mW
		Port 1: Disconnected

		After Test routine is executed:

		# ectool usbpdpower 0
		Port 0: SNK DRP PD 4906mV / 500mA, max 5000mV / 500mA / 2500mW
		Port 1: Disconnected
BRANCH=none

Change-Id: Iaac6e19706ceb10ccaff4d602d63fc086c808c8f
Reviewed-on: https://chromium-review.googlesource.com/425728
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-26 18:43:52 -08:00
Scott
44676699b0 pd: Move PD_DEFAULT_STATE to a common define in usb_pd.h
Servo_v4 requires the ability to have a different default state per
port. In previous devices, the assumption was that each supported port
had the same default usb pd state and power role. This CL moves the
by the default power role which in turn is derived from
CONFIG_USB_PD_DUAL_ROLE. In addiiton to moving the location, it now
uses 'port' as argument so it can be port specific if required.

PD_DEFAULT_STATE was a board.h specific config, but in practice each
instance used to date was set to PD_STATE_SNK_DISCONNECTED if
CONFIG_USB_PD_DUAL_ROLE was defined and set to
PD_STATE_SRC_DISCONNECTED otherwise.

BUG=chrome-os-partner:61878
BRANCH=servo
TEST=Manual run 'make -j buildall' to verify that all instances of
PD_DEFAULT_STATE were removed.

Change-Id: Iaf40718668732f525485ed7942ee7fc246d3f75d
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/431787
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-26 16:10:30 +00:00