Commit Graph

6402 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
ee005bd0a1 mkbp: Always keep memmap host event mask up-to-date
Keep the memmap copy of the host event mask up-to-date, in case it ever
gets used.

BUG=chrome-os-partner:59241
BRANCH=gru
TEST=None

Change-Id: I482a3344242ff0e744292ffd2ad8eff3a4628c74
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407124
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/415495
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:59:04 -08:00
Shawn Nematbakhsh
3a3834ab34 kevin / gru: Add custom charge profile
- Stop charging when thermal limits are violated.
- Don't start charging if battery percent is above 95% (but continue to
  charge if we're already charging).
- Don't allow battery voltage to get too close (10mA) to BD9995X VBAT
  setting. If battery voltage exceeds VBAT then back boosting may occur.

BUG=chrome-os-partner:56255
BRANCH=gru
TEST=Manual on kevin, insert charger with battery at 97%, verify battery
doesn't charge and reported current is 0. Discharge down to 95% and
insert charger, verify battery charges. Charge to 100%, verify battery
stops requesting current.

Change-Id: Icc5641e88bfad7d9d8ad4b6840338541fe7ba9a8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403483
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/415494
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:59:03 -08:00
Shawn Nematbakhsh
5602f4d515 i2c: Lock out i2c passthru except for desired ports
Lock out all non-essential i2c passthru ports when system is protected.

BUG=chrome-os-partner:58859
BRANCH=gru
TEST='ectool i2cxfer 0 0 0 0' on locked system, verify that "ACCESS
DENIED" is returned.

Change-Id: If4119bbb319aa491d0e79a9ed80c94daa7950c2f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403543
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
(cherry picked from commit d29fdb5484b994937c6586a50dd2818028f15f3f)
Reviewed-on: https://chromium-review.googlesource.com/415493
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:59:01 -08:00
Shawn Nematbakhsh
2c1626eb45 pd: Whitelist port after receiving IDENT response
Making dual-role determination after receiving source caps is not
sufficient, since we may not yet have identified the partner port.

BUG=chrome-os-partner:56966
BRANCH=gru
TEST=Attach 'old' Apple USB-C accessory to kevin, attach OEM charger to
accessory, run 'pd X hard', verify device charges from port.

Change-Id: I7333dd2c723e7245d30cf8a6cb1344e60073c063
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403118
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 09691a0e8dd93383fa76b74332d89707bfe16001)
Reviewed-on: https://chromium-review.googlesource.com/415492
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:59 -08:00
Shawn Nematbakhsh
efacd6b4eb kevin / gru: Enable Try.SRC
BUG=None
TEST=Manual on kevin, attach Ryu and verify kevin always goes to source
role initially.
BRANCH=gru

Change-Id: Ic8b138a4f6e7c651cd0834151354631885fb116d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403116
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 1e51ee7f23f9e9d6c5a089116a62136aaa0b4a72)
Reviewed-on: https://chromium-review.googlesource.com/415491
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:58 -08:00
Shawn Nematbakhsh
a9e329864f tcpm: fusb302: Fix BIST mode
Upon request, enter BIST mode 2 (alternating 1/0 output pattern) for
50ms.

BUG=chrome-os-partner:58282
BRANCH=gru
TEST=Verify compliance test runs on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie284066eb2fb54d1c567b516670d8bd966dc9a30
Reviewed-on: https://chromium-review.googlesource.com/401700
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 6686ed576ef9ad5134622f9267f4a1a90b1fac85)
Reviewed-on: https://chromium-review.googlesource.com/415490
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:56 -08:00
Shawn Nematbakhsh
0701e32446 power: rk3399: Wake from S3 on power button press rather than shutdown
BUG=chrome-os-partner:58599
BRANCH=gru
TEST=Boot kevin, go to S3, verify power button wakes. Hold power button
in S3, verify device wakes and then shuts down. Go to S3, close lid,
press power button, and verify no wake occurs.

Change-Id: I4fa2e4967babc18cea9b5ffc7cec264b6f2fa8e3
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399518
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
(cherry picked from commit 97bdf83b41834c072c5d1be516c8186c7911cee3)
Reviewed-on: https://chromium-review.googlesource.com/415489
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:55 -08:00
Shawn Nematbakhsh
87f871d1ae kevin: Bump PDCMD task stack size
BUG=chrome-os-partner:58480
TEST=Stress test dongle attach + detach, verify stack overflow
does not occur.
BRANCH=gru

Change-Id: I7bfddd286f92654081061cbc0d9bbee989f57e49
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/397700
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit e5d93b8001913a92250b70243379c73439691a27)
Reviewed-on: https://chromium-review.googlesource.com/415488
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:53 -08:00
Shawn Nematbakhsh
f5f3bcfe57 tcpm: fusb302: Remove dead rev.A code
Auto-toggle isn't used on rev. >= B so remove related dead code, and fix
VCONN setting on Rp selection.t

BUG=None.
TEST=Verify charging + DP dongles still work properly on Kevin.
BRANCH=gru.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2ce98760d3435a5721831864f8ea241151b5a54d
Reviewed-on: https://chromium-review.googlesource.com/397658
(cherry picked from commit 4d42d16fe97d35d1d9ea6200f2343934bba4341e)
Reviewed-on: https://chromium-review.googlesource.com/415487
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:52 -08:00
Shawn Nematbakhsh
81d32b8106 power: rk3399: Use longer SYS_RST hold time on chipset reset
BUG=chrome-os-partner:57990
BRANCH=gru
TEST=On kevin, verify `apreset` and kernel panic cause successful AP
reset.

Change-Id: Ic5ad2fd2d2d08ae32a60314e30f4cdff061da164
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/395533
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 8fb0dedd8daebeca3757bc341d0a5355d3b26ba5)
Reviewed-on: https://chromium-review.googlesource.com/396136
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:50 -08:00
Shawn Nematbakhsh
6598f08930 tcpm: fusb302: Always take hard reset actions when M_HARDSENT received
After sending a hard reset through Control3 SEND_HARD_RESET, packet Tx
will fail until PD_RESET is triggered. Therefore, always do such a reset
when we see an M_HARDSENT interrupt. Previously, it may have been possible
to skip our reset depending on prior Tx packet status, leaving the TCPC
in a wedged state.

BUG=chrome-os-partner:58232
TEST=Manual on kevin, spam 'pd 0 hard' for 10 hours with zinger attached,
verify TCPC is still responsive and negotiating to 20V.
BRANCH=gru.

Change-Id: I42db792a5f51218c58235dc38c2d49795b54986e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/393769
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 811534541c263244d2fe9bdf9465de196e1575da)
Reviewed-on: https://chromium-review.googlesource.com/415486
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:49 -08:00
Sam Hurst
18cce61081 kevin / gru: Disable USB PD communication in RO mode
When the EC is running in RO mode (ie for recovery), disable USB PD
communication (just use the type-C resistor to 5V/1.5A or 5V/3A)
in order to minimize the attack surface.

BUG=chrome-os-partner:49744
BRANCH=none
TEST=Manuel
In system.c, initialized static int force_locked to 1
> reboot ap-off
> chgsup
port=1, type=1, cur=3000mA, vtg=5000mV

Change-Id: I1b6bf302d235e9ba2f4c79250c02e97447d564c1
Reviewed-on: https://chromium-review.googlesource.com/391038
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit 360fbde14dd18e19878a3e0021dec537ecccba49)
Reviewed-on: https://chromium-review.googlesource.com/389691
Commit-Ready: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:47 -08:00
Shawn Nematbakhsh
68b4bf3e73 Revert "kevin: bd99955: Enable power save mode."
This reverts commit b2c844d349f5c784f02bba9db142da862a11b4e0.
BD99955 power save seems to prevent clearing or reading correct status
from interrupt status registers.

BUG=chrome-os-partner:57915
BRANCH=Kevin
TEST=Build + boot on kevin

Change-Id: I49cf500bea469d99bcf853aaaad503f279b0d855
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/390322
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit d37ceea62a0ed015b7a4fb99312e08c55ff10cfa)
Reviewed-on: https://chromium-review.googlesource.com/415485
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 17:21:17 -08:00
nagendra modadugu
684a4db39c CR50: add support for SHA-384 & 512 PKCS#1 signatures
This change adds support for signing SHA-384 & 512 hashes
when using PKCS#1 padding (CR50 does not support
SHA-384 & 512 at the moment, the actual hashing is to be
done on the host).

BRANCH=none
BUG=chrome-os-partner:59754
TEST=TCG tests pass

Change-Id: I78e774639a7968cbb50e58cdd0bf479e64123630
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/415218
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
2016-12-01 14:30:07 -08:00
Ryan Zhang
46ed8a026f Common: Fix factory mode hook by override function
1. factory mode is blocked by the override function.

BUG=chrome-os-partner:60338
BRANCH=master
TEST=`make -j buildall`,`ectool chargecontrol discharge will work`

Change-Id: I0570a15351d1a5a08797749906b000e7bfc0534b
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/414969
Commit-Ready: Ryan Zhang <ryan.zhang.quanta@gmail.com>
Tested-by: Ryan Zhang <ryan.zhang.quanta@gmail.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 06:28:35 -08:00
Shawn Nematbakhsh
b1014fc6bf charger: Add CONFIG option to maintain VBAT voltage
On the bd9995*, back boosting may occur when actual battery voltage
drops below VBAT register setting. Maintain the VBAT register at the
battery-requested charge voltage even when not charging to ensure the
bd9995* doesn't become a back boosted animal.

BUG=chrome-os-partner:56139,chrome-os-partner:54248
BRANCH=gru
TEST=Manual on kevin, unplug AC, run 'charger', verify that 'V_batt' is
maintained at 8688 mV. Attach charger, verify 'V_batt' stays at 8688 mV
and device charges.

Change-Id: Ia0cc7f9279cb460e20a8faf332ad432067dc5482
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400087
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-30 19:11:30 -08:00
Mary Ruthven
a285debf1f g: remove sleep disable/enable in rdd
Enabling and disabling sleep in the rdd interrupt is redundant because
USB already takes care of that. When USB is initialized it will disable
sleep. If it is released or suspended then it will re-enable sleep. This
change removes the sleep enable and disable from the rdd interrupt. With
this change now sleep can be enabled while suzyq is still plugged in
using the command 'ccd disable'.

BUG=none
BRANCH=none
TEST=manual
	The consoles still work

	Updating the EC, AP and Cr50 still works

	After running 'reboot ap-off' in the EC console and 'ccd
	disable' in the Cr50 console Cr50 will go to sleep.

Change-Id: Ie8e6201e9fd611c514e93bc70d298d3b0d228611
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/413606
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:55:02 -08:00
Vadim Bendebury
ed194f7a9a usb_updater: protocol version 6 (vendor commands over usb)
This patch introduces version 6 of the cr50 USB update protocol. This
version allows to multiplex TPM vendor and extension commands over the
same USB endpoint which is used for firmware updates.

When channeling TPM vendor commands the USB update frame looks as follows:

   4 bytes      4 bytes         4 bytes       2 bytes      variable size
 +-----------+--------------+---------------+-----------+------~~~-------+
 + total size| block digest |    EXT_CMD    | Vend. sub.|      data      |
 +-----------+--------------+---------------+-----------+------~~~-------+

Where 'Vend. sub' is the vendor subcommand, and data field is
subcommand dependent. The target tells between update PDUs and
encapsulated vendor subcommands by looking at the EXT_CMD value - it
is set to 0xbaccd00a and as such is guaranteed not to be a valid
update PDU destination address.

In the previous protocol versions target reset was requested by the
host sending a 4 byte PDU after the target receives the UPGRADE_DONE
message and moves the state machine to the 'awaiting_reset' state.

With the ability to transfer vendor commands, there is no need for the
target to have a special state for reset. The host can send the posted
or immediate reboot request using the appropriate vendor command.

As a result the 'awaiting_reset' state has been removed, the target
accepts vendor commands only when state machine is in the rx_idle
state.

Vendor command response size is not fixed, it is subcommand dependent.
In the current implementation the total size of the vendor command PDU
can not exceed 64 bytes, as there is no reassembly on the target side.

For backwards compatibility in case the target is running protocol
version earlier than 6, the 4 byte PDU is still sent to the target
after UPGRADE_DONE is sent.

BRANCH=none
BUG=chrome-os-partner:60013
TEST=tested updates on Reef and Gru, observed that it is possible to
     update earlier versions of firmware, and that it is possible to
     request immediate and posted reset (depending on the presence of
     the -u flag in the usb_updater invocation).

Change-Id: I6ea9e9f742c96b8ab0670e9cec87a83cd47bb20e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414948
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:53:54 -08:00
Vadim Bendebury
56310c97bf usb_updater: improve debugability
When usb update errors happen it helps a lot to be able to see the
actual error code returned by the target and where the error was
generated.

This patch adds a few printouts to help with debugging.

BRANCH=none
BUG=none
TEST=observed proper error messages generated while debugging
     introduction of extension/vendor commands transfer over USB.

Change-Id: I06c77e7467f7f9547704c88c4b673866fb2e6032
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414947
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:53:53 -08:00
Vadim Bendebury
6eae52a094 usb_updater: use proper TPM command code for vendor commands
Until extension commands using incompatible TPM command code are
phased out, the function sending vendor/extension commands to the TPM
needs to be aware of the subcommand code and use the matching TPM
command code.

BRANCH=none
BUG=chrome-os-partner:60013
TEST=with the rest of the patches applied both posted and immediate
     reset commands operate on Gru as expected.

Change-Id: I8977df22e4c2fadfd3427c0b4f70035f7f532e00
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414946
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:53:51 -08:00
Vadim Bendebury
1461cc8043 tpm: move extension and vendor command definitions into own file
Let's make sure that both embedded and host side use the same command
definitions. To avoid host compilation problems move the definitions
into a separate file.

BRANCH=none
BUG=none
TEST=compilation still works.

Change-Id: Id0d85a51aebabed0637965b3b19d7ed42c46e75e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414945
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:53:50 -08:00
Vadim Bendebury
5d80e5a865 tpm2: add extension command for immediate reset
Cr50 updates in development environment should allow resetting the
device immediately after update (without the need for SYS_RST_L to be
toggled).

This patch adds a vendor command to do just that.

BRANCH=none
BUG=chrome-os-partner:60013. chrome-os-partner:60321
TEST=none yet, with the rest of the patches applied the target gets
     rebooted immediately after a cr50 code update. Also, observed
     that flashing the console does not quite work, opend
     crosbug.com/p/60321 to address this.

Change-Id: Ia6f99ad6d22004347ad02aac2cbf4dd6c5594928
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414442
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-28 20:53:48 -08:00
Vadim Bendebury
6ac553462e g: update: expose USB PDU verification function
Some upcoming changes will introduce transfer of vendor and extension
commands over the usb updater endpoint.

This patch exposes a function which allows to verify integrity of
received USB PDUs.

BRANCH=none
BUG=chrome-os-partner:60013
TEST=no functional changes, usb_updater still works fine.

Change-Id: I8d9e6746ef0dfbb17bba618410514ca047a59a45
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414441
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-11-28 20:53:47 -08:00
Vadim Bendebury
b7f86ed3a1 usb_updater: unify normal and error messages
Just for consistency sake, make all normal messages generated by the
utility in the course of firmware update start with lower case letters
and all error messages start with upper case letters.

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

Change-Id: Ifb0bd8dec4c2bb5cbbb2c93b1918fc699c2f33dd
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414944
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-11-28 20:53:45 -08:00
Vadim Bendebury
cfbdf96086 usb_updater: use same endian conversion functions
This is just a clean up patch, unifying all cases where endian
conversions are used in the usb updater source code.

BRANCH=none
BUG=none
TEST=usb update of cr50 is still possible on gru (which uses the code
     being changed).

Change-Id: I362e9762493854b4fdbb9ec15c2cb363003f258a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414443
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-11-28 20:53:43 -08:00
james_chao
0f23c61fac twinkie: fix the compile error when set CONFIG_USBC_SNIFFER_HEADER_V2
If set the CONFIG_USBC_SNIFFER_HEADER_V2, the twinkie can't compile
with hook_call_deferred error

BUG=none
BRANCH=none
TEST=set CONFIG_USBC_SNIFFER_HEADER_V2, build twinkie

Change-Id: Idff3a0b6c1ff012ace40f97bf9193fb04ec10794
Signed-off-by: james_chao <james_chao@asus.com>
Reviewed-on: https://chromium-review.googlesource.com/414730
Commit-Ready: BoChao Jhan <james_chao@asus.com>
Tested-by: BoChao Jhan <james_chao@asus.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-28 08:31:40 -08:00
Vijay Hiremath
31e1ee1955 reef: 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.

BUG=chrome-os-partner:58969
BRANCH=none
TEST=Manually tested on reef. Discharge is in the permissible range.
     'chgstate' console command prints correct values.

Change-Id: I64afa992e50b6e18daf43edf237fde8cf658a8a2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/413153
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-11-28 01:01:16 -08:00
Bruce
ba50aab904 pyro/snappy: Support keyboard factory scanning
Add keyboard factory scanning tool.

BUG=none
BRANCH=none
TEST=check this tool work normal

Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Change-Id: Ifd6aa5c03ce668c4a44a5685fa721af11eb7a84e
Reviewed-on: https://chromium-review.googlesource.com/413764
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-27 22:00:51 -08:00
Bruce
09f2702066 pyro/snappy: add a pull down to KBD_KSO2 during hibernate
Cr50 has an internal pull down. This change changes the PULL_UP on KSO2
to a PULL_DOWN to match Cr50.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I0c25aebc727bf6c2015c3037305f3bd2f22efd20
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/414709
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-27 22:00:47 -08:00
Bruce
a9e1b4d093 pyro/snappy: Enable interrupt for BMI160
This patch enables an interrupt handler for BMI160. This will improve
response time of the motion sense task.

BUG=None
BRANCH=none
TEST=make buildall

Change-Id: Ibf5f0182273d076ed5f04156c680cd5b2f420306
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/414828
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-27 22:00:43 -08:00
Vadim Bendebury
b3a9852122 Revert "ec: Improve efficiency of host command dispatcher"
This reverts commit c459c8278e 
as the fix is not straightforwad, some host command codes in 
private repos are expressed using C preprecessor which 
breaks the assumption of this patch that all host commands 
are expressed as four digit hex numbers.

Change-Id: I922de9ae8dbab6eef048463c5c09b1f338152083
Reviewed-on: https://chromium-review.googlesource.com/414492
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-26 01:29:24 +00:00
Bill Richardson
1ece199078 Cr50: Enhance the console unlock warning message
Because the virtual dev-mode switch is stored in the TPM, when we erase
the TPM memory prior to unlocking the Cr50 console on reboot the system
reinitializes itself in normal mode. This is by design (Chromebooks
should fail into a more-secure state when possible), but it can be
unexpected.

This adds some extra caution to the unlock warning message, so that
owners who are fiddling with it for the first time aren't unpleasantly
surprised by losing all their work.

BUG=chrome-os-partner:57407
BRANCH=none
TEST=make buildall; test on Reef

From the Cr50 console, run

  lock on
  lock off

Observe the new, scarier warning.

Change-Id: I6fd1248a5a4c131fa107a902a4539fa73f2308f6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/414387
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-23 18:06:24 -08:00
Sam Hurst
c459c8278e ec: Improve efficiency of host command dispatcher
Use binary search in host command lookup dispatcher

BUG=chrome-os-partner:570895
TEST=manual testing on kevin
      - Kevin boots
      - ectool hello
      make buildall -j
      Verify *.smap hcmds section is sorted:
         100bca94 R __hcmds
         100bca94 R __host_cmd_0x0000
         100bcaa0 R __host_cmd_0x0001
         100bcaac R __host_cmd_0x0002
         100bcab8 R __host_cmd_0x0003
         100bcac4 R __host_cmd_0x0004
         100bcad0 R __host_cmd_0x0005
         100bcadc R __host_cmd_0x0006
         100bcae8 R __host_cmd_0x0007
         100bcaf4 R __host_cmd_0x0008
         100bcb00 R __host_cmd_0x0009
         100bcb0c R __host_cmd_0x000a
         100bcb18 R __host_cmd_0x000b
         100bcb24 R __host_cmd_0x000d
         100bcb30 R __host_cmd_0x0010
         100bcb3c R __host_cmd_0x0011
         100bcb48 R __host_cmd_0x0012
         100bcb54 R __host_cmd_0x0013
         100bcb60 R __host_cmd_0x0015
         100bcb6c R __host_cmd_0x0016
         100bcb78 R __host_cmd_0x0017
         100bcb84 R __host_cmd_0x0025
         100bcb90 R __host_cmd_0x0026
         100bcb9c R __host_cmd_0x0029
         100bcba8 R __host_cmd_0x002a
         100bcbb4 R __host_cmd_0x002b
         100bcbc0 R __host_cmd_0x002c
         100bcbcc R __host_cmd_0x0044
         100bcbd8 R __host_cmd_0x0045
         100bcbe4 R __host_cmd_0x0046
         100bcbf0 R __host_cmd_0x0047
         100bcbfc R __host_cmd_0x0061
         100bcc08 R __host_cmd_0x0062
         100bcc14 R __host_cmd_0x0064
         100bcc20 R __host_cmd_0x0065
         100bcc2c R __host_cmd_0x0067
         100bcc38 R __host_cmd_0x0087
         100bcc44 R __host_cmd_0x008c
         100bcc50 R __host_cmd_0x008d
         100bcc5c R __host_cmd_0x008f
         100bcc68 R __host_cmd_0x0092
         100bcc74 R __host_cmd_0x0093
         100bcc80 R __host_cmd_0x0096
         100bcc8c R __host_cmd_0x0097
         100bcc98 R __host_cmd_0x0098
         100bcca4 R __host_cmd_0x0099
         100bccb0 R __host_cmd_0x009e
         100bccbc R __host_cmd_0x00a0
         100bccc8 R __host_cmd_0x00a1
         100bccd4 R __host_cmd_0x00a8
         100bcce0 R __host_cmd_0x00a9
         100bccec R __host_cmd_0x00b6
         100bccf8 R __host_cmd_0x00b7
         100bcd04 R __host_cmd_0x00d2
         100bcd10 R __host_cmd_0x00d3
         100bcd1c R __host_cmd_0x00db
         100bcd28 R __host_cmd_0x0101
         100bcd34 R __host_cmd_0x0102
         100bcd40 R __host_cmd_0x0103
         100bcd4c R __host_cmd_0x0104
         100bcd58 R __host_cmd_0x0110
         100bcd64 R __host_cmd_0x0111
         100bcd70 R __host_cmd_0x0112
         100bcd7c R __host_cmd_0x0113
         100bcd88 R __host_cmd_0x0114
         100bcd94 R __host_cmd_0x0115
         100bcda0 R __host_cmd_0x0116
         100bcdac R __host_cmd_0x0117
         100bcdb8 R __host_cmd_0x0118
         100bcdc4 R __host_cmd_0x011a
         100bcdd0 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX
         100bcdd0 R __hcmds_end
BRANCH=none

Change-Id: Ideb9951b318763f71915e2c4e5052f4b4bfab173
Reviewed-on: https://chromium-review.googlesource.com/405528
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-23 15:36:00 -08:00
Daisuke Nojiri
e4609af63c Reef: Enable interrupt for BMI160
This patch enables an interrupt handler for BMI160. This will improve
response time of the motion sense task.

BUG=None
BRANCH=none
TEST=Install and run AIDA64 from Playstore. Wiggle Reef DVT. Verify
'CrosEC Gyroscope' readings change.

Change-Id: Ie8dacb51795fa194840817d833cc6356beb01c8f
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/413079
2016-11-22 23:35:13 -08:00
Nicolas Boichat
d3480636e8 hammer: Add support for USB HID touchpad
Add another endpoint, to be driven by the USB HID touchpad driver.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: I0fd62ceb233aa13e0af61f6ee6a0c0c9fc1c4b52
Reviewed-on: https://chromium-review.googlesource.com/410961
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 18:36:40 -08:00
Nicolas Boichat
13f8bb01de driver/touchpad_elan: Report events to USB HID touchpad
Pass reported events to the USB HID touchpad driver.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: I234be1a1db8526e615acdd13c5d4dae40be5bdff
Reviewed-on: https://chromium-review.googlesource.com/410960
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 18:36:39 -08:00
Nicolas Boichat
1b682dd05b chip/stm32/usb_hid: Add USB HID touchpad driver
This describes a 5-finger touchpad. The physical/logical dimensions
of the trackpad are hardcoded for the time being.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: I04a0833a28c013395974104ebdd6fcb29e5d6680
Reviewed-on: https://chromium-review.googlesource.com/407742
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 18:36:37 -08:00
Nicolas Boichat
67473cb5b4 chip/stm32/usb: Allow interface handler to reply with more than 64 bytes
For example, when a HID descriptor is longer than 64 bytes, we need
to split it in multiple packets.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make buildall -j
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: I25a05eabaf9413e332fe3cd70695a0d53639713d
Reviewed-on: https://chromium-review.googlesource.com/409316
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 18:36:36 -08:00
Manoj Gupta
0e4776ec28 Fix EC build for latest llvm for elm board
Mark host command structures as aligned for elm board.
Without marking as aligned, llvm was correctly complaining about
taking address of packed member.

util/ectool.c:1158 error: taking address of packed member 'size' of
class or structure 'ec_params_usb_pd_fw_update' may result in an
unaligned pointer value [-Werror,-Waddress-of-packed-member]

BRANCH=none
BUG=chromium:665240
TEST=Builds now

Change-Id: Ic4a2e81f6af8ef2a906d6ac7aca87ea6d00fe318
Reviewed-on: https://chromium-review.googlesource.com/413108
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-22 14:52:55 -08:00
Daisuke Nojiri
79251ee917 Reef: Disable keyboard and trackpad in tablet mode
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=chrome-os-partner:58792
BRANCH=none
TEST=Keyboard and trackpad are disabled when the lid goes beyond 180
and re-enabled when it's smaller than 180. Keyboard and trackpad are
disabled when the lid goes to 360 degree and the system doesn't wake
up by a keypress.

Change-Id: I48c04bd576f457a899dfdf9b4718d73b59419cbe
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/411395
2016-11-22 14:52:44 -08:00
Nicolas Boichat
526adbe531 hammer: Add keyscan task
This scans the keyboard matrix, and reports events. Pin layout
is temporary.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: Ifec7d1bd0223d4653c40b36e068d5d082d16284f
Reviewed-on: https://chromium-review.googlesource.com/411607
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 14:52:42 -08:00
Nicolas Boichat
f940d4f516 chip/stm32/usb_hid_keyboard: Add functions for keyscan
This first cleans up the code:
 - Define report as a structure.
 - Fix USB interval from 40 ms to 32 ms (Linux kernel complains
   otherwise).

Then, this removes the old set_keyboard_report interface, and
replaces it by the interface used by the keyboard scanner
(i.e. keyboard_state_changed and keyboard_clear_buffer).

This also means we need a keycode table to translate from
row/column to USB HID keycode.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make buildall -j
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer
     With evtest and "hid 0-7" in console, check that key are
     reported correctly.

Change-Id: I5d526db1568c29c7f28fc5e962e213e44303cc16
Reviewed-on: https://chromium-review.googlesource.com/411571
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 14:52:40 -08:00
Vadim Bendebury
481fede513 g: do not consider valid headers with the 'magic' field corrupted
When cr50 rollback happens, the newer header's magic field is set to
zero to prevent it from ever running again.

Take this into consideration when displaying versions of the inactive
RW image.

BRANCH=none
BUG=none

TEST=loaded two versions of the new code on a cr50 and then modified
     the fallback counter to force it to boot the older version and
     reboot a Reef. Once Reef fully boots to chrome os examine CR50
     version report:

     Before:

   > vers
   ...
   RW_A:    0.0.9/DEV/cr50_v1.1.5654-2228b76+
   RW_B:  * 0.0.11/DEV/cr50_v1.1.5654-2228b76+
   ...

    After:

   > vers
   ...
   RW_A:  * 0.0.9/DEV/cr50_v1.1.5654-2228b76+
   RW_B:    Error

Change-Id: I2a9ee13117a0bc91710226cd733c5c484c6d0595
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/413089
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-11-22 11:52:10 -08:00
Vijay Hiremath
242d298584 electro/reef: Configure the battery parameters for electro & reef
Electro & Reef use the same board files but have different batteries
hence configure the respective battery parameters for these boards.

BUG=chrome-os-partner:59876
BRANCH=none
TEST=Manually tested on Reef. Boot with/without/battery works.
     cut-off and boot from cut-off works.

Change-Id: I0e4684987133d6bcd9cabab5c5a1ce5b6c5684d2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/411353
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-11-22 11:52:06 -08:00
Mulin Chao
50fbfc5040 npcx: hwtimer: Add consecutive reading for ITCNT32
The mux for selecting source clock of ITIM will introduce a delay
and have a chance to make ITIM's source clock and core clock are
asynchronous. We need consecutive reading for ITCNT32 no matter source
clock is APB2 or 32k.

Modified sources:
1. hwtimer.c: Add consecutive reading for ITCNT32

BRANCH=none
BUG=chrome-os-partner:34346,chrome-os-partner:59240
TEST=No time stamp symptoms occur on wheatley for 30 hours.

Change-Id: I8b54e93b320e3ea74fc3d6ea13f0d178f9c449cd
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/412505
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-22 11:51:56 -08:00
li feng
20ca52a9ee ISH: set toolchain in core/minute-ia
When "make buildall" has board which uses core/minute-ia,
CROSS_COMPILE?=i686-pc-linux-gnu- doesn't get set unless
CROSS_COMPILE is not defined; however, it's defined before
this line, and wrong toolchain is used.
Remove "?" to set correct CROSS_COMPILE.

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

Change-Id: Ied4a9f93a4d44714c012d3a3e50e4a34f41a7c1f
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/410402
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-11-21 18:23:03 -08:00
Gwendal Grignou
bcbeb89da1 driver: bmi160: Remove unnecessary delay
Rereading the specification, remove delays when not needed:
- When we move the sensor out of suspend, we need to wait before
using it (BMI160 spec: 2.11.38 Register (0x7E) CMD)
When we do a softreset, we need just need to wait 300us for the
sensor to go in suspend, we will wait only when we change the rate
and enable the sensor.
- The timeout at fifo flush is not needed, it was added for debugging.
- Remove unnecessary printf when initializing the magnetometer.

BUG=chrome-os-partner:59188
BRANCH=glados, reef, strago
TEST=On reef, check the EC boot faster: time spend initializing the
sensors
decreased from 240ms to 133ms

Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/411964
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-11-21 18:22:56 -08:00
Daisuke Nojiri
88685f6a66 Reef: Swap Volume Up and Down GPIOs
The button closer to the hinge is assigned to volume down and
the one closer to the user is assigned to volume up. This change
swaps the GPIO assignments to fix the UX.

BUG=chrome-os-partner:60057
BRANCH=none
TEST=Verified the one closer to the hinge increases the volume and
the one closer to the user descreases the volume.

Change-Id: I3e716da288839c3f5be608fb2d63f277bbde1bc7
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/412981
2016-11-21 16:07:48 -08:00
Mary Ruthven
a6cbc2b868 cr50: remove the pull down on uart2 tx
The pulldown on diob5 is used to detect when servo is detached. It is
unnecessary during deep sleep and when the EC console is active because
servo detection is disabled. Having the pull-down enabled during these
times can increase power consumption.

This change disables the pulldown when the EC console and deep sleep are
enabled. It also disables the diob5 input during deep sleep.

BUG=chrome-os-partner:60020
BRANCH=none
TEST=manual
	Disconnect servo

	Use the suzyq consoles to turn off the AP.

	Enable deep sleep.

	Measure the power consumed by vddiob and make sure it is around
	0.3mW when the EC is in hibernate and when it is not.

Change-Id: I8a653c28800cfbeeb1b4b8598d166846124c6b53
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/412940
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-21 16:07:43 -08:00
Bill Richardson
94843eca31 Cr50: Add sysinfo vendor command
This returns the system information that is needed to determine the
correct signing keys for firmware updates.

BUG=chrome-os-partner:59747
BUG=chrome-os-partner:59705
BRANCH=none
TEST=make buildall; test on Reef

Run the "sysinfo" command on the Cr50 console:

  > sysinfo
  Reset flags: 0x00000800 (hard)
  Chip:        g cr50 B2
  RO keyid:    0x3716ee6b(dev)
  RW keyid:    0xb93d6539(dev)
  DEV_ID:      0x017950ab 0x04656742
  >

Send the raw command bytes from the Reef AP, observe the result:

  # /tmp/trunks_send --raw 80 01 00 00 00 0C 20 00 00 00 00 12
  80010000001C0000000000123716EE6BB93D6539017950AB04656742
  #

The result contains the same information from the console command:

  8001           TPM_ST_NO_SESSIONS
  0000001C       responseSize (28 bytes)
  00000000       RC_SUCCESS
  0012           vendor-specific subcommand
  3716EE6B       RO keyid
  B93D6539       RW keyid
  017950AB       DEV_ID0
  04656742       DEV_ID1

Change-Id: I82de3ebfb3e9be3b707583bc825d2efbcf851c5c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/413106
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-21 16:07:24 -08:00