Commit Graph

8329 Commits

Author SHA1 Message Date
Vadim Bendebury
b95b487cbc ccd: use async TPM reset where required
When TPM is wiped out on 'ccd open', the TPM reset could be invoked on
the TPM task context, if physical presence verification was not
required, or on the hooks task context, if PP was required.

This patch makes sure that the proper TPM reset is invoked depending
on the context. Also fixing the return value in ccd_command_wrapper(),
because it is expected to be from the ec_error_list enun, and this is
what is returned in the vendor command error response payload.

BRANCH=cr50
BUG=b:62537474
TEST=verified that TPM and device reset happen smoothly in both cases
     when 'ccd open' requires and does not require PP.

Change-Id: I1935fc90b386bb8f2158001e153da371fca22d03
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861206
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:09 -08:00
Vadim Bendebury
8347907c46 ccd: 'pp polling' vendor command option
When implementing 'ccd open' and 'ccd unlock' through gsctool, we need
to be able to pass to the host the state of the physical presences
state machine regarding the expected user action (pressing the PP
button).

Two new VENDOR_CC_CCD subcommands are being added: CCDV_PP_POLL_OPEN
and CCDV_PP_UNLOCK. In response to these commands, the Cr50 always
returns VENDOR_RC_SUCCESS return code and a single byte payload
showing the CCD and PP state:

  - CCDPP_CLOSED - PP process is not running, CCD closed. Maybe user
    missed a button press deadline.

  - CCDPP_AWAITING_PRESS (self explanatory)
  - CCDPP_BETWEEN_PRESSES (self explanatory)

  - CCDPP_PP_DONE - CCD is opened/unlocked (as per user request), PP
    process succeeded.

BRANCH=cr50
BUG=b:62537474
TEST=with the upcoming change to gsctool verified that PP states are
     properly conveyed to the user.

Change-Id: I97b1fef4440eea93c5c5ac01b7c60bfce9a4595c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861001
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:09 -08:00
Vadim Bendebury
35c8f62480 ccd: do not allow 'unlock' from console unless password is set
CCD management policies explicitly prohibit running the 'unlock'
command from the Cr50 CLI unless CCD password is set.

This patch enforces the policy.

BRANCH=cr50
BUG=b:62537474
TEST=ran the following commands on the Cr50 console:
  > ccd
  State: Locked
  Password: none
  ...
  > ccd unlock
  Cann't unlock without password
  Access Denied
  Usage: ccd [help | ...]
  >

Change-Id: I5a14a54049a233e86e097064ff235e9b7a8bbb86
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861000
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:09 -08:00
Vadim Bendebury
88c5e62f89 ccd: add 'in progress' return value
Depending on device configuration and compile time options, CCD
commands 'open' and 'unlock' could either be executed immediately, or
require the user to take the device through physical presence state
machine.

As these commands execute through TPM vendor commands, there needs to
be a different return value indicating that the command action is not
finished and PP process is in progress.

Let's add another vendor command return value, and do not consider it
a failure if vendor command returns this value in response to 'ccd
open' or 'ccd unlock'.

BRANCH=cr50
BUG=b:62537474
TEST=took an Eve through 'ccd open' sequence

Change-Id: Ie62ccfb4319a13b6fb6c1c854a0ea26beb9f517c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860999
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:08 -08:00
Vadim Bendebury
0207f0c53b pp: add API to show when press is expected
This patch adds an API which exports current physical presence state
machine state to allow the caller to see if the state machine is in
one of the three distinct states:
   - no PP process in progress
   - user PP input is expected
   - PP process in progress, user input is not currently expected

BRANCH=cr50
BUG=b:62537474
TEST=with the rest of the patches applied verified that PP state is
     properly communicated through this API.

Change-Id: Ia10cd20c490dadef595f30e0b7257e51b6abf8fa
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860998
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-01-12 03:27:08 -08:00
Vadim Bendebury
25b59e26ca pp: split fsm state in two
In preparation to conveying the PP state to gsctool let's split the
'PP_DETECT_IN_PROGRESS' physical presence FSM state in two:

 - PP_DETECT_AWAITING_PRESS, a state when user physical presence
   indication is expected

 - PP_DETECT_BETWEEN_PRESSES, a state when the previous indication was
   accepted, but the next one is not yet required.

The code is modified to accept the disjunction of the twp new states
as the old PP_DETECT_IN_PROGRESS state.

BRANCH=cr50
BUG=b:62537474
TEST=successfully took Eve through 'ccd open'

Change-Id: I0d229f2f8beeec01ea2a9106b0cbc3f9801ff479
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860997
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-01-12 03:27:08 -08:00
Vadim Bendebury
b946052a56 ccd: refactor to allow clear indication of CCD command being in progress
We want to be able to tell between cases when a CCD command executed
on the TPM vendor command context was invoked through CLI or received
over /dev/tpm0.

Let's add a flag set for the duration of execution of the CLI command.

BRANCH=cr50
BUG=b:62537474
TEST=none, this is not used yet.

Change-Id: I309b4364285816a5f54522b00c93a4bf5025e2c4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860913
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:08 -08:00
Elmo_Lan
bb1c9631d2 Nami: Update WiFi pin define
Made gpio.inc match the schematic.

BUG=b:71693050
BRANCH=none
TEST=Verify Nami connect Wifi.

Change-Id: I72268e507c026bdec517660d6e106ea5639eff64
Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/856377
Commit-Ready: Jeremy Lin <jeremy.p.lin@intel.com>
Tested-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
2018-01-11 22:22:54 -08:00
Ege Mihmanli
641f73185f board: rainier: fix accel orientation
Rainier has landscape orientation, therefore needs its accelerometer
base values adjusted.

BUG=b:71753415
TEST=Rotate rainier and make sure screen orientation is not off by 90
degrees.
BRANCH=None

Signed-off-by: Ege Mihmanli <egemih@google.com>
Change-Id: I60b49e717c691e34a39e817d2c064ea45b8d53d7
Reviewed-on: https://chromium-review.googlesource.com/862733
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-11 22:22:51 -08:00
Vadim Bendebury
b31fca4b91 cr50: pass essential ccd commands through tpm task context
Using and extending the existing framework, move ccd commands
'password, lock, open, and unlock to the same processing path.

The first three commands accept a single parameter, password. It is
required for the password command and optional for unlock and open.
The lock command does not require any parameters.

Wiping the TPM, if necessary, now happens on the same context where
CCD command is executed, i.e. the TPM task context. This is why the
same context TPM reset function needs to be exported and used here.

ccd_open() and ccd_unlock() could be further refactored, this would
require a bit more effort to find appropriate balance between
commonalities and differences.

BRANCH=cr50
BUG=b:62537474
TEST=verified that ccd commands to open, unlock, lock and set and
      clear password all work.

Change-Id: I2b9f2b550347b590a55bfaef262a4f050d3f4c1c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/854709
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-11 22:22:46 -08:00
Nicolas Boichat
7fbf25c096 config.h: Define CONFIG_EC_EC_COMM_BATTERY_MASTER/SLAVE
Instead of defining these options in other header files, set them
here. This also prevents pre-submit checks from complaining
about these symbols being used without being defined in config.h.

BRANCH=none
BUG=b:65697962
TEST=make buildall -j, presubmit checks pass for CL that makes
     use of CONFIG_EC_EC_COMM_BATTERY_MASTER.

Change-Id: I8098a8ae6422bf0ffb26523785d7c16a3ee1c6df
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861365
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-11 22:22:45 -08:00
Jett Rink
bdddd6fc18 grunt: Lowering I2C bus speed to 400kHz for TCPC chips
The ANX3429QN-AA-R I2C bus cannot operate above 400kHz without
first setting register 0x3 to 0x48. We can just lower the bus
to 400kHz without having to set any registers and everything
works as expected.

BUG=b:71810830
BRANCH=none
TEST=Booted grunt with new firmware and p0 TCPC communicates
with EC successfully

Change-Id: I98e3c1a4844e1a79d23f8478fdf97ada72ad1c7d
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/862543
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-11 19:37:40 -08:00
Edward Hill
b0630ce9f4 power: Fix interrupt enable in siglog_deferred
Recent eSPI change (d813935) resulted in siglog_deferred
leaving interrupts disabled.

BUG=b:71764538
BRANCH=none
TEST=apshutdown on grunt, see power signal changes

Change-Id: I33e234ad7191af92e2c4ffef700fc5b9356c3c71
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860571
Commit-Ready: Aaron Durbin <adurbin@google.com>
Tested-by: Aaron Durbin <adurbin@google.com>
Reviewed-by: Aaron Durbin <adurbin@google.com>
2018-01-11 00:20:42 -08:00
Jongpil Jung
66477c9767 nautilus: bug fix in sensor index.
From comment, we should follow rule to use sensor index.
"the first 2 entries must be accelerometers, then gyroscope."
If not, screen rotation and clamshell/tablet mode switch in ui
will not work.
And I think we had better reorder "motion_sensors" structure
as well. Use tab indent instead of space.

BUG=b:71370092, b:71370114, b:69399214
BRANCH=none
TEST=check screeen rotation and tablet/clamshell mode.

Change-Id: I6b19411890c4e1abf9ceda45b47d18616c6e7b94
Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/858878
Commit-Ready: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>
Tested-by: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-01-10 21:19:00 -08:00
Shawn Nematbakhsh
7bc128f7d1 chip/host: uart: Run uart_monitor_stdin() before task scheduling
After a call to pthread_create(), it is indeterminate which thread  the
caller or the new thread  will next execute. Synchronize with the new
thread and allow it to initialize (and print to console, before the
print can potentially interfere with other prints) before proceeding.

BUG=chromium:715011
BRANCH=None
TEST=Run 'make runtests', verify 'Console input initialized' is seen
before '--- Emulator initialized after reboot ---':

====== Emulator output ======
No flash storage found. Initializing to 0xff.
No RAM data found. Initializing to 0x00.
Console input initialized

--- Emulator initialized after reboot ---

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ieb622e9b7eea2d11d4a11a98bb503a44534f676c
Reviewed-on: https://chromium-review.googlesource.com/854989
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-10 18:20:01 -08:00
Aseda Aboagye
8d1d243134 cr50: Don't touch EC reset for USB-EC SPI bridge.
Cr50 should not automatically touch the EC reset when enabling the
USB-EC SPI bridge.  Otherwise, this could interefere with ECs that might
have internal SPI flash and need to have their resets deasserted in
order to access the internal SPI flash.

This commits simply removes the assertion of EC reset when enabling the
USB-EC SPI bridge.  The user or external scripts should control the
resets as necessary using servo or the cr50 console.

BUG=b:71548795,b:71557464
BRANCH=None
TEST=Flash meowth cr50.  Verify that I can flash the EC using a
servo_v4.
TEST=Repeat above test with a servo_micro.
TEST=Repeat above test with a SuzyQable.

Change-Id: I114c34df43cf1e8ba622e75c3e6ecf517afc40a4
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/850865
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-10 15:44:54 -08:00
Scott Worley
d1443721df ec_chip_mchp: Add chip flash image generator
Add Microchip MEC17xx compatible Python script
used by build process to generate the SPI flash
image.

Change-Id: I0e68c7bfb8633051840910a6000270c3b929c3e9
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840651
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:52 -08:00
Furquan Shaikh
56d3ee4dd4 nautilus: Implement workaround for broken reset flags
Current revision of nautilus boards will lose VBAT on power cycle and
therefore cannot successfully save the reset flag state.

Implement workaround that will allow boards to continue to work for
FAFT testing by indicating to the skylake chipset power code that it
could skip the PMIC reset when doing 'reboot ap-off'.

BUG=b:67062902
BRANCH=None
TEST=None

Change-Id: I078f6d62b2161c1b3322da15aba02efaca2010ba
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/855737
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-10 15:44:48 -08:00
Mary Ruthven
c1ad33b24d cr50: enable deep sleep on Bob
Enable deep sleep on rk3399 devices and start using SYS_RST_L to track
the AP state.

We can only release this once the EC has the proper support. It needs to
assert SYS_RST_L in S5.

If we have an old EC and this change in the Cr50 firmware, Cr50 won't be
able to tell when the AP is off. I think this will just cause an
interrupt storm on the AP UART and might not go into regular sleep in
S5.

If the EC change gets released before Cr50, Cr50 won't go to sleep in
S5, because SYS_RST_L is a wake on low pin. Cr50 will immediately wake
up from the SYS_RST_L pin when it enters sleep.

BUG=b:35647982
BRANCH=cr50
TEST=run firmware_Cr50DeepSleepStress on Bob

Change-Id: Iaf46f46eb5963e9479bba40457253a6ccc91ad32
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/699295
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:33 -08:00
Mary Ruthven
179c624133 cr50: configure sys_rst_l as wake on high before deep sleep
We have a requirement that this signal is asserted whenever cr50 is in
deep sleep. It is deasserted on resume. This change configures sys_rst_l
as wake on high before deep sleep, so cr50 doesn't wake up
immediately after entering deep sleep. This is consistent with the
behavior of plt_rst_l when it's used to track the AP state and enable
deep sleep.

This doesn't change anything right now, because no devices that use
sys_rst_l have deep sleep enabled.

BUG=b:35647982
BRANCH=cr50
TEST=none

Change-Id: Ie5c3a6bbf4d0a52c1f96a9b29ebd037104a8abc4
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/815335
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-10 15:44:32 -08:00
Vadim Bendebury
17a167cda1 ccd: Refactor routing CCD commands through TPM task
Currently only 'ccd password' command is processed using TPM vendor
command. More CCD commands are going to be processed the same way.
This patch refactors the code to make it easier to add more
subcommands.

BRANCH=cr50
BUG=b:62537474
TEST=verified that 'ccd password' still works both from crosh and CLI.

Change-Id: Id55da51d6edc5652591ad30160a4102b3026a186
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/854708
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:29 -08:00
Vadim Bendebury
877e5909b4 ccd: prepare for handling crucial CCD commands through TPM task context
We want CCD commands lock, open, password, and unlock (at least to
start with) to be available over both CLI and through crosh (i.e.
coming over /dev/tpm0).

Let's allocate a TPM vendor command for handling all CCD subcommands,
and move to this new framework the 'ccd password' command, which
already is available over vendor command.

BRANCH=cr50
BUG=b:62537474
TEST=verified that 'ccd password' still works both over Suzy-Q CLI and
     using gsctool on the target.

Change-Id: I2d06230b762f47af7e580b188a587bc5678ca169
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/853280
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:29 -08:00
Vincent Palatin
4cb76d6c52 stm32mon: do not write trailing empty space
Add a tweak to get faster flashing:
skip writing the empty trailing space at the end of the firmware image.

On the STM32H7x3, flashing 2MB of useless bytes over UART can be
really slow...

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

BRANCH=none
BUG=b:67081508
TEST=flash_ec --board=meowth_fp

Change-Id: Ie396ee7d5b5771e0f6249e38da37ef8329c84ae3
Reviewed-on: https://chromium-review.googlesource.com/856978
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-10 15:44:28 -08:00
Vincent Palatin
e3323bee69 stm32mon: add STM32H7 identifier
Add a new chip ID to support the STM32H7x3 parts.

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

BRANCH=none
BUG=b:67081508
TEST=flash_ec --board=meowth_fp

Change-Id: I3897a74f5414e0e6b13890291706134c2d916af9
Reviewed-on: https://chromium-review.googlesource.com/856977
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-01-10 15:44:28 -08:00
Vincent Palatin
906a1b5138 stm32mon: change erase timeout
On some chips, the full erase operation can take really long:
e.g 13s for 2MB mass-erase on the STM32H7x3 family.
Add a new mechanism retrying the ACK detection rather than extending
the default timeout which would imply very slow behavior in other cases
(e.g. connection).

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

BRANCH=none
BUG=b:67081508
TEST=flash_ec --board=meowth_fp

Change-Id: I428f56341c31c327debb9a3d2eba9b12c768ba86
Reviewed-on: https://chromium-review.googlesource.com/856976
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-10 15:44:28 -08:00
Nicolas Boichat
9a89170ed4 lux: Add lux board
lux is a dual-battery poppy derivative.

BRANCH=none
BUG=b:67029560
TEST=make BOARD=lux -j

Change-Id: I01fdb1e5e2b4803cdf7f03f9e6ee73603f84a7b8
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845542
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-10 12:58:55 -08:00
Daisuke Nojiri
c20884cf4e EFS: Add SIG_RW_B in fmap
This patch adds SIG_RW_B in fmap. It'll be referenced by futility to
show signature information.

BUG=b:69921268
BRANCH=none
TEST=futility dump_fmap build/fizz/ec.bin
area:            11
area_offset:     0x0007fc00
area_size:       0x00000400 (1024)
area_name:       SIG_RW_B

Change-Id: Ief9980b00f7bce876256c34cd5d35c9f6b7a31e0
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/858225
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 12:58:55 -08:00
Nicolas Boichat
5ec8f4f495 ec_commands: EC_CMD_BATTERY_GET_DYNAMIC: Clarify the meaning of flags
flags are actually _not_ BATT_FLAG_*, but EC_BATT_FLAG_*. Clarify
that in the comment, and add a new EC_BATT_FLAG_INVALID flag to
indicate that some of the data may be invalid (dual-battery master
needs to know that to make appropriate charging/discharging
decision).

BRANCH=none
BUG=b:65697962
BUG=b:65697620
TEST=Flash hammer and wand, flags make sense.

Change-Id: I3c428c850020a29b3f452504b60b52946a04c503
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/859400
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-10 09:19:05 -08:00
Nicolas Boichat
31e68a035b driver/charger/isl923x: Make sure CONFIG_CHARGER_NARROW_VDC is set
Without this, the battery will discharge if we disallow battery
charging (e.g. calling charge_request with either voltage == 0 or
current == 0, either by policy, or when the battery is full).

Also update config.h to set the option whenever isl923x is used.

BRANCH=none
BUG=b:66575472
BUG=b:35585464
TEST=make buildall -j

Change-Id: Id5515d5ea82a393a3693a3da44cbdc2778296a95
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/856538
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2018-01-10 06:02:13 -08:00
Nicolas Boichat
1caa2788c5 charger/isl923x: Implement charger_get_system_power from PSYS
On ISL923x, PSYS output is always enabled when the AP is on
(provided CONFIG_CHARGER_PSYS is enabled).

We add support for charger_get_system_power function, reading PSYS
value, when CONFIG_CHARGER_PSYS_READ is defined. This will be used
by the charging algorithm on lux.

We also rename CONFIG_CMD_CHARGER_PSYS to CONFIG_CHARGER_PSYS_READ
as CONFIG_CHARGER_PSYS_READ provides both "psys" console command
and the new function. We also cleanup unneeded undefs in board
files.

Note that this does not implement the function on bd9995x, but this
could be done without too much effort.

BRANCH=none
BUG=b:71520677
TEST=On lux, without AC connected, check that "psys" output roughly
     matches the output current from the battery.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: Ie1ce8e0ac103daacc5a08b8ccae604d1d83551b8
Reviewed-on: https://chromium-review.googlesource.com/848487
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 06:02:13 -08:00
Jongpil Jung
b167a193e6 nautilus: update sensor rotation matrix.
From rev02, Lid rotation matrix is changed.
So, we have to change rotation matrix as well.

BRANCH=master
BUG=b:69399214
TEST=check lid_angle on rev2.

Change-Id: I6718b607391aef068bee3c324e85138bac0e283e
Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/830990
Tested-by: Grace Kao <grace.kao@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-10 06:02:11 -08:00
Daisuke Nojiri
67b8bb85da EFS: Add EFS_VERIFY host command
If a bios carries an EC image signed by a wrong key, EFS EC falls back
to the previous slot upon reboot. Vboot currently does not handle this
case and tries to update the EC with an incompatible image again.
When this happens, a user sees 'applying critical update' screen
repeatedly.

This patch adds EFS_VERIFYV host command. Vboot on AP calls it to check
whether the EC likes a newly updated image or not. If the verification
fails, it's considered as update failure and vboot displays 'broken'
screen.

BUG=b:71719323
BRANCH=none
TEST=Flash EC SPI with an image which has a different RO key. Boot DUT
and let it run software sync. EC-RO rejects the updated image and falls
back to the previous one. The update counter is incremented and vboot
shows the 'broken' screen, requesting recovery.

Change-Id: I8a107a376963baa146ff691c50d80018ec3e429c
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/858159
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-09 21:13:39 -08:00
CHLin
a5fe9099d8 util: ecst: Add 2 CHIP_VARIANTs to support npcx7m6xb/npcx7m7w
This CL adds support for chip variant npcx7m6xb and npcx7m7w in the ecst
utility. It also fixed the coding style by replacing some inapproiate
tab characters with white space characters.

BRANCH=none
BUG=none
TEST=No build errors for make buildall.
TEST=Change CHIP_VARIANT to npcx7m7w/npcx7m6xb in
board/npcx7_evb/build.mk; "BOARD=npcx7_evb make"; Check ec image can be
built and image header is correct.

Change-Id: I44bae48dcb4fa3bc8984184d8f43744e54bcf8e7
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/851935
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-09 03:33:19 -08:00
Devin Lu
0ebb1c2479 Fizz: override DP EQ setting for Deterministic Jitter
Set lower EQ of DP port to 4.5db.

BUG=b:71613170
BRANCH=none
TEST=use ectools to read PS8751 reg offset 0xd3 as 0x98

Change-Id: Iedc0002028ead6f0f6fa7aeef4ad2845b028a76b
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/851756
Reviewed-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-01-09 01:04:44 -08:00
Hung-Te Lin
b9f78632fa ectool: Correct reporting fan numbers on fanless device.
`get_num_fans` tries to determine if fans are available according to
feature list, retrieved from an ec_command.

The ec_command today returns received output size on success, so to
we should not check the result by "rv == EC_SUCCESS".

Instead, we should check if rv returns a negative number, just like
the cmd_inventory.

BRANCH=none
BUG=b:71690953
TEST=(on fanless Eve) ectool pwmgetnumfans # see Fans=0
     ectool pwmgetfanrpm # see empty output, $?=0

Change-Id: Id748b70cec0afb0715febbda8883cd5ed53f7e3d
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/853755
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 22:42:09 -08:00
Justin TerAvest
084af6386f grunt: Add accel, gyro, and motion_sense task.
This adds support for the KX022 and BMI160 sensors.

It also enables the motion_sense task so that the keyboard can be
disabled in tablet mode.

BUG=b:69379570,b:69379621
BRANCH=None
TEST=Build

Change-Id: I72cc8f86ddd8d466b4208ff583e93fd51da63c49
Signed-off-by: Justin TerAvest <teravest@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/794525
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-01-08 19:56:43 -08:00
Gwendal Grignou
c49334f143 ec_commands: Add sync sensor
SYNC motion sensor are use to count event.
It sends an event to the AP each time a GPIO goes low/high, the datum
contains a 16 bit counter.
The location indicates the source of the event, as Android sensor hal
will use this information (via sysfs location attribute) to link the
sensor with other subsystem.

BUG=b:67743747
BRANCH=none
TEST=Unit tests.

Change-Id: Ia808b25730ad4100efa216c6a86b7b090197c5a3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848496
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-08 17:22:48 -08:00
Vincent Palatin
f5798790ad stm32: add meowth_fp board
Configure it as a fingerprint MCU.

Currently use ZerbleBarn as a proxy for it.

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

BRANCH=none
BUG=b:67081508
TEST=flash and run the image on ZerbleBarn,
do a finger image acquisition with the 'fptest' console command.

Change-Id: I6e060c2d1e950ec81092088e1793b186fc0a5fa0
Reviewed-on: https://chromium-review.googlesource.com/806169
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 17:22:48 -08:00
Vincent Palatin
d56195cfdb stm32: add SPI master for STM32H7
Add the driver for the new silicon used in STM32H7 SPI controller,
including its bad errata when used with DMA.

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

BRANCH=none
BUG=b:67081508
TEST=on ZerbleBarn, do finger image acquisition on the SPI fingerprint
sensor.

Change-Id: Ieaf4a09e961d3e0ef78b58886c409a7dfb63aaf3
Reviewed-on: https://chromium-review.googlesource.com/836617
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 17:22:48 -08:00
Vincent Palatin
e24a3953c2 stm32: Add STM32H7 family
Start adding support for the STM32H7 family of device and the first
available one the STM32H743.

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

BRANCH=none
BUG=b:67081508
TEST=manual, run on stm32h743i-eval and zerblebarn boards
get a stable serial console.

Change-Id: I9ae10f0d843e5318451713c21ed22d455a23758c
Reviewed-on: https://chromium-review.googlesource.com/806168
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 05:41:23 -08:00
Vadim Bendebury
57bb4ddf41 cr50: fix annoying LD warnings
The compiler marks data put into the TPM2_common.bss section as
PROGBITS, which the linker does not like. Changing the section name
prevents the marking and keeps linker happy.

BRANCH=cr50
BUG=chromium:799385
TEST=verified that local_state is still in where it belongs:
    $ egrep '(local_state|__bss_libtpm2)' build/cr50/RW/ec.RW.smap
    00010400 B __bss_libtpm2_start
    00015d0c b local_state
    00015d18 B __bss_libtpm2_end

Change-Id: I48f7d2cb08c7ccb2ef3b3159eaf4d66e2b8720b4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/852793
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-05 14:28:47 -08:00
Vadim Bendebury
0b9a068894 gsctool: use full path when invoking trunks_send
The gsctool utility sometimes is used in environments where path to
trunks_send is not set. As a result 'gsctool -t' invocations fail.

Let's make sure PATH includes /usr/sbin before trunsk_send is invoked.

BRANCH=none
BUG=none
TEST=verified that gsctool invocations in crosh started in a tab and
     in a linux shell ran under user 'chronos' do not fail.

Change-Id: Ib8af365dc5707cfec19acda9aa0228d33eb4573f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/851266
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2018-01-05 12:10:05 -08:00
Nicolas Boichat
13f3e27c80 poppy: Move base detection logic to separate file
wand will have a very different detection logic: moving this to
a separate file will make it easier and cleaner to implement.

BRANCH=none
BUG=b:67029560
TEST=make buildall -j
TEST=soraka: Base detection still works, power is cut in S5.

Change-Id: Ibc4ad0d9f5ad9a0df7834c712145035f7c62f335
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/851554
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-01-05 12:10:01 -08:00
Nicolas Boichat
1c0d70d1b0 soraka: Replace individual files symlinks by directory symlinks
Makes it easier to add new files in poppy folder.

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

Change-Id: I1614d26b4a3766da9aff8c05eaed632a9589955d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/851553
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-01-05 12:10:01 -08:00
Nicolas Boichat
ca7bf51513 poppy/soraka: Remove charger profile override functions
The battery gas gauge is configured properly, and we do not need
these hacks.

BRANCH=none
BUG=b:70816727
TEST=On soraka, check that we can recover from dead battery
TEST=On soraka, check that we can recover from battery cut-off
     (both HW and SW)
TEST=Check that battery stops requesting power when over or under
     set temperature (done by ODM/battery vendor, see bug)

Change-Id: I0b9d605632d86a3c39d07676d62374602ba068b4
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/835728
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-01-05 05:43:19 -08:00
Hung-Te Lin
9de2d245cf gsctool: Add option '--any' to auto-detect -s/-t availability.
For partners and developers, it's usually better to have a single simple
instruction to invoke commands. Currently gsctool needs either -s (if
/dev/tpm is not locked) or -t (if trunksd is running) and partners have
to either try both commands (-s or -t) or read the error messages and
try to figure out which option to use.

For example, see the extra logic in CL:831787.

Instead of putting the check everywhere in scripting, it seems easier
and more convenient to have a simple switch - "--any (-a)" that
automatically selects between -s and -t.

BUG=b:70184153
TEST=gsctool -f -a; stop trunksd; gsctool -f -a

Change-Id: Ie1590b0b8fef882178465ceee64a7150eda6b0dd
Reviewed-on: https://chromium-review.googlesource.com/851612
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-05 03:14:37 -08:00
Nicolas Boichat
cfc69f6fb8 ec_ec_comm_master: Functions for EC-EC communication master
This adds functions required for the master in EC-EC communication,
requesting base battery static and dynamic information, and charger
control.

BRANCH=none
BUG=b:65526215
TEST=Flash lux and wand, EC-EC communication works.

Change-Id: I7a46ee3f5848d22c2c9bea7870cbd7e74141cf3d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/839201
2018-01-05 00:51:29 -08:00
Nicolas Boichat
3fecdbdcf9 chell: Enable CONFIG_LTO
Saves about 4K of flash space. Note that LTO has been enabled
on glados for a long time, so hopefully this is safe.

build/chell/RO/ec.RO.flat shrank by 4096 bytes: (106200 to 102104)
build/chell/RW/ec.RW.flat shrank by 4264 bytes: (105988 to 101724)

BRANCH=none
BUG=chromium:798914
TEST=Flash both chell and chell_pd, system boots to OS, keyboard
     works, charging works.

Change-Id: Id97f2e73959ced16d6579f6c05f3ce4cd21f4062
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848594
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:05 -08:00
Nicolas Boichat
f14879eae1 charger/isl923x: Protect CONTROL1 read-modify-write with a mutex
CONTROL1 bits can be modified from multiple tasks:
 - charger_enable_otg_power (charger or pd task)
 - charger_discharge_on_ac (host command or console)
 - charger_enable/disable_psys (chipset task)
 - print_amon_bmon (console)

Since we use I2C read, modify, then I2C write access pattern,
there is a small chance of races between these accesses:
let's protect them with a mutex.

Also, the current code sometimes uses charger_get_option/set_option
instead of manipulating CONTROL0 directly: fix those to regain
a bit of the extra code size caused by the mutex.

BRANCH=none
BUG=b:67029560
TEST=Flash lux, battery charges, amon works fine.
TEST=Flash elm, battery charges.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: If375d9922db53dd582582bfa44d6218fe0b416ec
Reviewed-on: https://chromium-review.googlesource.com/848486
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-04 21:52:05 -08:00
Nicolas Boichat
51b6222520 npcx/uart: Pull up communication line during transaction
Boards needs to define GPIO_EC_COMM_PU, which needs to be driven
high during EC-EC transaction. This makes sure that the line does
not go low, even when the base goes away during the transaction.

BRANCH=none
BUG=b:68954760
TEST=EC-EC communication works with this change.
TEST=With signal analyzer, check that UART line is always kept
     high while transaction is in progress.

Change-Id: Iad7b26a9a93b674aa4fff0bc3a72a13e6782515d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845544
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:01 -08:00