Commit Graph

5697 Commits

Author SHA1 Message Date
Vadim Bendebury
ea91c71c08 util: do not generate unrelated version information
The recent addition of the multicomponent version string for cr50,
requires further tweaking of the version generating script. In
particular, the CROS_EC_VERSION32 variable used by the "verson" cli
command is not supposed to include any information about subcomponents
of the image, it should reflect the EC version only.

Separating everything after the first space accomplishes that.

BRANCH=none
BUG=chrome-os-partner:55373
TEST=verified that RO_x and RW_x versions are printed properly:
  > vers
  Chip:    g cr50 B2
  Board:   0
  RO_A:    0.0.1/84e2dde7
  RO_B:  * 0.0.3/8fe06b9e
  RW_A:    cr50_v1.1.4992-7c9f891+ private
  RW_B:  * cr50_v1.1.4989-52b3cc6+
  ...

Change-Id: I192eb29816dfa963b08aa97f749b978b1367d6b7
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364490
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-29 21:37:54 -07:00
Shawn Nematbakhsh
d6c71d9031 Revert "charger: bd99955: Adjust VSYS based on fast vs precharge state"
This reverts commit 7369f0a689. Keep VSYS
constant throughout precharge / fastcharge.

BUG=chrome-os-partner:55524
BRANCH=None
TEST=Build only.

Change-Id: I35cda81b42833af2c860f35dd492ecb4f1e49025
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364625
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-29 21:37:51 -07:00
Vadim Bendebury
3d01f46a5b HACK tpm: reset fallback counter when ready
As a temp measure until a proper solution is implemented, reset the
restart counter when the PCR_Read command is issued by the host.

This is a good indication that Chrome OS is through the boot process,
as PCR value is used to determine the boot mode.

BRANCH=none
BUG=chrome-os-partner:55667
TEST=installed the new image on a Kevin cr50 and rebooted it in normal
     and recovery modes, observed on the cr50 console the message like
  > system_process_retry_counter:retry counter 1

Change-Id: Ib55e161d5edbf8f6e2d387fd756b94aa53c20ed8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364311
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-29 19:22:04 -07:00
li feng
17276a7a7e reef led: add battery led support
BUG=chrome-os-partner:55492
BRANCH=none
TEST=on Reef proto, verified led behavior on battery charing,
discharging cases

Change-Id: Ibc134b741e5c433697b752f73bd3e29ba5910124
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/364025
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-29 19:21:54 -07:00
Divya Sasidharan
7b0206a3a4 tcpm: anx74xx: Fix cable orientation detection
Aux switch settings set the polarity and this happens once on every
cable connect. But when the cable is kept connected if the mux is
set to 0 this is also reset and remains 0 for any next valid mux state.

BRANCH=ToT
BUG=chrome-os-partner:55757
TEST=manual:on reef, plug HDMI type-C dongle and check if DUT screen
    is displayed on HDMI display for both the orientation.

Change-Id: Ie1320d11d1927acb292dbaf4c932b48cdfd7768e
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/364693
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-29 15:02:45 -07:00
Daisuke Nojiri
b517067a41 cts: Add timer test
The timer test checks the accuracy of the internal timer. After sync,
DUT and TH start counting down one second. After one second, DUT raises
GPIO level.  TH determines whether the test passes or not based on how
much more or less time elapsed than one second, assuming its clock is
calibrated.

This test takes advantage of TH running on a bare chip. If the host
were measuring (instead of TH), the timing would be affected by many
software and hardware layers (e.g. UART drivers on DUT and host,
python interpreter, etc.).

BUG=chromium:624520
BRANCH=none
TEST=cts.py --module timer && cts.py --module gpio && make buildall

Change-Id: I535e7772b4d93f1f5d248506f7ea167429a50174
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361384
2016-07-29 15:02:44 -07:00
Shawn Nematbakhsh
4a72f8f607 npcx: shi: Improve host command handling reliability
- Pass-thru to IBF handler code in case both IBHF and IBF interrupts are
  pending, in order to properly keep track our Tx byte count.
- Don't disable the SHI IRQ in our host command handler callback since
  system-wide interrupts are already disabled.

BUG=chrome-os-partner:55711,chrome-os-partner:55721
BRANCH=None
TEST=Manual on gru with subsequent commit. Verify `flashrom -p ec -r
file.bin` passes 100x with no errors or warnings.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6225ffde1fe0127c7484933fe4a151d22f42415c
Reviewed-on: https://chromium-review.googlesource.com/364234
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-07-29 15:02:39 -07:00
Bill Richardson
6b808b90a9 g: lock the active bootloader, just in case
Whether the bootrom locks the bootloader or not is deteremined by
fuses and/or flags in the bootloader's signed header. This CL
locks the active bootloader, just case those aren't configured to
do so.

BUG=chrome-os-partner:55261
BRANCH=none
TEST=manual

On an unlocked bootloader, I see this after booting:

  > rw 0x40090100
  read 0x40090100 = 0x00000001

With this CL applied, I see this instead:

  > rw 0x40090100
  read 0x40090100 = 0x00000000

Change-Id: I2e1396b7d7e71c8633d97d3cb573e9468eeb51e7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364280
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-29 15:02:22 -07:00
David Hendricks
1d3e67cc31 reef: Update pins for EVT
Updates for EVT:
- TCPC0 interrupt polarity is now low, define GPIO_INT and set ANX74xx
  internal polarity control based on IS_PROTO.
- Swapped pin assignments for USB_C1_PD_INT_ODL and EN_USB_C1_5V_OUT.
- Rename USB_PD_RST_ODL to USB_C0_PD_RST_L and make it push-pull.
- Add USB_C1_PD_RST_ODL

BUG=chrome-os-partner:54958,chrome-os-partner:54952,chrome-os-partner:55165
BRANCH=none
TEST=needs testing

Change-Id: I075934cced532d656f942841c30e3640a6f42568
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/358944
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2016-07-29 15:01:59 -07:00
David Hendricks
9d2cb33fb1 reef: Check if interrupt is active in tcpc_alert_event
This ensures that we're only checking the reset signal for the
corresponding interrupt. Otherwise we can hit a race condition
when both TCPC chips are taken out of reset.

(This is also how it's done on Amenia)

BUG=none
BRANCH=none
TEST=needs testing

Change-Id: I47513b3b47e947c8b4644f4d837ddc3fb1ee7a30
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361061
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-29 15:01:58 -07:00
David Hendricks
854695981f reef: Initialize TCPC chips in their own function
This makes board_set_tcpc_power_mode() a noop since that's controlled
by anx74xx code and we have another TCPC chip onboard. Instead, we'll
reset the TCPC chips in a hook that will run after board and I2C init.

This is more like what Amenia code does.

BUG=chrome-os-partner:54952
BRANCH=none
TEST=needs testing.

Change-Id: Id3af4af1014432235b699a9568ee19df63601b2c
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361060
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-29 15:01:56 -07:00
CHLin
65a5e480d4 npcx: Consecutively sample IBUFSTAT until reading the same value twice
It has rare chance for FW to get a unexpected value when reading
IBUFSTAT. This is because the clock source of SHI and CPU are
asynchronous. The reading value is invalid if IBUFSTAT is during
transition state. Use two consecutive equal reading can make sure
the value is valid.

BUG=chrome-os-partner:34346
TEST=run "while true; do ectool version; done" on gru, verify each
failure happens about 50000 host commands
BRANCH=none

Change-Id: Ie246561d201dd87d89cb2424c23d016dcdcd47c9
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/362734
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: CH Lin <chlin56@nuvoton.com>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-07-29 10:51:34 -07:00
Daisuke Nojiri
d3d6814b2d printf: Add sign ('+') flag
'+' flag can be used with signed integer type (%d) and causes positive
integers to be prefixed with '+' (e.g. +1745). This emphasizes output
values as a signed value. It can be mixed with left-justification flag
'-': %-+8d. It's ignored when used with unsigned integer or non-integer
types: %u, %x, %p, %s, %c, etc.

BUG=none
BRANCH=none
TEST=make buildall &&
int32_t d = 1745;
CPRINTS("'%-+8d'", -d);     /* '-1745    ' */
CPRINTS("'%-+8d'", d);      /* '+1745    ' */
CPRINTS("'%d'", d);         /* '1745' */
CPRINTS("'%+08d'", -d);     /* '000-1745' */
CPRINTS("'%+08d'", d);      /* '000+1745' */
CPRINTS("'%+d'", -d);       /* '-1745' */
CPRINTS("'%+d'", d);        /* '+1745' */
CPRINTS("'%+s'", "foo");    /* 'foo' */
CPRINTS("'%-+8s'", "foo");  /* 'foo     ' */
CPRINTS("'%+08x'", d);      /* '000006d1' */
CPRINTS("'%+u'", d);        /* '1745' */

Change-Id: I8dcd34b0cf03dbefc500b9c98fea235d85bde8d3
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363924
2016-07-29 10:51:22 -07:00
Daisuke Nojiri
4e0c89c23a stm32l4: Enable extended interrupts (EXTI)
BUG=none
BRANCH=none
TEST=Validated by CTS timer test (up-coming)

Change-Id: I9c23e7dbfab779dc4e847fa5c9b93bee484e55e2
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363007
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Chris Chen <twothreecc@google.com>
2016-07-29 10:51:20 -07:00
Koro Chen
a1b8cda639 pd: tcpci: Fix tcpci_tcpm_set_vconn() to set bit0 (VCONN) only.
Previously, tcpci_tcpm_set_vconn() would set bit0 and clear all others
of POWER_CTRL. With this patch, only bit0 is updated.

BRANCH=oak
BUG=chrome-os-partner:55221
TEST=plug/unplug apple dongle, check TCPCI 0x1c bit4 should be always 1

Change-Id: I83f113c13bdaad8ce6ece56241296a8f097e1f0a
Signed-off-by: Koro Chen <koro.chen@mediatek.com>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/360771
Reviewed-by: Todd Broch <tbroch@chromium.org>
2016-07-29 07:03:17 -07:00
Vadim Bendebury
33bbf37d2a util: collect cr50 versions from multiple git trees
The cr50 code comes from four different repositories. This patch
introduces an array of the repositories where version information is
supposed to come from.

For all boards but cr50 this array includes just the local repository,
for cr50 the array is extended with the three other components.

This patch also allows to change the 'tree dirty' marker appended to
the sha1s of the 'dirty' trees, having a shorter marker helps to keep
multicomponent version strings shorter.

All external component's version information in the generated combined
version string is prepended by the component's root directory name.

BRANCH=ToT
BUG=chrome-os-partner:55373
TEST=ran the script for two EC boards, kevin and cr50, verified the
     output:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

then introduced some local changes in the ec and tpm2 directories and
ran the script again. Note the '+' used as the 'dirty' marker in the
cr50 string:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is dirty, using time of last compilation */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is dirty, using time of last compilation */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Change-Id: I4b4ec23ce003970c09442e8d8aeed2306d4e5dd8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363917
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2016-07-28 22:57:21 -07:00
Mary Ruthven
12f22933e3 cr50: fix usb spi to disable resets while doing updates
We need to ignore sys_rst_l right now when we use the usb spi endpoint
to update the AP or EC. We hold the EC and AP in reset and this causes
sys_rst_l to be asserted at the start of updating the AP and when the EC
comes out of reset.

Using the USB SPI endpoint may require doing a bunch of transactions
back to back. Cr50 should not reset itself between each one.

This change postpones the reset until we're done using the usb spi
endpoint. Once sys_rst_l just resets the TPM we can remove all of this.

BUG=chrome-os-partner:52366
BUG=chrome-os-partner:54982
BRANCH=none
TEST=manual
	verify 'util/flash_ec --board=kevin --raiden' updates the EC

	'sudo flashrom -p raiden_debug_spi:target=AP -w $IMG' updates
	the AP

	The AP and cr50 reset after usb_spi is disabled.

Change-Id: I68a76012bc7bf6d3abd073a70f0b90e440d72c49
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364051
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:20:51 -07:00
Vadim Bendebury
3531d6123b util: refactor getversion.sh
It is necessary to collect information about more then one git
repositories status for the cr50 board. To facilitate this, separate
the code retrieving build version information into a function,
get_tree_version().

The function returns a two element string, the version information and
the 'dirty' marker in case the tree has any uncommitted changes. The
0x01 character is used to join the elements of the string, which makes
it easier to split the string when processing it.

BRANCH=ToT
BUG=chrome-os-partner:55373
TEST=ran the script before and after changes, observed that generated
      output is identical.

Change-Id: I2c211cbda8c3cab3c8c21b4430e4b3102691e74a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362849
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:20:44 -07:00
Mary Ruthven
eb0660283d g: add wake pin info to pinmux command
It is useful to be able to see which pins are set as wake pins and what
type they are. This change adds prints to show_pinmux to describe the
wake pins.

BUG=none
BRANCH=none
TEST='pinmux' should show DIOA12 as a wake_low source.

Change-Id: I2a0ccdbf9b07abb627c3d52c7dd28433a2beff3c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363494
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:20:42 -07:00
Brian Norris
43b2f5bac6 kevin: invert accelerometer matrix
We have the lid and base sensors correct in relation to each other.
e.g., when at 90 degree lid angle, this reports correctly:

    # ectool motionsense lid_angle
    Lid angle: 90

But it appears that our axes are opposite from (e.g.) what Chrome
expects. With the lid angle at 180 degrees flat on a desk, I see:

    # ectool motionsense
    Motion sensing inactive
    Sensor 0: -571	1018	-16302
    Sensor 1: 0	0	0
    Sensor 2: 896	-3424	-16208

but the Z-axis should be positive. After this patch, I see:

    # ectool motionsense
    Motion sensing inactive
    Sensor 0: 580	-1000	16289
    Sensor 1: 0	0	0
    Sensor 2: -832	16368	1008

Which looks more accurate, and actually gets Chrome to rotate properly.

All tested on kevin rev3.

BRANCH=none
BUG=chrome-os-partner:55717
TEST=`ectool motionsense`, `ectool motionsense lid_angle`; also test
     rotation in Chrome

Change-Id: Ie1bffe27989c893d6037e251499f235ef10d4578
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364161
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-28 20:20:19 -07:00
Bill Richardson
dcf9d709df Cr50: Don't build native tests for this target
The ancient native tests can't deal with board-specific
configurations, don't build them. We run generic changes with
host tests and board-specific cases by running on real hardware.

BUG=chrome-os-partner:55705
BRANCH=none
TEST=make BOARD=cr50 tests; make buildall; test on Cr50 hardware

Change-Id: I5eb7229ca9df16293d6f0f84b474d4c992277baf
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363942
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-28 20:19:53 -07:00
Mary Ruthven
2f256ad698 cr50: fix wake pin handling when resuming from sleep
Cr50 was not waking up long enough after SPS_CS_L was asserted for the
spi slave transactions to start and disable sleep. It also was not
handling SYS_RST_L properly when it was asleep.

This change sets SPS_CS_L to be an edge triggered wake up source instead
of level triggered, because cr50 should just wake up on the edge and
disable sleep until the spi transaction is done.

It also adds sys_rst_l as a wakeup source. The sys_rst_asserted
interrupt cannot be triggered while cr50 is asleep, so the
pmu_wakeup_interrupt will call sys_rst_asserted if SYS_RST_L is low at
resume. This change relies on the EC extending the delay in
chipset_reset to be long enough for SYS_RST_L to still be asserted when
cr50 resumes.

BUG=chrome-os-partner:54331
BRANCH=none
TEST=manual
	make sure suzyq is disconnected.

	verify ap boots up to the kernel after running
	'gpioset SYS_RST_L 0' then 'gpioset SYS_RST_L 1' on the ec
	console.

	Check that cr50 goes to sleep when the AP is not trying to use
	the TPM.

	When cr50 is asleep pwrbtn + refresh still resets the system.

	Disable SYS_RST_L_IN as a wake source and verify the system
	verification fails and requests a recovery image.

Change-Id: I807b1918842d96c9d2922aa33404d87ab28b9906
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363606
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:19:51 -07:00
Mary Ruthven
893e1c0cb7 Reenable "Cr50: Set the default idle action to Sleep"
Cr50 sleep has been fixed so we can now set the default idle action to
sleep.

This reverts commit 734d834bec to add back
commit 9a644c429a.

BUG=chrome-os-partner:54331

Change-Id: I62edffe0823f6d49a50d8e3fbde3d16f075585c8
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363582
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:19:50 -07:00
Mary Ruthven
4b202194e9 kevin: increase the delay in chipset_reset
Cr50 has sys_rst_l as a wake source, but it can't tell which pin woke it
on resume. To know the source it has to check the value of the pin on
resume. This change makes the delay long enough for Cr50 to resume and
check that sys_rst_is asserted.

BUG=chrome-os-partner:55674
BUG=b:30308276
BRANCH=none
TEST=enable sleep on cr50 and verify apreset still reset it

Change-Id: I8e088c5f13a4222142161d8b79550dfc6eb529d6
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364170
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-28 20:19:48 -07:00
nagendra modadugu
c3fe992ed8 CR50: re-enable rsa 1024-bit keygen test
Re-enable the RSA 1024-bit keygen test, which
was fixed by change 76ab8e6f44.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
BUG=chrome-os-partner:53893
TEST=test/tpm_test/tpmtest.py passes

Change-Id: Id46bcf4ce4468928bd5256a5aadbf5b62419a6e1
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/364240
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 21:50:30 +00:00
Vincent Palatin
2300ecc611 kevin: reef: enable CCD provided by an external chip
The case close debug (CCD) feature is provided by the external security
chip. We add CONFIG_CASE_CLOSED_DEBUG_EXTERNAL to be able to detect debug
accessory with Rd/Rd (by setting Rp/Rp when VBUS is detected without
seeing Rp).

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

BRANCH=none
BUG=chrome-os-partner:55410
TEST=manual:on Kevin, plug a SuzyQ (with Rd/Rd) either in S5 or
transition the device to S5 afterwards and see the debug USB endpoint
works.

Change-Id: Icef4209470463be77d43f4a46e32769ebf58f558
Reviewed-on: https://chromium-review.googlesource.com/363401
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-27 02:03:51 -07:00
Vincent Palatin
c48408f0ba pd: support CCD provided by an external chip
When the case close debug (CCD) feature is provided by an external chip
(e.g security chip or TCPC), we still need to be able to detect debug
accessory with Rd/Rd (by setting Rp/Rp when VBUS is detected without
seeing Rp).
Add a CONFIG_CASE_CLOSED_DEBUG_EXTERNAL configuration parameter for this
case.

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

BRANCH=none
BUG=chrome-os-partner:55410
TEST=manual:on Kevin, enable CONFIG_CASE_CLOSED_DEBUG_EXTERNAL,
plug a SuzyQ (with Rd/Rd) and verify that the device in debug mode
when transitioning to S5.

Change-Id: Ie04a000a7b0eb670e3808f7bca1180298dfcd9db
Reviewed-on: https://chromium-review.googlesource.com/363400
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-27 02:03:49 -07:00
Shawn Nematbakhsh
e8a95db059 kevin: battery: Revive batteries in soft-disconnect state
ESC+F3+Power+AC removal puts the battery into a soft-disconnect state
where is stops supplying current. Revive batteries in this state by
supplying a precharge current.

BUG=chrome-os-partner:55617
BRANCH=None
TEST=Manual on kevin. Put battery into soft-disconnect state. Attach
charger and verify EC doesn't lose power and battery again supplies
current.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8dfcfa90c723d627636d9bebca48429b9f1106f7
Reviewed-on: https://chromium-review.googlesource.com/363004
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 23:55:10 -07:00
Shawn Nematbakhsh
4ffe42b427 rk3399: Start 'force shutdown' timer on initial power press
On a power press that will bring the system to S0, start our 8 sec
timeout in case the power button is never released.

BUG=chrome-os-partner:55666
BRANCH=None
TEST=Press and hold power button on kevin to bring device to S0, verify
device boots in normal mode and powers down ~8 seconds after initial
press.

Change-Id: I1cbb52974bcc09d23a130df13815cee07968467a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363592
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 19:42:47 -07:00
Chris Chen
7bd4984b01 cts: Added parsing for cts suites
Added test recording when calling reset from command
line. These results are printed on the screen and
saved in /tmp/results/<board>/<module>.txt

BRANCH=None
BUG=None
TEST=Manual
- Connect, build and flash boards
- Navigate to ec/cts
- ./cts.py --run
- Find test results /tmp/results/<board>/<module>.txt
- Tests names should be left aligned in one column
  and their results right aligned in a 2nd column

Change-Id: I3429d6092f2bd5d5f6825245f5439ace3f47f1fa
Reviewed-on: https://chromium-review.googlesource.com/360653
Commit-Ready: Chris Chen <twothreecc@google.com>
Tested-by: Chris Chen <twothreecc@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 19:42:33 -07:00
Shawn Nematbakhsh
93de085455 kevin / gru: Increase size of code RAM
Reduce size of UART Tx buffer to 1024 bytes on all npcx platforms and
increase size of code memory by 6K bytes on Kevin.

BUG=chrome-os-partner:52876
BRANCH=None
TEST=`make buildall -j` with subsequent commit.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib9e52a4406f84cfc434984f8819d7ef02b70beb4
Reviewed-on: https://chromium-review.googlesource.com/363591
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-26 17:32:31 -07:00
Scott
c358ee77a0 tcpm: fusb302: Changed get_cc to use full manual mode for revB
The FUSB302A had silicon limitation that required using its
autodetect logic when presenting as a SRC. While testing on
Kevin/Gru and connecting PD dongles, observed issues where
following successful connects, the USB PD state machine would
remain in SRC_DISCONNECTED state after removing the dongle.
Flipping the connector (to reverse polarity) will recover from
this stuck state.

In order to resolve this problem and to make the tcpm_get_cc()
FUSB302 driver function more consistent with the USB PD protocol
state machine while acting as a source, the autodetect feature
is now only used when a revA silicon device is detected.

If it's not revA, then full manual mode is utilized for tcpm_get_cc.
In addition, a new measure_cc_pin_source funciton was added
that consolidates the operations that are shared between both
autodetect and manual modes.

BUG=chrome-os-partner:55429
BRANCH=None
TEST=Manual
Connected display adapter dongles and TypeC hub dongle repeatedly
and verified that each connect attempt resulted in the USB PD
state machine getting to SRC_READY state. Never observed the
error state described above which previously could be repeated
within ~ < 10 connection attempts.

Change-Id: I3c8c6990129e0f1555a6698574adc603d6b7b45b
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361617
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Joe Bauman <joe.bauman@fairchildsemi.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-26 17:32:30 -07:00
Vadim Bendebury
7a9ba2bae9 cr50: process retry counter and act on it
A recent cr50 loader modification introduced a counter in a scratch
register which is incremented on every startup. The idea is that valid
RW would decrement the counter, signaling that the start was
successful.

Should the counter exceed the value of 5, the loader assumes that the
RW being started is not fit to run, and picks the older RW to run, if
available.

This patch adds a function to process the startup retry counter.

First of all the counter is zeroed, as this function is supposed to be
called only once the RW run is considered successful and reliable.

Then the current situation is examined. If the counter value read from
the scratch register exceeds 5 AND running image is not the newer of A
and B, it is considered an indication of a fallback from a bad newer
image.

To prevent the newer image from being considered a contender on the
following startups, its header is corrupted.

BRANCH=none
BUG=chrome-os-partner:55151, chrome-os-partner:55667

TEST=modified code for testing purposes, by adding a call to
    system_process_retry_counter() to tpm_task() after line 534, which
    would cause the new function to be called soon after boot.

    built a new image and installed it on the debug board. Then
    modified the image to throw an exception early in the boot up
    sequence, and installed it as a newer image on the debug board.

    Observed the debug board restart the new image several time and
    then fall back to the older image, printing the following on the
    console:

system_process_retry_counter:retry counter 7
corrupt_other_header: RW fallback must have happened, magic at 44000 before: ffffffff
corrupt_other_header: magic after: 0

   The following restarts start the older image without trying to run
   the failing newer image.

Change-Id: Ia7497401e38fe2c3957af910cf745e45da985245
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362776
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-26 17:32:02 -07:00
Daisuke Nojiri
b3b92f45fd cts: Move C flags to cts/build.mk
We should separate global Makefile from CTS stuff as much as possible.
This makes reading and chaging code simpler.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: If9e99e0e9b660707b1e22f2362bd6f782930dc09
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363006
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Chris Chen <twothreecc@google.com>
2016-07-26 15:16:46 -07:00
Shawn Nematbakhsh
136ca23afe kevin / gru: Add psys console command
Add `psys` console command for system power monitoring. Note that pmon
resistor / cap are not stuffed by default.

BUG=chrome-os-partner:55616
BRANCH=None
TEST=Verify `psys` command on kevin prints a result.

Change-Id: I9ac7b55ad30d0709624f94c27e173eb80f80a1ac
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363061
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-26 12:27:35 -07:00
Bill Richardson
20a6d75aee g: Improve version info for dual RO & RW images
The SoC looks for two RO images at reset, and is typically
configured for two RW images as well. This CL reports version
strings for all those images, as well as identifying the active
RO and RW copies.

Since the RO image doesn't contain a version string, we create
one using the epoch_, major_, minor_, and img_chk_ members of its
signed header.

BUG=chrome-os-partner:55558
BRANCH=none
TEST=make buildall; run on Cr50 hardware

The "version" command now includes information like this:

  RO_A:  * 0.0.2/a3c3d5ea
  RO_B:    0.0.2/8895c9eb
  RW_A:    cr50_v1.1.4965-a6c1c73-dirty
  RW_B:  * cr50_v1.1.4959-2f49d5c

The '*' indicates the active image.

The test/tpm_test/tpmtest.py program has been updated to request
the version information at startup, and it also now reports
similar information, just all on one line:

  RO_A:* 0.0.2/a3c3d5ea RO_B: 0.0.2/8895c9eb RW_A: cr50_v1.1 ...

The active images are marked with a '*' following the ':', so
that the same regexp can match either format:

  ($ro, $rw) = m/RO_[AB]:\s*\*\s+(\S+).*RW_[AB]:\s*\*\s+(\S+)/s;

Change-Id: Ic27e295d9122045b2ec5a638933924b65ecc8e43
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362861
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-26 12:27:33 -07:00
Shawn Nematbakhsh
0564276033 charge_manager: Treat soft-disconnected batteries as not present
For the purpose of spoofing dual-role capability, treat
soft-disconnected batteries as not present, since they are not capable
of supplying a current until they are revived.

BUG=chrome-os-partner:55617
BRANCH=None
TEST=Manual on kevin w/ subsequent CL. Put battery into soft-disconnect
state. Attach charger and verify EC doesn't lose power and battery again
supplies current.

Change-Id: Ie6b83b3d4e1e33c4bbbd1a90450506e7dcd1dfb2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363003
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-07-26 12:27:19 -07:00
Shawn Nematbakhsh
dd57786342 tcpm: fusb302: Set VCONN appropriately when enabled
VCONN must be enabled separately when a CC line is selected for
communication.

BUG=chrome-os-partner:55383
BRANCH=None
TEST=Manual on kevin. Insert DP dongle, verify we enter SRC_READY state.

Change-Id: I8bb8de2cb2faedcd7eafc931da7a0137b6b41018
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361530
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-07-25 21:02:05 -07:00
Vijay Hiremath
6b6a6fbca6 charge_state_v2: Add console command to test discharge on AC
Added support to test discharge on AC using console command.

BUG=chrome-os-partner:55572
BRANCH=none
TEST=Manually tested on Reef.
     "chgstate discharge on"  - Battery is discharging
     "chgstate discharge off" - Battery is charging

Change-Id: I07733fe28d22b0ad6e3bd172a445e43a60650762
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/362678
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-25 21:01:50 -07:00
Vijay Hiremath
4f75b9949a charge_state_v2: BD99955: Do not inhibit charge in battery learn mode
BD99955 charger auto exits from the battery learn mode if the charge
is inhibited. Hence, do not inhibit the charger in battery learn mode.

BUG=chrome-os-partner:55491
BRANCH=none
TEST=Manually tested on Reef using 'ectool chargecontrol' command.
     Able to enter/exit battery learn mode safely.

Change-Id: If05f9a9451842b77619e0a8c5db5e54fec24f399
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/362123
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-25 21:01:48 -07:00
Shawn Nematbakhsh
d4b6f8153d charger: bd99955: Remove incorrect VSYSVAL_THL / THH settings
VSYSVAL_THL / THH are high / low hysteresis values below which dead
battery condition is triggered, which doesn't match our register
configuration. Leave these regs at default for now until we better
understand the effect of dead battery detection.

BUG=chrome-os-partner:55626
BRANCH=None
TEST=Manual on kevin with other pending changes, verify dead battery
successfully charges.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I35a44dd0005f165f17073e8b0f2fd5dca1eda856
Reviewed-on: https://chromium-review.googlesource.com/363030
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-25 17:09:04 -07:00
Shawn Nematbakhsh
7369f0a689 charger: bd99955: Adjust VSYS based on fast vs precharge state
Rohm suggests setting VSYS to the higher value during precharge and only
setting it to the lower voltage after we have crossed the lower voltage.
Note that the VSYS register also controls the pre vs fastcharge
threshold, so setting VSYS to the lower voltage essentially enables
fastcharge.

BUG=chrome-os-partner:55524
BRANCH=None
TEST=Manual on kevin, verify dead battery is able to charge through
precharge to fastcharge.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ia5b953c8dfbb25970ab329d5487a317ad37ba609
Reviewed-on: https://chromium-review.googlesource.com/362442
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-25 17:09:02 -07:00
Bill Richardson
3a7d749f2c g: Remove unused GC_REVISION compile-time constant
This constant is not used anywhere, so we don't need to specify it.

BUG=none
BRANCH=none
TEST=buildall; try on Cr50

Change-Id: I82fef5d3172ec7d5a781405c8e66f74af49ed172
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362852
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-24 23:11:30 -07:00
Vadim Bendebury
913f149a3f g: report proper silicon version
There are two g chip versions in circulation currently, B1 and B2.
Make the 'version' command properly report it.

BRANCH=none
BUG=none
TEST=verified that both B1 and B2 report versions properly

Change-Id: I1c5b9f0da0170cda2c636b857e92b9d3de165422
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362643
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-24 19:33:00 -07:00
Vincent Palatin
d1fae75ba4 tpm: remove int_status variable
It doesn't seem to be used anywhere,
so let's remove it rather than having to re-initialize it.

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

BRANCH=none
BUG=chrome-os-partner:52366
TEST=make BOARD=cr50

Change-Id: I08175621fe26a4344ce1716a83ad4233531043a1
Reviewed-on: https://chromium-review.googlesource.com/361940
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-23 15:00:10 -07:00
Myles Watson
698777d4e3 include: Add HCI include files from NewBlue
Copied with permission from Dmitry Grinberg, the original author.

Add HCI_SUCCESS, some minor fixes.

BUG=None
BRANCH=None
TEST=None

Change-Id: Ia4f6f0d092674fca1297e94a16edbc14399d2c63
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362348
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-07-22 20:37:17 -07:00
nagendra modadugu
e819881b8c CR50: add endorsement certificate flow
This change implements logic for installing
endorsement certificates in the RW section.

The endorsement certificates are initially
provisioned in a fixed RO flash region and
are copied in the RW TPM data region (once
this region has been initialized).

Also add code for reading from the info bank,
which is where the endorsement seed is
initially stored.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
BUG=chrome-os-partner:50115
TEST=TCG tests running

Change-Id: Id8c16d399202eee4ac0c4e397bdd29641ff9d2f3
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/362402
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-23 02:18:49 +00:00
Myles Watson
c44ee5f93d nrf51: Make timer handling names more obvious
There are three timers, each with four capture/compare (CC)
registers.  The timer code uses 3 CC registers from one timer.

Use macros for the defines, so that it is more obvious which
timer and which register are being used.

TEST=make BOARD=hadoken
BRANCH=NONE
BUG=None

Change-Id: Icb058d9717800a87b394270eef38a3a744a13b7d
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361793
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-07-22 18:40:13 -07:00
Shawn Nematbakhsh
a11c8b0b14 hostcmd: Flush UART before doing cold reboot
Flush our UART buffer to ensure that we don't miss prints when we reboot
the EC.

BUG=chrome-os-partner:55539
BRANCH=None
TEST=Manual on kevin, issue cold reboot host command, verify that
"Executing host reboot command" is seen on console.

Change-Id: I96d5687b413ba4f603e3e7845b5cbba1c2d65efa
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362681
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-07-22 18:40:11 -07:00
Shawn Nematbakhsh
1f99b58bd3 kevin / gru: Warn users when incompatible GPIO config is used
Old kevin / gru boards are no longer supported by our current GPIO
configuration and must revert a CL to boot properly. Detect if old
boards are used with an incompatible config and warn users of this fact
by spamming the EC console and blinking the LED red.

BUG=chrome-os-partner:55561
BRANCH=None
TEST=Boot new kevin, verify no console spam or LED blinkage is seen. Verify
old kevin + old gru spam the console and blink LED.

Change-Id: I6d49720f760a6bef2bb3db6872857a5f61259e06
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362653
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-07-22 18:40:09 -07:00