Commit Graph

5726 Commits

Author SHA1 Message Date
Myles Watson
fc55bb5026 nrf51: Add Bluetooth LE test code for the radio
Implement support for Direct Test Modet packets.

BUG=None
BRANCH=None
CQ-DEPEND=CL:361960
TEST=use hci commands to send and receive test packets.

Change-Id: Idc12812fb88319ba6f8aad4396a175e3299211b8
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362143
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-08-03 19:40:45 -07:00
Myles Watson
8c7bdcd5b6 nrf51: Add Bluetooth LE support
RADIO_STATE is broken: remove it.
Build on the geneneric radio support to send and receive
Bluetooth LE packets.
Add macros in registers.h to configure PCNF0 and PCNF1.

BUG=None
BRANCH=None
TEST=Send advertisements with console commands
  ble_adv type length [interval_us]
  for example: ble_adv 2 8
  Advertisements should be received by other devices

  The Bluetooth Address has the form C5:A4:A3:A2:A1:A*
  The device name is a substring of ABCDEFGH...

  ABCDEFGH @ C5:A4:A3:A2:A1:A2 (name length is 8, type is 2)
  ABCDEFGH @ C5:A4:A3:A2:A1:A2 (name length is 8, type is 2)
  ABCDEF   @ C5:A4:A3:A2:A1:A6 (name length is 6, type is 6)
TEST=Listen for advertisements with console commands
  ble_adv_scan chan [num] [addr0]
  for example: ble_scan 37

  Example output:

  BLE packet @ 20000448: type 2, len 33,
  5c.f3.70.6b.65.d2 AdvA

  20000454: 02 01 08 17 09 43 68 72
  2000045c: 6f 6d 65 62 6f 78 20 66
  20000464: 6f 72 20 4d 65 65 74 69
  2000046c: 6e 46 16

  02 01 08 = 2 bytes, Flags, LE and BR capable
  17 09 43... = 23 bytes, Name, "Chromebox for Meetings"

Change-Id: I2bd3f1d87acb069da0b56c1d7878e7d4fd6a06f3
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361960
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-08-03 19:40:43 -07:00
David Hendricks
961f6d2d16 reef: Complain (loudly) if FW is built for wrong board
This adds a hook that will run every second and complain if the EC
firmware was built for the wrong board.

BUG=chrome-os-partner:54947
BRANCH=none
TEST=tested on proto and EVT units

Change-Id: I9799249f74f3cea9a3f6b66b2441af8f16be7e01
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365505
Reviewed-by: Martin Roth <martinroth@chromium.org>
2016-08-03 17:47:17 -07:00
Rachel Nancollas
ff3721e685 anx74xx: only enable SBU mux in DP mode
TEST=manual on reef
BRANCH=none
BUG=none

Change-Id: I714e40bab8400ffc0b1fef703e7aed1ce73739a4
Signed-off-by: Rachel Nancollas <rachelsn@google.com>
Reviewed-on: https://chromium-review.googlesource.com/360337
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-08-02 23:21:24 -07:00
Rachel Nancollas
299e44ac8b reef: 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:55858
BRANCH=None
TEST=Manual on reef. Put battery into soft-disconnect state. Attach
charger and verify EC doesn't lose power and battery again supplies
current.

Change-Id: I9a772bf02a8bd40edc1db51de66de135f7299212
Signed-off-by: Rachel Nancollas <rachelsn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365495
Commit-Ready: Rachel Nancollas <rachelsn@google.com>
Tested-by: Rachel Nancollas <rachelsn@google.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-08-02 23:20:50 -07:00
Nick Sanders
0152ba2c83 servo_v4: add usb-c gpio configs
Default to set DUT_CC1 to RD to enable USB and indicate
USB SS orientation. Add ADC entries for SBU detect.

BUG=chromium:571476
TEST=check that ADC maps to the right pins, check that usb3 initializes.
BRANCH=None

Change-Id: Ic9f7c6d1506b9ef83ed3b93a98516ab10b1a471c
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364301
Reviewed-by: Todd Broch <tbroch@chromium.org>
2016-08-02 23:20:49 -07:00
Myles Watson
ef137bdecc common: Add Bluetooth LE support
Add data structures, defines, and helper functions to parse
packets and implement frequency hopping.

BUG=None
BRANCH=None
TEST=None

Change-Id: I0f7a7d4bee55e00343f6f87f304fb2ba57cb6ec0
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362174
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-08-02 23:20:41 -07:00
David Hendricks
d173f84190 reef: Check PD reset level in tcpc_get_alert_status
Only report alert status if the PD chip is not being held in reset.

(idea borrowed from Amenia's implementation)

BUG=none
BRANCH=none
TEST=built and booted on reef

Change-Id: Ic637b1ab4e20527c806311a45c149b9ea5f64362
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/360020
Reviewed-by: Martin Roth <martinroth@chromium.org>
2016-08-02 23:20:36 -07:00
David Hendricks
218e7386e3 reef: Rail and PMIC init changes for newer boards
Proto brought up 5V, 3.3V, and PMIC very early in the EC boot process
due to dependencies in the power topology. This had some other side-
effects, for example, a lot of the power rails would already be up by
the time the EC got around to processing the power state machine thus
leaving it waiting for signal changes that were supposed to come
later but had already occurred instead.

This patch updates the nominal codepath for rail and PMIC init on EVT
while using IS_PROTO to retain the Proto sequence if desired.

BUG=chrome-os-partner:54962
BRANCH=none
TEST=built and booted on proto and evt boards with subsequent patches

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: If9ddd41044f132e719b0b7f0ab80ed908ddb1d9b
Reviewed-on: https://chromium-review.googlesource.com/358913
Reviewed-by: Martin Roth <martinroth@chromium.org>
2016-08-02 23:20:34 -07:00
David Hendricks
fdcec72d1a spi_flash: Remove unused write-protect ranges
This removes write-protect ranges that are unnecessary so
that we save a bit of space.

BUG=chromium:633431
BRANCH=none
TEST=compiled only.

Change-Id: Ib34c6a125b001fc92a21f795ac3d922e77143342
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365210
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-02 18:49:52 -07:00
Aseda Aboagye
f5ec39ee0f mkbp: Clear host interrupt if no more events.
BUG=chromium:633694
BRANCH=None
TEST=Flash kevin; verify that no more console spam is present on the EC.

Change-Id: I240fbe330952b82e2a5f97d0be7ebe4b2a8e2b46
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/365470
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-02 18:49:04 -07:00
Bill Richardson
18b18474fc Cr50: Tweak debug messages in extra/usb_updater/
Print the reply bytes, be more consistent between %d and %x.

BUG=none
BRANCH=none
TEST=manual

Build debug version, verify that it prints more stuff.

Change-Id: I8c8a983360f4895ccc72b73ed67ce2d45a461bad
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365120
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
2016-08-02 14:29:41 -07:00
Chris Zhong
e46b2e393a Kevin: support DP hot-plug
The kernel DP driver do not support hpd gpio detect, it use
EXTCON_DISP_DP cable state to decide power on/off DP PHY. Hence, do not
change GPIO_USB_DP_HPD level, but set or clear the TYPEC_MUX_DP when hpd
level changing in attention.

BUG=chrome-os-partner:52872
BRANCH=none
TEST=keep Type-C Dock inserted
1. plug HDMI cable, check with "ectool usbpdmuxinfo"
Port 0: USB DP
2. unplug HDMI cable, check with "ectool usbpdmuxinfo"
Port 0: USB

Change-Id: I369a92135bf0ca177e81eab6385980d51d863172
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/364401
Commit-Ready: Guenter Roeck <groeck@chromium.org>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-02 14:29:37 -07:00
Bill Richardson
3d7fe12257 tpm: TPM_FW_VER returns chip ID and board revision
The chip revision and board version show up on the second line of
the returned string, immediately before the build info.

BRANCH=none
BUG=chrome-os-partner:55558
TEST=Queried version string using tpm_test

make -C test/tpm_test && sudo ./test/tpm_test/tpmtest.py

Starting MPSSE at 800 kHz
Connected to device vid:did:rid of 1ae0:0028:00
RO_A:* 0.0.2/d0c9abe3 RO_B: 0.0.2/13eda43f RW_A: cr50_ [...]
B2:0 cr50_v1.1.5013-ab0e228+ [...]
^^^^

Change-Id: Iaa1efe5dca441aca24f281f76c1f218e24c844be
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365421
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
2016-08-02 14:29:36 -07:00
Shawn Nematbakhsh
25f19f5bbd shi: Enable SHI interrupt from CS interrupt
Enable the SHI interrupt only after we have received and begun
processing our host command. Disable the SHI interrupt once our
transaction is complete (with either success or error status). This will
prevent the SHI interrupt from being asserted at the same time as the CS
interrupt, which can lead to the SHI interrupt being serviced first.
Also, it avoids needless, non-useful SHI interrupts during error
transactions.

BUG=chrome-os-partner:55710,chrome-os-partner:55795
BRANCH=None
TEST=Manual on gru. Stress test flashrom w/ unpowered Donette attached
(for host command spam), verify no errors encountered after 100 minutes.

Change-Id: I0ab20b0202ebcfe15c04b272ec67001a6a358dad
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364698
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-08-02 14:29:27 -07:00
Myles Watson
c88b86852b nrf51: Add generic radio support
Add functions to initialize and disable the radio.
Add packet definitions.
Update the spelling of the FICR_OVERRIDEEN register.

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

Change-Id: I3a9e500d0f177b6ce77a3b6ed6a42acd4f49eb7e
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362175
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-08-02 12:17:10 -07:00
Shawn Nematbakhsh
0a1ab50bcf kevin / gru: Remove task profiling to improve SHI interrupt latency
BUG=chrome-os-partner:55710
BRANCH=None
TEST=Manual on gru with subsequent commit. Verify `flashrom -p ec -r
file.bin` passes 100x with no errors or warnings.

Change-Id: Id208ebc5d402518012f9adc10f86d8b4de5a35ce
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364235
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-01 22:20:35 -07:00
Shawn Nematbakhsh
8cda422254 gru: Align images sizes to flash block erase size
Image sizes must be aligned to block erase size to ensure that the host
can erase the entire image and nothing but the image.

BUG=chrome-os-partner:55828
BRANCH=None
TEST=Manual on kevin, rebuild FW with new EC, rebuild + flash EC once
again, verify that SW sync completes and unit boots to OS.

Change-Id: If6110f39869d6421038a3fe7afdc7d918323249e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365142
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-01 22:20:29 -07:00
Vadim Bendebury
7fbac79e94 tpm: make TPM_FW_VER register return both build and version strings
Both build string (which includes status of all firmware components of
the running image) and the firmware version string (which show
versions of various objects in the flash) are important to the user.

Let's include both of these strings into the TPM_FW_VER register
output. Buffer storing the string needs to be increased accordingly.

BRANCH=none
BUG=chrome-os-partner:55558
TEST=verified the contents of the AP firmware console log:

localhost ~ # grep cr50 /sys/firmware/log
Firmware version: RO_A: 0.0.1/84e2dde7 RO_B:* 0.0.2/13eda43f RW_A: ...
cr50_v1.1.5003-af11829+ private-cr51:v0.0.66-bd9a0fe tpm2:v0.0.259-8f3d735...

Change-Id: I67df3e810bd07053d0b7d8b6fac350253ca06bb0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364830
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-01 20:02:04 -07:00
Mary Ruthven
b4a9135ffc g: disable sps as a wake source in deep sleep
Cr50 cant retain the TPM state in deep sleep so it wont be enabled until
it knows that the AP is off. If the AP is off it wont be asserting
SPS_CS_L, but it may be low because the AP isn't pulling it up.
This change disables it as a wake source in deep sleep.

BUG=chrome-os-partner:54796
BRANCH=none
TEST=run 'idle d'. Make sure cr50 goes into deep sleep and only resumes
due to a rdd event or when sys_rst_l is asserted.

Change-Id: Idf3ded6b439b71a27ac7eb4682a65dcdd6342cb9
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364864
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-01 20:02:02 -07:00
David Hendricks
4b4baaf552 reef: Enable thermal sensors
BUG=chrome-os-partner:54818
BRANCH=none
TEST=field
CQ-DEPEND=CL:363008

Change-Id: I236e7e39f4d60e9bd758c387c93ac57e64868bf8
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/360722
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-01 20:01:50 -07:00
David Hendricks
201211f2dc thermistor: Add generic linear interpolation algorithm
The existing algorithm makes several assumptions for a particular
thermistor circuit. This patch introduces a more generic version
that can be used for multiple thermistors on a single board.

The idea is to approximate a curve produced by solving for voltage
measued by an ADC using the Steinhart-Hart equation. For a straight
line one only needs two data points. For a steady curve data
points can be distributed evenly. For the most part, though, data
points should be provided after a significant change in slope.

More data points give more accuracy at the expense of memory, and
we mostly only care about accuracy in the range between "warm"
and "too hot" so only a few data points should be used.

BUG=chrome-os-partner:54818
BRANCH=none
TEST=added unit test, needs real testing

Change-Id: I046e61dbfd1e8c26c2a533777f222f5413938556
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344781
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-01 20:01:49 -07:00
Vadim Bendebury
83b6d69732 g: increase usb console TX buffer size to 4K
Increasing the USB console TX buffer size allows to see pretty much
all early startup messages generated before USB console is
initialized.

There is still plenty of room left in SRAM, 23K on cr50, much more on
all other g based boards.

BRANCH=none
BUG=none
TEST=observed better USB console output on cr50 restarts.

Change-Id: I82f37ee7f3aecd8b7e95f3d421789c11375b2fd4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364811
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Nadim Taha <ntaha@chromium.org>
2016-08-01 13:45:00 -07:00
Brian Norris
c0a3f29b71 gru: support lid accelerometer
BRANCH=none
BUG=chrome-os-partner:55758
TEST=gru tablet mode

Change-Id: I4396f39da74f8ef409d4d335cdef92d2697f7421
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364842
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-01 13:44:42 -07:00
Vadim Bendebury
6b24cff09b tpm: allow TPM_FW_VER register to return arbitrary number of bytes
As the version string grows longer, reading it in 4 byte chunks
becomes more and more expensive, the overhead of setting up a separate
SPI transaction per very chunk is just too much.

There is no reason not to allow the host to read as many bytes at a
time as it requires (limiting it by the maximum version string buffer
size of course).

BRANCH=none
BUG=chrome-os-partner:55558
TEST=verified that the version string is still read properly by the
     TPM driver on Kevin

Change-Id: Ib76cd151e8dc32374f87135af36266b4ec725a56
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364831
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-01 13:44:28 -07:00
Vadim Bendebury
45e7be2213 g: use single buffer for version reporting
The only place where two separate buffers for the RO version strings
is required is the tpm_registers.c:set_version_string() function.

In preparation of reporting the build string along with the version
string, let's rearrange the function not to require separate buffers
for the RO versions.

BRANCH=none
BUG=chrome-os-partner:55558

TEST=verified that version reported by the TPM driver on Kevin is
     still correct:

  localhost ~ # grep cr50 /sys/firmware/log
  Firmware version: RO_A: 0.0.1/84e2dde7 RO_B:* 0.0.2/13eda43f RW_A:*...

Change-Id: I8924ac48bd838851670f0d659e95aa92a8524665
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364587
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-01 13:44:26 -07:00
Vadim Bendebury
ff8c0b129e system: split long build lines
Some boards now provide very long build version strings including
version strings of multiple subcomponents.

Let the version command split those long lines printing each
subcomponent's version string in a separate line.

BRANCH=none
BUG=chrome-os-partner:55373
TEST=verified on cr50:
  > vers
  Chip:    g cr50 B2
  Board:   0
  RO_A:    0.0.1/84e2dde7
  RO_B:  * 0.0.2/13eda43f
  RW_A:  * cr50_v1.1.4980-2b9f3e1
  RW_B:    cr50_v1.1.4979-8cec36d+
  Build:   cr50_v1.1.4980-2b9f3e1
           private-cr51:v0.0.66-bd9a0fe
           tpm2:v0.0.259-2b12863
           cryptoc:v0.0.4-5319e83
           2016-07-28 20:40:55 vbendeb@kvasha

Change-Id: Ie14af3aa9febd5a3b02b273a7ab6302e74777e43
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364491
2016-07-31 15:11:35 -07:00
Ravi Chandra Sadineni
78a875eadb separate dptf logic from existing thermal logic.
Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>

BRANCH=none
BUG=chromium:631848
TEST=make buildall -j

Change-Id: I718a29b067d37af477306f9bebfcb8e71d84d4ee
Reviewed-on: https://chromium-review.googlesource.com/363008
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2016-07-30 01:24:52 -07:00
Ravi Chandra Sadineni
bcb0de22a4 Use CONFIG_DPTF flag instead of THROTTLE_AP.
Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>

BRANCH=none
BUG=chromium:631848
TEST=make buildall -j
CQ-DEPEND=CL:363008

Change-Id: I3c35f5ab2e3a1537ac6e8c750171d5c2b3a6570f
Reviewed-on: https://chromium-review.googlesource.com/363583
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2016-07-30 01:24:50 -07:00
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