Commit Graph

8360 Commits

Author SHA1 Message Date
Daisuke Nojiri
5232cdd16b CBI: Add host command to get board info
This patch adds host command to get board info from EEPROM.

BUG=b:70294260
BRANCH=none
TEST=Run ectool cbi get <type> to get board version, OEM, SKU

Change-Id: I41a84d3eea6da9d88fa8122db36dcd1df515842d
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/865161
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-18 05:09:31 -08:00
Daisuke Nojiri
c62060d9d9 CBI: Add cbi-util
cbi-util is a build command line tool, which creates a blob containing
board information. When invoked with '--show' option, it prints the
information stored in a blob and validates the data.

BUG=b:70294260
BRANCH=none
TEST=Run the command as follows:
$ cbi-util --create /path/to/cbi.bin \
  --board_version 0xabcd --oem_id 2 --sku_id 3 --size 256
$ cbi-util --show /path/to/cbi.bin
CBI blob: /path/to/cbi.bin
  BOARD_VERSION: 0.1 (0xab.cd)
  OEM_ID: 2 (0x02)
  SKU_ID: 3 (0x03)
Data validated successfully
$ cbi-util --create /path/to/cbi.bin \
  --board_version 0xabcd --oem_id 2 --sku_id 3
Missing required arguments
$ cbi-util --create /path/to/cbi.bin --board_version 0xabcde
Invalid --board_version

Change-Id: I7e7b439c50943523039c3cafda3bdf7d08962c61
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/860961
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-18 05:09:30 -08:00
Daisuke Nojiri
6e3e0f87b1 CBI: Read board info from EEPROM
This patch adds Cros Board Info APIs. It reads board info from EEPROM.
This patch sets CONFIG_CBI for Fizz to make it use CBI.

BUG=b:70294260
BRANCH=none
TEST=Read data from EEPROM.

Change-Id: I7eb4323188817d46b0450f1d65ac34d1b7e4e220
Reviewed-on: https://chromium-review.googlesource.com/707741
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-01-18 05:09:29 -08:00
CHLin
a0f25e398e npcx7: Add definition/configuration for npcx7m6xb/npcx7m7w
In this CL, we add the following changes to support the CHIP_VARIANT
npcx7m6xb and npcx7m7w:
1. Define the code RAM, data RAM, BBRAM base address/size.
2. Initialize the wov.c file for WoV driver development. (It will be
compiled only when CHIP_VARIANT=npcx7m7w in the build.mk and
CONFIG_WAKE_ON_VOICE is defined in board.h)
3. Fix the the incorrect offset of PWDWN_CTRL7 register.

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. Flash the image on EVB; make sure EVB bootup.

Change-Id: I87bccb9097f8f0a6c67f96a8d90adf201ae9e773
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/858637
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-17 23:37:27 -08:00
Nicolas Boichat
6432c52a72 stm32/usb: usb_wake: Update STM32_USB_CNTR with interrupts off
STM32_USB_CNTR may be written from both interrupt context, and
usb_wake (not necessarily in interrupt context). Let's disable
interrupts to make sure the operation is atomic.

BRANCH=none
BUG=b:35775088
BUG=b:67766202
BUG=b:71688150
TEST=Flash hammer, hammer can wake from USB autosuspend

Change-Id: I9c2a3259902ecb759a6d0d89c7746c7aa72ae73d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/744282
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-17 23:37:26 -08:00
Mary Ruthven
7b5b83055c cr50:ap_state: reenable detect ap on interrupt
ap_state doesn't disable/enable the detect ap interrupt correctly. This
means cr50 is mostly just polling the AP state. Cr50 may not realize the
AP is up until almost a second after it first turned on. This change
reenables the detect ap on interrupt while debouncing the AP state or if
Cr50 thinks the AP is off, so cr50 can more quickly detect the
transition from off to on.

This issue doesn't affect devices that detect the AP with TPM_RST_L,
because we never disable the TPM_RST_L interrupt and that handler calls
ap_on_deferred directly.

BUG=b:71866206
BRANCH=cr50
TEST=run power_state:rec on Dru and make sure there are no tpm irq
timeouts.

Change-Id: I67388f9dce94fb22efe5755a0de563e5af42f8f5
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/869410
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-17 06:20:39 -08:00
Nicolas Boichat
e71899a573 ectool: battery: Allow negative present current
Battery interface over host command is different, as it allows
negative current values to indicate discharge, let's not fail in
that case.

BRANCH=none
BUG=b:65697620
TEST=ectool battery 1 does not fail when battery is discharging.

Change-Id: I89ca750e24706f55a0589201aeaf9fea50f3132f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/869552
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-17 06:20:38 -08:00
Vincent Palatin
c10a631026 meowth_fp: add flashing script
Simple shell to flash the FP MCU firmware from the AP through the STM32
DFU mode (over the SPI interface).

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

BRANCH=none
BUG=b:71986991, b:36125319
TEST=run flash_fp_mcu on Meowth and see a new FP MCU is flashed

Change-Id: I99af754b3ed4916ee04a800859f1b28feb640de1
Reviewed-on: https://chromium-review.googlesource.com/866840
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-17 06:20:38 -08:00
Vincent Palatin
9d38e46641 ectool: add servo v2 spi support
Add a new transport for ectool to send host command V3 over the Servo v2
SPI interface using libftdi.

Build this new communication mechanism only for the 'build' architecture
as it has a dependency on libftdi, the new ectool binary is called
ectool_servo.
Fix the 'build' tools build if they don't have a source file matching
their binary name.

The serial number of the servo board can be passed in the 'name'
parameter, e.g. :
sudo ectool_servo --name=905537-00474 version

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

BRANCH=none
BUG=b:70320279
TEST=with ZerbleBarn connected to a servo V2, run:
sudo ectool_servo version

Change-Id: Ia7067d465a42f76695fed5932f32fac9a6d0988e
Reviewed-on: https://chromium-review.googlesource.com/864164
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-17 06:20:37 -08:00
Philip Chen
1e1b5d4463 power/rk3399: Change power-off sequence for KD panel
We should turn off PP3300_S0 and then PP1800_S0 to meet
KD panel spec. PP3300_S0 has to be on in S3_WoUSB, so PP1800_S0
also has to be on - let's move PP1800_S0_EN to s0s3_usb_wake_power_seq.

BUG=b:71057948
BRANCH=none
TEST='suspend_stress_test' for 10+ cycles without seeing things go wrong

Change-Id: Ic44411062b4c9e857b9f8ca6565550ba8bd2f950
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/862254
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2018-01-16 21:26:28 -08:00
Shamile Khan
0348eb1059 glkrvp: Enable eSPI instead of LPC including eSPI VW based SCI/SMI
BUG=None
BRANCH=None
TEST=GLKRVP can boot to OS when a coreboot image with eSPI
     enabled is flashed.

Change-Id: Ia534bdbbe517c53ba2e0beafc41b421872f1e33d
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/818196
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-16 21:26:27 -08:00
Ruben Rodriguez Buchillon
51e9e69f38 power: introducing pwr_avg console command
pwr_avg provides an average voltage, current, and power over the last
1 minute. It's up to the battery drivers to implement this
functionality.
This change allows us to have better power tracking while minimizing
the power impact on the EC, because
- the pwr_avg command only needs to be called once every minute, and is
short, thus less expensive to parse on ECs without a UART buffer
- the work done to keep the avg is partially done by the batteries
already and it's just a question of retrieving it.

undefined on wheatley since no power debugging planned on that board.

usage:
> pwr_avg
mv = 7153
ma = -605
mw = -4327

BUG=chromium:752320
BRANCH=None
TEST=make buildall -j

Change-Id: Id1a3479d277aedf90dfa965afb4ee9136654b1cf
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/823884
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-16 04:08:26 -08:00
Edward Hill
be1f97a255 grunt: Enable TCPC + PPC interrupts and overcurrent GPIOs
BUG=b:69378796
BRANCH=none
TEST=PD still works on both ports

Change-Id: I6c9d378483d141db821da2a717cf1256099b01ec
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/867234
Reviewed-by: Aaron Durbin <adurbin@google.com>
2018-01-16 01:26:15 -08:00
Edward Hill
7f1bb54c10 grunt: Set source current limit to enable 3A output
Call ppc_set_vbus_source_current_limit to enable 3A output.

BUG=b:69378796
BRANCH=none
TEST=connect PD sink and see 5V 3A on both ports

Change-Id: Ia38ebcb3b1b3d1148a00b3050fcda2bd2cf73af5
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/866158
Reviewed-by: Justin TerAvest <teravest@chromium.org>
2018-01-16 01:26:15 -08:00
Edward Hill
76bd681c8f grunt: Don't return error when disabling all charge ports
charge_manager_refresh() asserts that
board_set_active_charge_port(CHARGE_PORT_NONE) returns EC_SUCCESS,
so if port 1 on Grunt's daughter board is disconnected, the EC
gets stuck in an assert crash loop. Just printing the error and
continuing seems like a better way to handle the missing port.

BUG=b:71955904
BRANCH=none
TEST=grunt with no daughter board doesn't assert

Change-Id: I8a0f79e45c7b564794498cfc41bcc4acd8fd231f
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/866214
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
2018-01-16 01:26:15 -08:00
YB.Ha
67ae6eb9b0 nautilus: support BC1.2 on USB Type-A port
support BC1.2 on USB Type-A port

BUG=b:71775046
BRANCH=none
TEST=build/flash nautilus

Change-Id: Iff9e95d06c0498d8f093d508bc50a0754e973c37
Reviewed-on: https://chromium-review.googlesource.com/858979
Commit-Ready: YongBeum Ha <ybha@samsung.com>
Tested-by: YongBeum Ha <ybha@samsung.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-15 20:31:57 -08:00
Nicolas Boichat
eaaf890188 wand: Enable CONFIG_CHARGE_RAMP_HW
Enable ramping by default. Follow-up CL will have EC-EC master tell
the slave if it's necessary to ramp.

BRANCH=none
BUG=b:71840796
TEST=lux fully charged, in S0ix, wand connected. Connect old
     BC1.2 charger, see that the charger is not browning out anymore.

Change-Id: I5f1052257db4c581bcb700c7f0306f14f792ea03
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/863349
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-14 18:38:31 -08:00
Nicolas Boichat
4c56c17a1a battery: Add support for reading base battery through host command
This adds support for EC_CMD_BATTERY_GET_STATIC and
EC_CMD_BATTERY_GET_DYNAMIC host commands, that can currently only
fetch the base battery information using index = 1.

In the future, all battery information can be passed to AP using
these host commands (i.e. lid could provide its own battery
information on index = 0).

BRANCH=none
BUG=b:65697620
TEST=ectool battery shows lid battery information (no change)
TEST=ectool battery 1 shows base battery information

Change-Id: Ib819e4917b3acc337348764f6cc2aa7380bed700
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/863863
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-14 18:38:29 -08:00
Edward Hill
66bc9c1082 grunt: Fix ENABLE_BACKLIGHT to be active low
BUG=b:71806495
BRANCH=none
TEST=backlight turns on in S0

Change-Id: Ib9271d6cbe9befdf4ed492a9c2b676452e5f4d9b
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/865155
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-01-14 18:38:27 -08:00
Edward Hill
ad59381ca3 grunt: Enable BMI160 gyro interrupts
Setup bmi160_interrupt and enable in board_init.

BUG=b:69379621
BRANCH=none
TEST=none

Change-Id: I80d08146367af0b91d8d9ac1495c85fe8edd0203
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/864827
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-01-14 18:38:27 -08:00
Edward Hill
dd404f34d5 grunt: Add CONFIG_VBOOT_HASH
The vboot hash calculation needs to be enabled for EC software sync.

BUG=b:64935726
BRANCH=none
TEST=see hash on console

Change-Id: I2d26ef997fc9ed803e80cc716a518a2834632269
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/864826
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@google.com>
2018-01-14 06:23:22 -08:00
Ege Mihmanli
0765c05d33 rainier: final fix for accel orientation.
Rainier has landscape orientation and last patch was 90 degrees off in
its base rotation value.

BUG=b:71753415
TEST=Flash ec on rainier and tilt device.
BRANCH=None

Signed-off-by: Ege Mihmanli <egemih@google.com>
Change-Id: I1d0837b2391ec4d0051c6c9af984d801264fe64c
Reviewed-on: https://chromium-review.googlesource.com/865803
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-12 22:37:52 -08:00
Aseda Aboagye
6efe929ecc meowth: zoombini: Check for battery disconnect.
This commit enables support for reviving a battery from disconnect while
also providing the code to detect if the batteries are disconnected or
not.  The disconnection code behaves similarly to some other battery
packs used in Chromebooks.

BUG=b:71515229
BRANCH=None
TEST=Flash zoombini; cut off battery; apply AC and verify that we do not
leave safe mode until the battery is no longer "disconnected".
TEST=Repeat above test for meowth.
TEST=Cutoff the battery and apply AC and verify that board wakes up from
cutoff.

Change-Id: I52fe91bd6522901671ad5a302bfa0ca27e5f5aa0
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/864830
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-12 17:12:35 -08:00
Simon Glass
2bd336f1d2 grunt: Add I2C support for the BMI160
We need to enable I2C_PORT_ACCEL so that the driver supports I2C
transfers.

BUG=b:71877225
BRANCH=none
TEST=On EC console:
> accelinit 1
> accelread 1
With this CL we avoid an error

Change-Id: I9b7018ef9615992d91fbf8685832ff73c3cc1172
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/863206
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-12 14:31:21 -08:00
Simon Glass
9802a28f19 grunt: Enable the CPU temperature sensor
Set this up so we can measure the CPU temperature.

BUG=b:71868256
BRANCH=none
TEST=on EC:
> temps
  Charger             : 312 K = 39 C
  SOC                 : 321 K = 48 C
  CPU                 : 331 K = 58 C

CPU shows 58 C (which seems a lot cooler than it actually is)

Change-Id: Ia625e36b95a566aa436eff751c2ebf5863d984ad
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/862885
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
2018-01-12 14:31:13 -08:00
Edward Hill
cb8c632801 grunt: rename volume GPIOs
BUG=b:64935726
BRANCH=none
TEST=press volume buttons, see console messages

Change-Id: I327a166e05bd815acc66d2f6e30fe8ae9d6d1cce
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/864825
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-01-12 14:31:09 -08:00
Vincent Palatin
f77552abc4 meowth_fp: enable the hostcmd interface
Use the SPI1 controller as the host command slave interface.

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

BRANCH=none
BUG=b:67081508
TEST=On reworked Meowth board with ZerbleBarn connected to the PCH SPI
bus, use to the kernel cros_ec interface to communicate with the MCU.

Change-Id: Ia7bdc72677cda2752a0849266282d2a779980152
Reviewed-on: https://chromium-review.googlesource.com/860933
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-12 14:31:07 -08:00
Vincent Palatin
47c7e189b9 stm32: add SPI slave support for STM32H7
Update the host command support on the STM32 SPI slave for the STM32H7
silicon.

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

BRANCH=none
BUG=b:67081508
TEST=with a servo v2 connected to ZerbleBarn,
send host commands v3 through the servo FTDI SPI interface.

Change-Id: I26ff4b6a3a45e446cd16e9da43c6932c24c37256
Reviewed-on: https://chromium-review.googlesource.com/839864
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-12 14:31:07 -08:00
Vadim Bendebury
a41c59598d gsctool: add options to control ccd
The user needs to be able to unlock/open/lock CCD in addition to
setting the CCD password.

This patch adds command line options for these three CCD subcommands.
They all are communicated to the TPM using the same vendor command.
'open' and 'unlock' subcommands could require the user to enter the
password. This is indicated by the appropriate vendor command return
code.

If return code of 'open' or 'unlock' subcommand indicates the need for
physical presence, the utility starts polling the Cr50 prompting the
user to press the power button when the chip expects it.

Some input parameters sanity checks are added to make sure that the
user does not request mutually exclusive actions.

BRANCH=none
BUG=b:62537474
TEST=verified that CCD can be unlocked and opend with and without
     password, with and without PP required.

Change-Id: Iea229a220e9f3d2f5d07cebdaebcb9b297939310
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861209
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:10 -08:00
Vadim Bendebury
d99e680b3c ccd: add distinct return code to indicate that password is required
When user is trying to execute 'ccd open' or 'ccd unlock' and password
is set, the return error code does not allow to tell the reason for
the command failure.

Let's add a distinct return code to indicate this condition so that
the user can supply password.

BRANCH=cr50
BUG=b:62537474
TEST=verified along with the accompanying gsctool modifications.

Change-Id: I286f87ab12114cd7dd7ebcdf0e321f7a24723367
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861208
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:10 -08:00
Vadim Bendebury
d9831e6015 gsctool: allow password handling function to run on different subcommands
With the upcoming addition of ability to manage CCD using gsctool, it
is necessary to send user password in several CC_CCD subcommands. This
patch modifies the password handler to allow the user to specify the
subcommand code to use.

VENDOR_RC_IN_PROGRESS is added to the list of acceptable return codes,
as this is what could be returned in response to 'ccd unlock' or 'ccd
open'.

BRANCH=none
BUG=b:62537474
TEST=verified that password still could be set and cleared from the
     CLI and gsctool

Change-Id: Ic58f344a728897fb535cd9b7bedd47d28b30f5f8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/861207
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-12 03:27:10 -08:00
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