Commit Graph

7216 Commits

Author SHA1 Message Date
Wei-Ning Huang
5b1d2b878d rose: add touchpad related host commands
Add touchpad related host commands:
1) EC_CMD_TP_SELF_TEST: run open short test.
2) EC_CMD_TP_FRAME_INFO: get number of frame and frame size.
3) EC_CMD_TP_FRAME_SNAPSHOT: make a snapshot of the frame.
4) EC_CMD_TP_FRAME_GET: get frame data.

BRANCH=none
BUG=b:62077098
TEST=`make BOARD=rose -j`
     `ectool --name=cros_tp tpselftest` and
     `ectool --name=cros_tp tpframeget` works

Change-Id: I43db82278e556b1e6f6301fe88233fe7c4a18a14
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/515282
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-06-07 05:22:56 -07:00
philipchen
859a33ff46 scarlet: remove lid accel and add barometer
Remove lid accelerometer (kx022) driver and dependent code.
Add barometer (bmp280) driver.

BUG=chrome-os-partner:62207
BRANCH=gru
TEST=make BOARD=scarlet
TEST=manually test on gru

Change-Id: I521027b8877b9c45880090b9af736adc339edb2b
Reviewed-on: https://chromium-review.googlesource.com/431878
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/524974
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-06-07 03:02:56 -07:00
Vadim Bendebury
25fb7bb3e5 Cr50: usb_updater: add commands to get/set board id
This patch enhances the Cr50 usb_updater to allow to get and set Board
ID value saved in the Cr50's INFO1 space using the earlier introduced
dedicated vendor commands.

Getting or Setting the board ID does not require establishing a
connection with the Cr50, the new option is --board_id/-i. When
specified without a parameter, the new option will cause the Board ID
to be read. When specified with a parameter, the board ID value will
be set. The parameter includes one or two values in a single string,
the values separated by a colon.

The first value is a 4 byte board ID, and the second value is the
flags field. The default flags field is set to 0xff00.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified that it is possible to get and set the board ID value
      using usb_updater, both over USB and TPM.

      verified that it is not possible to set a new board ID value is
      the INFO1 space has been already programmed.

      verified that it is not possible to set a board ID value which
      would not allow the currently running image to start (even
      though there is no run time check yet).

Change-Id: Ief175d8b2ef3177db13fa86f831914088d9447b0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525096
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-07 03:02:55 -07:00
Scott Collyer
16da7b4c8c coral: Modify battery_info struct for 3S + 1P style battery
Initial version of battery.c for coral is just a straight copy from
Reef. Updated this file to include the battery being used for the
first HW build. Removed the profile override config for the starting
point as well.

BUG=b:62272260
BRANCH=none
TEST=Run 'make BOARD=coral' and verify it builds. Can't test on actual
HW yet as the boards aren't build yet.

Change-Id: I15fcf438918c03bf1d459f5806dff04c82fe8b46
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/521756
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-06-06 19:32:29 -07:00
Gwendal Grignou
cf5555a9ce stm32mon: Add support for STM32F412
BRANCH=none
BUG=b:38506987
TEST=On eve, where some sectors were locked, was able to unlock them:
- Enter bootloader:
st_flash --board=eve --enter_bootloader=true
- Unlock all pages:
/tmp/stm32mon -a 8 -l 0x8c -u
ChipID 0x441 : STM32F412
Bootloader v1.2, commands : \
00 01 02 11 21 31 44 63 73 82 92 32 45 64 74 83 93 00
Flash write unprotected.

Change-Id: I423e4b7f235ee2c9dddf28f4166fca2a74132733
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/511886
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-06 17:09:28 -07:00
Gwendal Grignou
7719869dac board: Add support for nucleo-f411re
Add nucleo-f411re for testing STM32F411.
Fix registers.h to include F411 specific features.

TEST=Check uart,gpio works. Check BMI160 accel/gyro sensor works over
i2c
Install firmware with "make BOARD=nucleo-f411re flash"

BUG=b:38018926
BRANCH=none

Change-Id: I8514d1aa48e06708053e72f8d4be15738eda6cf4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249994
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-06 17:09:28 -07:00
Vadim Bendebury
885c02a92d cr50: usb_updater: do not send setup request unless necessary
There are only two usb_updater actions which require establishing a
connection with the Cr50: transferring the firmware image during
update and reporting the version of the running image (because the
version is reported when the connection is established).

This patch refactors usb_updater code to establish the connection only
when necessary.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified that 'usb_updater -c' succeeds both issued over USB and
      TPM

Change-Id: I6a0c82eb440c092263d4802f124f458f148a8ab5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525095
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 17:09:28 -07:00
Vadim Bendebury
af92414985 cr50: include more vendor commands into the USB set
The upcoming changes in usb_updater will allow to issue vendor
commands to set and get board ID value. It is also useful to be able
to corrupt the alternative RW header over Suzy-Q when Cr50 is running
a debug image.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=not yet.

Change-Id: I54ac6eb4cebd85f97407211c5212b868d61e560f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/524894
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 17:09:27 -07:00
Vadim Bendebury
b06942187e cr50: usb_updater: add proper vendor command processing
So far vendor command processing has been a second class citizen in
the Cr50 usb_updater: return codes were mostly ignored even when using
TPM, when using USB there was no way to communicate return codes at
all.

This patch refactors the source code to use a single function to
process vendor commands over both USB and TPM, adding proper passing
of the result codes back to the caller in both cases, retrieving the
return code from the response header when using TPM and from the first
byte of the response payload when using USB.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified that it is possible to update rw13, rw18 and rw20 both
     over TPM and USB, which indicates that vendor commands are
     properly handled.

Change-Id: I837e17b29d3b025fbca5b1ef49463cfb1729fe6c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525094
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 17:09:27 -07:00
Philip Chen
aafff584ae scarlet: Adapt to the master branch
To port Scarlet from firmware-gru-8785.B to master, we need
some change in naming/definition of variables/functions.

BUG=b:62307687
CQ-DEPEND=CL:524034, CL:524973, CL:524981
BRANCH=gru
TEST=build image and boot Scarlet

Change-Id: I20c1a4f311c9250a3bf1a2a5b0c70dd0f7c7e45b
Reviewed-on: https://chromium-review.googlesource.com/524987
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 17:09:27 -07:00
Philip Chen
d8036441ca scarlet: enable mkbp
BUG=chrome-os-partner:62987, b:62307687
CQ-DEPEND=CL:524987, CL:524034, CL:524973
BRANCH=scarlet
TEST=manually push VolUp/VolDown on scarlet

Change-Id: I593bdce6c69856c4099c8c17059f5fd1eb8aae33
Reviewed-on: https://chromium-review.googlesource.com/443746
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/524981
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-06-06 17:09:27 -07:00
philipchen
f7930038a1 scarlet: Remove one usb type-c port
BUG=chrome-os-partner:62207, b:62307687
CQ-DEPEND=CL:524981, CL:524987, CL:524034
BRANCH=gru
TEST=make BOARD=scarlet
TEST=manually test on gru - only one type-c port works.

Change-Id: I0b1735d3da11ee9432ce97467036e2a6cf2b8dbe
Reviewed-on: https://chromium-review.googlesource.com/431000
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/524973
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-06-06 17:09:27 -07:00
philipchen
1861f5695a scarlet: initial mainboard
Copied board-related files from
gru folder and updated some minor changes
to make it compilable.
Will do more follow-up modification based on this work.

BUG=chrome-os-partner:62207, b:62307687
CQ-DEPEND=CL:524973, CL:524981, CL:524987
BRANCH=gru
TEST=make BOARD=scarlet

Change-Id: Ib508ef69e448028809276fe010c3f5fbef0500b4
Reviewed-on: https://chromium-review.googlesource.com/430965
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
(cherry picked from commit 63592fef936909fe97af487f4ded44b9daa5847f)
Reviewed-on: https://chromium-review.googlesource.com/524034
Commit-Ready: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-06-06 17:09:26 -07:00
Duncan Laurie
9565b8ba06 eve: Set VCCIO rail to 0.85 and disable low power
Set the VCCIO rail to 0.85V where it should be for Y-series parts
instead of forcing it to 1.0V.  The EDS is pretty clear that pushing
this voltage higher on Y-series parts will have significant power penalty.
(up to 250mW at 0.95V)

We also don't want this rail dropping in low power mode, which shoudln't
be happening as S0ix is disabled so SLP_S0 shouldn't assert, but just in
case disable this as well.

BUG=b:35587084
BRANCH=eve
TEST=stress testing on Eve EVT units

Change-Id: I5535fe0d894f283a8d453d61101dfeb6b9287b7c
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/525836
Reviewed-by: Todd Broch <tbroch@chromium.org>
2017-06-06 14:36:30 -07:00
Vadim Bendebury
51f5875da6 cr50: usb_updater: include return codes into USB response payload
When vendor commands are processed by the TPM device, the result of
the command execution is communicated through the TPM response header.
When vendor commands are sent through USB the command execution result
value is lost, as the USB reply includes only the response payload,
(if any), but not the result value.

With this patch the single byte result value is prepended to the USB
response payload. The recipient will always look for the value in the
first byte of the response to find the vendor command execution
status.

The corresponding change to the Cr50 usb_updater will remove the
response code from the payload before considering the command's return
data.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified proper existing extension commands processing (post
     reset, turn update on) by the new version of usb_updater and
     backwards compatibility with earlier Cr50 RW version (down to
     0.0.13).

Change-Id: I5c8b3ea71d3cbbaccc06c909754944b3ab04675d
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525093
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 14:36:28 -07:00
Vadim Bendebury
a75f7c8680 cr50: usb_upgrade: allow responses lager than requests
When invoking vendor command handlers in try_vendor_command(), the
buffer containing the command is passed to the handler to communicate
the command contents and to hold the command execution return data. It
was fine when invoking vendor command handlers from the TPM stack, as
the receive buffer is 4K in size and is large enough for any expected
vendor command response.

It is different in case of USB: the command is in the receive buffer
of the USB queue, and the response data could easily exceed the
command size, which would cause corruption of the USB receive queue
contents when the response data is placed into the same buffer where
the command is.

Let's introduce a local storage to pass the command and receive the
response data from the handler. 32 bytes is enough for the foreseeable
future, should a need arise for a larger buffer, testing would result
in an error (a new error type is added to indicate insufficient buffer
space for command processing).

BRANCH=none
BUG=b:35587387,b:35587053
TEST=with the rest of the patches applied verified proper processing
     of the 'Get Board ID' command for which response size exceeds the
     request size.

Change-Id: I2131496f3a99c7f3a1869905120a453d75efbdce
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525092
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 14:36:28 -07:00
Nicolas Boichat
6d05a31a44 rollback: Include board-generated entropy when adding entropy
Mix in board-generated entropy with the externally provided one,
which should help make the per-device secret stronger.

BRANCH=none
BUG=b:38486828
TEST=reboot; rollbackaddent Hello => works fine when USB is connected,
     fails otherwise, as board-generated entropy relies on USB timing.

Change-Id: I314f44759c5f8b859913a748db95e9d42b5cdd11
Reviewed-on: https://chromium-review.googlesource.com/518609
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-06 08:52:16 -07:00
Nicolas Boichat
39db721f9a hammer: Add board_get_entropy function (and test)
This function will be used to generate some entropy using the
Clock Recovery System.

BRANCH=none
BUG=b:38486828
TEST=make BOARD=hammer -j tests
     ./util/flash_ec --board=hammer --image=build/hammer/test-entropy.bin
     EC console: runtest
TEST=Test fails when no USB connection is active
TEST=Test passes when USB connection is active
TEST=Pasting the values into:
     tr ';' '\n' | awk 'BEGIN { e = 0; tot=16384.0 }
                  { p = $1/tot; if (p > 0) { e -= p*log(p)/log(2) } }
                  END { print e }'
     shows an entropy > 4 bits per sample.

Change-Id: I2363c7bce42c72c33ef0bf3f099d709ee9c13d13
Reviewed-on: https://chromium-review.googlesource.com/518608
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-06 08:52:16 -07:00
Harry Pan
2f436f4cc9 isl9238: Enable system power monitor function
The system power monitor function, aka. PSYS, of the ISL9238 chip
is disabled by default, this patch enables PSYS monitor in the
EC driver.

BUG=b:62041842
BRANCH=none
TEST=Able to read non-zero value at the MSR of
MSR_PLATFORM_ENERGY_STATUS (0x64D) by iotools;
Also, kernel powercap driver probes PSYS domain correctly;
Such that the kernel exports the sysfs node of intel-rapl:1

Change-Id: I7a533032815e873ae74dca42ec07041be0d0f975
Signed-off-by: Harry Pan <harry.pan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/520549
Tested-by: Kane Chen <kane.chen@intel.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-06 05:15:55 -07:00
Mary Ruthven
4315a010b0 g: add flag to delay int enable until board_init
Cr50 has different gpio configurations for different boards. They cannot
be determined until board_init. We want a way to delay enabling the gpio
interrupts until the board type can be determined.

This change adds a gpio flag, GPIO_INT_DISABLE. When set gpio_pre_init
will setup the interrupt, but not enable it. board_init then enables all
of the interrupts with init_interrupts.

BUG=b:35587228
BRANCH=cr50
TEST=use 'gpiocfg' to verify the setup hasn't changed. Add print
statements to verify that gpio_pre_init skips enabling the interrupt on
any gpio that has GPIO_INT_DISABLE set

Change-Id: I91f73297ab80781b99aa82eda479ae311c13cb77
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/523808
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-05 18:33:57 -07:00
Aseda Aboagye
7dab0e853c chip: g: Add support for UART bit banging.
The UART block on the g chip has no functionality to adjust the parity.
Unfortunately, this feature is needed for certain applications.

This commit adds a UART bit bang driver with support for configuring the
baud rate and parity.  It currently only supports 8 data bits.

BUG=b:35648297
BRANCH=cr50
TEST=make -j buildall
TEST=With some other patches, successfully flash rowan EC at 9600 baud.

Change-Id: I86a160c0960e46b3a8bb1057518f625aefb7d81f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/503473
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-05 14:49:09 -07:00
Duncan Laurie
2ac6afd3e6 eve: Disable discharge-on-ac with board 5+
Board version 5+ has BD99954 charger which does not have audible
noise when battery is full and charger is at 20V.  Disable the
discharge-on-ac workaround for these boards.

BUG=b:37228827
BRANCH=none
TEST=tested on board version 5 that discharge-on-ac is not enabled
when the battery is full.

Change-Id: I72e6870e06328d84a802c2f736659677de1f9a08
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/524222
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2017-06-05 14:49:08 -07:00
Mary Ruthven
a80267f1d6 g: expand pinmux to print info on spi and i2c
pinmux only prints uart and gpio information. This change makes pinmux
print i2c and spi connections too.

This does not handle the direct pin to peripheral mappings, so the spi0
and sps0 peripheral pins still won't show up.

BUG=none
BRANCH=cr50
TEST=run pinmux on reef

Change-Id: Iaa6204e2af7f018569b92280bd1367aef201cc28
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/501172
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-05 14:49:08 -07:00
Scott Collyer
8bb308cc6b eve: Update LED behavior to match new spec
The previous LED implementation was modelled on Kevin and enhanced to
give developer feedback. This CL implements the Eve specific LED
operation.

BUG=b:35584895
BRANCH=none
TEST=Manual
Used EC console command 'battfake' to force different charge levels
and verified that the expected LED patterns were generated.

Change-Id: I46bc2889540f320e8aadf3d9d634c36dbc38c161
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/516548
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2017-06-05 13:01:50 -07:00
Vincent Palatin
4e53e01c2c cr50: implement an ASN.1 DER x.509 certificate builder
Add primitives to build x.509 certificates encoded in ASN.1 DER,
as a building block for the U2F feature.

Mostly copied over from the cr52 code-base.

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

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve
and manually verify the individual attestation certificate with an ASN.1
parser.

Change-Id: Ie90730d8c401c661c8ab3b1b19631337b7390e9c
Reviewed-on: https://chromium-review.googlesource.com/518134
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-05 11:21:51 -07:00
Chun-Ta Lin
d5c08763e1 usb_i2c: extend the protocol to support larger payload
The default USB packet has a maximum size of 64 bytes, however, we need
to support some USB over I2C write transaction that exceed this default.

To support so with protocol backwards-compatible in mind, we enable a
config option CONFIG_USB_I2C_MAX_WRITE_COUNT that will enlarge the USB
RX queue.

BRANCH=none
BUG=b:35587174
TEST=Complete presubmit test.
TEST=Manually update elan trackpad firmware with interrupt disabled.

Change-Id: Ia8983b036b7297f7ca673459ae34b7e5ecd2ee01
Reviewed-on: https://chromium-review.googlesource.com/513642
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-05 07:55:32 -07:00
Vijay Hiremath
ce65199e5e BD9995X: Disable input current limiting for VBAT < VSYSREG_SET
The initial value for input current limit is set to
CONFIG_CHARGER_INPUT_CURRENT which is typically 512 mA. In deeply
discharged battery cases (Vbat < 5.8V), the 512 mA input current limit
can cause VSYS to collapse which in turn causes the EC to
reset. Depending on how discharged the battery is, the EC may remain
off until the external charger is disconnected and reconnected again,
or it may undergo a number of reset cycles, each time charging the
battery just a little, until Vbat becomes > ~5.8V and the charger is
able to stabilize. When the charger type is determined, either from
BCD detection, or Type C/USB PD, the input current limit is set to the
appropriate level.

In order to avoid the issue described above, this CL sets a bit in the
VIN_CTRL_SET register which will disable the input current limit in cases
Where the VBAT is less than the VSYSREG_SET value.

BUG=b:35648317
BRANCH=none
TEST=Manually tested on Electro.
     a. With Zinger attached DUT boots without the battery after
        plugging in AC
     b. DUT boots from cut-off battery
     c. With Zinger attached DUT boots from cold-reset without the
        battery
     d. With no battery & DCP charger, anti-collapse occurs,
        input current is limited to 512mA & the DUT is
        power-up inhibited.

Tested also on Eve with signal wires attached to both PPVAR_VSYS,
PP3300_DSW, and Vbat. Verified that on certain boards (some board to
board variation) that PPVAT_VSYS would collapse when the input current
limit was set to CONFIG_CHARGER_INPUT_CURRENT. Then after adding this
CL, verifed on the scope that the collapse of PPVAR_VSYS no longer
occurred.

Change-Id: Ief9960550f988e69ab4637db85450e91c70d3b51
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/456049
Commit-Ready: Vijay Hiremath <vijay.p.hiremath@intel.corp-partner.google.com>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.corp-partner.google.com>
2017-06-03 20:31:40 -07:00
Nicolas Boichat
698cf1e268 poppy: Update led control logic to obey manual controls
Also fix color name mixup.

BRANCH=none
BUG=b:37970194
TEST=ectool [left|right] [white|amber|auto] work fine
TEST=left/right LED still light up properly when charging

Change-Id: I330dc70d057b73da799b30762873dedb119da4d8
Reviewed-on: https://chromium-review.googlesource.com/523203
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shen-En Shih <petershih@chromium.org>
2017-06-03 03:57:39 -07:00
Gwendal Grignou
35f4d8acaa Add flash command support to boards with STM32F4
Add support to write and erase all flash with flashrom.
Add support to use all the memory.

Note that PSTATE must not used its own page, as the STM32F4 use big pages.

BUG=b:38018926
BRANCH=none
TEST=With flashrom, write all, RO, RW regions.
Use flash command on the console, including flashwp

Change-Id: I4f0aee1b3a4f342bdf4ca97bf5d8e8bcc153fd9c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264032
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-03 02:02:42 -07:00
Nicolas Boichat
5c9118b311 hammer: Add support for new key
There is a new keyboard matrix layout:
 - We can map the search key to both KSO1, KSI0 and KSO0, KSI3
   (old layout will only use the former, new layout will use the latter).
 - There is a new key on KSO0, KSI5, which we can map to HID page 0xffd1
   code 0x0018.

BRANCH=none
BUG=b:62004286
TEST=Flash hammer
     kbpress 0 3 1; kbpress 0 3 0 reports KEY_LEFTMETA as expected
     kbpress 0 5 1; kbpress 0 5 0 reports "BTN_0", which is probably
     incorrect, and needs to be fixed.

Change-Id: I9fb428805ff756b6d63f50cc5b061c6a0e1defbc
Reviewed-on: https://chromium-review.googlesource.com/512502
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-06-02 23:59:05 -07:00
Gwendal Grignou
cc8fd2386f stm32mon: Add offset/length parameter to read/write a particular memory region
Use that option to read a particular portion of the flash

BUG=None
BRANCH=none
TEST=Check data retrieved is correct.

Change-Id: Ib2bc98aa7352515c2e651443f322dd0250c72cdd
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/260886
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-02 18:39:37 -07:00
Gwendal Grignou
09a7fa4aef stm32mon: Add support for STM32F411
Add support for i2c boot protocol 1.1 and erase non-strech erase
command.
Add option to specify i2c slave address.

TEST=Read, Erase and Write SH on Ryu P4.
BUG=chrome-os-partner:36018
BRANCH=none

Change-Id: Ib0649323fd8879fef6e2dc5e62001c891afe128a
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250101
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-02 18:39:37 -07:00
Gwendal Grignou
72afc55bd9 stm32: cleanup flash-f by using constant from register.h
Use constants from registers.h, to easily support other ECs.
Fix indentation in registers.h

BRANCH=none
TEST=compile + following patches tested on STM32F411
BUG=None

Change-Id: Iecb3ce759a5c4ff13463e7df1cb7e03fc1ce6f69
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264030
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-02 18:39:37 -07:00
Gwendal Grignou
92ea78398b common: Add deferred erase support
Some device has large pages that take up to 2s to erase.
Add support to send a deferred erase command, that willi
be processed on HOOK task.

It can leave the other tasks (HOST_CMD) responsive.
If the whole EC can stall on flash erase, like the STM32F4 do,
at least the command FLASH_ERASE_GET_RESULT can be retried when it times
out.

BRANCH=none
TEST=Check with flashrom doing a loop of overwrites.
BUG=b:38018926

Change-Id: I8ce8e901172843d00aac0d8d59a84cbd13f58a10
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/510012
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-02 18:39:37 -07:00
Rong Chang
9ca4586129 common: Add support for flash with regions of different size
Add support to handle devices with flash regions of different sizes.

BRANCH=none
TEST=compile
BUG=b:38018926

Change-Id: I8f842abaa50de724df60dd7e19f9e97cb9660367
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264031
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-02 16:59:36 -07:00
Vadim Bendebury
d0ee126b4c cr50: usb_upgrade: pass proper number of bytes to the vendor commands
The code invoking vendor commands callbacks rightly passes the pointer
to the command payload as the address right after the subcommand
field, but does not deduct the size of the subcommand field from the
size of the payload passed to the handler.

This patch fixes the issue, the command handlers do not see two extra
bytes at the tail of the command any more.

BRANCH=cr50
BUG=b:62294740, b:35545754
TEST=verified that vendor commands sent over USB and TPM still work
      properly (in particular the TURN_UPDATE_ON command).

Change-Id: I11a45f65163044f808a82b214f9c5faf775f9020
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/522943
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-02 16:59:33 -07:00
Philip Chen
ee54592238 cr50: Add console and TPM vendor commands to get/set board ID
This patch adds vendor and console commands to read and write the
board ID space in the INFO1 block.

Current image's board ID settings are saved in the image header by the
latest codesigner.

Board ID write attempts are rejected if the board ID space is already
initialized, or if the currently running image will not be allowed to
run with the new board ID space settings.

Error codes are returned to the caller as a single byte value.
Successful read command returns 12 bytes of the board ID space
contents.

The console command always allows to read the board ID value, and
allows to write it if the image was built with debug enabled.

BUG=b:35586335
BRANCH=cr50
TEST=as follows:
   - verified that board ID can be read by any image and set by debug
     images.

   - with the upcoming patches verified the ability to set and read
     board ID values using vendor commands.

Change-Id: I35a3e2db92175a29de8011172b80091065b27414
Signed-off-by: Philip Chen <philipchen@google.com>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/522234
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-02 16:59:33 -07:00
Duncan Laurie
1444ace29f eve: Swap volume up and down GPIO
The buton behavior is inverted if we follow the schematic, so swap the
GPIO on these inputs so they match the expected behavior.

BUG=b:62120390
BRANCH=none
TEST=manual test of side volume button behavior

Change-Id: I0ad18b4a15fcc2832d97dfad3b03186180e4517a
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/522410
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2017-06-02 12:25:47 -07:00
Scott Collyer
9b28aa4531 coral: GPIO modifications for differences from Reef
Account for EC GPIO changes from Reef to Coral.

BUG=b:35584895
BRANCH=none
TEST=Run 'make BOARD=coral' and verify it builds. Can't test on actual
HW yet as the boards aren't build yet.

Change-Id: If677e152f10b9e12870f14f57503b082e71ff938
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/517361
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2017-06-02 12:25:47 -07:00
Vincent Palatin
ea274f2722 cr50: change the power button handling
Enable permanently the power button interrupt and discard the unneeded
presses, rather than enabling the interrupt on demand.
This is a preparatory work for the U2F feature which is using the power
button as the user physical presence sensing. It will need to be able to
detect all the button touches.

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

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve.

Change-Id: Ifd90970932684d31ad7687db260bafa65a56e854
Reviewed-on: https://chromium-review.googlesource.com/518138
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-02 10:38:57 -07:00
Vincent Palatin
5479dcbbc5 cr50: configure flash counter
Add the robust non-volatile counter provided by CONFIG_FLASH_NVCOUNTER
in order to support the U2F implementation.

The counter implementation needs 2 (raw) pages of flash for its
underlying storage.
In order to try to avoid disrupting the existing machines by
invalidating the nvmem if we touch its mapping, those pages are placed
in each RW between the code/read-only and the read-write nvmem area by
shrinking the code/read-only by one page, so the nvmem mapping should be
untouched.

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

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve.

Change-Id: Ib3d7dcb9a1b13cff74b56461332937e3a4cc9ae1
Reviewed-on: https://chromium-review.googlesource.com/518137
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-02 10:38:57 -07:00
Vincent Palatin
5babc4f359 Add non-volatile flash counter
Add the implementation of a robust non-volatile incrementing counter
using 2 pages from the underlying flash.
It is used to implement the U2F functionality.

The main goal of the counter is providing a strictly incrementing value
whatever adverse events (malicious or not) happen as it is used to
prevent rollback attacks in the U2F protocol.
Given the limitation of the flash process: ie wear-out endurance and
2kB-page erase granularity only and possible isolated bit-flips
(accentuated by power losses), the counting is done by pulling down
several bits at a time from their erased state (1) to 0.

The counting is implemented this way with 2 pages called LOW and HIGH:
The LOW page is implemented in a strike style, with each "strike" zero-ing
out 4 bits at a time, meaning each word can be struck a total of 8
times.

Once the LOW page is completely struck, the HIGH page is incremented by 2.
The even increment is for the value, the odd increment is a guard signal
that the LOW page must be erased. So as an example:
If HIGH is 2, the LOW page would increment to 3, erase itself, and then
increment to 4.  If this process is interrupted for some reason (power loss
or user intervention) and the HIGH left at 3, on next resume, the HI page
will recognize something was left pending and erase again.

For a platform with 2-kB flash pages, it can count up to 8388608, then
it is stuck at 0xFFFFFFF indefinitely.

Mostly copied over from Marius code in cr52 code-base.

Signed-off-by: Marius Schilder <mschilder@google.com>
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve

Change-Id: Idd0756078e3641c4a24f9c4ccf6611909bd5f00f
Reviewed-on: https://chromium-review.googlesource.com/518135
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-02 10:38:57 -07:00
Gwendal Grignou
9bdde3e766 npcx: Fix response size
max_response_packet_size was incorrectly set to
response_size + SPI header/footer,
leading to the command handler to return EC_RES_OVERFLOW when the
response buffer size was set by the host to a larger size then
response_size.

It is happening since flashrom does not limit itself to 128 bytes
command since cl/264034.

The SHI repsone buffer is laid out as follow:
 ,.... out_msg_padded
/
|
|< SHI_OUT_START_PAD >|< SHI_MAX_RESPONSE_SIZE >|< SHI_OUT_END_PAD >|
+---+-----------------+-------------------------+-------------------+
|   |                 |                         |                   |
+---+-----------------+-------------------------+-------------------+
    |                 \
    |                  -------
    |                         \
    | EC_SPI_FRAME_START_LENGTH
    |
    \..... out_msg

BUG=b:35571522,chromium:725580
BRANCH=gru
TEST=Before flashrom would fail:
cros_ec_set_max_size: sending protoinfo command
cros_ec_set_max_size: rc:12
cros_ec_set_max_size: max_write:536 max_read:163
...
Reading flash... __cros_ec_command_dev_v2(): Command 0x11 returned
result: 11
Ater, flashrom works:
cros_ec_set_max_size: sending protoinfo command
cros_ec_set_max_size: rc:12
cros_ec_set_max_size: max_write:536 max_read:160
...
Reading flash... done.SUCCESS
Verified that cros_ec.c/cros_ec_spi.c set some space for header and
footer in addition to max_response_packet_size.

Change-Id: I0de7ee5e8109e9277692113f2bb1d4a4758be9f6
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520585
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-01 22:01:56 -07:00
Todd Broch
b04aacb260 eve: default ALS config.
Nominal eve ALS config is 0.3088 scale.
The default bias for sensor of -256 is a good nominal value so leave
it alone.

BUG=b:37179776
TEST=manual,
boot to linux prompt,
  localhost ~ # cat /sys/bus/iio/devices/*/in_illuminance_calibscale
  0.308800
  localhost ~ # cat /sys/bus/iio/devices/*/in_illuminance_calibbias
  -256

Change-Id: I7c8425a38b1af094a39b37b464f812f5ac875083
Reviewed-on: https://chromium-review.googlesource.com/510809
Commit-Ready: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
2017-06-01 16:50:55 -07:00
Aseda Aboagye
01b811f56d cr50: Have CCD_MODE_L respect "ccd keepalive".
If CCD was set to the "keepalive" mode, removing the debug accessory
would cause the CCD_MODE_L pin to be pulled high, ignoring the keepalive
state.  CCD was still kept alive, but the state reflected on the pin
didn't indicate so.

This commit changes the behaviour such that the CCD_MODE_L pin is set up
as an input only when CCD keepalive is not enabled.

BUG=None
BRANCH=cr50
TEST=Plug in debug accessory and remove debug accessory.  Verify that
CCD_MODE_L is high after removal.
TEST=Enable ccd keepalive.  Remove debug accessory.  Verify that
CCD_MODE_L is still low.

Change-Id: I407994d5c394a717d6e1a87f283f6441bd26bf55
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/520603
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-01 00:51:38 -07:00
Scott Collyer
440146ca11 eve: Enable double tap gesture
The LED spec requires a double tap gesture. This CL adds the
appropriate CONFIG options to enable double tap gesture for Eve and
enables the interrupt for the bmi160. The board specific function in
this CL is just a placeholder.

BUG=b:35584895
BRANCH=none
TEST=Manual Verifed double tap is detected by seeing the console print
that's generated each time a double tap event occurs.

Change-Id: If3506cf1fbcfc2b380ac36c9d3039e0a8823eba1
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/516547
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2017-06-01 00:51:37 -07:00
Scott Collyer
2992ee1771 eve: Enable gpio interrupt for bmi160 accelgyro sensor
The config option to use interrupts for this sensor was defined,
however, the gpio interrupt for the interrupt from this sensor was not
being enabled.

BUG=b:35584895
BRANCH=none
TEST=Added a wire to the interrupt line on an Eve. Verified that when
the interrupt was triggered (verified by scope) that ISR for this gpio
was being called.

Change-Id: I9d9f6b5e6efa47665aba9a9d024b30aa10528002
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/518523
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-06-01 00:51:37 -07:00
Scott Collyer
4166314b47 sensor: Add board specific function for double tap event
The previous boards that used double tap both used lightbar
sequence. Eve, also needs double tap, but doens't have lightbar. Added
a board specific call when processing the double tap event to allow
more flexibility.

BUG=b:35584895
BRANCH=none
TEST=Manual tested double tap and verified it was detected based on
the console print.

Change-Id: I73d8669803e7dcbbbac00de09822f4a286965fce
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/516546
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-06-01 00:51:37 -07:00
Scott Collyer
8bf7f38597 sensor: bmi160: Fix macro used to set double tap interstice
The line to convert the desired double tap window time to its
register value was using the incorrect macro. Have corrected this to
use the intended one.

BUG=b:62202895
BRANCH=none
TEST=On Eve verified that double tap events are properly detected.

Change-Id: I70d810c93a8e27a3f61f3175e1ea95d0e59554ac
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/518522
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-05-31 21:14:36 -07:00
Vadim Bendebury
d89eeb6ec8 codesigner: accept the new command line option
The upcoming "real" signer update will introduce a version which is
not backwards compatible with the existing one wrt the command line
flags: the command line flag '-b' will have to be present.

To keep the default "dummy" signer in sync let's make it accept and
ignore the '-b' command line flag.

BRANCH=none
BUG=none
TEST=verified that the updated signer and the dummy signer both work.

Change-Id: Ia8ab6d7ae01d249046f267608b5971a7a7c95e29
Signed-off-by: Vadim Bendebury <vbendeb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/517678
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-05-31 21:14:30 -07:00