Commit Graph

6474 Commits

Author SHA1 Message Date
Mary Ruthven
1016bdfd11 cr50: add vendor command to invalidate inactive rw
This adds a vendor command to invalidate the old rw. It should be used
when the tpm has been validated.

BUG=chrome-os-partner:55667
BRANCH=none
TEST=manual
	run the vendor command

	run 'ver' on the cr50 console and verify the inactive RW version
	is Error

	reboot cr50 10 times and make sure there is no rollback.

Change-Id: Ibec3dde77d6b1ab921e43613d54638b7318f3f57
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/420407
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-16 20:56:44 -08:00
Duncan Laurie
34fa0064ce eve: Ignore VCC1_RST status bit when determining reset cause
The EC on Eve has VCC1_RST connected to 3.3DSW which drops when
resetting for recovery.

Since I need this to work on current boards treat Eve the same as
Wheatley and use the workaround that always reports reset-pin
instead of power-on status.

BUG=chrome-os-partner:61028
BRANCH=none
TEST=successfully enter recovery mode on eve with the keyboard

Change-Id: Ica583d9a95d78689ee1b21ccfa882fced2a414d9
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/421128
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-16 15:42:56 -08:00
Martin Roth
fd355c219f common/i2c.c: Check that i2c port is always 0 or greater
Previously, an assert was checking the port value after the
port value had been converted to the controller.  Instead, verify
that the value is not negative, and return if it is.

The if sequence generates much less code than the ASSERT, and protects
both paths.

Fixes coverity warning 141748: Negative array index read

42 files changed.
Total size change: -1248 bytes.
Average size change: -29 bytes.
These platforms increased in size:
lucid/RO/ec.RO.flat grew by 4 bytes: (64404 to 64408)
lucid/RW/ec.RW.flat grew by 20 bytes: (63996 to 64016)
pyro/RO/ec.RO.flat grew by 120 bytes: (131212 to 131332)
pyro/RW/ec.RW.flat grew by 144 bytes: (130764 to 130908)

TEST=Build
BUG=None
BRANCH=None

Change-Id: I8d39db04c4ca3194f99e17840365429ed2d39390
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/371401
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-12-16 15:42:47 -08:00
Martin Roth
e2409e3921 cr50: Initialize variable where it's used
The previous code split the initialization of digest_len
out into a separate area than were it was used.  This confused gcc
into thinking that the variable might be uninitialized when it was
used later.  By putting it all in one area, we save a couple of bytes
and make things more plain for the compiler.

This does not change the size of any ec.*.flat file.

BRANCH=none
BUG=none
TEST=build succeeds under GCC 4.9.2, 5.3 and 6.2

Change-Id: I1e21a13e3d7f9dc296296db6465ec975187a1cc0
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/411407
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-16 15:42:19 -08:00
Martin Roth
2584ccb1d2 spi_nor.c: Initialize variables to fix GCC warnings
Looking at these warnings, none of these are real issues, so just
initialize the variables to make GCC happy.  There might be a way to
rewrite the functions to make GCC be less confused, but I haven't
figured it out yet, and the solutions I tried generally ended up
increasing the binary size.

The function spi_nor_read_jedec_id() will initialize the variables or
return an error, so there isn't a path where they would be used without
initialization.

common/spi_nor.c: In function 'command_spi_nor_info':
common/spi_nor.c:771:3: error: 'mfn_id' may be used uninitialized in
this function [-Werror=maybe-uninitialized]
common/spi_nor.c:771:3: error: 'mfn_bank' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

The function spi_nor_device_discover_sfdp_page_size() will either set
these variables or return an error, so these should never actually be
uninitialized when they get used.

common/spi_nor.c: In function 'spi_nor_init':
common/spi_nor.c:449:30: error: 'capacity' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
common/spi_nor.c:450:31: error: 'page_size' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

This does not change the size of any ec.*.flat file.

BRANCH=none
BUG=none
TEST=build succeeds under GCC 4.9.2, 5.3, and 6.2

Change-Id: I6bbe73b4acf3dcbbaa03d9cbf1dcdfeb883c0a6d
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403503
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-16 15:42:18 -08:00
Martin Roth
ec5c396b47 i2cs.c: Initialize variable to fix GCC warnings
word_in_value shouldn't be able to be used without being initialized,
so just initialize it to make GCC 5.3 happy.  It's configured separately
in the (last_write_pointer & 3) and (!(last_write_pointer & 3)) paths,
so it can't actually slip through uninitialized.

There is probably a way to rwrite this that won't confuse GCC as much,
but I haven't found it yet.  The solutions I did try generally ended
up increasing the binary size, so I'm falling back to just initializing
the variable.

chip/g/i2cs.c: In function '_i2cs_write_complete_int':
chip/g/i2cs.c:178:19: error: 'word_in_value' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

This does not change the size of any ec.*.flat file.

BRANCH=none
BUG=none
TEST=build succeeds under GCC 4.9.2, 5.3 and 6.2

Change-Id: Iaf8641b3d252c494ad13fbeb8ad8ece3cdfe6e76
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403504
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-16 15:42:16 -08:00
Martin Roth
6354dc7cd1 make i2c_handle_sda_irq() static to fix GCC 5.3 warning
GCC 5.3 and 6.2 complain about the the i2c_irqs array being defined as
static because it's used by a non-static inline function.
Since i2c_handle_sda_irq is only used in the i2c.c file, it makes sense
to make it static.
Additionally, remove the inline keyword for i2c_handle_sda_irq since
it's a huge function, if it were used more than once, we wouldn't want
it to be inlined.

chip/npcx/i2c.c:462:22: error: 'i2c_irqs' is static but used in inline
function 'i2c_handle_sda_irq' which is not static [-Werror]
task_disable_irq(i2c_irqs[controller]);

npcx_evb/RW/ec.RW and npcx_evb_arm/RW/ec.RW.flat each shrank by 20 bytes.
npcx_evb/RO/ec.RO and npcx_evb_arm/RO/ec.RO.flat each shrank by 64 bytes

BUG=none
BRANCH=none
TEST=make buildall passes under GCC 4.9.2, 5.3 and 6.2

Change-Id: I79691bb57083fd925f9c4be06de706f676a1d043
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403502
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-16 15:42:14 -08:00
nagendra modadugu
f431441083 CR50: only build crypto test code on DEV builds
Avoid building and including crypto test code in
prod builds: only define CRYPTO_TEST_SETUP when
CR50_DEV is defined.

At HEAD, this change drops the size of prod ec.RW.bin
from 200704 to 188416.

BRANCH=none
BUG=chrome-os-partner:54104
TEST=build succeeds

Change-Id: I1e6018ec917dbe71cb445206ce232b8ea7a46cb1
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/418489
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2016-12-15 22:25:32 -08:00
Vijay Hiremath
3ca6ca9a12 reef: Do not discharge on AC when battery is still waking up
Reef discharges on AC till the charger is detected and settled but
when booting from the cut-off mode this will kill the power hence
do not discharge on AC when battery is still waking up and settled.

BUG=chrome-os-partner:60974
BRANCH=none
TEST=Reef can boot from cut-off mode to S0.

Change-Id: I34c5fd8df03a1e60736541c85627fbb18a6d56f7
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/420467
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-15 13:05:33 -08:00
Mulin Chao
f5da4daf8c npcx: lpc: clear EC_LPC_CMDR_BUSY status bit on init & LRESET asserted.
There's a small period between ec cleared EC_LPC_CMDR_BUSY status bit
for sysjump and executed notify hook function to let lpc driver disable
lpc's interrupts. If ec received a new host command in this period,
EC_LPC_CMDR_BUSY status bit has chance not to be cleared since ec
already jumped to the the other region. In case ec and host enter
dead-lock loop, we need to clear it on lpc_init().

Since HIPMnST only can be reset by core domain reset, it's better to
clear EC_LPC_CMDR_BUSY status bit when LRESET asserted. It makes host
can reset host command mechanism if something wrong.

BRANCH=none
BUG=chrome-os-partner:60928
TEST=make BOARD=reef; pass the tests mentioned in issue #60928

Change-Id: I08ac0515cb2cfee277a7c7704d131574d928fb6b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/419908
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-15 05:03:48 -08:00
Shawn Nematbakhsh
94d27d9779 tcpm: fusb302: Don't mistake meaningful packets for GOOD_CRC
If a partner port sends a packet at approximately the same time as we
send a packet, we may end up with the initial packet followed by the
GOOD_CRC reply in our HW FIFO. Don't automatically discard the first
packet in the FIFO. Instead, discard the packet only if it's a GOOD_CRC
packet. And, modify our get_message function to automatically discard
GOOD_CRC in search of a meaningful packet.

In addition, due to interrupt latency, we can't rely on receiving one
interrupt per incoming packet. If our Rx FIFO is non-empty, assume that
it contains at least one packet.

BUG=chrome-os-partner:60242
BRANCH=gru
TEST=Manual on kevin, attach Apple dongle with no inputs. Attach zinger,
verify we negotiate to ~20V. Repeat 10x and verify negotiation is
successful each time.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I7e4430fc2b7ed44b1aa4b561d72c8e1e964b245a
Reviewed-on: https://chromium-review.googlesource.com/414927
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 373f5dfd75e8ea5074d26fc6392eafe83de4f905)
Reviewed-on: https://chromium-review.googlesource.com/419186
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-14 20:14:38 -08:00
Duncan Laurie
8a8af6c10e eve: Increase keyscan output settle time to 80us
Increase the output settle time to 80us from the default 50us
to prevent duplicate keys.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=build and boot on eve

Change-Id: Ied1acef0b763b9a321f7fe36477eee6e467ce17f
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/419825
Commit-Ready: Duncan Laurie <dlaurie@google.com>
Tested-by: Duncan Laurie <dlaurie@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-12-14 20:14:36 -08:00
philipchen
4912f214aa i2c_passthru: fix virtual battery operation
In some cases, the virtual battery code creates
transactions that violate SB spec.

One example:
If the host command is structured as two messages -
a write to 0x03 (reg addr), followed by two bytes of write data,
the first byte of the second message (write data) will be sent to
virtual_battery_read(), as if it were a reg read request.

Let's do the following change for virtual battery:
1. Parse the command more carefully with state machines.
2. Support write caching for some critical registers.
3. Cache more attributes (0x03 and 0x0f).

BUG=chrome-os-partner:59239, chromium:659819
BRANCH=none
TEST='power_supply_info' works on kevin

Change-Id: Icdeb12b21f0dc3c329f29b206b7b9395ca4c9998
Reviewed-on: https://chromium-review.googlesource.com/407987
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-14 06:03:14 -08:00
nagendra modadugu
c648430a6d CR50: fix errors flagged by coverity
- Update SHA_DIGEST_MAX_BYTES to reflect SHA-512 support
- Fix unitialized variable error in tpm2/hash.c

BRANCH=none
BUG=none
CQ-DEPEND=CL:419327
TEST=make buildall succeeds

Change-Id: Ie002e5807d1e616da034dbb8896867572e148e00
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/419698
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-14 06:03:07 -08:00
Nicolas Boichat
dba4c11113 usb_pd_protocol: Force rediscovering identity on boot
This is useful with Apple's HDMI adapter, as the code that sends
the discovery message will also swap vconn as required.

BRANCH=none
BUG=chromium:644663
TEST=On elm, S5. Plug adapter with power+HDMI. Switch on elm,
     display works.

Change-Id: I21d47c69e2c7153a5d808dedcb1abe360ce3f5c0
Reviewed-on: https://chromium-review.googlesource.com/415698
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-14 06:02:56 -08:00
Nicolas Boichat
87e8cd6103 usb_pd_policy: Automatically swap vconn if adapter requests it
During discovery, if adapter requests vconn power in the AMA flags,
make sure that we provide vconn.

This, for example, is necessary for the Apple HDMI adapter to work
on boot, when connected in S5. In that case, adapter does request
vconn swap, but we reject that as the system is off, and, therefore
5V supply is off. On boot, we send another discovery request, which
will detect this case and swap the power.

BRANCH=none
BUG=chromium:644663
TEST=On elm, S5. Plug adapter with power+HDMI. Switch on elm,
     type "pd 0 vdm ident" in console, display works.

Change-Id: I55b6658c2bc0574b8427ae086f61daf03730a725
Reviewed-on: https://chromium-review.googlesource.com/415697
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-14 06:02:54 -08:00
Nicolas Boichat
a573d17be9 usb_pd_protocol: Rename PD_FLAGS_DATA_SWAPPED to _CHECK_IDENTITY
Rename the variable to actually tell us what it does (it sends a
Discover Identity command), instead of littering the code with
comments explaining why we set DATA_SWAPPED when the data roles
have not really been swapped.

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

Change-Id: Idbad38e48a55d6518ef82b32a4d96fee65264aae
Reviewed-on: https://chromium-review.googlesource.com/415696
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-14 06:02:53 -08:00
David.Huang
224466d3ac Basking: Add two support battery.
BRANCH=reef
BUG=chrome-os-partner:60899
TEST=Insert these two battery to check charge/discharge and cutoff normally.

Signed-off-by: David Huang <David.Huang@quantatw.com>

Change-Id: I14d9b7db5c9d36861952a2c724640e6906310ce4
Reviewed-on: https://chromium-review.googlesource.com/418565
Commit-Ready: David Huang <David.Huang@quantatw.com>
Tested-by: David Huang <David.Huang@quantatw.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-14 02:53:53 -08:00
li feng
e95ce7682e bmp280: handle divided by 0 case
In bmp280 driver bmp280_set_data_rate(), parameter rate may be 0

On reef ISH enabled board, this caused unhandled exception.

BUG=None
BRANCH=None
TEST=On reef ISH enabled board, verified barometer bmp280
sensor initialized succefully.

Change-Id: I7cdae8efbc618fca1551fd9fe809cb69ba0cee34
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/419744
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-14 02:53:50 -08:00
nagendra modadugu
c7ea2c9125 CR50: make SHA512 a config option
Turn SHA512 support into a config option so that
boards may individually enable SHA512 support.

BRANCH=none
BUG=chromium:673778
CQ-DEPEND=CL:419578
TEST=make buildall succeeds

Change-Id: Ib857a3e97f1c2ec7066ae23ac725c7bf3d194e01
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/419327
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-13 23:49:39 -08:00
Vijay Hiremath
d3e662bf77 reef: Discharge on AC till charger is detected
To avoid inrush current from the external charger, enable discharge
on AC till the new charger is detected and charge detect delay has
passed.

BUG=chrome-os-partner:60547
BRANCH=none
TEST=Multiple Ramp Resets and inrush current is not observed.

Change-Id: Ie3317fa6e6c2e8f00d4ce7cb9c6bee81c50d7bb2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/417168
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-13 21:21:58 -08:00
Vadim Bendebury
80d5601f39 cr50: prepare for releasing rw version 0.0.13
Which is coming soon.

BRANCH=none
BUG=none
TEST=built a new image, verified that its rw version is 0.0.13

Change-Id: I7a8b2497078f67393df93181d29cfde905d20ba6
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/419182
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-12-13 17:51:37 -08:00
Daisuke Nojiri
b7a425e0d0 reef/electro: modify keyboard scan rate
(from CL:415672)

Slow the keyboard scan rate from 50 us to 80 us. This compensates the
additional delay added to the KBO line by Silego / H1.

BUG=chrome-os-partner:60335,chrome-os-partner:60615
BRANCH=reef
TEST=check press key "f3" then system only output "f3" scan code.

Change-Id: Icaa8f040c20f72b1fa1c9260f86b29da8c69ec2b
Reviewed-on: https://chromium-review.googlesource.com/419577
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-13 17:51:33 -08:00
Duncan Laurie
aff701c574 eve: Use ternary encoding for board version
The Eve board version will use Hi-Z to get 3 values out of
each bit in the version.  In order to support this read each
strap and determine the ternary encoding.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=ensure P0 reports 0 and P1 reports 1, test with an unused
GPIO to ensure that a tristate pin will also be read properly.

Change-Id: Ib1f569e2b06bed0995eb70f24c90533cbccb0fb8
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418978
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:53 -08:00
Duncan Laurie
fffc34706d eve: Set KBD_KS02 to pull-down when hibernating
cr50 has an internal pull-down on this pin so the EC should match it
to prevent leakage.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=build and boot on eve and verify hibernate enter/exit

Change-Id: I3eba0661211d356783c0c710f0d7d5fe11fd6c26
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/415225
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:52 -08:00
Duncan Laurie
bd237603ce eve: Enable TCPC controlled DRP toggle
BUG=chrome-os-partner:58666
BRANCH=none
TEST=build and boot on eve

Change-Id: I72a62dbcf75f9c81c41fbc5775537005fdcf563e
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414543
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:50 -08:00
Duncan Laurie
71a87324f3 eve; Enable BD9995X power save mode when hibernated
Turn off the charger BGATE when the system is hibernated to
save maximum power.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=build and boot on eve P0 and enter hibernate

Change-Id: I8c694789276cf4e50e32e6fe0956a3743380ca3a
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414542
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:48 -08:00
Duncan Laurie
2240466ede eve: clear HPD bit in board level TCPC init
If keeping HDMI/DP Type-C cable connected doing sysjump sets
HPD signal to high while it is already high from previous state,
so the SOC does not see a pulse.  Manually set it low so it will
be asserted high again to send a pulse to the SOC.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=connect HDMI dongle, boot with EC SW sync enabled and see
that the display is still working in the OS.

Change-Id: I7b6ea24880bf4a0c44f7c92d9173372404d3fc4b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414541
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:47 -08:00
Duncan Laurie
6be6411c16 eve: Enable IMVP8 workaround for P0b
Enable the core VR workaround for P0b boards as well as P0.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=build and boot on eve P0

Change-Id: I02df92567d458305ab39d9fa7b1b4efc04d02a45
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414540
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-13 11:50:45 -08:00
nagendra modadugu
0bb18fbaac CR50: add support for SHA-384 & 512
This change adds the plumbing for SHA-384 & 512.
The actual hash implementation is software only,
and a part of the third_party/cryptoc library.

BRANCH=none
BUG=none
CQ-DEPEND=CL:418263
TEST=TCG tests pass

Change-Id: Iba7e6d420fd7fa0bce4ad9061e00f9275ecf4d72
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/417888
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2016-12-12 23:28:20 -08:00
Vadim Bendebury
995c6b6985 cr50: reduce UART TX buffer size
As we are getting short on SRAM and do not need that extensive UART
debugging support, let's reduce the UART TX buffer size to a standard
value of 512 bytes.

BRANCH=none
BUG=chrome-os-partner:58961
TEST=built and booted a new image. Verified that the cr50 console
     connection is still operational.

Change-Id: Ieb77671cb144b9ea5073f5d3242c9e41e5d78883
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418948
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-12-12 21:03:39 -08:00
Vadim Bendebury
ac4c3020de g: tweak cflush() to wait a bit longer
It turns out that even when the UART status register returns TX_IDLE
bit set, the transmitter is still active - probably working out the
stop sequence.

So, resetting immediately after TX_EMPTY is asserted causes the last
character to be corrupted on the receiving side.

This patch adds a wait for the duration of transmitting 10 bits at
115200 baud, which should be plenty. Wait loop in capped in case timer
is not running for any reason.

BRANCH=none
BUG=chrome-os-partner:60321
TEST=added code to print out a string and then call cflush() and reset
     immediately. The last character is not lost any more, the exact
     string is printed.

Change-Id: If386c515d9d9cc63d161fba73e6ed4e70e465136
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418487
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-12-12 21:03:37 -08:00
Gwendal Grignou
e2e875c566 driver: bmi160: Add temperature sensor
Allow BMI160 to report temperature like other device with a temperature
sensor.
Temparature is returned in K. Although BMI160 resolution is 9bits per
degree, we round to the nearest degree.

BUG=chrome-os-partner:58894
BRANCH=reef
TEST=After enabling sensor on Reef, check we can measure the temperature
with EC console commands temp or from user space with 'ectool temps 3'
Check 'ectool tempsinfo 3' returns valid data:
Sensor name: Gyro
Sensor type: 1

Change-Id: Ib48f988e078cdee1dfbc05b23df806bd4eb09931
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/416297
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-12 18:34:34 -08:00
li feng
f50b1cec17 ish: correct i2c write operation buffer size
ISH i2c write operation failed due to wrong buffer size passed.

BUG=None
BRANCH=None
TEST=On reef ISH enabled board, verified sensor i2c read/write are
successful.

Change-Id: Icda625ad16e1e60832bb22e3148e23fcb8e6a937
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/418876
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-12 18:34:32 -08:00
Mary Ruthven
1b5bb68b8b g: remove the impact of deep sleep resumes from the rolling reboot count
Deep sleep needs to be considered a normal behavior and should not add
to the rollback count. This change subtracts one from the reset count
when the system sees that it just resumed from deep sleep.

Ideally the rollback counter would be able to verify the TPM
functionality and detect rolling reboots. With this change the rollback
counter will only be able to detect rolling reboots, but it fixes the
false positives for rolling reboots we were seeing before.

BUG=chrome-os-partner:60449
BRANCH=none
TEST=manual
	check the reset counter

	turn off the AP

	wait for cr50 to enter deep sleep

	plug in suzyq

	check it resumes from deep sleep and that the reset counter
	still has the same value

Change-Id: Ie8490c29636403b409b2a3f0912a5b312d23bc24
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418321
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-09 21:48:46 -08:00
Bruce
b19c81b0b6 pyro/snappy: ensure tablet mode state is correct at startup
Follow reef setting.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I953f5380820c1ff94be7d4dbf70ff744dfbf8f10
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/418597
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-09 14:37:21 -08:00
Mary Ruthven
f74c136a17 cr50: change uart rx to wake_low
Having cr50 resume on the falling edge of its uart rx signal is causing
some issues, and wake on low is good enough and works fine. This change
switches uart rx from DIO_WAKE_FALLING to DIO_WAKE_LOW

BUG=chrome-os-partner:60449
BRANCH=none
TEST=cr50 can still resume on uart activity and plugging in the charger
has no impact on cr50 remaining in deep sleep.

Change-Id: If77126cb64cf2fa949a75d53bb40098f037a2aa4
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/418335
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-08 22:47:19 -08:00
Nicolas Boichat
9d7d189450 usb_pd_protocol: tcpm_get_message: Check return value
We currently rely on *head == 0 as error condition, which is
fragile and inconsistent across TCPCs implementations.

Instead, let's return a proper return value on all implementations.

BRANCH=none
BUG=chrome-os-partner:60575
TEST=elm FW as of 65fb80d (later version include a fix that would
     hide this issue), cherry-pick this patch, connect j5create
     adapter, then HDMI, then power => no crash

Change-Id: If7235e0491e9f80fdd50ce2605477ee518f8e1aa
Reviewed-on: https://chromium-review.googlesource.com/417443
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-08 22:47:02 -08:00
Nicolas Boichat
0d5562fa73 tcpci_tcpm_get_message: TCPC_REG_RX_BYTE_CNT includes header
From TCPC spec:
"""
RECEIVE_BYTE_COUNT: Indicates number of bytes in this register
that are not stale. The TCPM should read the first RECEIVE_BYTE_COUNT
bytes in this register. This is the number of bytes in the
RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and
RX_BUF_HEADER).
"""

We were always reading 3 bytes too many. This is an issue if we
receive a packet followed by a hard reset, as the register value
will be set back to 0, but TCPC_REG_RX_HDR may contain a valid
header, leading to corrupted packets being passed down the stack.

Also update usb_pd_tcpc to match the specification.

BRANCH=none
BUG=chrome-os-partner:60575
TEST=elm FW as of 65fb80d (later version include a fix that would
     hide this issue), cherry-pick this patch, connect j5create
     adapter, then HDMI, then power => no crash

Change-Id: I9ed8f3b500d5733ec7563e31246505e0b8bd48bb
Reviewed-on: https://chromium-review.googlesource.com/417442
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-08 22:47:00 -08:00
Mary Ruthven
c7559d4d23 g: make sure usb clocks are enabled before going to deep sleep
This change adds a usb clock enable before trying to write to the usb
registers when preparing for deep sleep.

It is possible that usb has not been initialized, so we need to make
sure that the clock is enabled.

BUG=chrome-os-partner:60555
BRANCH=none
TEST=manual, on both dev and prod fused H1
	run hibernate on the EC

	wait until cr50 enters deep sleep

	plug/unplug the charger

	verify the AP can boot to the kernel

Change-Id: I26359f4224cd25dc57c32d1508e26b133c43d317
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/417771
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-08 19:50:33 -08:00
Carl Hamilton
097c2bb04c Cr50: Ensure that trng.h is self-contained.
* Include trng.h from trng.c before any other header to verify that the
  header is self-contained.

* Add inclusion of stdint.h to trng.h to provide definition for uint32_t.

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

Change-Id: I78fb6d915c357236ca0fed2a57f093f0eec07fe9
Reviewed-on: https://chromium-review.googlesource.com/417424
Commit-Ready: Carl Hamilton <carlh@chromium.org>
Tested-by: Carl Hamilton <carlh@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-12-08 19:49:53 -08:00
Bruce
80121352b0 pyro/snappy: Disable keyboard and trackpad in tablet mode
(Original CL: https://chromium-review.googlesource.com/#/c/411395/)

Enabling/Dislabling keyboard and touchpad is required to prevent EC
from waking up the system from S3 in tablet mode.

This change disables the keyboard and the trackpad when the lid goes
beyond 180 degree.

Keyboard and touchpad are also enabled/disabled by the tablet switch.
When the lid reaches 360 position, keyboard and touchpad are disabled.
And they stay disabled as long as the lid stays at 360 position.
This prevents keyboard and touchpad from turning on by the (faulty) lid
angle calculation.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I919f44bae4a13aa4d9e6072e96e46bb90c08ec22
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/417643
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-08 16:38:36 -08:00
Mary Ruthven
0175c4b812 g: change default idle behavior based on bus obfuscation availability
Set the default idle action based on whether bus obfuscation is enabled.

BUG=none
BRANCH=none
TEST=verify the idle default is sleep on b1 boards and wfi on b2.
     Verify that both types of chips go to sleep and resume
     successfully.

Change-Id: Ib5a11c4060aa411ff36c06c7fcadf0bf4c223bf1
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410167
2016-12-08 16:38:34 -08:00
Bruce
b65e2a895a pyro/snappy: BD9995X: Suspend DC-DC converter when discharging on AC
When the battery is fully charged or not charging, upon removal of
the AC, discharge takes long time. To overcome this issue suspend
the DC-DC converter when discharging on AC.
(Refers Reef CL:413153)

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Iebfcb95d0469be552283d17eb1aea0310eccbcb9
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/417428
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-08 16:38:32 -08:00
CHLin
a0f1cda901 npcx: lpc: Fix KB malfunction after power-key off and then on
The original thought of setting LRESET_PLTRST_MODE to 1 is to remove the
need to reinitialize host module registers whenever LRESET# occurs in
order to save time when boot-up.

However, some of these registers will be reset by core domain reset. It
means every time LRESET is de-asserted, we need to initialize the host
setting again. Therefore, setting LRESET_PLTRST_MODE to 1 is unnecessary
and sometimes dangerous. If BIOS believes LRESET will reset ec's host
state machine to default but ec not, it will cause unexpected behavior.

Modified drivers:
1. lpc.c: allow LRESET/PLTRST generate host domain reset

BUG=chrome-os-partner:60211
BRANCH:none
TEST=make buildall. run "dut-control pwr_button:press; sleep 11; dut-control
pwr_button:release; sleep 7; dut-control pwr_button:press; sleep 1;
dut-control pwr_button:release". Verify keyboard works normally.

Change-Id: I94d428cde69f828468547c44844983f25686ea04
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/417745
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-12-08 16:38:27 -08:00
Aseda Aboagye
11be87540b kevin: gru: Don't disable trackpad in tablet mode.
Apparently, one does not simply remove power from the trackpad and
restore it at will; the kernel needs to be involved and decide if the
device needs to be fully reinitialized, or if it was supposed to keep
some state.  Therefore, let's not touch it except from startup and
shutdown and let the higher parts of the stack make the necessary
decisions.

BUG=chrome-os-partner:60478
BRANCH=gru
TEST=Boot in tablet mode and verify trackpad still works.
TEST=Go from clamshell to tablet mode and verify trackpad still works in
both modes.

Change-Id: I7674c5516ce4d237b0d2a15fb94b47e6fbe3ba39
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/417110
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-12-08 12:33:03 -08:00
Vadim Bendebury
e4250052a7 cr50: update minor versions to 12
In preparation to a new release let's bump up minor versions of both
prod and dev images to 12.

BRANCH=none
BUG=none
TEST=built images and verified version number

Change-Id: I55979374f5e3e21fedde128410c4861e4c2ad9c4
Reviewed-on: https://chromium-review.googlesource.com/417883
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2016-12-08 12:32:45 -08:00
Shawn Nematbakhsh
6f8f51012e npcx: watchdog: Log PC on watchdog from exception context
If we watchdog while in exception context, our process PC is not very
useful. Log the actual watchdog PC as our SW panic param, stored in R5.

BUG=chrome-os-partner:60470
BRANCH=gru
TEST=Add "while(1);" in ISR, wait for watchdog, check with 'panicinfo'
that saved R5 is our watchdog PC.

Change-Id: Idbdf1bc3507cc88e7a944c7bbe24ed87a6720eea
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/417061
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 2404a5e7bff4bed278b22260513132a985fa4004)
Reviewed-on: https://chromium-review.googlesource.com/417113
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-08 12:32:41 -08:00
Vijay Hiremath
f62bec5792 BD9995X: Disable input current limitation for all types of chargers
Charger Operation Control Setting 1 (CHGOP_SET1) has separate bits to
disable input current limitation for DCP, SDP, others. If it is not
disabled, input current is automatically selected, which results in
hard resets on weak chargers hence disable the input current
limitation for all types of chargers.

BUG=chrome-os-partner:60722
BRANCH=none
TEST=Tested on Reef. Input current is not automatically set to all
     types of chargers.

Change-Id: Ideb16ac2a40b403c94c28e85f254043ead7415e0
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/417234
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-08 12:32:38 -08:00
Shawn Nematbakhsh
a0bfd989d1 npcx: hwtimer: Fix deadlock close to hwtimer wrap
__hw_clock_event_set() is not reentrant and may be called from both our
event timer ISR and our hwtimer ISR when hwtimer is close to wrapping.
Modify the interrupt priority of our hwtimer int to match our event
timer int so that one cannot preempt the other. Originally the priority
was changed to allow the hwtimer ISR to run first in case both are
pending, but this condition can be handled cleanly and isn't a big
concern.

BUG=chrome-os-partner:60470
BRANCH=gru
TEST=Pass 500 S/R cycles on kevin with hwtimer wrap rate sped up 300x
(roughly equivalent to 150,000 real S/R cycles).

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ied466f14661f04c8662b5db709c0e3770a5bb200
Reviewed-on: https://chromium-review.googlesource.com/417060
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit ac28ec53b63a02c4d25e8a222d13595bc857fef0)
Reviewed-on: https://chromium-review.googlesource.com/417112
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-08 12:32:31 -08:00