Commit Graph

2128 Commits

Author SHA1 Message Date
Chun-Ta Lin
ab238235f8 i2c: support large reading in i2c_xfer()
There might be more than one place that will use very similar codes in
CL:542716 (usb_i2c.c). To avoid unnecessary duplication of code, we fold
the logic into i2c_xfer(). With config enabled (illustrated in this CL),
i2c_xfer() will support large reading. An early prototype of potential
usage is demostrated in CL:781300.

BRANCH=none
TEST=For CONFIG_I2C_XFER_LARGE_READ:
     With proprietary software on slave: ./touchpad_updater -d
TEST=For usb_i2c regression:
     ./touchpad_updater still works (where the reading is less than 255)
TEST=For generic EC regression test:
     On poppy EC (With CONFIG_I2C_XFER_LARGE_READ defined)
     (1) Prevent override of update
       /usr/share/vboot/bin/set_gbb_flags.sh 0xa39
     (2) flashrom -p ec -w ec_binary_contains_this_CL.bin
     (3) ectool reboot_ec cold
     (4) "ectool version" verified that both RO/RW/Build info is local.
     (5) Test with a type-C DP dongle on DELL 2408WFP.
     (6) Plug-in type-C charger and external display still works.
     (7) Confirmed that battery is charging.
     (7) "ectool battery" reads same data (for fixed field) as before.
     (8) "ectool usbpdpower", confirmed charger info displayed as before.
     (9) "ectool usbpd 0", confirmed content exactly as before.
     (10) For Gyro. Verify under Arc++
          Using App: com.gamma.bubblelevel, works the same as before.
     (11) For Accelerometers. Verify under Arc++
          Using App: com.innoventions.sensorkinetics,
          small movement's charts looks as expected.
TEST=For generic EC regression test:
     On Caroline EC (Without CONFIG_I2C_XFER_LARGE_READ defined).
     Details in CL:810332
BUG=b:63993891

Change-Id: I654868945fa535e784800177d54eb2d9803f5249
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/788479
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-07 05:09:28 -08:00
Aseda Aboagye
eff4baf03f sn5s330: Add support for Vbus detection.
The SN5S330 has support for detecting when Vbus is present on a port.
This commit simply adds an API to query the PPC.

BUG=None
BRANCH=None
TEST=`make -j buildall`.
TEST=Flash a board with the SN5S330, with some extra code, verify that
Vbus can be detected with this API.

Change-Id: I45bf7ff24bcdc447efe12932f51f8094108e29d5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791502
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 17:30:46 -08:00
Vincent Palatin
d757f9bf3b eve_fp: update fingerprint architecture
split the common FP sensor code and use the updated private driver.

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

BRANCH=none
BUG=b:69460856
TEST=do a finger capture on Eve EVT.
CQ-DEPEND=CL:*520759

Change-Id: I8b46762218eed0773a4c49a02c2ee6c3966cfa60
Reviewed-on: https://chromium-review.googlesource.com/806166
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 14:28:56 -08:00
Jenny TC
67c31eb10b host_events: Introduce unified host event command
Unified Host Event Programming Interface (UHEPI) enables a unified host
command EC_CMD_PROGRAM_HOST_EVENT to set/get/clear different host events.
Old host event commands (0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E,
0x8F) is supported for backward compatibility. But newer version of
BIOS/OS is expected to use UHEPI command (EC_CMD_PROGRAM_HOST_EVENT)

The UHEPI also enables the active and lazy wake masks. Active wake mask
is the mask that is programmed in the LPC driver (i.e. the mask that is
actively used by LPC driver for waking the host during suspended state).
It is same as the current wake mask that is set by the smihandler on host
just before entering sleep state S3/S5. On the other hand, lazy wake masks
are per-sleep masks (S0ix, S3, S5) so that they can be used by EC to set
the active wake mask depending upon the type of sleep that the host has
entered. This allows the host BIOS to perform one-time programming of
the wake masks for each supported sleep type and then EC can take care
of appropriately setting the active mask when host enters a particular
sleep state.

BRANCH=none
BUG=b:63969337
TEST=make buildall -j. And verfieid following scenario
1). Verified wake masks with ec hostevent command on S0,S3,S5 and S0ix
2). suspend_stress_test with S3 and S0ix
3). Verified "mosys eventlog list" in S3 and s0ix resume to confirm
	wake sources (Lid, power buttton and Mode change)
4). Verified "mosys eventlog list" in S5 resume to confirm wake sources
	(Power Button)
5). Verified above scenarios with combination of Old BIOS + New EC and
    New BIOS + Old EC(making get_feature_flags1() return 0)

Change-Id: Idb82ee87fffb475cd3fa9771bf7a5efda67af616
Signed-off-by: Jenny TC <jenny.tc@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/576047
Commit-Ready: Jenny Tc <jenny.tc@intel.com>
Commit-Ready: Jenny Tc <jenny.tc@intel.corp-partner.google.com>
Tested-by: Jenny Tc <jenny.tc@intel.com>
Tested-by: Jenny Tc <jenny.tc@intel.corp-partner.google.com>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-12-06 03:45:57 -08:00
Aseda Aboagye
fb32b6d30c ppc: Create generic PPC driver framework.
This commit introduces a driver framework for power path controllers.
It provides some common PPC APIs as well as allowing a board to use
multiple different PPCs drivers/parts.  This should make it easier to
add PPC drivers in the future.

BUG=None
BRANCH=None
TEST=`make -j buildall`
TEST=Flash zoombini; verify PPC works as expected.
TEST=Flash meowth; verify PPC works as expected.

Change-Id: Icfb99f384610590b431456cfd28d4aff18442cb2
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/807630
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 01:08:24 -08:00
Aseda Aboagye
9c4008e35c ppc: Add common APIs.
It'll be easier to add support for new PPCs if we make a generic API.

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

Change-Id: I9aac1750eb4c163eb2b94aa8975c797f86d0a25a
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791499
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-05 22:43:45 -08:00
Daisuke Nojiri
23149261dc system: Allow hibernate to clear AP_OFF flag
After firmware update, cr50 toggles the EC's reset line, expecting
the system will boot. This isn't the case for Chromebox because it
sets AP_OFF flag on a clean shutdown (to restore the previous power
state after power loss & restore).

This patch adds EC_REBOOT_HIBERNATE_CLEAR_AP_OFF to EC reboot
command. It makes EC first clear AP_OFF then hibernate.

BUG=b:69721737
BRANCH=none
TEST=Verify Fizz reboot after cr50 update.

Change-Id: If3207d7284f244ca1adf0d516ef744dbc739a9c1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/802632
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-12-05 18:00:38 -08:00
li feng
39efbc3ada ish i2c: add I2C Fast Mode Plus 1Mbps speed option
Also added CONFI_ISH_I2C_PORT0_SPEED, CONFI_ISH_I2C_PORT1_SPEED, and
CONFI_ISH_I2C_PORT2_SPEED to define speed for each ISH I2C port. By
default, those are set to fast mode, 400kbps, I2C_SPEED_FAST.
The values can be modified in board.h.

BUG=None
BRANCH=None
TEST=On Soraka modified board for ISH, set I2C stardard mode, fast mode
and fast mode plus, measured I2C clock freq using scope respectively and
confirmed the freq matched I2C mode.

Change-Id: I426b50dc935c3760903360a50f6069e99bd0abff
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/784091
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-12-04 20:02:58 -08:00
Furquan Shaikh
55b87f4847 charge_state: Change CHARGE_MAX_SLEEP_USEC to 1 minute
CHARGE_MAX_SLEEP_USEC was originally set to 1 minute (i.e. equal to
POLL_PERIOD_VERY_LONG) in CL:191767. However, during re-factoring in
CL:193876 it got changed to 1 second as charge_state_v1 used this
value. Looking at the way CHARGE_MAX_SLEEP_USEC is used, value of 1
minute makes more sense because sleep_usec could be set to
POLL_PERIOD_VERY_LONG when device is off or suspended. With the
current logic in suspend/off state, sleep_usec is set to
POLL_PERIOD_VERY_LONG and immediately gets reset to
CHARGE_MAX_SLEEP_USEC in charger_task.

This change fixes the above behavior by defining CHARGE_MAX_SLEEP_USEC
as 1 minute. As a side-effect of this, we might not wake up early
enough in case of critical battery. Thus, check if we need to shutdown
on critical battery and adjust sleep time accordingly.

BUG=b:69695376
BRANCH=None
TEST=make -j buildall

Change-Id: Ieba7279dc4b02c3d64022c3c5ac09fb869a3632d
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/788181
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-30 20:30:11 -08:00
Furquan Shaikh
0fd8813520 software_panic: Add a new software panic type for PMIC fault
This change adds a new software panic type PANIC_SW_PMIC_FAULT that
can be used to report any PMIC faults during previous boot.

BUG=b:65732924,b:69334392
BRANCH=None
TEST=make -j buildall

Change-Id: I218b5d01ee145bb02a773495046f4255f1ec8986
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/797910
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-30 11:48:57 -08:00
Rong Chang
96bc7cd9b5 charger: add sy21612 buck-boost converter driver
SY21612 is buck-boost converter with selectable source/sink mode.

BRANCH=none
BUG=none
TEST=none

Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: I71248eedd9be775790d71010f69dfae41cd64a27
Reviewed-on: https://chromium-review.googlesource.com/673964
Reviewed-by: Benson Leung <bleung@chromium.org>
2017-11-29 04:04:12 -08:00
Furquan Shaikh
d33eb02aef sb_fw_update: Get rid of CONFIG_SB_FIRMWARE_UPDATE
CONFIG_SB_FIRMWARE_UPDATE is dead on ToT. So, get rid it completely.

BUG=b:69695376
BRANCH=None
TEST=make -j buildall

Change-Id: Ic1eedff21d82f729a73ec9a7c1d554b6b571e827
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/792013
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-28 17:56:29 -08:00
Furquan Shaikh
126a303c69 chipset: Introduce CHIPSET_STATE_ANY_SUSPEND
There are two different types of suspend states that are supported on
x86 platforms -- S3 and S0ix. When AP enters S3, the chipset state is
identified as CHIPSET_STATE_SUSPEND. On the other hand, when AP enters
S0ix, the chipset state is identified as CHIPSET_STATE_STANDBY. There
are several components within the EC e.g. charger state machine, usb
pd task, motion sense task that take actions based on the chipset
suspend state (and checked only for CHIPSET_STATE_SUSPEND until
now). In order to ensure that different EC components do not have to
worry about checking for all the different types of suspend states
that are supported, introduce a new combination
CHIPSET_STATE_ANY_SUSPEND which is a combination of
CHIPSET_STATE_SUSPEND(S3) and CHIPSET_STATE_STANDBY(S0ix).

BUG=b:69690699
BRANCH=None
TEST=make -j buildall. Ruben verified that with this change, EC power
consumption in S0ix drops from 7.85mW to 6.59mW on Soraka.

Change-Id: I599a0ea2fe2f39132764a6068fa77c3aea02affa
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/786919
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-11-28 15:44:19 -08:00
Vadim Bendebury
baff7ae621 cr50: ccd: add vendor command to disable RMA mode
The new vendor command takes the CCD state machine through necessary
transitions leaving it in the CCD locked state.

It succeeds only if user password is not set and CCD capabilities are
right, which is guaranteed to be the case after an RMA unlock.

BRANCH=cr50
BUG=b:68213540
TEST=tested using the modified gsctool utility.

Change-Id: Ic2cce34e74b1ff476841cfa1a99f50d6a947c315
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/784352
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-28 15:44:16 -08:00
Furquan Shaikh
c5dfb7945c hostevents: Reclaim EC_HOST_EVENT_EXTENDED bit
Now that we have support for 64-bit events, there is no need to
reserve a bit in lower 32 bits for extended events.

BUG=b:69329196
BRANCH=None
TEST=make -j buildall

Change-Id: Ide02c4384c2b3ab4a63b028f126c48b73d6cd269
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/791863
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-28 15:44:13 -08:00
Daisuke Nojiri
26b4617c43 charge_manager: Add EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT
Usually, the max current and supply voltage of dedicated chargers
are not known to the EC.

This patch adds EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT, which
allows the host to change the max current and supply voltage of the
dedicated charge port.

BUG=b:64442692
BRANCH=none
TEST=make runtests && buildall. Boot Fizz and let coreboot set
the adapter current and voltage.

Change-Id: I29b3f5762f8b316ca363c23e230530cdf4ca207a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/769152
2017-11-28 10:22:27 -08:00
Philip Chen
675bdc2e2c Separate VBUS detection and measurement mechanisms
For now we guard charger-based VBUS voltage measurement
behind CONFIG_USB_PD_VBUS_DETECT_CHARGER.
But we should be able to measure VBUS voltage by charger
while detecting VBUS presence by other methods.

BUG=b:67991345
BRANCH=none
TEST=plug in guppy on Scarlet rev2, 'ectool usbpdpower' on console,
and see VBUS is measured as 4975mV

Change-Id: I94cada81159ea4b097001997e2444873ec2d8763
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/789910
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-11-27 22:50:47 -08:00
Chun-Ta Lin
f326fb05b5 hammer: enable large block reading on usb i2c passthru.
Originally, i2c passthru is limited to use I2C_XFER_SINGLE flag where
it can only read at most 255 bytes at a time.  For application that
requires larger i2c bus reading, we change the flag setting and the
command protocol.

TEST=old ./touchpad_updater still works (previous protocol)
TEST=new ./touchpad_updater can get more than 500 bytes per transaction
TEST=Debug message only print when -d assigned.
     ./touchpad_updater -d
TEST=Manually change #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 6)
     to #define CONFIG_USB_I2C_MAX_READ_COUNT (1024 - 4) and trigger
     POWER_OF_TWO assertion.
BRANCH=none
BUG=b:35587174, b:63993891

Change-Id: Id75b11ea49ba89bab8e18af24d47219030c778c5
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/542716
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-11-24 02:39:04 -08:00
Randall Spangler
952189623d ec_commands: Add structs for host command protocol V4
This only adds the structs for V4 packets.  Host command support for
them is coming in a subsequent CL.  V3 packets will continue to be
supported for a while, until all sides support V4.

BUG=chromium:787159
BRANCH=none
TEST=make -j runtests

Change-Id: I7e188a063d8ed60c85f3b8359959c424e3ccd1d9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/780452
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-11-22 22:54:46 -08:00
Furquan Shaikh
c9cd870600 host_events: Bump up host events and masks to 64-bit
With the upcoming change to add a new command to get/set/clear host
events and masks, it seems to be the right time to bump up the host
events and masks to 64-bit. We are already out of available host
events. This change opens up at least 32 bits for new host events.

Old EC commands to operate on host events/masks will still deal with
lower 32-bits of the events/mask. On the other hand, the new command
being added will take care of the entire 64-bit events/masks. This
ensures that old BIOS and kernel versions can still work with the
newer EC versions.

BUG=b:69329196
BRANCH=None
TEST=make -j buildall. Verified:
1. hostevent set 0x4000 ==> Sets correct bit in host events
2. hostevent clear 0x4000 ==> Clears correct bit in host events
3. Kernel is able to query and read correct host event bits from
EC. Verified using evtest.
4. Coreboot is able to read correct wake reason from EC. Verified
using mosys eventlog list.

Change-Id: Idcb24ea364ac6c491efc2f8dd9e29a9df6149e07
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/770925
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-21 18:53:35 -08:00
Nicolas Boichat
cd1f377f16 usb_i2c: Remove usb_i2c_board_enable/disable
These functions are not used by usb_i2c.c on chip/stm32, let's
move them to board/cr50 which is the only place where they are
used.

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

Change-Id: I8c1b292838b8dbee9a9001add9332e0add80c342
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/778749
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-20 23:25:45 -08:00
Nicolas Boichat
4cb524de67 touchpad_elan: Rename task/interrupts functions
Change the names to generic touchpad_* functions, instead of
vendor-specific names. Makes it a little easier to add drivers
for other touchpads.

Also fix console_channel.inc to add the channel whenever any
touchpad is used.

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

Change-Id: I6d268db5ebd53db272fb2ee7bbf06bbe80845734
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/778750
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-20 04:53:20 -08:00
Aseda Aboagye
34a97f50d5 buttons: Make buttons[] common.
Nearly every board had a buttons array defined in which its contents had
the standard volume buttons.  This commit creates a single common
buttons array that can contain the standard volume buttons and recovery
buttons.  If a board has volume up and down buttons, they can simply
define CONFIG_VOLUME_BUTTONS and it will populate the buttons array with
the standard definition.  The buttons are active low and have a 30 ms
debounce period.  Similiarly, if a board has a dedicated recovery
button, defining CONFIG_DEDICATED_RECOVERY_BUTTON will also populate the
buttons array with a recovery button.

BUG=chromium:783371
BRANCH=None
TEST=make -j buildall.
TEST=Flash a device with CONFIG_VOLUME_BUTTONS, verify pressing volume
buttons still work.

Change-Id: Ie5d63670ca4c6b146ec8ffb64d40ea9ce437b913
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/773794
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-17 20:18:38 -08:00
Gwendal Grignou
f587852570 motion_sense: Put set_range in common code
At the end of the sensor initialization, all _init sensor routines set
the range to the default value from board.c file.
Put all the code in a single place, move it from sensor_common.c to
motion_sense.c.

BUG=none
BRANCH=none
TEST=compile

Change-Id: If89cf27c6438e0f215c193d68a480e027110174c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767610
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-17 20:18:30 -08:00
Gwendal Grignou
2590ce9538 common: Add software CTZ implementation when needeed
CTZ - Count Trailing Zero - is not implemented in hardware on cortex0 or
nds32.

Used in ST sensor drivers.

BUG=none
BRANCH=none
TEST=compile

Change-Id: I2d62fd60f05169189b24ba2a3308bec69ed9de9c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767609
Commit-Ready: Ely Vazquez <nadia198877@gmail.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-16 23:32:11 -08:00
Gwendal Grignou
c5c061f9b5 poppy: Lower sensor max ODR
EC seems to miss sample while providing sensor data at 200Hz.
Limit sensors ODR to 100Hz.

BUG=b:67112751
BRANCH=none
TEST=compile, tbd

Change-Id: Ic324c3d989854ae8b7f6b27bf6338266ce01ceda
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/753434
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-11-15 20:21:03 -08:00
Scott Collyer
071142fe68 system: Add wait-ext option to ec reboot command
EC_IN_RW signal is used to determine if the switch to dev mode can be
safely made. However, EC_IN_RW needs the EC_RST_L line driven low in
order to be reset. In faft tests that utilize crosEcSoftrecPower
method, EC_RST_L is not being driven by servo to fix other test
failures related to keeping EC and AC reboots in sync.

This CL adds a new argument 'wait-ext' to the EC reboot command.
When this option is used, instead of the EC generating a reset via
it's system watchdog, it will wait 10 seconds for EC_RST_L to be
driven.

BUG=b:64603944
BRANCH=coral
CQ-DEPEND=I086687c3dd7591460099267880d56ab8265d2e4b
TEST=Ran "/usr/bin/test_that --board=coral <ip addr> firmware_DevMode"
mutliple times and verified that it passes. Previoulsy, this test
always fails when the EC is in RW before it starts. Also tested
platform_ServoPowerStateController_USBPluggedin and verified it passed.

Change-Id: I614f9156066d5719601ee43e29c7a064f9bba6e2
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/737524
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-15 16:07:26 -08:00
Furquan Shaikh
99182e10d3 Revert "power: Get rid of power_board_handle_host_sleep_event"
This reverts commit 352276235c.

This is required to ensure that PMIC VR decay is enabled before
SLP_S0# is asserted. Else, the setting does not take effect and hence
results in higher power consumption.

BUG=b:69337192
BRANCH=None
TEST=make -j buildall

Change-Id: I6885e7447277d853a2414be299dfea25f5547df4
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/771054
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-11-15 13:23:32 -08:00
Dino Li
2bb1811f07 it83xx: add espi module
Add espi control module for it83xx.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. it8390+Intel SKL-Y RVP3 and boot to shell.
     2. console command "kbpress 1 4" to test keyboard data.
     (board code for espi module test on CL:392587)

Change-Id: I1b32bd16f7e01abf07b9c9a68ebef2399cc9828d
Reviewed-on: https://chromium-review.googlesource.com/394471
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 21:52:39 -08:00
Nicolas Boichat
7fdcb8bf86 usb_update: Add support for touchpad debugging feature
We support touchpad-specific debugging feature over the USB update
protocol. This will be used to fetch raw data from the sensor,
without requiring to remove the write-protect screw.

BRANCH=none
BUG=b:63993891
TEST=./usb_updater2 -g 00 -d 18d1:502b

Change-Id: I46dfd97aaa17b73a5893fe1e8c62327a302f829b
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/763574
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 03:22:31 -08:00
Daisuke Nojiri
20d7149b19 Fizz: Switch power source to BJ at G3/S5
This patch allows Fizz to switch the power source from a type-c
charger to a barrel jack adapter if the system is in S5.

BUG=b:38321259
BRANCH=none
TEST=Verify the following with 45W and 60W type-c chargers:
1. Boot Fizz with a type-c charger
2. Go to S5 if not already.
3. Plug in a BJ adapter. Fizz boots to S0 using BJ power.

Also verified other boot modes are not affected:
1. Auto boot on BJ insert
2. Auto boot on Type-C insert
3. Recovery boot on BJ
4. Recovery boot on Type-C
5. Stay off if it's previously S5

Change-Id: I86aa0fe6e403bcbacfe396997d897111ffcf8e74
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/706251
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-13 10:57:37 -08:00
Shawn Nematbakhsh
dedd0ab913 gru: Remove flashinfo command for RAM savings
BUG=None
TEST=`make buildall -j`
BRANCH=None

Change-Id: Ibfbb6875327dfc13dcba57933d39fd207f382ac1
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/761299
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-11-09 19:16:33 -08:00
Vadim Bendebury
3919001a39 tpm: provide means of shutting down comms layer while in reset
Currently the Cr50 code resets TPM communications layer at a certain
point during TPM reset process.

It turns out that this is not sufficient - the comms layer keeps
receiving and trying to invoke TPM layer, which does not mesh well
with TPM reset.

Let's provide two callbacks for each comms layer - to shut it down and
to bring it back up. We shut down the comms when starting TPM reset
and bring them back up when reset is completed.

BRANCH=cr50
BUG=b:68012381
TEST=ran AP firmware test suite on both SPI and I2C based devices.

Change-Id: I7caf4a09b9a5c6e5fc6bfe60eae1c0d64ab24904
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/754502
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-11-07 17:52:15 -08:00
Patrick Georgi
887e3962ca Mark reset and panic functions as noreturn
gcc 6.3 (as provided by coreboot-sdk) needs that to know which code
paths end early.
Also add a loop after the command that is "supposed" to reset the
machine so that the compiler believes it (and in case that assumption
fails).

BRANCH=none
BUG=b:65441143
TEST=none

Change-Id: Idb87253ec7880d66ffec30d75f4d007f02f63aab
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/742916
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2017-11-07 15:25:17 -08:00
Shawn Nematbakhsh
fee1bde58d pd: Add pd_capable() to check PD capability of partner port
It's undesirable to do BC1.2 detection on power swap, so add a function
to check if the partner port is known to be PD-capable.

BUG=chromium:780905
BRANCH=gru
TEST=With subsequent CL, attach USB-PD phone capable of role swap.
Verify USB 2.0 device is enumerated on plug, and not re-enumerated
through a series of "pd # swap power" commands on the EC console. Also
verify BC1.2 charging and PD charging are still functional on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ifa75c94e9758d3e407492bbda6fc52ed7bc378fa
Reviewed-on: https://chromium-review.googlesource.com/755877
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-07 12:17:44 -08:00
Shawn Nematbakhsh
f4ee6caa66 bd9995x: Use fixed PD-port-to-VBUS/VCC mapping
The bd9995x driver was written to allow any PD port # to be VBUS or VCC,
but the mapping is broken in a few places. Since all boards use VBUS =
port 0, remove the conversion entirely.

BUG=chromium:781849
BRANCH=kevin
TEST=Verify PD and BC1.2 charging still works on kevin.

Change-Id: I3687866835d1684342d9f746d91b3a6079ab5cc4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/755000
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-11-07 12:17:43 -08:00
Ryan Zhang
f48cf0e8b2 Fizz: Modify thermal table
Modify thermal table for Fizz
reference patches: 627542, 288256, 329359

       on  off  RPM
step0              0
step1  16   2   2800
step2  27  18   3200
step3  35  29   3400
step4  43  37   4200
step5  54  45   4800
step6  64  56   5200
step7  97  83   5600

Prochot degree:
	active when t >= 88C
	release when t <= 85C
Shutdown degree: when t >= 90C

BUG=b:67487721, b:64439568
BRANCH=master
TEST=fan target speed follows table, make -j buildall pass

Change-Id: I3378668a560b8ddc568fe9cbf2703613fad8e4b6
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/729606
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-11-06 13:48:38 -08:00
Shawn Nematbakhsh
2f127f3081 charge_manager: Enter safe mode at boot
Charge port / current selection often needs to be significantly altered
when a battery cannot provide sufficient charge, so have charge_manager
initially enter safe mode. After a battery with sufficient capacity has
been identified, charge manager will leave safe mode, and port / current
selection will return to standard rules.

BUG=chromium:777596
BRANCH=None
TEST=Pass charge_manager unit tests. On kevin, remove battery, attach
Apple PD charger, verify safe mode is not exited and device does not
brown out. Hot-plug battery and verify safe mode is exited. Next,
remove battery, attach to Samus, verify safe mode is not exited and
device doesn't brown out. Hot-plug battery, verify that safe mode is
exited and no active charge port, due to dual-role exclusion.

Change-Id: I7784865750087a037aad8dbbac058b22c77ba6d4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/733954
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-02 23:21:52 -07:00
Aseda Aboagye
7bf1696711 chg_ramp: Add charge_is_consuming_full_input_current().
Most boards had an identical implementation for this function,
previously known as board_is_consuming_full_charge().  To reduce copy
paste, let's just move it to common code.  Boards that charge ramp
without a battery will have to define their own implementation, but
there probably won't be any boards like that in the near future.

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

Change-Id: Ic99a378ac26dfd35d7d718bf9376eacfa8609166
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/748919
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-01 16:47:21 -07:00
Dino Li
73d0ed0b79 driver: add IT5205 mux driver
Add support the ITE IT5205 Type-C USB alternate mode mux.

BRANCH=none
BUG=none
TEST=1. Successfully verify chip ID.
     2. Verify set_mux() and get_mux() functions set and return
        consistent values.
     3. The mux control register setting as expected after set_mux().

Change-Id: I9ff066dc9e74683df1371b70290e2aeaa86cb96b
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/741211
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-31 21:49:24 -07:00
Furquan Shaikh
352276235c power: Get rid of power_board_handle_host_sleep_event
power_board_handle_host_sleep_event was added to allow boards like
poppy to enable/disable PMIC VR decay only once during S0ix
entry/exit. Now that the chipset hooks have been fixed, there is no
need of this board specific callback. If in the future, there is a
need to have such a callback, this change can be reverted.

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

Change-Id: I1d60e43da6c0d462132593efa26bc52312b81786
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/745982
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-10-31 15:15:14 -07:00
Furquan Shaikh
19f96191d3 port80: Clean up macros
1. Add a new config option to define history buffer length. This
allows boards to override this option if required.

2. Get rid of unused PORT80_POLL_PERIOD macro

BUG=None
BRANCH=None
TEST=Verified that all port80 messages from a boot-up or S3 resume are
present in port80 history buffer.

Change-Id: Ie64680459f58358713a1b1445a0b99fcfe1c1cdc
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/745902
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-10-31 13:04:59 -07:00
Furquan Shaikh
d4d73eb806 power: Add default sleep event state HOST_SLEEP_EVENT_DEFAULT_RESET
Instead of using HOST_SLEEP_EVENT_S0IX_RESUME as a reset state to
reinitialize S0ix flag, add a new default state
HOST_SLEEP_EVENT_DEFAULT_RESET. This also allows different parts of
the code to take correct action depending upon the state that is
currently triggered.

BUG=None
BRANCH=None
TEST=Verified that SLP_S0# interrupt doesn't get asserted during
runtime S0ix.

Change-Id: Id6fc8f3b015561d2899a9d39796b77a11a57e758
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/745901
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-10-31 13:04:59 -07:00
Furquan Shaikh
7d66541b46 lpc: Add and use lpc_resume_clear_masks
Add a new LPC helper routine lpc_resume_clear_masks that can be used
to clear SCI, SMI and wake masks upon resume from S3. This is done to
mask the events until host explicitly unmasks them.

It also ensures that these masks do not get reset on resume from S0ix
where the host does not re-configure these masks.

BUG=b:68669668
BRANCH=None
TEST=Verified following:
1. make -j buildall
2. On resume from S0ix, SCI mask is not reset.
3. On resume from S3, SCI mask is reset and then set again by host request.

Change-Id: I17a86bd60ef066b3716fb79ecce62f311eb45509
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/745533
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-10-31 13:04:58 -07:00
Vincent Palatin
7b8fb2ad2a twinkie: clean-up disabled SNIFFER_HEADER_V2 code
Remove all the CONFIG_USBC_SNIFFER_HEADER_V2 code, it was not fully
satisfactory and we have a better alternative.

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

BRANCH=twinkie
BUG=none
TEST=make BOARD=twinkie

Change-Id: I26d3396b2933be5276f916e3ac60c96347cb67f6
Reviewed-on: https://chromium-review.googlesource.com/743015
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-31 03:54:43 -07:00
Vadim Bendebury
734fe2d40b ccd: pass 'ccd password' execution through tpm task context
It is necessary to be able to set password both from the Cr50 console
and through a vendor command.

This patch moves all password management logic to the TPM task context
using the alternative vendor command path.

BRANCH=cr50
BUG=b:62537474
TEST=verified that using Cr50 console CCD password still can be set
     and cleared as before.

Change-Id: I0574caf931e3717567fdb270e406643eac47764b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/740914
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-10-27 16:14:16 -07:00
Nicolas Boichat
ab9084fd2a chip/npcx: Add support for pad-switching UART
NPCX5* only has one UART controller, which can be switched
between 2 pads. We keep the default pad for EC console,
however, we allow switching to the alternate pad for short,
infrequent, transactions. Both pads are assumed to use the
same baudrate and other line settings.

When switching pad, we first configure the new pad, then switch
off the old one, to avoid having no pad selected at a given time,
see b/65526215#c26.

Because of the added complexity of npcx_gpio2uart (and the fact
that it uses the global variable "pad" define in uart.c), we
move the implementation to uart.c (npcx_uart2gpio is also moved
for consistency).

When the pad is switched to alternate pad, characters input
and output on the EC console (default pad) would be lost. To
compensate for this, we:
 - Switch back to main pad in case of EC panic, so that output
   is shown on EC console.
 - Immediately abort current alternate pad transaction if a
   character is received on the default pad. Note, however,
   that the first character will be lost (this can be worked
   around by telling user to press enter, and have servod/FAFT
   always send 2 blank lines (instead of just one) before
   sending a command).
 - Inhibit pad switching for 500ms after receiving a character
   on default pad. Assuming a reasonable typing speed, this
   should allow developers to type console commands relatively
   comfortably, while not starving the alternate pad communication
   for too long.

The logic above could be simplified significantly by implementing
software flow control (XON/XOFF, see b/67026316).

BRANCH=none
BUG=b:65526215
TEST=While follow-up CL that writes long 1k buffers, the following
     works fine:
     - type 'uart' in EC console
     - Read battery power consumption from servod, which "types" in
     the EC console:
     while true; do dut-control ppvar_vbat_mw; sleep 1; done
     no failure is seen.
TEST=Add this test code in uart_alt_pad_read_write, after the pad
     has been switched, and check that panic information is
     consistently printed correctly:
	{
		static int t;
		if (t++ > 20)
			t = t / ret;
	}

Change-Id: I18feed2f8ca4eb85f40389f77dac3a46315310e7
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/659458
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-25 03:58:50 -07:00
Sam Hurst
c91dbb26d8 PD: Make current USB PD Stack REV 3 compliant
Implement the following required features in the USB PD Rev. 3.0
specification.

Not_supported control message: Inform a port partner that a
particular message is not supported.
Battery capabilities extended message: Report battery design
capacity and last full charge capacity.
Battery status data message: Report battery state of charge
Collision avoidance: New scheme to avoid collisions caused when both
source and sink want to send messages.

Cable communication: Only the VCONN source can communicate with the
cable plug. This is NOT implemented because although the drivers have
the capability of communicating with a cable plug, the PD stack doesn't
currently need to talk to a cable plug. This is okay since the current
PD design doesn't source or sink more than 3 amps and all Type-C cables
are required to be 3 amp capable.

BUG=b:64411727
BRANCH=None
TEST=`make -j buildall`
Passed relevant PD Rev 2.0 compliance tests
Successful PD negotiation with PD Rev 2.0 and 3.0 chargers
Tested with low power none PD charger.
Modified a Kevin to operate as a PD 3.0 charger and sent
all required messages and verified the return messages.
Also tested collision avoidance by verifying that a sink only
transmits when the source indicates it's okay.
Used Twinkie to verify that PD was operating as v3.0.
Signed-off-by: Sam Hurst <shurst@chromium.org>

Change-Id: Ifd77e92ec4e9106236f9221393d2bfb97263d979
Reviewed-on: https://chromium-review.googlesource.com/603003
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-24 15:30:15 -07:00
Vadim Bendebury
e3d15afa68 tpm: let the caller of TPM reset decide if the EC needs to be reset too
TPM reset sequence when TPM wipeout is requested has a side effect of
rebooting the entire device. This is not always desirable, in some
cases other actions need to happen before the device is rebooted.

This patch makes resetting the EC the TPM reset caller's responsibility,

BRANCH=cr50
BUG=none
TEST=verified that RMA reset and WP disable properly wipe out the TPM
      and reboot the device.

Change-Id: I6e827ce923a2454ae5b2e2597d1a4c9390bbb8b6
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/733813
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-24 12:57:45 -07:00
Vadim Bendebury
aeb0c8e4b9 rma: process proper auth code
When RMA process has been initialized and the user entered the
expected authentication code value, the Cr50 needs to wipe out TPM
memory, open and unlock CCD and reboot the device.

This patch adds a function to accomplish that. User response is
validated on the TPM task context, and TPM reset request also requires
TPM task processing. To decouple response processing from the
following reset, the response processing is handled by a hook task
callback, delayed for 1s to make sure that user receives the response.

After TPM has successfully reset the CCD is reinitialized with RMA
'opened' and the device is rebooted.

Just in case something goes wrong with the unlock and the hook is not
invoked, add a 10s deferred function to take the EC out of reset so
that the device still can reboot.

BRANCH=none
BUG=b:67007905
TEST=on a Bob device:

   - on the Cr50 console enter 'ccd lock', verify that ccd is locked
     (by examining output of the 'ccd' command)

   - at the bash prompt enter gsctool -r -s -t, copy the
     authentication code from the Cr50 console and pass it to gsctool.

   - observe the device reset TPM wiping out its memory, enable CCD
     and reboot.

Change-Id: I6fafb5e642cb2b6f2040507a7f1989607fd31316
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/729983
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-10-24 12:57:45 -07:00