Commit Graph

2764 Commits

Author SHA1 Message Date
Nicolas Boichat
3d4db585fa charge_state_v2: Reduce OTG voltage to 12V for better efficiency
BRANCH=none
BUG=b:73528930
BUG=b:73660652
TEST=Flash lux, check that lux adc VBUS voltage when only no
     charger is connected is around 12V.

Change-Id: Iccc245c96ca3c83674446f96f78f1ce15ffa7de2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/948322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-03-05 18:34:29 -08:00
Philip Chen
9896e428f7 Introduce CONFIG_USB_PD_5V_CHARGER_CTRL
Add a new config for the boards using charger (e.g. rt946x)
to report if VBUS source is enabled instead of using GPIO.

BUG=b:65446459
BRANCH=none
TEST=Charge Scarlet rev3 with SDP and DCP.

Change-Id: Id0a07945f0f888b6a36c422c596b56c5aa5065c0
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/905400
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-03-05 00:21:22 -08:00
Vadim Bendebury
f6b72676a0 cr50: fix console command RMA authentication code check
When checking the RMA authentication code the code currently just
verifies the value, but does not act on it.

This patch directs the user input through the same vendor command path
which is used when the RMA operation is controlled using gsctool.

BRANCH=cr50, cr50-mp
BUG=b:74080723
TEST=verified that issuing 'rma_auth <code>' on the Cr50 console now
     trigger CCD open and reboot.

Change-Id: Ib3fab131b6a24b65618f0b1f2504638f8df11a4b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/945311
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-03-02 13:25:12 -08:00
Mary Ruthven
097f5e6a0b cr50: include GscFullConsole in rma open
Set GscFullConsole to Always in RMA open. We need this to be accessible
after rma open, so that we can use RMA open as a ccd open testlab
replacement.

Commands like rddkeepalive and bitbang are needed for testlab use, so
they should be accessible after open.

BUG=b:74019846
BRANCH=cr50, cr50-mp
TEST=build, do rma open, verify commands are not locked out, and do rma
disable

Change-Id: Iaeb89cea94d478dc0eb25c92bb09d488d14cad41
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/942309
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-03-01 16:13:34 -08:00
Vincent Palatin
045aef2cda make EC_FEATURE_RWSIG definition more useful
Also define the EC_FEATURE_RWSIG feature bit if the RO firmware contains
the RWSIG task but not the RW.
Given the RWSIG verification task is not terribly useful in RW
(where it is never executed), it can be skipped there but the host
program trying to detect RWSIG usage (e.g. flashrom) still wants to be
able to detect it.

In order to be able to do so, add the HAS_TASK_xXx_RO and
HAS_TASK_xXx_RW flags which define the tasks defined in the other
partition (at compilation-time you might still run a frankeinstein combo).

Fix ectool 'inventory' to avoid segfaulting on missing feature string
definition.

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

BRANCH=none
BUG=b:36125319
TEST=on ZerbleBarn, run 'ectool inventory', also uses flashrom to
re-flash the RW partition.

Change-Id: I224a6cc4aef956204792a2cc04ad12aaed5abf47
Reviewed-on: https://chromium-review.googlesource.com/937262
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-03-01 16:13:10 -08:00
Vincent Palatin
f917f447d7 fix shmem console command
The shmem console command was looping with the wrong iterators,
doing an infinite loop when there was more than one allocated or
free block.

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

BRANCH=none
BUG=none
TEST=build software with CONFIG_MALLOC and CONFIG_CMD_SHMEM, then run
'shmem' on the console at different time without hitting watchdog reset.

Change-Id: I93a9cff3811669ab895fa8753d1571e90aeb4f33
Reviewed-on: https://chromium-review.googlesource.com/943070
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-03-01 12:39:05 -08:00
Jett Rink
284c0c3589 usb-pd: Tell TCPC and PPC to both source Vconn
BRANCH=none
BUG=b:72961003,b:72956593
TEST=verified with grunt that parade TCPC will no longer shut down when
PPC sources Vconn

Change-Id: I6c1cee4dd8a40a992813841ec227a6af04de5313
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/935301
2018-02-27 14:51:13 -08:00
Marius Schilder
3c4800e594 ec: add crc32_ctx..() to take context parameter.
Add crc32_ctx.. functions to take context parameter.

This allows for multiple instances to exist in parallel.

Signed-off-by: mschilder@google.com
TEST=make buildall -j8 succeeds
BRANCH=none
BUG=b:73832883

Change-Id: I66bbc56377eeebf01c790caad0bc4c7a51a1bc58
Reviewed-on: https://chromium-review.googlesource.com/935825
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-02-23 23:13:01 -08:00
Daisuke Nojiri
546c606b5f CBI: Share common code between host tool and firmware
This patch makes EC firmware and cbi-util share the common code.

BUG=b:70294260
BRANCH=none
TEST=Set fields using ectool. Verify the contents by cbi command.
Verify cbi-util creates the same binary as before.
Verify emerge ec-utils ec-devutils pass.

Change-Id: If5e65e48dd03960e0adf23ef775f67aecf785d85
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/932001
2018-02-23 03:36:35 -08:00
Daisuke Nojiri
8a5a83aef3 CBI: Make cbi command dump EEPROM contents
Currently, cbi console command dumps the buffered contents. This
patch will make the command dump the entire EEPROM.

BUG=b:70294260
BRANCH=none
TEST=Run cbi command on Fizz:
CBI_VERSION: 0x0000
TOTAL_SIZE: 18
BOARD_VERSION: 514 (0x202)
OEM_ID: 2 (0x2)
SKU_ID: 0 (0x0)
 43 42 49 5c 00 00 12 00 00 02 02 02 02 01 00 01
 01 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ...

Change-Id: I39f3335a38eb72c95d53264ddc7386dd0910e946
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/930322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-22 20:17:20 -08:00
Vincent Palatin
00ac588099 pd: retry DR_SWAP after a WAIT
If the other side answers our DR_SWAP request with a WAIT message (as
bizarre as it might be), we want to retry later rather than giving up.
Set again the PD_FLAGS_CHECK_DR_ROLE flag in order to do so.

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

BRANCH=fizz
BUG=chromium:814098
TEST=do repeated cold reset on Fizz connected to the 'interesting' USB-C
screen and see the DP alternate mode negotiated.

Change-Id: Icfb9fa209ce8cbe3c42c1e6946b43464544bdaea
Reviewed-on: https://chromium-review.googlesource.com/921141
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
2018-02-21 04:27:09 -08:00
Vadim Bendebury
53ca6cfbdf cr50: Allow spihash extension command over USB
Execution of this command requires physical presence on the DUT, this
is why it is save to allow it over USB.

BRANCH=cr50, cr50-mp
BUG=chromium:812880
TEST=using modified gsctool verified that the command goes through and
     physical presence indication is requested

Change-Id: I0aa371d8aaa5a480cc12d5d16edad8497142f4b4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/927796
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-02-20 22:50:10 -08:00
Daisuke Nojiri
971ef1e03c host_command: Count suppressed host commands individually
BUG=chromium:803955
BRANCH=none
TEST=Verify counters are printed every hour and before sysjump as follows:
[12.540051 HC Suppressed: 0x97=25 0x98=0 0x115=0]

Change-Id: I1c1aecf316d233f967f1d2f6ee6c9c16cc59bece
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/912150
2018-02-16 21:41:41 -08:00
Daisuke Nojiri
5946911129 CBI: Make data offset and size variable
Currently CBI data offset and size are fixed. This patch makes them
variable. Each data item consists of <tag><size><value> where <tag>
is a numeric value assigned to each data item, <size> is the number
of bytes used for <value>.

BUG=b:70294260
BRANCH=none
TEST=Use 'ectool cbi set' to set board version, oem, sku.
Verify the contents by cbi console command and ectool cbi get.
1. ectool cbi set 0 0x202 2 2 (Init CBI and write board ver. of size 2)
2. ectool cbi set 1 1 1 (write oem id of size 1)
3. ectool cbi set 2 2 1 (write sku id of size 1)
4. ectool cbi get 0
 514 (0x202)
5. ectool cbi get 1
 1 (0x1)
6. ectool cbi get 2
 2 (0x2)
7. Run cbi console command:
 CBI_VERSION: 0x0000
 TOTAL_SIZE: 18
 BOARD_VERSION: 514 (0x202)
 OEM_ID: 1 (0x1)
 SKU_ID: 2 (0x2)
  43 42 49 8c 00 00 12 00 00 02 02 02 01 01 01 02
  01 02

Change-Id: I5a30a4076e3eb448f4808d2af8ec4ef4c016ae5e
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/920905
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-02-16 18:47:52 -08:00
Vincent Palatin
59c68a1d4b fpsensor: add quality test capture type
Add support for an additional finger image capture type
used for quality testing.

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

BRANCH=none
BUG=b:72360575, b:71770455
TEST=On Meowth, run 'ectool --name=cros_fp fpmode capture qual'
then 'ectool --name=cros_fp fpframe raw > finger_mq.bin'

Change-Id: I1b9525dc2adf0b91aef2f7124803c90d6a3bb0ca
Reviewed-on: https://chromium-review.googlesource.com/924124
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
2018-02-16 18:47:47 -08:00
Vadim Bendebury
f495e27ce6 tpm: ccd: allow alternative commands when ap is held in reset
A typical CCD use case is when the DUT is not fully functional, or
even completely dead, including corrupted AP/EC firmware.

We still want to be able to enable CCD in this case, but routing CCD
commands through TPM task context (necessary to ensure the large stack
size some CCD commands require) is blocked if TPM was not reset after
startup.

Let's allow both reset requests and alternative commands when AP is
held in reset after reboot. The only situation when the alternative
command arrives would be the CCD use case of the system not generating
TPM reset pulse at startup and the operator is trying to execute a CCD
or RMA reset command.

BRANCH=cr50, cr50-mp
BUG=b:73292631

TEST=on a reef device: destroyed AP firmware and observed that the
     'ccd open' command indeed results in the hung Cr50 console after
     Cr50 is reset in this state.

     Loaded the new Cr50 image, (which caused another Cr50 reset),
     successfully took it through the 'ccd open' sequence resulting in
     enabling AP flash write access, restored the AP flash and
     observed the DUT boot into Chrome OS.

Change-Id: I4413bc200f5b2be563ba666ff80dd2d889ae5790
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/920924
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-02-15 21:43:57 -08:00
Simon Glass
5ae1a9915d led_pwm: Add a few more features to the ledtest command
Add a way to report the current state using this command. This is useful
when debugging.

BUG=b:71902053
BRANCH=none
TEST=manually

> ledtest 0
PWM LED 0: led_id=0, auto_control=1
> ledtest 0 enable amber
> ledtest 0
PWM LED 0: led_id=0, auto_control=0

Change-Id: I478980d82573b60b536ea0f4dcf324b7ccfb6fdb
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/919764
2018-02-15 21:43:53 -08:00
Furquan Shaikh
c7f6e2a80f power_button_x86: Honor power_button_pulse setting on sysjump
On sysjump, if power button is held down, first check
power_button_pulse_enabled setting to decide if powerbtn to pch should
be asserted. This is important to prevent accidental shutdowns when
user is attempting to do an EC reset with Vup+Pwr held down.

BUG=b:73129177
BRANCH=None
TEST=Verified following:
1. Reset EC by holding Vup+Pwr.
2. Keep holding Vup+Pwr until AP reaches depthcharge.
3. Ensure that AP does not shutdown.

Change-Id: I0375fc8e8baabb40807dfdc6d4c9fa70c9b3b87d
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/912364
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-02-12 18:59:36 -08:00
Jett Rink
242cd4e3ad usb-pd: Apply Vconn before Vbus as per USB TypeC spec (v 1.3)
According to table 4-25 in USB TypeC spec version 1.3, Vconn should be
sourced before Vbus or within 2ms. On Grunt I am see tVconnON around 2.3
ms, which is out of spec. We can simply source Vconn first to comply with
spec.

BRANCH=none
BUG=b:72811851
TEST=Grunt's tVonnOn is now <2ms

Change-Id: I52ca6a52bf576487061b2c33f348edf58eb06ca0
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/911928
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-12 18:59:34 -08:00
Jett Rink
7a23aa72bf usb-pd: Clear active contract bit before browning out system
In the case where we are resetting Vbus and it is our only power source,
then we will brown out before we set the active port to 0.

BRANCH=none
BUG=none
TEST=Did a cold reset on grunt with no battery power. System booted as
normal.

Change-Id: I3823af6b0475e4cf8abbe12dd8ae4ceef26d1eab
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/911613
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-02-09 19:03:20 -08:00
Nicolas Boichat
b34b34e6e8 charge_state_v2: No base/lid power transfer in S0ix/S5
BRANCH=none
BUG=b:71881017
TEST=Suspend system, see that base does not provide power to lid,
     and vice-versa.

Change-Id: I54e26c9b8decff2afdebc34adb62d4f5cef18e37
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/882524
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-09 07:55:34 -08:00
Nicolas Boichat
abdb022a2b battery: Allow 2 batteries to be fetched via ACPI
We share the same shared memory fields for both batteries. When
the host wants to switch battery to read out:
 - The host sets EC_ACPI_MEM_BATTERY_INDEX to the required index
 - EC then swaps the data is the shared memory fields, then update
   EC_MEMMAP_BATT_INDEX
 - Host waits for EC_MEMMAP_BATT_INDEX to have the required value,
   then fetches the data

BRANCH=none
BUG=b:65697620
TEST=Boot lux, both /sys/class/power_supply/BAT0 and BAT1 are
     present, data is valid.
TEST=Unplug base, BAT1 goes away, replug, BAT1 comes back.

Change-Id: Icce12f9eef2f6f8cde9bae0a968a65e1703d0369
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/888382
Reviewed-by: Gwendal Grignou <gwendal@google.com>
2018-02-09 07:55:33 -08:00
Vincent Palatin
4ee04e1c4a Fix shmalloc unit test
We want to build the shmalloc common code in test mode *only* for the
shmalloc test not for all test binaries (which are missing the helper
functions).
The previous version was broken for any board declaring CONFIG_SHMALLOC
(but none were excepted cr50 which has tests disabled)

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

BRANCH=none
BUG=b:72360575
TEST=emerge-meowth chromeos-ec

Change-Id: Ic89c74569fbadbc75d9090b084adab8f40ddfa5d
Reviewed-on: https://chromium-review.googlesource.com/909210
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-02-09 05:24:46 -08:00
Randall Spangler
ff4d22819a cr50: Add SPI hashing command
This allows hashing or dumping SPI flash from the Cr50 console even on
a locked device, so you can verify the RO Firmware on a system via CCD.

See design doc: go/verify-ro-firmware
(more specifically, "Cr50 console commands for option 1")

BUG=chromium:804507
BRANCH=cr50 release (after testing)
TEST=manual:
   # Sample sequence
   spihash ap -> requires physical presence; tap power button
   spihash 0 1024 -> gives a hash; compare with first 1KB of image.bin
   spihash 0 128 dump -> dumps first 128 bytes; compare with image.bin
   spihash 128 128 -> offset works
   spihash 0 0x100000 -> gives a hash; doesn't watchdog reset
   spihdev ec
   spihash 0 1024 -> compare with ec.bin
   spihash disable
   # Test timeout
   spihash ap
   # Wait 30 seconds
   spihash 0 1024 -> still works
   # Wait 60 seconds; goes back disabled automatically
   spihash 0 1024 -> fails because spihash is disabled
   # Presence not required when CCD opened
   ccd open
   spihash ap -> no PP required
   spihash 0 1024 -> works
   spihash disable
   # Possible for owner to disable via CCD config
   ccd -> HashFlash is "Always"
   ccd set HashFlash IfOpened
   ccd lock
   spihash ap -> access denied
   # Cleanup
   ccd open
   ccd reset
   ccd lock

Change-Id: I27b5054730dea6b27fbad1b1c4aa0a650e3b4f99
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/889725
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-02-08 23:42:33 -08:00
Daisuke Nojiri
d54cdec85b Fizz: Execute PMIC reset before vboot_main
When AP requests cold reboot, currently EC does not perform PMIC
reset because chipset_handle_reboot is executed only after EC jumps
to RW. This causes EC to miss CHIPSET_STARTUP and CHIPSET_RESUME
events because power rails do not cycle.

This patch will make EC execute PMIC reset to before vboot_main.

BUG=b:73093795
BRANCH=none
TEST=reboot, reboot ap-off, verify USB ports are powered after
transitionining to dev mode.

Change-Id: Ic04395d8a4bff45d9fc60601b07c600dfb75d9c0
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/908094
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-08 12:58:20 -08:00
Jett Rink
bbb707727d usb-pd: Adding port number to debug messages
BRANCH=none
BUG=none
TEST=verified debug message on grunt

Change-Id: Ibc1632d22b6e4bbc5b95c140db4a7cfb536687c8
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/907417
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-02-08 12:58:16 -08:00
Ryan Zhang
6c5a4424d7 Fizz: Update thermal table by project
1. Prochot/Shutdown Point
	a. Prochot on: >=81C, off: <=77C
	b. Shutodwn: >=82C

2. custom fan table
	There are three projects sharing two tables, and
	use Kench & Teemo's table before getting correct OEM ID
	because it raises fan speed quicker than the other one.

	a. Kench & Teemo & default
	b. Sion

BUG=b:70294260
BRANCH=master
TEST=EC can get two fan tables with different cbi value.

Change-Id: Ie1bffbcf5c353a9aae5806f6c2b41554eed22b7d
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/886121
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-02-08 09:24:07 -08:00
Nicolas Boichat
ececca49aa whiskers: Disable keyboard/USB interface when magnet sensor active
BRANCH=none
BUG=b:72722179
TEST=lidopen/lidclose, see that USB interface is getting enabled/disabled
TEST=Close/open sensor with a magnet, see that USB interface is getting
     enabled/disabled
TEST=Boot with sensor open, USB interface is on

Change-Id: Ic738fa2f2adea03cd29914bb5fc96a1fa6834122
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/894783
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-08 06:57:51 -08:00
Vadim Bendebury
4a673c15ad rma: enable WP on RMA disable
When RMA procedure is completed WP needs to be enabled back.

BRANCH=cr50, cr50-mp
BUG=b:37952913, b:73075443
TEST=on a Robo device, verified that WP is enabled, took the device
     through RMA unlock, verified that WP is disabled, took the device
     through RMA disable, verified that WP is enabled again.

     Also confirmed that after RMA is disabled WP status follows the
     battery.

Change-Id: Iad6af7d16aadcd10d580f709aeb942cf508a8489
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/905926
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-08 02:31:20 +00:00
Vadim Bendebury
41a308abcb tpm: set waiting task ID earlier.
The TPM task is running on a higher priority than the hook task
invoking TPM reset for RMA purposes. The waiting task ID value needs
to be set before TPM task is signaled to reset.

BRANCH=cr50, cr50-mp
BUG=b:37952913
TEST=with the corresponding ccd_config.c changes fully verified RMA
     process (not just generating and processing the challenge).

Change-Id: Id112d59ae0c3fd31a32e652c6a043fc3fd3bbe07
Signed-off-by: Vadim Bendebury <vbendeb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/905925
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-07 15:04:13 -08:00
Nicolas Boichat
824351c839 charge_state_v2: Separate update_base_battery_info
Indentation in charger_task is getting out of control, let's move
the logic to a new function.

BRANCH=none
BUG=b:71881017
TEST=Flash lux and wand, battery algorithm works as expected.

Change-Id: Ife008370218f0d9eb0f96088ec144b0aba40716f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/901442
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-02-07 11:55:58 -08:00
Nicolas Boichat
ad286a050e charge_state_v2: Store battery information in new structures
On dual battery systems, this allows to keep both batteries
information in similar structures. This also means that battery
information can only be fetched via host commands
EC_CMD_BATTERY_GET_STATIC/DYNAMIC (next CL will make it possible
to fetch the information via shared memory/ACPI).

BRANCH=none
BUG=b:65697620
TEST=Boot lux/wand, dual-battery algorithm works, AP can fetch
     both battery information via host commands.

Change-Id: I3c087e8f378c5cef0006f6bfe58335228a880e5b
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/888381
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-02-07 11:55:57 -08:00
Aseda Aboagye
d940d2a991 common: Add support for PWM LEDs.
This commit adds support for a common framework for PWM controlled LEDs.
If there are multiple LEDs, they will all follow the same pattern.  The
pattern is such that it follows the Chrome OS LED behaviour
specification, essentially a similar version of led_policy_std.c but for
PWM controlled LEDs.

To use this framework, a board must do the following:

- First, define the number of logical PWM LEDs which will be controlled
  by this common policy, CONFIG_LED_PWM_COUNT.

- Then declare those logical LEDs and define the PWM channels that
 comprise those LEDs. (struct pwm_led pwm_leds[]).

- Next, define what each color should look like (struct pwm_led
  led_color_map[]).

By default, the colors follow the recommended colors in the LED
behaviour spec, which assume an LED with a red and green channel.  If a
board differs or wishes to change the colors in general, they can
redefine the colors (CONFIG_LED_PWM_*_COLOR) as they see fit.  The
colors must be one in enum ec_led_colors.  These colors are the ones
that can represent the charging state, SoC state, etc.

BUG=b:69138917,chromium:752553
BRANCH=None
TEST=make -j buildall
TEST=Enable led_pwm for meowth, and verify that LEDs behave as expected.

Change-Id: I945b86a7f8ed30df58d7da835d83577192548bea
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/888220
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-02-05 23:05:39 -08:00
Jett Rink
2cbc9f98ad cleanup: adding port info and timing to debug message
BRANCH=none
TEST=none
BUG=none

Change-Id: I5639be21b285beef61e939f1c70c5ab5a14ade7e
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/900305
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-02-05 19:08:44 -08:00
Nicolas Boichat
1af3e53626 keyboard_scan: Disable when USB is suspended without wake
Keyboard matrix scanning can be disabled when the USB interface is
disabled without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be
ignored anyway.

BRANCH=none
BUG=b:72683995
TEST=keyboard matrix scanning is disabled when lid is closed.

Change-Id: I0b2346cc3426b9ef51127424f9953fd5c20ecd49
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897068
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-05 19:08:21 -08:00
Daisuke Nojiri
044cc72496 Enable PD communication in RO for external display
This patch makes EC enable PD communication if it's running in
manual recovery mode. This is required to show recovery screen
on a type-c monitor.

This patch also makes EC-EFS ignore power availability. It will
make EC verify & jump to RW even if power is sourced by a barrel
jack adapter. This should allow depthcharge to show screens
(e.g. broken, warning) on a type-c monitor.

BUG=b:72387533
BRANCH=none
TEST=On Fizz with type-c monitor, verify
- Recovery screen is displayed in manual recovery mode.
- Critical update screen is displayed in normal mode.
- Warning screen is displayed in developer mode.
Monitors tested: Dingdong, Dell S2718D

Change-Id: Ib53e02d1e5c0f5b2d96d9a02fd33022f92e52b04
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/898346
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-03 02:38:10 -08:00
Nicolas Boichat
f0532aa93a charge_state_v2: Safer power transfer between lid and base
To avoid issues where adapter would drive against OTG of lid or
base, and to make sure that we do not over-current the adapter,
we disconnect the base/lid power transfer whenever a new
adapter is connected.

We reenable power transfer as needed.

We also separate out base current control as a new function,
that allows us to record the previous base current only when
the base charge control command is successful, and ignore
errors until the base is responsive for the first time.

Finally, we make sure that
charge_allocate_input_current_limit is only called from a
single location in charger_task.

BRANCH=none
BUG=b:71881017
TEST=Plug/unplug base, reset lux EC, connect charger.
     Base is detected, power allocation works as expected.

Change-Id: I8b206d5b0fbcf0fe868b56a0336745aebe2a6dc2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/880021
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-02-02 23:53:40 -08:00
Nicolas Boichat
76927bdc5a stm32/usb: Add HOOK_USB_PM_CHANGE, called when USB is resumed/suspended
In particular, this will allow touchpad driver and keyboard matrix
scanning to be powered off/disabled when the USB interface is
disabled without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be
ignored anyway.

BRANCH=none
BUG=b:72683995
TEST=With next CLs, touchpad and keyboard matrix scanning are disabled
     when lid is closed.

Change-Id: I3750bfaf8c31cde075adf9da4fef39753b8981c5
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-02 10:17:30 -08:00
Daisuke Nojiri
ebb34ee92f CBI: Return ACCESS_DENIED on write failure due to WP
This patch makes EC_CMD_SET_CROS_BOARD_INFO return
EC_RES_ACCESS_DENIED if the command fails due to write-protect
switch.

BUG=b:70294260
BRANCH=none
TEST=Verify 'ectool cbi set 2 4' prints 'WP enabled?' when WP
is enabled.

Change-Id: I7c27ee748caf32e57f22ab79edcbff96e42c44ad
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897683
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-02-01 21:29:33 -08:00
Vadim Bendebury
8dba841b4e ccd: fix scan-admin warnings
Automated code scanner highlighted a few problems in the recent ode
additions. This patch fixes the problems.

BRANCH=cr50
BUG=none
TEST=none

Change-Id: I1f199eb5d2af992384ab04f3010b4b646464a70f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897993
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-02-01 18:08:45 -08:00
Aseda Aboagye
e127855f27 ppc: Add Vconn and CC polarity settings.
BUG=b:72292985
BRANCH=None
TEST=Flash meowth; Verify with twinkie that Vconn is provided for a sink
that requires it.

Change-Id: I8168d2e4c46e04810dcf5c2898b2c337424eefec
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/888224
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-02-01 18:08:36 -08:00
Alexandru M Stan
c870c87f2d motion_sense: Check presence of {set,get}_{range,offset}
Prevents a null pointer dereference when the AP asks the EC
for nonexistent settings of a sensor.

BUG=chromium:761758
TEST="ectool motionsense offset ${ID of baro_bmp280 sensor}"
And see no null pointer dereference, but an invalid command error
BRANCH=master

Change-Id: I3050feaa3c9752abebc30237dac1befa4e5775cc
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/850639
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-02-01 14:55:17 -08:00
Edward Hill
11bda19561 sn5s330: Enable VBUS interrupts
If the sn5s330 PPC is being used to detect VBUS presence
(CONFIG_USB_PD_VBUS_DETECT_PPC), then enable interrupts and call
usb_charger_vbus_change when VBUS_GOOD changes.

BUG=b:72007153,b:72007492
BRANCH=none
TEST=Connect 3A and 1A USB-A chargers to each of Grunt's USB-C ports,
check that BC1.2 detection is working:
	With 1A:
	> chgsup
	port=0/1, type=7, cur=500mA, vtg=5000mV, lsm=1
	With 3A:
	> chgsup
	port=0/1, type=7, cur=2400mA, vtg=5000mV, lsm=1
TEST=Boot Grunt to OS, then connect USB2 mouse or USB3 flash drive to each
of Grunt's USB-C ports. Devices do not work due to b:71772180, but gpioget
shows EC is setting USB_C0/1_BC12_VBUS_ON_L correctly.

Change-Id: Iffc352105a321997adb364b9fbb8bafef248c224
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/887938
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-01-31 22:38:56 -08:00
Aseda Aboagye
eb60e291e8 led: Only report auto control for supported LEDs.
BUG=None
BRANCH=None
TEST=make -j buildall

Change-Id: I6508d2bfa01919c89a9b5c1129af35919deb1557
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/888219
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-01-31 18:01:04 -08:00
Jett Rink
760caca89b usb pd: Adding PPC vbus discharge path
Boards with a PPC will use the PPC to discharge the VBUS line instead
of the TCPC or GPIO discharge path.

BRANCH=none
BUG=b:72179253
TEST=Fall time after device removal on grunt within spec now

Change-Id: I822923a1cedb32a20efc3610cce4437ade3387f0
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/886563
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-31 11:14:01 -08:00
Shawn Nematbakhsh
9afcd8d602 cleanup: Remove CONFIG_USB_PD_TCPC_BOARD_INIT
It's no longer necessary to call board_tcpc_init() from PD tasks, since
HOOK_INIT completion is guaranteed before the task starts. Also, calling
board_tcpc_init() for each PD task without a port arg is a bad idea.

BUG=b:72229154
BRANCH=none
TEST=`make buildall -j`

Change-Id: I6fba07771693b8343568041960a263e02775a8fc
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/881538
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-30 14:54:23 -08:00
Shawn Nematbakhsh
9362b06201 samus_pd: Remove 'adc' console command
Remove console command for flash / RAM savings.

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

Change-Id: Ibfccbdf45e5c86260cc55237387994fdf094c19c
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/885463
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-30 14:54:17 -08:00
Nicolas Boichat
cbd086d13b charge_state_v2: Fix current limit when lid has no battery
The logic of drawing as much current as possible when no battery
is connected (on the lid), and system unlocked, makes sense during
early bringup.

However, it will not work when the base is also connected, as we
did not implement the required no-battery logic in the base/lid
power allocation algorithm (nor do we plan to, as it is only
required during very early bringup, when we should not expect
power transfer between lid and base to work properly).

Also, we need to record input_voltage in
charge_set_input_current_limit, even when lid battery is not
present (yet), otherwise the algorithm gets confused and believes
no power is available.

BRANCH=none
BUG=b:71881017
TEST=Boot lux from dead battery and base connected, lux does not
     attempt to drive OTG to the base.

Change-Id: I0cdd0956a82a724dbbf9c010760dcb956a58c1bf
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/874982
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-30 03:56:25 -08:00
Gwendal Grignou
051aebf5e0 sensors: Remove debug printf
Remove prints when activity triggers.

BUG=b:72533440
BRANCH=eve
TEST=compile

Change-Id: I047e14990ef734c35161293b9c5fbbece0ddab0c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/890632
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2018-01-29 16:38:26 -08:00
Nicolas Boichat
a954cecd3e charge_state_v2: Fetch static battery information when flags change
Instead of fetching static battery information all the time, we
first fetch the dynamic information, and see if the flags changed.
If they did, refetch the static information.

This also covers the cases when the base is disconnected/reconnected.

BRANCH=none
BUG=b:71881017
TEST=ectool battery 1 shows correct static battery information after
     plug/unplug.

Change-Id: I936983fc0fdc4dae0494e8a24f890927e30555dc
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/872813
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-29 05:24:48 -08:00