Commit Graph

4333 Commits

Author SHA1 Message Date
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
Gwendal Grignou
0e01759ced math: Add inverse matrix calculation
Add a slow inverse matrix calculation function.
It is needed to apply factory offset properly.

Also consider the NULL matrix the identity matrix.

BRANCH=smaug,cyan
TEST=Unit test
BUG=chromium:517675

Change-Id: Ifa11954992e6f2fab02b4e92684e7b01bbaafe94
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294594
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:20 +00:00
Gwendal Grignou
de42bb285f motion_sense: calculate threshold properly
Working on light sensor, sensor were read on every time,
SENSOR_EC_THRES was not taken into account.
Fix 64/32 conversions and add a function for dealing with rollover.

TEST=Set light sensor probe at 1s. Set accel sensor at 100Hz to fill
fifo often; verify that light sensor is queried every second only.
BRANCH=smaug
BUG=chrome-os-partner:39900

Change-Id: If1df53c1a9a304c992f8e517f5d516210118a437
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291992
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:15 +00:00
Gwendal Grignou
5faadc6748 motion_sense: Force flush when sensor disabled.
When sensor is disabled, HAL will not send flush request to EC.
However, when sensor is reenabled, only new events are expected.
When we have a change in frequency, we have to request the host to
query all the current events.
Flush the FIFO when events are not needed because all sensors are
disabled.

BRANCH=smaug
TEST=Pass more tests: tests like ..._fastest_batching after _50hz_flush
have more change to pass.
BUG=chrome-os-partner:39900

Change-Id: I1a8fc3784e3e6be260b23103b28e336e242f14cd
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291991
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:10 +00:00
Gwendal Grignou
179d5d3c83 bmm150: add measurement repetition
To reduce noise the magnetometer measures in burst and
average the data.
Use "regular" presets: max frequency is limited to 100Hz.
Using a more precise presets limit frequency to no more than 50Hz.

BRANCH=smaug
TEST=Check magnetomter still works.
BUG=chrome-os-partner:39900

Change-Id: Ida6af86f6c207cc91e11378c129032f6d9e6b9ea
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291990
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:04 +00:00
Ben Lok
0b79533f88 oak: add battery setting for rev3 & rev4
The battery type of rev3 is changed to 3S, add this setting to battery_info.
But in order to compatible to 2S battery, set the minimum voltage of
battery to 6V rather than 9V.
For rev4, it should always connect to 3S battery and doesn't necessary to
support 2S battery.

BRANCH=none
BUG=chrome-os-partner:44428
TEST=manual
1. connect 2S battery to rev3.
2. check the battery info with EC command:
   > battery
3. confirm the voltage of battery is match to setting of battery_info.
4. connect 3S battery to rev3, and repeat step 2&3.

Change-Id: I626ed150d76a1dfba7d1caf08c4f19882e9cb089
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/295024
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-08-24 11:43:29 +00:00
Gwendal Grignou
da4239f64b ryu: add si1141 support
Add si1141 to the list of motion sensors.
Setup IRQ line and other constants.

BRANCH=smaug
TEST=Check sensor is working
BUG=chrome-os-partner:32829

Change-Id: Ic05bc24164d067a1dee6a6241681420348d7a843
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291336
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-22 09:31:57 +00:00
Gwendal Grignou
bbbbde0fc0 driver: si114x: Add ALS/Proxy sensor SI114x
Add the Silicon Image sensors, add it to the motion_sense module
to be used with the FIFO.

BRANCH=smaug
TEST=Check light and proxy on Smaug:
Check Light value in Lux are reasonable.
Check Proxy is detecting object, but value are in opposite of distance.
BUG=chrome-os-partner:32829

Change-Id: I11419a0f0613f0fae9323f99deedf5a1e6c6e29c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291335
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-22 09:31:50 +00:00
Gwendal Grignou
59138ad097 motion_sense: Allow multiple IRQ based sensors
Add a mask of custom events reserved for IRQ based sensors.
Copy data from raw_xzy to xyz while filling the FIFO
when FIFO is enabled.

BRANCH=smaug
TEST=Test with si1141 driver, check irq works for both driver.
BUG=chrome-os-partner:32829

Change-Id: I5e106df0c121e3bf1385f635195717395235ccc3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291334
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-22 09:31:45 +00:00
Gwendal Grignou
7b10244142 bmm150: Add support for calibration
Allow sending calibration information to the magnetometer.

BRANCH=smaug
TEST=Check from user space that calibration is taken into account.
BUG=chrome-os-partner:39900

Change-Id: Ic0f595bde1afdc0b6a79e3516a42b55d1f50c17c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291333
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-22 09:31:38 +00:00
Bill Richardson
ed0192a9b1 Cleanup: Remove cruft in Makefile from long ago
This removes a bit of Makefile magic left over from commit
950d507 (April 2013), when we began mocking individual functions
instead of files. It hasn't be used or useful since then.

BUG=none
BRANCH=none
TEST=buildall

Change-Id: Iacbef05cb07936f873f29948715e742e1ff465fc
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295175
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-22 01:38:00 +00:00
Gwendal Grignou
f59ab4c5f3 cyan: fix sensors matrices
Matches definitons set in
chromium/chromeos/accelerometer/accelerometer_types.h.

Using that standard, the coordinate frames of the lid and base DO NOT
line up perfectly when the lid is fully closed or fully open.

Therefore, rotate the lid vector 180 along the X axis before
calculating the lid angle.

BRANCH=cyan
BUG=chrome-os-partner:40177
TEST=When the device is open 180 degrees, check the sensors
agree with each other:
Flat on the back (Z pointing to the sky):
localhost devices # cat */*raw
-1008 [keyboard : X]
-112  [keyboard : Y]
16544 [kyeboard : Z]
-256  [lid : X ]
2000  [lid : Y ]
16336 [lid : Z ]
On the right side (X pointing to the ground)
localhost devices # cat */*raw
-16928
-48
-1040
-16176
432
80
On the bottom edge (Y pointing to the sky)
localhost devices # cat */*raw
-192
15872
1648
496
15936
752
Check the angle as calculated by the EC is correct using accelinfo.

Change-Id: Ib8ee42da8cf818213f892b1f024253f37a4da488
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294716
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
2015-08-22 01:37:55 +00:00
Shawn Nematbakhsh
9312676ab3 i2c: Fix i2c_lock deadlock on sysjump
On sysjump we attempt to lock all i2c ports in use, but locking is
by-controller. This leads to a deadlock if two ports from the same
controller are in use. Fix this by directly locking all controllers
present in the system.

BUG=chrome-os-partner:44214
TEST=`sysjump rw` and then `sysjump ro` on glados
BRANCH=None

Change-Id: I21d65cd4455769414216016a5c97ad118a712117
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294959
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-22 01:37:51 +00:00
Kevin Cernekee
5ca252d4ef i2c: Fix SCL unwedge logic
The current logic breaks out of the for() loop if SCL gets unwedged
(goes high), but still falls through to the "I2C unwedge failed,
SCL is being held low" case.  Fix this so that we only hit the
"SCL is being held low" case if SCL actually is stuck low.

BUG=none
BRANCH=None
TEST=compile-test only, on samus

Change-Id: I39df1966dc25517ee03a56109e7d0b740c5ca12b
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295043
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-22 01:37:45 +00:00
Shawn Nematbakhsh
ad8ce3f806 usb_pd: Add host command to limit external charger voltage / current
PD charger voltage + current can now be limited with
EC_CMD_EXTERNAL_POWER_LIMIT. The limit is automatically cleared when the
AP transitions out of S0 into S3 / suspend.

BUG=chrome-os-partner:43285
TEST=Manual on Samus w/ zinger.
- Plug zinger, verify charging at 20V/3A.
- `ectool extpwrlimit 3000 12000 --dev=1`, verify charging at 12V/3A
- `ectool extpwrlimit 1000 5000 --dev=1`, verify charging at 5V/1A
- Plug zinger into other port, verify still charging at 5V/1A
- `powerd_dbus_suspend`, verify charging at 20V/3A
- `chglim 2000 12000`, verify charging at 12V/2A
- `ectool extpwrlimit 0xffff 0xffff --dev=1`, verify charging at 20V/3A
- `chglim 1000 20000`, verify charging at 20V/1A
- `chglim`, verify charging at 20V/3A
BRANCH=ryu

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6cd5377be91b3df75f99cb414fd3fa5a463b56cb
Reviewed-on: https://chromium-review.googlesource.com/293954
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-22 01:37:38 +00:00
Vadim Bendebury
6f8637a6df cortex-m: provide ability to insert free space into RO image base
Some platforms might expect the header of the image to be a certain
platform specific blob. This patch adds an ability to insert an
arbitrary size header in the binary blob, if so desired, the intention
is to have the platform specific tools to postprocess the image and
replace the header with sensible data.

Ideally we should be able to produce an image which is mapped to start
at an offset to the FLASH_BASE, but the macros in ec.S.lds files are
way too smart for this.

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

Change-Id: Icabf00c6b90657b0ae3370ddad3567ccedf3ff49
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295200
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-22 01:37:31 +00:00
Bill Richardson
65d683a7e5 Cr50: Build external libs remotely, but put objects here
When building components from external libraries, instead of
rsyncing the library into our build directory and building there,
just build in the library directory and have it put its generated
objects into our build tree. That will keep any build artifacts
in the library directory from polluting our builds unexpectedly.

BUG=chrome-os-partner:43025
BRANCH=none
TEST=make buildall

Change-Id: I2f07a2b49d1a0ba9fd9fff0822551486be820b70
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295044
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-22 01:37:25 +00:00
Vadim Bendebury
0bb856d9e8 cr50: add tpm response processing.
This patch closes the loop of processing TPM commands, the response
generated by ExecCommand() is placed in the buffer to be returned
through FIFO read accesses.

State machine and register states are updated as per TCG Platform
Specification. A lot of debug output is generated, this is useful for
debugging, will be filtered eventually.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=with the appropriate tpm2 and trunks patches in place trunksd
     successfully initializes the CR50, sending such commands as
     Startup, GetCapability (three times) and SelfTest.

Change-Id: Ibbd952b53930e4530461db7dcdbc510a8022412c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293910
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
2015-08-21 20:08:59 +00:00
Ben Lok
ee6663563d stm32: spi: clear the spi sleep mask when AP in S3.
The SLEEP_MASK_SPI will not be cleared, if SPI received a bad data.
It is possible to block EC to enter deep sleep if AP send a bad
packet to EC before AP goto S3/S5. In order to ensure that deep
sleep can be enabled, clear SLEEP_MASK_SPI in chipset suspend hook
to avoid this situation.

BUG=chrome-os-partner:44170
BRANCH=None
TEST=manually
1. use AP console command to let AP enter S5:
   > shutdown -h now
2. check the sleepmask in EC console.
   > sleepmask
   sleep mask: 00000000

Change-Id: Ib5f5c421c123d9a3c2cc6fead07c8fa515e452f1
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/294432
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-08-21 08:10:27 +00:00
Rong Chang
c2ebc9e477 oak: use EXTRA_CLFAGS instead of CONFIG_BOARD_OAK_REV
Oak board revisions are not global configs. Move them out of
include/config.h . This change also makes it easier to build EC
and PD image for different board revisions.

BRANCH=none
BUG=none
TEST=manual
  build for board revision n and load on oak:
    make BOARD=oak clean
    make BOARD=oak_pd claen
    make EXTRA_CFLAGS=-DBOARD_REV=n BOARD=oak -j
    make EXTRA_CFLAGS=-DBOARD_REV=n BOARD=oak_pd -j

Change-Id: I331b4c5a1af94b179d7c6f7878a9c3939ea6025a
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294441
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-21 08:10:23 +00:00
Rong Chang
9f146c7b8a oak: enable oak TCPM power status
Oak doesn't have enough interrupt pins to detect VBUS change. This CL
enables oak TCPM power status alert.

BRANCH=none
BUG=chrome-os-partner:41226
BUG=chrome-os-partner:42610
TEST=manual
  load on oak rev2. plug in normal type-c charger or legacy type-c
  chargers and check charging status.

Change-Id: I9659e749b515f999fe9e81373567f52ec3fe956a
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291161
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-21 08:10:16 +00:00
Alec Berg
16cbaf1cd1 oak: add usb charger tasks
Add USB charger tasks to oak to detect legacy charger type.

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

Change-Id: Idb8061c39b0bb8b42f47cbe3ff213b04f14c889a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/290420
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2015-08-21 08:10:11 +00:00
Scott
d862dd0598 pd: Enable detection of VBUS via the TCPM/TCPCI interface
Modified TCPC layer to utilize the Power_Status and Power_Status_Mask
registers. VBUS status is stored in Power_Status and when a change
is detected, it's communicated to the TCPM via the ALERT# line.

BUG=chrome-os-partner:43440
BRANCH=none
TEST=Tested the feature on Glados and Oak connecting to both Ziger
and Samus. Verfied that VBUS status is communicated via the TCPCI and
that PD contracts are established without using the VBUS_WAKE GPIO
lines on Glados and Oak.

Change-Id: Ie5aa32eecc887f3cb00880a285f1e710b7064384
Signed-off-by: Scott Collyer <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289931
Reviewed-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2015-08-21 08:10:03 +00:00
Vijay Hiremath
646760bb20 Skylake: Add low power Pseudo G3 support
BUG=none
TEST=Used "shutdown -h now" Kernel console command to test on Kunimitsu.
     With only battery after 1 hour, device enters to Pseudo G3 and the
     V3p3A is off. With AC connected, device is in G3.
BRANCH=none

Change-Id: I955662eb69ac608e9b2d12bdcfbc1258ca83f3a5
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/292976
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-21 03:46:19 +00:00
Todd Broch
f0a1e5dfd1 ryu: re-calibrate lightbar colors for device.
Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=smaug
BUG=chrome-os-partner:44029
TEST=manual,

1. Boot device into S0
2. From EC console

lightbar
...
 15     0f     06
 16     0f     20
 17     16     08
 18     06     21
 19     26     11
 1a     1d     0b

These values match requested values.

Change-Id: Ib65044510ac24bd41d63586534685f995fcb131d
Reviewed-on: https://chromium-review.googlesource.com/294840
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2015-08-21 00:49:26 +00:00
Wenkai Du
60ddfc8310 kunimitsu: Enable CONFIG_VBOOT_HASH
Port Shawn's patch for glados to kunimitsu:

Enable CONFIG_VBOOT_HASH to support image hash related host commands.
Originally-reviewed-on: https://chromium-review.googlesource.com/294567

Removed temperature sensor test command to save space.

BUG=chrome-os-partner:44214
TEST=Verify `ectool echash` prints a hash
BRANCH=None
Change-Id: I72312cd4d3ae116073e15bb07ca3256c82efe3dd
Signed-off-by: Wenkai Du <wenkai.du@intel.com>
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/294735
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-21 00:49:17 +00:00
Todd Broch
82bc3c7028 bq2589x: Add CONFIG_CHARGER_TERM_CURRENT_LIMIT support.
Create a config to allow customization of a board's charger
termination current and add support to bq2589x charger.

Note, BQ2589X_TERM_CURRENT_LIMIT_DEFAULT, currently set to 64 to make
CL benign to ryu board.  Future CL will change to 256 as thats the POR
value for that charger.

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

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

Change-Id: I79348ed62a077a6432c8d8db6ac90e1e4e92dbc7
Reviewed-on: https://chromium-review.googlesource.com/293095
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2015-08-20 07:49:48 +00:00
Bill Richardson
09b065c84c lightbar: document how it all works
Add a huge comment so people can figure this out easier.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I042a209c06023210b8ad53d138971ffee4b89ab7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294179
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-08-20 04:43:46 +00:00
Shawn Nematbakhsh
3449026b47 glados: Enable CONFIG_VBOOT_HASH
Enable CONFIG_VBOOT_HASH to support image hash related host commands.

BUG=chrome-os-partner:44214
TEST=Verify `ectool echash` prints a hash
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ida17b6cbd03ba0a136df1306bf277dc548a5d9ef
Reviewed-on: https://chromium-review.googlesource.com/294567
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-20 03:12:12 +00:00
Shawn Nematbakhsh
43b3f5bc88 glados: Remove console commands to reduce image size
Remove 'i2cscan' and 'hash' (not yet present, but would be added with
subsequent commit) to reduce image size.

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

Change-Id: I3831ff8565291a992b14a28d5c3a14a74828a57a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294566
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-20 03:12:07 +00:00
Dino Li
911de4d175 nds32: use INT_MASK instead of GIE
When there is an interrupt event, N8 CPU will save PSW register to IPSW
register and clear GIE then jump to interrupt service routine. N8 will
restore PSW from IPSW after "iret" instruction (the above are purely
hardware mechanism).

Nested interrupt will occur if we set GIE again in interrupt context.

symptom:
    power button pressed while LID open -> exception or unknown reset.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. Manually pressed power button x200.
     2. Console "eflash" erase and write eflash OK.

Change-Id: Ic04a23d473ebc6417dffea814a27583cb8d63a1f
Reviewed-on: https://chromium-review.googlesource.com/289437
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2015-08-20 01:37:56 +00:00
Mulin Chao
8c633e5af6 nuc:
Modified i2c driver into controllers and ports to support I2C0 port 0/1 at
the same time.

Modified drivers:
1. i2c.c: Support i2c controller mechanism and fixed bug for i2c_raw functions
used by i2c_wedge and i2c_unwedge.
2. gpio.c: Fixed bug for gpio_alt_sel since wrong type of func.
3. lpc.c: Fixed bug for port80. Since disabling SUPPORT_P80_SEG, we should
replace GLUE_SDP0/1 with DP80BUF.

BUG=chrome-os-partner:34346
TEST=make buildall -j; test nuvoton IC specific drivers
BRANCH=none

Change-Id: I9919269e4f5e795d9ceb8a4cd2c39abbd7bb6b1a
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/294015
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-19 08:10:27 +00:00
Aaron Durbin
b3d1171d42 skylake: power sequencing update
There are a number issues with the current skylake power
sequencing. First, SLP_SUS_L was not being honored from
the chipset when a deep S5 or S3 was requested. Additionally
the BATLOW_L signal was being used to block the chipset from
waking which caused a race in waking from deep S5 that required
an additional pulse of the PCH_WAKE_L signal instead of the
chipset seeing the power button event. Another issue is that
POWER_S5 state was being completely bypassed so any global
resets that brought down SLP_S4_L caused the state machine
to enter into G3 state.

The code was changed to remove BATLOW_L usage, PCH_WAKE_L
in the POWER_G3S5 state, and SLP_SUS_L is honored in the
non POWER_S5G3 and POWER_G3 state. That allows SLP_SUS_L
pass-thru to work on glaods. Lastly the code was reorganized
to accomodate the above change without sprinkling them
throughout the state transitions.

BUG=chrome-os-partner:44081
BUG=chrome-os-partner:44082
BUG=chrome-os-partner:43475
BRANCH=None
TEST=Built and booted glados. Deep S3 and S5 wakes work. Fresh
     flash plus a global reset doesn't bring the system down to G3.

Change-Id: Id1d7af1b6a733a9db5aad584950da8ab5898ea83
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293844
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-19 08:10:20 +00:00
Aaron Durbin
7ad94648a5 glados: make BATLOW_L open drain and default high
The BATLOW_L signal is externally pulled up to PP3300_DSW.
Therefore, there's no need to pull this up internally to
the EC's rail. Additionally, allow BATLOW_L to be high
by default as a forthcoming power sequencing change doesn't
utilize the BATLOW_L signal.

BUG=chrome-os-partner:44081
BUG=chrome-os-partner:44082
BUG=chrome-os-partner:43475
BRANCH=None
TEST=Built and booted glados.

Change-Id: I175408d64b728cacc3f6a305680962fe0320eeb9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293843
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-19 08:10:16 +00:00
Aaron Durbin
eb1327ea0c glados: don't pull up SLP_S0_L
The SLP_S0_L signal lives in the primary power well of skylake
while the EC's VCC is on the DSW rail. If SLP_S0_L is pulled up
then there is leakage into the primary well when it's not on.

BUG=chrome-os-partner:44098
BRANCH=None
TEST=Built and booted glados. Default powerindebug state shows SLP_S0_L
     low when in deep sleep states.

Change-Id: If9c7972fb6a8b8f90738c1c0f7eea6cf2373d64b
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293842
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-19 08:10:09 +00:00
Shawn Nematbakhsh
4d382ad640 charge_manager: Support multiple independent charge ceilings
We will soon have a need to independently set a charge ceiling from both
the PD state machine and from incoming host commands. Store these
ceilings separately, and have the minimum take effect.

BUG=chrome-os-partner:43285
TEST=Pass unit tests. Also, host command current limit takes effect with
subsequent commit.
BRANCH=None

Change-Id: I0ecfe888a7df0d5da5a68999c164c7c841da348b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293818
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-19 01:50:21 +00:00
Duncan Laurie
aa14b36f18 skylake: Wake from Deep S5 after battery low is deasserted
The system will not wake from Deep S5 if BATLOW# is asserted,
so wait for that to deassert, then pulse the wake pin and wait
for SLP_SUS_L to deassert.

BUG=chrome-os-partner:43545,chrome-os-partner:44079
BRANCH=none
TEST=verified on P2 board

Change-Id: I3b36159b574d418c9b79c478d0a41f753474fa6a
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293595
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-17 20:15:42 +00:00
Bill Richardson
5a4ae0c3cd Cr50: Fix spshc console command
The SPS RX FIFO handler prototype changed from passing cs_enabled
to cs_disabled, but the callback function for the spshc command didn't.
Now it does.

The spshc command switches the protocol on the SPI Slave bus to
expect EC Host Commands.

BUG=none
BRANCH=none
TEST=manual

At the EC console:

  spstpm off
  spshc

On the build machine, with an FTDI cable connected to the SPS
input:

  cd extra/ftdi_hostcmd
  make
  ./test_cmds

Change-Id: I69294a977b83854c5f6348904330bf74416cc6ec
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293619
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-15 01:32:39 +00:00
Shawn Nematbakhsh
4e355700aa glados: Switch to V2 board
Switch to V2 glados as the default, and remove support for V1.

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

Change-Id: I58f33225177d259916e8877084c2c431922e7bc5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293303
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-08-14 21:04:48 +00:00
Vadim Bendebury
571b7bb640 cr50: tpm2: pull in the tpm2 library sources
This patch syncs up TPM2 sources into the build area when building
cr50 image. This relies on a specific directory layout so that the ec
makefile has access to the tpm2 source tree.

The sources are copied using rsync, the tpm2 library is a dependency
for the RO/RW elf images, and is declared to be a phony make target,
which guarantees that the tpm2 make is always run when cr50 image is
built.

Include files in board/cr50/tpm2 are necessary to be able to build
tpm2 code using the bare metal toolchain used for building ec code.
memory.h is in fact empty, it is easier to add it here than to wrap it
in conditional compilation at the source.

Make variables CROSS_COMPILE and CFLAGS are exported for the benefit
of the tpm2 makefile. ROOTDIR indicates where tpm2 library should look
for .h files not available from the toolchain.

CQ-DEPEND=CL:292946
BRANCH=none
BUG=chrome-os-partner:43025
TEST=make buildall -j succeeds;
     when linked with the latest tpm2 source, the combined image
     starts the tmp task and reacts to the host sending the startup
     command (failing due to unplugged stubs).

Change-Id: Ia3fd260588558c2bacd724df9583052fa4660ca3
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/292975
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-08-14 21:04:43 +00:00
Vadim Bendebury
6386c37379 cr50: introduce tpm task skeleton
TPM command processing should not be happening on the interrupt
context.

This patch adds a skeleton of the task which handles TPM functions. It
initializes the TPM and then enters endless loop waiting for an event
trigger from interrupt, which happens when a valid FIFO message is
received.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=none yet

Change-Id: I63dce2762cc07370a05bf00bdf144c5d9eb6019b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289332
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-08-14 21:04:38 +00:00
Vadim Bendebury
73a8098d79 export MSDN clock() function
TPM implementation requires a free running clock with granularity
better than a 10 us. clock_t definition comes from the toolchain
includes.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=none yet

Change-Id: Id3de5fd055aa598afe15657011b88d2c6be4cdfb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-14 21:04:32 +00:00
Dino Li
26984c7de4 it8380dev: add __muldi3.S
symptom:
Enable debugging and profiling statistics for hook functions
(#define CONFIG_HOOK_DEBUG), and __muldi3 function is missing
while link.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. compile successful and hook_notify starting to print message.
     2. console "hookstats"

Change-Id: Ia2815bcefd0f9ac06dab9c75ea6ee06312878ca2
Reviewed-on: https://chromium-review.googlesource.com/293432
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2015-08-14 14:34:26 +00:00
Dawei Li
68088eb93f twinkie: bug fix for injector.c:cmd_bufrd
bug: when typing
> tw bufrd 3 2
in twinkie console, the command will output 3 elements
However, the third argument(3) is where it starts output
the elements; and the fourth argument(2) is the number
of elements to be printed.

Original code uses: "cnt = strtoi(argv[0], &e, 10);" to
get the count.
It should use "cnt = strtoi(argv[1], &e, 10);" instead.

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

Change-Id: I04cf041e47cdf72c5189e4b8446c8f8e4cc5e2e5
Reviewed-on: https://chromium-review.googlesource.com/293561
Tested-by: Dawei Li <daweili@google.com>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Commit-Queue: Sheng-liang Song <ssl@chromium.org>
2015-08-14 02:25:55 +00:00