Commit Graph

4376 Commits

Author SHA1 Message Date
Ben Lok
a572c882e4 driver/temp_sensor: Add power control API for TMP432
Some boards didn't define the CONFIG_TEMP_SENSOR_POWER_GPIO (such as: Oak),
Due to the hardware design, the power of temp sensor is always on.
But, we can enable/disable the temperature measurement circuitry of tmp432 by
setup the shutdown (SD) bit. Add a new API: tmp432_set_power() to let upper
layer to control the power of tmp432 by SW approach for power saving.

BRANCH=none
BUG=chrome-os-partner:44170
TEST=manual
1. make BOARD=oak -j
2. Turn off the TMP432:
   > tmp432 power off
3. check whether tmp432 is shutdown:
   > tmp432
   ERROR: Temp sensor not powered.
   Not Powered
4. Turn on the TMP432:
   > tmp432 power on
5. check whether tmp432 is running:
   > tmp432
   Local:
     Temp        29C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C
   Remote1:
     Temp        27C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C
   Remote2:
     Temp        27C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C

   STATUS:  10000000
   CONFIG1: 00000000
   CONFIG2: 00111100

Change-Id: Iab95c4c0b0130baf3bce380a8132e08ded8d159e
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/295058
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-03 04:24:33 -07:00
Shawn Nematbakhsh
45c28eed9b mec1322: Remove FPU support by default
Floating point is used in very few places in the code, none of which are
needed by mec1322 boards (yet). If needed, individual boards can define
CONFIG_FPU.

BUG=None
TEST=Verify glados continues to boot AP successfully and image is shrunk
by 64 bytes.
BRANCH=Strago

Change-Id: I6ea46c15bedbc498e7baa96098b002d711ac20fb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297029
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-02 20:34:23 -07:00
Shawn Nematbakhsh
ee74d29cc8 strago: Remove temp-sensor console commands
command_tmp432 will soon grow with the addition of power control which
will exhaust our program memory space.

BUG=chrome-os-partner:44170
TEST=`make buildall -j`
BRANCH=Strago

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I5789ab86ad022bdc3e985794f40b3a25e44ad458
Reviewed-on: https://chromium-review.googlesource.com/296992
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-02 18:56:38 -07:00
Shawn Nematbakhsh
ac9f0f3736 cleanup: Clarify use of flash layout CONFIGs
Based on feedback from programmers, it's not clear when
config_std_internal_flash should be used, and when non-standard
chip-specific layouts need to be defined. Add clarity here with the
following changes:

- Explain in-depth the one config that config_std_internal_flash should
  be used for.
- Move non-standard chip-level flash layout CONFIGs to their own new
  chip-level file, config_flash_layout. All chips should either include
  config_std_internal_flash.h OR define their own layout in their own
  config_flash_layout.

Functionally, this change is a NOP.

BUG=chrome-os-partner:23796
TEST=`make buildall -j`
BRANCH=None

Change-Id: I6037b68db9048d90fa2a2da4c9c9e09d1143fa68
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296527
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-02 18:56:37 -07:00
Bill Richardson
2b5acbc813 Cr50: Add stub to implement native NV storage
This adds the unimplemented NVMem.c functions from libtpm2 to the
local repo. It depends on the libtpm2 CL that removes NVMem.c
from the embedded library.

BUG=chrome-os-partner:44745
BRANCH=none
CQ-DEPEND=CL:296476
TEST=manual

  sudo emerge tpm2 tpm2-simulator

  cd src/platform/ec
  make buildall

Change-Id: If7f0d5d71b3e68626cf2c80ea3335ebb9bc9902f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296525
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-09-02 12:48:09 -07:00
Alec Berg
f44f02e865 pd: send soft reset before an EC reset
Send soft reset to all connected USB PD ports before a user
initiated reset (via console or host command). This fixes a problem
where EC will send PD hard reset to a charger after an EC reboot, which
will cause another reboot if battery is not present.

BUG=chrome-os-partner:44085
BRANCH=none
TEST=tested on glados without a battery. with zinger attached, issue
'reboot' from console and verify that we only reboot once.

Change-Id: Id6c56cda33c289e3425cb433f7fcbe76669d2dff
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295889
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-01 16:10:43 -07:00
Ben Lok
af79591ed2 oak: usb_pd: avoid broken SS connection during enter DP mode.
For type-c multi-function accessory (for example: apple's HDMI adapter,
or type-c dock), it has SS & DP connection. The SS connection may be
established before enter DP mode. The SS connection will be broken if
the mux is disabled during enter DP mode. So, it needs to check the mux
status and avoid to disable the mux if SS connection is already existed.

BRANCH:none
BUG=chrome-os-partner:43096
TEST=Manual on Oak rev3
1. connect apple type-C HDMI adapter to right side port(C0).
2. list usb devices in AP console:
   > lsusb
   Bus 002 Device 017: ID 05ac:100e Apple, Inc.
3. confirm that apple's device is present.

Change-Id: I47a52076de45da9f9a78d114f20c4ff6bb4aa2bc
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/295351
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-01 03:25:38 -07:00
Gwendal Grignou
1dfaf92f3a driver: si114x: Convert unit to distance
Instead of returning the amount of light returned,
convert the data into distance (cm). It can be adjust via range.

BRANCH=smaug
BUG=chrome-os-partner:42526
TEST=check the data is usable by HAL.

Change-Id: I97510246ce054af4e61325d7e295ca09cc536457
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296472
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2015-09-01 01:28:00 -07:00
Ben Lok
c2cf0fb198 oak: enable MBKP events for PD events
(refer to CL:273620) enable the MKBP event feature to send host event
and wire up the PD specific events.
But, CONFIG_MKBP_EVENT conflicts with CONFIG_KEYBOARD_PROTOCOL_MKBP,
due to the GPIO name of EC interrupt pin. Align the GPIO naming of EC
interrupt pin to EC_INT_L.

BRANCH=none
BUG=chrome-os-partner:44643
TEST=On Oak rev3, plug/unplug USB devices and add kernel trace to see
the PD events happening.

Change-Id: I10de9c6611583bb6165bdc1848e542d4b8bba954
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/296012
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-08-31 22:59:52 -07:00
Kaiyen Chang
a030c63baf Fixed a failure of power button press while entering G3 state.
If the power button is pressed while S5 inactivity timer is about to
expire, EC need to give CPU a little time to start up before changing
the state from S5 to G3 (the hard off state); otherwise the system will
not start up. This issue can be reproduced on Rambi.

BUG=chrome-os-partner:42728, chrome-os-partner:42811
BRANCH=None
TEST=Implement an ec command to simulate power button press while S5
     inactivity timer is about to expire, and then make sure that the
     patch did solve the issue.

Change-Id: I022e8e14fd41447898760a4d57a4702e2c00a0d5
Signed-off-by: Kaiyen Chang <kaiyen.chang@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/290280
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296436
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-31 21:15:41 -07:00
Bill Richardson
1bc9067502 cortex-m: Fix sysjump to RO with CONFIG_RO_HEAD_ROOM
This accounts for the extra head room in the RO image.

BRANCH=none
BUG=chrome-os-partner:43025, chrome-os-partner:44625
TEST=the cr50 image validates *and jumps to* the RW image at boot.

Change-Id: I8c87e7a9e7da187c19f135176ae5144cbc609cb9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296453
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-31 19:26:59 -07:00
Bill Richardson
0860b19a97 cortex-m: CONFIG_RO_HEAD_ROOM should only affect RO image
When we add head room to the RO image, it's generally to provide
a chip-specific boot header of some sort. That header is only
needed for the RO image, not the RW image. The macro name implies
this, but this CL makes it so.

BRANCH=none
BUG=chrome-os-partner:43025, chrome-os-partner:44625
TEST=the cr50 image validates *and jumps to* the RW image at boot.

Change-Id: I0e5b2c32e232418970e01c7409ddcbbabd4786d5
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296451
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-31 17:38:01 -07:00
Wenkai Du
323f5e2ccf kunimitsu: port increase powerbtn task stack size
This patch port powerbtn stack patch from glados.

Original-change-Id: I858ad50e86b998e4283a5e11d3a720212150f657
Originally-signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Originally-reviewed-on: https://chromium-review.googlesource.com/295571

BUG=chrome-os-partner:44202
TEST=build EC for kunimitsu and boot
BRANCH=None

Change-Id: I96d295748a2a557621ea17a4e3f9fce629861d5f
Signed-off-by: Wenkai Du <wenkai.du@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/295916
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-31 13:52:30 -07:00
Aaron Durbin
1a3c776410 glados: document behavior of SLP_S0_L
Note the current behavior and mitigation with the current
design regarding SLP_S0_L.

BUG=chrome-os-partner:44098
BRANCH=None
TEST=Built.

Change-Id: I784dda5e442496c48a5b74614996ff19285e2812
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295248
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-31 13:52:25 -07:00
Aaron Durbin
c3b5b1739b skylake: allow power button power ons in S5 after apshutdown
On skylake the apshutdown command holds the power button asserted until
the power state machine decides to deassert the power button. Previously
this check was taking place in G3 state. As such when the board waited
in S5 for 10 secs one couldn't re-power on the system. To alleviate that
move the logic for power button deassertion into the S5 state.

BUG=chrome-os-partner:44532
BRANCH=None
TEST=Used apshutdown. When device got to S5 power noted another
     powerb command would bring the system back up instead of waiting
     to enter G3 power state.

Change-Id: I9989b27bd48819d7c3e5efd071b0327c38fe91e2
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295198
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-31 12:29:30 -07:00
Gwendal Grignou
fa0c85b6c9 cyan, kunimitsu, strago: motion_sense: use new rate calculation
Use new config structure.
Remove pre-init when sensors are shutdown in S3 on strago:
motion_sense is not setting ODR to 0 inconditionally when
sensors are not active.

active_mask now means state (S0, S3, S5) where sensors are powered on.
When sensor is powered but unused, EC can use the config array to set
the polling and ODR to 0.

BUG=chromium:513458
TEST=On Cyan, verify the sensors are working in S0. In S3, check the
motion_sense task is idle (now sensor to probe). Check the task
comes back on resume.
BRANCH=cyan,strago

Change-Id: Ib3d118b7139f94755fef4cb73fc1274e9e2f2826
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295781
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-29 01:34:15 -07:00
Gwendal Grignou
32867104da samus: Use new config, fix gesture
Use new config table.
Move ODR setting in motion sense, fix variable names.

BRANCH=samus
BUG=chromium:513458
TEST=Test accelerator and double tap on Samus

Change-Id: I341add11a18de8e4cc97c57da29f9114bd2014cf
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295638
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-29 01:34:15 -07:00
Gwendal Grignou
4e7e1bb796 motion_sense: Add more complex EC/AP sensor rate support.
Add config settings for ODR and EC rate per requestor and
per power state (1 for the AP, 3 for the EC).
This way we can finely set ec rate and ODR depending on usage.

On chromeos, AP is not setting frequency, so EC sets for different power
state. On some platform, sensors can now be suspended in S3/S5.

Allow EC oversampling when AP is only looking for a few samples.
It is useful for double tap detection where high accelerator ODR is
required.

BRANCH=ryu
TEST=Tested on Ryu
BUG=chromium:513458

Change-Id: Ic3888a749699f07b10c5da3bc07204afd4de70da
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295637
2015-08-29 01:34:14 -07:00
Gwendal Grignou
398bd9a017 driver: kxcj9: Remove some printf to fit into kunimitsu
Remove some printfs for the new sensor code to compile.

BRANCH=kunimitsu
BUG=None
TEST=compile

Change-Id: Ia7b203a03866fd497cdfaf5fa91f651423279f61
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295856
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-29 00:04:16 -07:00
Gwendal Grignou
e11637aed6 common: motion_sense: Fix Light sensor sequencing
Light was gathered too often:
- missing timestamp when reading completes.
- error when calculating next timestamp.

BRANCH=ryu
BUG=chrome-os-partner:32829
TEST=check the light is sampled ~ every seconds, whatever the
motion task frequency

Change-Id: Id070af3c8d2e080780334822278dda267bea058c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295636
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-29 00:04:15 -07:00
Gwendal Grignou
7a2299163b driver: change get_ interface.
Simplify sensor get_data_rate, get_range and get_resolution.
Error code was not checked and these functions as currently implemented
have no reason to fail.

BRANCH=ryu,samus,cyan,strago
BUG=chromium:513458
TEST=Check on ryu, compile

Change-Id: I40dca41cee29a19f65b2f84d434b4c19eb6cbf3c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295635
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-29 00:04:15 -07:00
Alec Berg
252dce9bd3 glados: increase voltage hysteresis in fast charging
Increase voltage hysteresis in fast charging to 100mV to avoid
bouncing back and forth between low and high voltage profiles.

BUG=chrome-os-partner:44299
BRANCH=none
TEST=test on glados, charge up from below 8.2V to above 8.3V
with zinger and verify that we switch cleanly from the low
voltage profile to the high voltage profile.

Change-Id: Ia4c03b93da66c4913848ba8eec0e09988c4d71d8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296024
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-28 19:43:42 -07:00
Vijay Hiremath
5943f49e17 Keyboard: Add a macro to conditionally compile the console commands
Added macros to conditionally compile the keyboard test console commands to
save the memory. These macros can be enabled/disabled in the board specific
files.

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

Change-Id: I3ad190f1f3c9310e4f706b3b23cb8ca8755e49ef
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/295942
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Commit-Ready: Divya Jyothi <divya.jyothi@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-28 18:09:06 -07:00
Dawei Li
97a1d1671b twinkie firmware: add support for vbus voltage and current
The format of an ep packet header (8 bytes) :
Packets for cc1: [sample_tstamp, sample_seq, vbus_voltage, tstamp_offset]
Packets for cc2: [sample_tstamp, sample_seq, vbus_current, tstamp_offset]
Updated: use array to implement a circular queue; when a forming a packet,
remove one element from the queue. In this way, we can capture more samples
of vbus information.
Updated: when sniffer task has not started sending packets, most recent vbus
info is always stored at the first position of the queue, making sure that
the first reported vbus info is the most recent one.

Updated: allow user to compile the original version or the new version of the
source code. In ec/board/twinkie/board.h
Use #define CONFIG_USBC_SNIFFER_HEADER_V1, if you do not want twinkie to
send out vbus info;
Use #define CONFIG_USBC_SNIFFER_HEADER_V2, if you want twinkie to send out
vbus info.

Signed-off-by: Dawei Li <daweili@google.com>

BUG=chrome-os-partner:42703
BRANCH=none
TEST=BEGIN
connect Twinkie to a waveform generator, record data using:
sudo sigrok-cli -d chromium-twinkie --continuous -o test.sr
then check the resulting waveforms on pulseview.
END

Change-Id: Ifdb6402eb7d998ffb25128c510d1780491b11872
Reviewed-on: https://chromium-review.googlesource.com/282388
Commit-Ready: Sheng-liang Song <ssl@chromium.org>
Tested-by: Dawei Li <daweili@google.com>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-28 01:19:33 -07:00
Dawei Li
405ac32148 twinkie_sink: allow twinkie commands in the sink mode twinkie
Previously, the "twinkie" commands are only avaible in sniffer/normal
mode. By allowing the twinkie commands in sink mode. We can
do more testings in the sink mode. The following important commands
are now available in sink mode:
twinkie bufrd, twinkie bufwr, twinkie fsm, twinkie send.
With these commands, we can command sink mode twinkie to send
arbitrary USB PD packets, and see how the target devices respond.

Since sink mode and sniffer mode may have conflicts with each
other, the commands may not behave in the same way as in sniffer
mode. See the #ifdef HAS_TASK_SNIFFER ... #endif blocks for details.

Signed-off-by: Dawei Li <daweili@google.com>

Change-Id: I06d4a7674d9aa897d09d4a2e6f2410f2c84f8f4b
Reviewed-on: https://chromium-review.googlesource.com/294956
Commit-Ready: Sheng-liang Song <ssl@chromium.org>
Tested-by: Dawei Li <daweili@google.com>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-28 01:19:33 -07:00
Vijay Hiremath
eb57628abe Kunimitsu: Buffer AC status to the PCH
Ported the patch from Glados.
 Change-Id: Id7e6ca674e35c98594d09b86ab5bdf518f8b3984
 Reviewed-on: https://chromium-review.googlesource.com/288922

BUG=none
BRANCH=none
TEST=boot on Kunimitsu and verify PCH_ACOK is asserted when the device
     starts to charge and is deasserted when no cable is connected.

Change-Id: I869dab9dacc9c80da1cff79d795f07e16cbd37de
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/295864
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-27 21:27:49 -07:00
Gwendal Grignou
8cd6cb8d2b ectool: Add description for new sensors.
Add string for new sensors.

BUG=none
BRANCH=ryu
TEST=show newest sensor properly:
Type:     proximity
Location: lid
Chip:     si1141

Change-Id: Ia41f845cd02ba7a1fd322c15692be0bb177eada4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295634
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-27 21:27:48 -07:00
Mike M Hsieh
6ced01bb86 kunimitsu: battery led implementation
Implement LED function for battery charging behavior

BUG=none
BRANCH=none
TEST=checked and verified LED behavior while charging and remaining battery
capacity under 3%/10%
Signed-off-by: Mike Hsieh <mike.m.hsieh@intel.com>

Change-Id: Ic340d4ea428f7726611b2ae24a4d18563c63ee80
Reviewed-on: https://chromium-review.googlesource.com/295476
Commit-Ready: Wenkai Du <wenkai.du@intel.com>
Tested-by: Wenkai Du <wenkai.du@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-27 14:39:53 -07:00
Todd Broch
5bc9b32807 ryu: Change charger termination current to 192mA.
Good rule of thumb for charger current is that it should be set
between C/20 & C/50 for the battery of the device.

For ryu its presently set at 64mA which may explain why we see
charger's status as charging even when battery is full.  In any case
its well below recommendation so lets change it to something within
that.

Sampled data (see issue tracker) indicates charging current is ~256mA
when battery reaches 100% charged.  Setting to 192mA (3 * 64) to error
on the side of charging slightly longer.  This number is still within
termination current recommendation:
  C/20 > term_current >= C/50

Note, also changing bq2589x default termination to match its POR value
of 256 as no other board uses this charger presently.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=smaug
BUG=chrome-os-partner:42848
TEST=manual, read charger IC termination register and see termination
current set to 192mA

Change-Id: I60dbb9326c3abb8091fd9ab18eda08b9eabb197b
Reviewed-on: https://chromium-review.googlesource.com/293096
Commit-Ready: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-08-27 11:45:57 -07:00
Aaron Durbin
6ebc6c493f glados: implement x86 power cycle on EC reset
On certain glados boards (board id >= 2) there is a
gpio conntected to the LDO_EN pin of the BD99992 pmic.
This is a requirement for pulling power from the x86
side of the system. Add a check at HOOK_INIT time to
check the current system reset flags. If a watchdog,
hard, or soft reboot occurred the LDO_EN is deasserted
to bring down the DSW and primary rails.

BUG=chrome-os-partner:44527
BRANCH=None
TEST='reboot', 'reboot ap-off', host cmd reboot.

Change-Id: I7e971a03c8894e1cbf20aaad67903db2057aad41
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295116
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-26 21:50:29 -07:00
Aaron Durbin
12cee55423 system: provide optional chip_save_reset_flags()
Certain boards may need to handle fixing up the RESET_FLAG_s
because of the boards' designs. Provide an optional per-chip
implementation to save the reset flags. Note that this
function is not protected by a CONFIG_ option as it can just
be implemented by the chip if a board requires it. Lastly,
implement chip_save_reset_flags() for mec1322 for future use.

BUG=chrome-os-partner:44527
BRANCH=None
TEST=Built and booted on glados.

Change-Id: I604fe4e6a069f31727bab52288595a349e3dbe72
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295115
Reviewed-by: Robbie Zhang <robbie.zhang@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-26 21:50:28 -07:00
Aaron Durbin
73338cc986 glados: disable console history
We're already too close to limits. Disable console history to
provide more breathin room for features.

BUG=chrome-os-partner:44527
BRANCH=None
TEST=Can build with follow up code that actually links.

Change-Id: I53f9fdace64e01d28081f62fa535bb6efd0f5675
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295114
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-26 20:21:58 -07:00
Aaron Durbin
2fd997c27c glados: enable CONFIG_BOARD_VERSION
Glados has board ids, but the config variable was
never set. Enable the config and also change the name
of the GPIOs to match the expectations of the common
infrastructure.

Prior:
> version
Chip:    smsc mec1322 81
Board:   0
RO:      glados_1.1.9999-f3a5046
RW:      glados_1.1.9999-f3a5046
Build: glados_1.1.9999-f3a5046 2015-08-26 10:42:45 @adurbin-chromium

With chnage:
> version
Chip:    smsc mec1322 81
Board:   1
RO:      glados_1.1.9999-028832d
RW:      glados_1.1.9999-028832d
Build: glados_1.1.9999-028832d 2015-08-26 11:41:43 @adurbin-chromium

BUG=chrome-os-partner:44527
BRANCH=None
TEST=version command reports board id strapping.

Change-Id: I9b7e41d2f61a91de4648a09ac9da9f101f7bb830
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295113
Reviewed-by: Leroy P Leahy <leroy.p.leahy@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-27 01:49:43 +00:00
Aseda Aboagye
9fc5ae515e util: More enhancements to config_option_check.py.
This commit enhances the config_option_check.py script a little bit
more.

Firstly, I fixed a bug where lines beginning with an '*' were treated as a
comment where it was not so.

  ex: *status = (CONFIG_BAR_PORT & 0x23);

Additionally, I added support for considering deletions.  This allows
the script to check to see if a CONFIG_* option being removed is being
used anywhere else in the repo.  If the option isn't used elsewhere,
then it appears to be the removal of the last use.  An error is flagged
informing the user to remove that option from the main config file.
This helps to keep the config file up to date without leaving stale
CONFIG_* options where one might not know if they still work or not.
Debug config options are always assumed to be used as those are
typically enabled locally.

BUG=chromium:510672
BRANCH=None
TEST=Used a new config option without adding it to the main config file
and watched the error be flagged.
TEST=Removed the last use of a CONFIG_* option while leaving the option
in the main config file. Observed that it was flagged.
TEST=cros lint --debug util/config_option_check.py
TEST=make -j buildall tests

Change-Id: I8702ad06d9856c14f7bcd4592e917a5d3fcb6b57
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/294620
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-08-27 01:49:38 +00:00
Aaron Durbin
10dbdc3feb mec1322: fix console in lfw
The console support in lfw was not very in for printing messages.
The version was smashed against the name of the program and
the image type was at the same column as end of version:
littlefwglados_1.1.9999-f3a5046
                               lfw-RO load

Fix this by adding a space after the program name and outputting
a carriage return if a new line is encountered. With these changes
the new console looks like:
littlefw glados_1.1.9999-f3a5046
lfw-RO load

BUG=chrome-os-partner:44527
BRANCH=None
TEST=Built for glados. 'reboot' shows legible console output.

Change-Id: I7b80b2c7db453c09a401a740155de98e78f3cf84
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295112
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-27 01:49:31 +00:00
Tom Wai-Hong Tam
38ddecb897 Ryu: Add a console command to control the buttons VolUp and VolDown
(cherry-pick back to ToT)

FAFT needs these buttons (VolUp and VolDown) be controllable
such that it can automate the firmware mode switching flows.
It is done by EC overwriting the GPIO values such that AP can
see the results.

BRANCH=ToT,smaug
BUG=None
TEST=AP boots into the firmware menu screen. Run the following commands
in EC console:
> btnpress voldown 1
> btnpress voldown 0  # See the next option selected, like a real button pressed
> btnpress volup 1
> btnpress volup 0  # Boot in the selected option, like a real button pressed
> btnpress volup
Button volup pressed = 0

Change-Id: I5e0b514d9986b8e5729ffd3560560d650669e0b7
Signed-off-by: Vic Yang <victoryang@google.com>
Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294882
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 77291b156d10f31dd059a4662aa249a8f8ea762e)
Reviewed-on: https://chromium-review.googlesource.com/295162
2015-08-27 01:49:25 +00:00
Gwendal Grignou
456d1baa25 Ryu: increase HOST_CMD stack size
Hit overflow while sending autocalibrate command.

At rest, we were already close to the limit:
   7   HOSTCMD          00000000    0.104035  472/488
Increase to 640 bytes.

BUG=chrome-os-partner:44381
BRANCH=ryu
TEST=Check auto calibrate works.

Change-Id: Ife014baf4316cdca952104c5158f38cd106e023f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295590
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-26 08:28:24 +00:00
Shawn Nematbakhsh
bcab6d22df glados: Increase stack size for powerbtn task
We occasionally see stack overflows in the powerbtn task, so bump the
stack size.

BUG=chrome-os-partner:44202
TEST=Manual on Glados. Disable SLP_S0 GPIO interrupt, run 'reboot' on EC
console, verify that stack overflow is not encountered.
BRANCH=None

Change-Id: I858ad50e86b998e4283a5e11d3a720212150f657
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295571
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-26 05:12:38 +00:00
Shawn Nematbakhsh
d43ced8c8d mec1322: i2c: Unwedge controller on transaction timeout
If clk or dat aren't pulled up for an extended period, the i2c
controller may get into a wedged state that requires a controller reset
to recover from. There are no outward signs of the controller being in
such a state, other than transaction timeouts. Therefore, on a
transaction timeout, reset the controller.

BUG=chrome-os-partner:43270
TEST=Manual on glados:
- Run `gpioset PP3300_USB_PD_EN 0` on PD console and wait several seconds
- Run `gpioset PP3300_USB_PD_EN 1` on PD console
- Run `i2cscan` and verify all ports / devices ack
- Repeat above several times
BRANCH=None

Change-Id: I2ae42762ee6c961224ff50309a448475b67854b5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295404
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-26 00:17:46 +00:00
Bill Richardson
70951c9b75 Cr50: Export toolchain to child $(MAKE) processes
The external libraries need to inherit the tool chain, so they're
built with the same tools.

BUG=chrome-os-partner:43025
BRANCH=none
CQ-DEPEND=CL:295456,CL:295409
TEST=make buildall

Change-Id: I8b0b275ec77a003e07481391998961ab421066c8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295447
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-25 21:31:45 +00:00
Vadim Bendebury
9005ddd4bc cr50: add plumbing for signing CR50 RO images
The signer utility needs to be built and the flat image needs to be
signed. The signer utility is written in C++, supporting this required
adding a new make command to Makefile.rules and a build file for the
utility.

The signing now needs to be a part of generating the .flat file. To
achieve this an alternative set of rules is defined in Makfile.rules
for targets where RO image needs to be signed.

Rules for converting elf to hex have been consolidated as there is no
need to omit the --set-section-flags when it does not apply.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=as follows:
    - ran 'rm build/cr50; make BOARD=cr50'
    - observed that both build/cr50/ec.bin and
      build/cr50/RO/ec.RO.flat have the required signature header in
      the first 1024 bytes.
   - verified that the cr50 board can be booted over SPI using the
     image in build/cr50/RO/ec.RO.flat

Change-Id: Iacc22561de67fadfaf8e049bf9578cbd08cfad86
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295291
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-08-25 21:31:33 +00:00
Vadim Bendebury
d9a614826b cr50: add code for the signer utility
This utility reads a binary file, verifies that the first 1024 bytes
of the file are set to zero and replaces this block with a header,
containing the signature and other information required by the recent
CR50 ROM.

A test private key is included, it matches the FPGA ROM public key.

The use convention is simple: two parameters are required, the private
key file name and the binary file name. The signed binary file is saved
in the file with extension ".signed".

BRANCH=none
BUG=chrome-os-partner:43025
TEST=the utility builds using

   g++ -std=c++0x -I . -o signer codesigner.cc publickey.cc -lcrypto

  ec.RO.flat signed with this utility can be successfully bootstrapped
  a CR50 over SPS

Change-Id: I046b13d20f0dd8cff884e37ef966593e01dcb043
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295208
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2015-08-25 20:10:55 +00:00
Vadim Bendebury
b37514eed2 cr50: Move to RevB:20150820 FPGA
This changes the register description to match the newer FPGA version.
The new version supports firmware integrity verification as well as
bootstrapping over SPI slave interface.

BRANCH=none
BUG=chrome-os-partner:43791
TEST=with the rest of the patches (providing ability to sign firmware
     and load it over SPI) the code gets signed properly and loaded
     and started on the target

Change-Id: Ibebe5f6c510fbfb2c7c6ff40ab58ea643f051b1b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295211
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-08-25 20:10:50 +00:00
Vadim Bendebury
be7fbf3802 cr50: allocate RO header for signature
Leave 1024 bytes at the cr50 RO section for the signature required by
maskrom bootloader.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=with this and other changes the latest cr50 image gets signed and
     booted properly.

Change-Id: I64efe242b958bbb4e320cb3bb16c653d210dd662
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295201
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-08-25 20:10:44 +00:00
Rong Chang
f3a5046ed7 glados: oak: Add charger AMONBMON console command
AMONBMON is a charger feature to measure input current and battery output
current. ISL9237 output analog value of voltage diff across sense
resistor to EC's ADC channel. This change also reorders oak's ADC channel
to fix a reading bug.

BRANCH=none
BUG=chrome-os-partner:42270
TEST=manual
  in EC serial console, type command 'adc' and check AMON_BMON value.
  type command 'amonbmon' and check AC current and BAT current.

Change-Id: I9db0a72be7c9a428a16d1609eb8c461c6928e548
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/283665
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-25 13:11:19 +00:00
Shawn Nematbakhsh
1155520c8a glados: Disable keyboard + trackpad in tablet mode
The internal keyboard and trackpad must be disabled in tablet mode to
prevent unwanted input.

BUG=chrome-os-partner:44305,chrome-os-partner:40849
TEST=Manual on Glados. Boot system with lid open, verify that keyboard
is functional and ENABLE_TRACKPAD is high. Swing lid to tablet mode,
verify that keyboard is not functional and ENABLE_TRACKPAD is low.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9f250ae82963c8b497de991b6cce52c86841d08a
Reviewed-on: https://chromium-review.googlesource.com/295206
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-24 20:25:41 +00:00
Gwendal Grignou
3a7e513273 driver: bmi160: use rotation matrix to handle offsets.
Store offsets using sensors axis, not the device axis.
Therefore apply rot_standard_ref to the offset vector before
get and rot_standard_ref^-1 before set.

BRANCH=smaug
TEST=using mag sensor, check the offset are applied to the right axis
and store correctly.
BUG=chromium:517675

Change-Id: I95c8ef2a62603890184412674e7bde91ebecd288
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294596
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:40 +00:00
Anton Staaf
69bd4ce351 USART: Add DMA based receiver
This DMA receiver uses a separate small circular buffer to DMA into.
This allows the DMA transaction to be made circular, and thus it does
not require the interrupt latency to be low enough to setup the next
transfer before the next character comes in.

Additional diagnostics output have been added to the usart_info console
command to facilitate tuning of the FIFO size.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify DMA works by cross connecting two discovery boards

Change-Id: Idcdf95a47fadf21ec2154f0c9128cd3586e568ec
Reviewed-on: https://chromium-review.googlesource.com/292870
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
2015-08-24 19:08:35 +00:00
Anton Staaf
16f63703c9 USART: Add usart_info command
This optional console command is enabled with CONFIG_USART_INFO_COMMAND.
It will display and clear dropped character and overrun counts for all
configured USARTs.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: Icf6061aaab2cda71e9d317455c897828b9daf844
Reviewed-on: https://chromium-review.googlesource.com/292770
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
2015-08-24 19:08:30 +00:00
Gwendal Grignou
f7fa6248bf driver: accel: Apply offsets after rotation
Offsets are in the axis of the device, not the sensor.
Apply the offsets after rotiation

BRANCH=cyan
TEST=compile, test on cyan
BUG=chromium:517675

Change-Id: Iae9282efcbb5889bb0f1f556b7e5ca9fabe31b22
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294595
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:24 +00:00