Commit Graph

5004 Commits

Author SHA1 Message Date
Mulin Chao
f700e3bb0e nuc: Add support for CONFIG_LOW_POWER_S0.
To get better power consumption in S0, we add FW support for
CONFIG_LOW_POWER_S0.

Before entering deep idle in S0, we must enable Host interrupt to wake up
EC if it needs to service LPC bus.

This version also add a new bit of sleep_mask (SLEEP_MASK_FAN) in system.h
to prevent EC enter deep idle if fan's duty isn't zero. Normally, the freq of
PWM fan is 25 kHz. It means we must select apb2 clock as the source clock of
PWM fan. Or fan would stop when ec enters deep idle because of no PWM signal.

In hwtimer.c, we reset the preload counter to maximum value in ITEI32's ISR
since preload counter is changed by __hw_clock_source_set all the time.
We also found there're no event set if it's deadline is over 32 bits but
current source clock isn't. To prevent ec doesn't wake-up in deep-idle even if
ITIM32 expires, FW set an event for ITIM32 after process_timers().

Modified sources:
1. wheatley/board.h: Add CONFIG_LOW_POWER_S0 definition.
2. clock.c: Enable Host interrupt for LPC.
3. clock.c: Disable LP_WK_CTL for better power consumption.
4. gpio.c: Add ISR for Host interrupt.
5. uart.c: Introduce bit 6 of USTAT to make sure transmitting is completed.
6. register.h: Add uart_clear_pending_wakeup function.
7. hwtimer.c: Fixed watchdog issue when ITIM32 is closed to overflow.
8. fan.c: Enable deep sleep if duty cycle is zero.
9. include/system.h: Add SLEEP_MASK_FAN for fan control loop.
10. core/cortex-m/task.c: Add "isb" to flash the garbage data in the
    instruction pipeline.

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

Change-Id: Ibe3630d0d68cf3f32206adb2afa1b5958916a2be
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/324651
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-06 01:57:58 -08:00
Luigi Semenzato
4ec554dd8f ectool: add inject-keys.py
A simple wrapper for "ectool kbpress" to do basic automation
when working remotely (for instance, logging in).

Includes a test script.

BUG=b:26349756
TEST=ran on platform in various ways
BRANCH=none
Signed-off-by: Luigi Semenzato <semenzato@chromium.org>

Change-Id: I96fdd99aa228b51cf22f9323facdc4ddb59db9ff
Reviewed-on: https://chromium-review.googlesource.com/322286
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-05 06:02:49 -08:00
nagendra modadugu
c68e5a7c9b CR50: Add initialization code required by TPM2 compliance tests.
BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524,chrome-os-partner:50115
TEST=initial TPM2 tests pass

Change-Id: Ie614f29e578fb177245c33e6d1a896534a8d6095
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/326180
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-05 06:02:46 -08:00
Mulin Chao
ff52ac20c1 common: Fix sleep mask for multi-port lock.
This change use a simple counter to to prevent ec enter sleep if there's
any i2c port active. Once there's no i2c port active, we enable sleep bit of
i2c in i2c_lock() func. Please note FW disables interrupt during changing
counter to prevent preemptive conditions.

Modified sources:
1. common/i2c.c: Fix sleep mask for multi-port lock.

BUG=crbug.com/537759
TEST=make buildall -j; test on wheatley when CONFIG_LOW_POWER_S0 is deifned.
BRANCH=none

Change-Id: I17c226108fee0e5d656fa157808179898f9a8dbf
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/325256
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-04 19:15:06 -08:00
Nadim Taha
1b9e6b2375 Cr50: Modified the flash driver to retry operations as appropriate.
The max retry counts are based on the TSMC specification. This is a necessary
change given that we're using their smart program/erase algorithms.

BRANCH=none
BUG=chrome-os-partner:45366
TEST=Tested RW updates.

Change-Id: I18ca09e54ce13f2cf75dac32fb2457d5963ca040
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/325535
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-04 20:56:10 +00:00
li feng
00fbe2a0aa kunimitus: add VCONN swap ability
BUG=none
BRANCH=glados
TEST=make -j buildall

Change-Id: Ifa4273acbeab8b8463eddae2d9dde9c158f337a3
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/325529
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-03 21:34:56 -08:00
Shawn Nematbakhsh
c5e0634054 cleanup: Fix signed vs unsigned typing
- ec_response_thermal_get_threshold.value is unsigned, so it can not be
  less than zero.
- make power_button_wait_for_release() take a signed int, to match its
  existing usage.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie5748df3d9904d1e417adc38fee18f8cb3ce9750
Reviewed-on: https://chromium-review.googlesource.com/325840
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-03 21:34:47 -08:00
Aseda Aboagye
086e501be3 util: ec3po: Add OOBM queue and dynamic loglevels.
This commit adds an Out Of Band Managament queue which will allow the
console to receive commands outside of the PTY which it can take
action on.  The first use of this is to dynamically change the logging
level.  Prior to this change, changing the log level using dut-control
would not affect the log level of the console or interpreter.

BUG=None
BRANCH=None
TEST=Launch modified servod; issue dut-control loglevel:debug, verify
that debug messages from both servod and ec3po are emitted.  Then
issue dut-control loglevel:info and verify that no debug messages from
either are emitted.

Change-Id: I692824742b018da9540a81305985f6f355f716e6
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/325134
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-03 17:16:33 -08:00
Anton Staaf
f6f06c95d6 NPCX: Move control of PD GPIO hibernation state to board
Use board_set_gpio_hibernate_state to configure the PD GPIO's to support
charging while hibernating.

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

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

Change-Id: I7b960967670c07f4861a59345bc23c97d3f61cc0
Reviewed-on: https://chromium-review.googlesource.com/325443
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2016-02-03 17:16:31 -08:00
Stefan Reinauer
bc404c94b4 Enforce compilation without system headers
This patch introduces HOST_CPPFLAGS to be used for all
objects being compiled with HOSTCC rather then the target
compiler.

Since glibc is not linked into the EC, no glibc include files
should be included in the EC code base. Hence, create local
definitions for clock_t and wchar_t that match what the glibc
include would have done, and remove some unneeded includes.

Due to very eager optimization, we have to give gcc a little
notch to not kick out memset.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BUG=chrome-os-partner:43025
BUG=chrome-os-partner:49517
BRANCH=none
TEST=compile tested

Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239
Reviewed-on: https://chromium-review.googlesource.com/322435
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-02-03 15:00:50 -08:00
Bruce
fc9ed52397 Chell: Setting battery charging maximum value of temperature
Setting battery charging maximum value of temperature.
If battery temperture is over than 45 degree, set charge current to
0 mA, and charge state to idle. Then LED will turn to white in idle
state.

BUG=chrome-os-partner:49695
BRANCH=glados
TEST=check the battery will not charge when battery temperture is
over than 45 degree, and LED turn to white. Then temperture is less
than 45 degree, the battery will charge and LED turn to amber.

Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/323982
Reviewed-by: Shawn N <shawnn@chromium.org>
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
(cherry picked from commit 4994d85d3b6c589e3ac297697aeb36456f2401a6)
Change-Id: Ic7d3fe0c482fab76041c5ae3f35402e529576b1c
Reviewed-on: https://chromium-review.googlesource.com/325487
2016-02-03 15:00:45 -08:00
Aseda Aboagye
8d3fe8d54d util: ec3po: Change console permissions to 660.
666 gives out permissions to everyone and should be avoided.  A
similar change is made in servod.

BUG=None
BRANCH=None
TEST=Run console.py and verify that the created PTY has the
permissions of 660.

Change-Id: Ib58952af5f9681fdc2ef351b2c2ac2ec10109095
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/325493
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-03 15:00:19 -08:00
nagendra modadugu
dfb7901709 CR50: fix unaligned memory accesses in dcrypto/aes.
BRANCH=none
TEST=new tests under test/tpm2/ pass.
BUG=chrome-os-partner:43025,chrome-os-partner:47524

Change-Id: Ibfc92eae8238954a861a8e91432f90db6d174ead
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/325495
Commit-Ready: Vadim Bendebury <vbendeb@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
2016-02-03 14:59:36 -08:00
Todd Broch
1ca9536835 kunimitsu: lars: enable USB PD logging.
Enable USB PD logging.

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

BUG=chrome-os-partner:45933
BRANCH=none
TEST=make -j buildall
make -j BOARD=kunimitsu tests

Change-Id: I05f80712e2efe59a3a3cdf333885b111cc79953b
Reviewed-on: https://chromium-review.googlesource.com/325380
Commit-Ready: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-03 14:59:36 -08:00
nagendra modadugu
18197b8034 CR50: fix incomplete hash state initialization.
The hashAlg field is expected to be populated
by _cpri__StartHash.

BRANCH=none
TEST=new tests under test/tpm2/ pass.
BUG=chrome-os-partner:43025,chrome-os-partner:47524

Change-Id: I237183c916fa800a82853aee8def7d734f53d6e9
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/325386
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
2016-02-02 23:48:49 -08:00
Vijay Hiremath
33fe5e437d charger/Kunimitsu: Fix for boot from cut-off battery
Battery in cut-off mode wakes when voltage is applied to the PACK
and takes approximately 2 to 3 seconds to initialize before capable
of providing the power. Hence made the battery present status to
BP_NO in case of cut-off mode. Once the battery is ready new status
is updated as BP_YES.
When the battery status changes from BP_NO to BP_YES, charger input
current is set to board specific charger input current which is not
sufficient to boot the AP hence the system reboots. To avoid this
issue, added code to write charger manager negotiated current to
charger input current when the battery status changes from BP_NO to
BP_YES.

BRANCH=none
BUG=chrome-os-partner:49224
TEST=Manually tested on Kunimitsu.
     Used console command 'cutoff' to put the battery in cut-off mode.
     Inserted the adopter to wake the system, system doesn't reboot &
     the battery charges.

Change-Id: Ia5a1457506b4bef0b3dd27993e4b60ae64c8f746
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/322430
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-02 23:48:33 -08:00
CHLin
0c50cae42e nuc: Reduce the period of watchdog check timer
There is probability to fail in firmware_ECWatchdog FAFT test by using
CONFIG_WATCHDOG_PERIOD_MS period for check timer. Use
CONFIG_AUX_TIMER_PERIOD_MS instead can fix it.

Modified drivers:
1. watchdog.c: change watchdog check timer period from
CONFIG_WATCHDOG_PERIOD_MS to CONFIG_AUX_TIMER_PERIOD_MS.

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

Change-Id: I93e700968751ecd58f032c2f5866cf4f2eb0ffe4
Signed-off-by: CHLin <chlin56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/324712
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-02 23:48:28 -08:00
nagendra modadugu
83b9a7ea70 CR50: define EMBEDDED_MODE=1 for code under cr50.
EMBEDDED_MODE was missing from code compiled under
cr50/tpm2, which resulted in code under third_party/tpm2
and cr50/tpm2 inferring differing declarations for
a given type.

BRANCH=none
TEST=tests under test/tpm2 pass
BUG=chrome-os-partner:43025,chrome-os-partner:47524

Change-Id: I56935f5ae8fc45e6b7f71eb239b3e0c325086795
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/325471
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
2016-02-02 23:48:11 -08:00
Shawn Nematbakhsh
990ca7a1bc pd: Reinitialize state variables on TCPC reset
Resetting our state to default without also resetting the power role may
lead to a state / role mismatch.

BUG=chrome-os-partner:49563
TEST=Verify kunimitsu correctly detects charger at either polarity on
sysjump.
BRANCH=glados

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I239df9793773429e9b84a847e55d6753577fab32
Reviewed-on: https://chromium-review.googlesource.com/325385
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-02 23:48:04 -08:00
Vadim Bendebury
9abc13d25a cr50: signer should be a dependency for RW_B target too
The makefile is missing an explicit dependency which ensures that the
signer utility is available by the time the RW_B image is built. This
works most of the time, but once in a while RW_B gets ahead in the
race and the build fails.

Adding explicit dependency will prevent this from happening.

BRANCH=none
BUG=chromium:578761
TEST=make buildall -j still succeeds.

Change-Id: I7f5223f51e71b1d78de012bf5d934f1a17c86cc0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/325031
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-02-02 17:20:10 -08:00
Patrick Georgi
960cf45b3f Don't declare functions inline that aren't always defined as such
gcc 5.2 bails out on an inline declaration that isn't followed up with
a definition in the same compilation unit.

BRANCH=none
BUG=chrome-os-partner:49517
TEST=compile tested with coreboot's toolchain. samus, oak and others
that failed now build.

Change-Id: Ic9c28fc12c80e24ea0dbf85f35846fd6a0b56a2d
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324970
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2016-02-02 17:20:04 -08:00
Duncan Laurie
b7cf464b86 chell: Enable S0ix power state support
Enable the config option for S0IX power control and set the GPIO to
use power_signal_interrupt_S0.

BUG=chrome-os-partner:49274
BRANCH=glados
TEST=echo freeze > /sys/power/state
Unfortunately currently SLP_S0_L is not asserting so this is difficult
to actually test the EC behavior

Change-Id: I302da7735c9622975e0386a0b4542f41c7231df9
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324567
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-01 17:18:26 -08:00
Stefan Reinauer
4f6f505900 Fix null pointer check in tokenFilename()
From https://scan.coverity.com/projects/chromium-ec :
CID61407: Dereference after null check

The home directory that is received from getpwuid()
needs to be assigned to home but it wasn't.

BUG=none
BRANCH=none
TEST=build tested
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: I36c30906e1388e2f8a0d466d516a5ffa6ae70bf6
Reviewed-on: https://chromium-review.googlesource.com/324637
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-01 17:18:23 -08:00
Nadim Taha
c8484a9138 Cr50: Fixed soft resets on silicon.
Fixed the peripheral clock enable definitions and enabled the low speed
timers.

BRANCH=none
BUG=none
TEST=Tested soft resets on silicon.

Change-Id: Ie63e5732e5bead174abda89e5c5069b818212e9b
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324843
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-01 21:17:22 +00:00
Nadim Taha
9c4f2b00eb Cr50: Removed references to FPGA-only registers from the bootloader.
BUG=none
BRANCH=none
TEST=Booted to an RW image on silicon.

Change-Id: Iadca3c05cfd095427867d877e4a916c999a9cdb3
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324803
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-01 20:58:14 +00:00
Vijay Hiremath
e7a9ccbf04 Kunimitsu: Change the battery minimum voltage value
Charger Low_VSYS_Prochot# threshold voltage assertion is set to
6V hence increased the minimum battery voltage to 6.1V to avoid
unwanted Prochot# assertions.

BUG=none
TEST=Drained the battery to 6.1V, Prochot# pin did not assert.
BRANCH=glados

Change-Id: Ie5d4decf3327a45d64638771dd8a5fc7017db261
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/324564
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-01-31 05:04:32 -08:00
nagendra modadugu
cddf3c05da CR50: implement _cpri__StirRandom as a no-op.
Stirring the random pool on CR50 is not currently
supported, so just implement as a no-op.

TEST=none
BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524

Change-Id: I32b0144737139e524d4f71a11cc9d4ad939cd9cb
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324620
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-29 22:44:37 -08:00
Donald Huang
bca1ba350f it8380dev: util: Enhance iteflash
Add verify function.

BRANCH=none
BUG=none
TEST=Test OK on ITE8390CX.
     You can run "make -j BOARD=it8380dev" to build ec.bin
     and flash the ec.bin via
     "sudo ./build/it8380dev/util/iteflash -w ./build/it8380dev/ec.bin"

/* ==SNAPSHOT START== */

(cr) (b-verify) donald@donald-nb ~/trunk/src/platform/ec $ sudo ./build/it8380dev/util/iteflash -w ./build/it8380dev/ec.bin
Waiting for the EC power-on sequence ...CHIPID 8390, CHIPVER 82, Flash size 256 kB
Done.
CHIPID 8390, CHIPVER 82, Flash size 256 kB
Erasing chip...
/100%
Writing 262144 bytes at 0x00000000
Done.
Verify 262144 bytes at 0x00000000
-100%
Verify Done.

/* ==SNAPSHOT END== */

Change-Id: Iac08e2eeb934c3a4a721e17a85de628ea4d9d065
Signed-off-by: Donald Huang <donald.huang@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/322524
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-29 01:06:33 -08:00
Shawn Nematbakhsh
88e64e11e1 chell: Trigger PMIC shutdown rather than hibernate
Shut down all PMIC-supplied power rails rather than initiating EC / PD
hibernate. This results in considerable power savings.

BUG=chrome-os-partner:48835
BRANCH=glados
TEST=Manual on chell. Run "hibernate" on EC console, verify that 3.3V EC DSW
rail goes to 0V, and the EC powers up on zinger insert, lid open or power
button press.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I7bf0c494ea240183240f5a6abc3d611df8efb45a
Reviewed-on: https://chromium-review.googlesource.com/324087
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-01-28 22:54:54 -08:00
Shawn Nematbakhsh
9148a4dc01 system: Add hibernate board-level callback
Allow boards to take action (such as entering a custom low-power
hibernate-like state) before putting the chip into hibernate state.

BUG=chrome-os-partner:48835
BRANCH=glados
TEST=Manual with subsequent commit on chell. Verify board-level
hibernate callback is called when "hibernate" is run on EC console.

Change-Id: Ie1da044037a74ff8bce5c822f28ce837c62ceec0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324086
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-01-28 22:54:54 -08:00
Nadim Taha
db7194fbe4 common: Fixes the SFDP_BITFIELD() macro.
BUG=none
BRANCH=none
TEST=<redacted>

Change-Id: If6e2732a29e084417ba1d2f80732ac412028342a
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324622
Reviewed-by: Ewout van Bekkum <ewout@chromium.org>
2016-01-29 02:59:58 +00:00
nagendra modadugu
26bbc59b46 Fix bug in software sha256_hash()
The implementation for sha256_hash() copied
and incorrect number of bytes to the output.
This change provides a fix and a test.

TEST=added test case
BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524

Change-Id: I74e98c6f5005a14dd5c0ca19ea7540622dd6c7d7
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324391
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 14:16:19 -08:00
Akshu Agrawal
d60d263b83 Kunimitsu: Fixing build error when enabled CONFIG_GYRO_L3GD20H
Fixing a typo which causes build error when building with GYRO_L3GD20H

BUG=None
BRANCH=master
TEST=build and run with #define CONFIG_GYRO_L3GD20H

Change-Id: I04abb4bff9cdf9208ff224de74188315094fb941
Signed-off-by: Akshu Agrawal <akshu.agrawal@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/323630
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-28 14:16:18 -08:00
Ewout van Bekkum
747a9f0786 cr50: adds the ability to configure muxed inout peripherals
Adds the the code necessary to support muxed inout peripherals on
cr50 like SPS and SPI0 by adding a new signnal to pin connection
flag. Note these are for direct wired peripherals where no muxing
is necessary, the input pads just need to be enabled.

BRANCH=none
BUG=none
TEST=verified pinmux registers through m3

Change-Id: I1a375a3a14fb44fc4f9ced764fd2c54bb2b91e22
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/323848
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 21:45:53 +00:00
Ewout van Bekkum
99f62cb3a9 common: Adds a JEDEC SFDP v1.* based Serial NOR Flash driver
Adds a JEDEC SFDP v1.* compatible Serial NOR Flash driver to control
multiple Serial NOR Flash devices (NOR EEPROMs, etc.). The SFDP tables
are used to discover parts' page sizes and capacities.

This driver only supports parts with capacities under 4GiB. If the
parts are larger than 16MiB, then the 0xB7 4-Byte addressing mode
entry opcode and 0xE9 4-Byte addressing mode exit opcode are required.
This driver also assumes that a 4KiB erase opcode of 0x20 is always
available.

BRANCH=none
BUG=none
TEST=Tested on cr51 with multiple EEPROMs with various SFDP revs

Change-Id: I5c2b757267e23c4f22ac89c6d5048a54b04de0c3
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/321922
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 21:45:37 +00:00
Nadim Taha
8f39d1d519 Modified the bootloader to check PMU_PWRDN_SCRATCH30 and load the newer
of the two RW images if set.

Imported the Haven "signed_header.h" file into chip/g and fixed prior
references to the util/ copy.

BUG=none
BRANCH=none
TEST=Went through a full update. Simulated a botched update.

Change-Id: I1e4c006ef391270a7e350fea6f43cc1a1b057d0e
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324109
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 20:58:32 +00:00
Ewout van Bekkum
f8f0618ca4 common: Adds JEDEC SFDP v1.0 & v1.5 encoding and decoding
Adds a header with JEDEC SFDP v1.0 (JESD216) & v1.5 (JESD216A)
encoding and decoding support to enable a part agnostic Serial NOR
Flash driver.

BRANCH=none
BUG=none
TEST=Tested through the spi_nor driver

Change-Id: I00b3f0434bfb8582aebad7cd0682445980b57773
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/321921
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 12:19:31 -08:00
Dino Li
a313fc9b1a chip: it83xx: fix EC interrupt vector registers issue
We have a limitation for EC interrupt vector registers.
System may read incorrect interrupt number in ISR so we need to add
a workaround to prevent it.

The following is a example that got incorrect interrupt number:
1. REG IVCTx = 0x10. (no interrupt pending)
2. EC INT6 interrupt occurs (IVCTx = 0x16) and jump to ISR.
3. Read interrupt vector register to determine interrupt number.
4. Higher priority interrupt of same interrupt group occurs
   (for example: INT134, IVCTx = 0x96) while the system is reading the
   interrupt vector register for EC INT6, we may end up with an incorrect
   interrupt number between 0x16 and 0x96.

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

BRANCH=none
BUG=none
TEST=1. EC interrupts work normally: WUI (GPIO interrupt), timer, uart,
        LPC, I2C, and PECI.
     2. Console command 'taskinfo'.

Change-Id: I54e61f417ad506eb3b4cd5d0652f64eed9a28a17
Reviewed-on: https://chromium-review.googlesource.com/322097
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-28 00:02:03 -08:00
Ewout van Bekkum
347f516d84 cr50: updates watchdog and hw clock to use hw regdefs
This commit updates the cr50 watchdog and hwtimer drivers to use the
hardware header specified regdefs to determine the frequencies for
the cr50 device.

BRANCH=None
TEST=Verified gettime and watchdog behavior on cr51
BUG=chrome-os-partner:46737
Change-Id: Iec7dc56b160dbec1b71077cecfd5561436d6f3ab
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/321867
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 00:02:02 -08:00
Vincent Palatin
7d0152a78b tcpc: add support for TCPC with integrated high-speed muxes
The TCPCI specification defines ane optional register
18h 'CONFIG_STANDARD_OUTPUT' providing a standardized way
of steering the high-speed muxes.

Implement the feature as a usb_mux_driver, under the conditional flag
CONFIG_USB_PD_TCPM_MUX.
The USB PD port index should be set in the port_addr field of the
'usb_mux' structure.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:49605
TEST=run pdeval-stm32f072 connected to a Parade PS8751 board and test USB/DP
muxing.

Change-Id: I7e5f0b8ec70b1910b2cff9d106514baca8c899e5
Reviewed-on: https://chromium-review.googlesource.com/322956
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 14:52:18 -08:00
Anton Staaf
0801ac67b9 GPIO: Remove gpio_get_level_reg function
After talking with Simon Glass about this we concluded that this was an
optimization that is not needed, as such, and since it is only used in
one location and only available from one chip family I'm removing it.
This further simplifies the GPIO API and removes more uses of port/mask
pairs.

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

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

Change-Id: I40754a385e0a4fa3a56d67fca1dd59fc8f3cc85a
Reviewed-on: https://chromium-review.googlesource.com/323827
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-27 08:44:22 -08:00
Anton Staaf
28eb478881 GPIO: Remove GPIO_TO_PORT_MASK_PAIR
This macro is no longer used, removing it so that it doesn't get used
as we work towards removing port/mask from the public GPIO API.

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

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

Change-Id: Ic924cd520689c0805a2784be5005dbecfe89f389
Reviewed-on: https://chromium-review.googlesource.com/323873
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 08:44:21 -08:00
Anton Staaf
255a551062 GPIO: Use gpio_reset in a few more places
The new gpio_reset function simplifies the pattern used in this code,
that of returning a GPIO to its original configured state.  It also
removes a few instances of using port/mask pairs.

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

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

Change-Id: I6e411aaf2f0fbc18aca0ed8742c400a0efe5690d
Reviewed-on: https://chromium-review.googlesource.com/324059
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 08:44:20 -08:00
Shawn Nematbakhsh
2e37a50b37 glados / chell: Power Optimize S0ix PMIC VRs
Allow VCCIO to decay to 0 and reduce the voltage of V0.85A supply in
S0ix.

BUG=chrome-os-partner:43908
TEST=Stress-test glados stability coming into and out of S0ix
BRANCH=glados

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I5aa61164c43ac624cef86f478919294e4cd4e581
Reviewed-on: https://chromium-review.googlesource.com/293345
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-01-26 23:59:50 -08:00
Mulin Chao
9e0506d331 nuc: Fixed the bug of i2c caused by writing START bit in SMBCTL1.
In rare case, executing i2c_interrupt function will generate unnecessary
START condition if START bit is 1 in SMBCTL1.

Please see the layout of SMBCTL1 register below.
         Bit [7] - STASTRE
         Bit [6] - NMINTE
         Bit [5] - GCMEN
         Bit [4] - ACK
         Bit [3] - EOBINTE
         Bit [2] - INTEN
         Bit [1] - STOP
         Bit [0] - START

In order to set or clear bits of INTEN and NMINTE, we need to read SMBCTL1,
or the bit2,6 and write back to register. But we will issue unnecessary
START condition if bit 0 is 1. (ie. Start condition is not sent yet)
Then FW will receive unexpected SDAST interrupt and sometime it collapses
state machine when i2c receives NACK condition.

The solution is enabling these two bits in i2c_init_bus function. Using
task_enalble/disable_irq (NVIC register) to enable or disable i2c interrupts
instead.

Modified sources:
1. i2c.c: Fixed the bug of i2c caused by writing START bit in SMBCTL1.
2. i2c.c: Add more debug messages for unexpected bus state.

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

Change-Id: I37dbb0e5b61f4a5ba12f0638535f8031522c1711
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/322883
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-26 23:59:49 -08:00
Dino Li
72ad260847 chip: it83xx: update ec2i module
1. The previous EC2I module does not meet section
   '7.17.5 EC2I Programming Guide'. We need to correct it to prevent
   conflict with H2RAM (LPC I/O cycles 800h ~ 9ffh) which cause LPC keeps
   long wait states.
   NOTE:
   If EC is using EC2I internal bus to access PNPCFG registers while host
   accessing EC ram through H2RAM interface at the same time,
   the symptom will appear.

2. Remove 'CONFIG_IT83XX_PNPCFG_HOST_ACCESS'.
   We don't allow the host access PNPCFG registers.

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

BRANCH=none
BUG=none
TEST=1. To use console command 'rwreg' to r/w PNPCFG registers and
        there is no error code return.
     2. To create a stress test for this change.
        - EC use 'ec2i_read()' and 'ec2i_write()' to access PNPCFG
          registers per-10ms.
        - run ectool 'version' command per-100ms.
        Before the change was made, LPC will keep in long wait states
        immediately.
        After the change, we run the test of ectool 'version' command
        over 20000 times.

Change-Id: I84e86fc17ef624d4a60a1a051bc301ebdf56a3da
Reviewed-on: https://chromium-review.googlesource.com/323563
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-26 23:59:47 -08:00
Anton Staaf
74e81bf9da GPIO: Prefer gpio_set_flags
Convert some uses of gpio_set_flags_by_mask to plain gpio_set_flags.
The result is usually more readable due to being able to use the
GPIO_* enum names, and it removes more instances of port/mask
implementation details leaking outside the gpio.c chip specific code.

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

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

Change-Id: I06a7ad8a53e553a8e432a6abb5b38c25a98df6c6
Reviewed-on: https://chromium-review.googlesource.com/323815
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-26 18:54:28 -08:00
Duncan Laurie
e9c8d3850c chell/glados/kunimitsu/tlars: Enable temporary host storage
Enable the temporary secure storage feature for vboot on skylake.

BUG=chrome-os-partner:46075
BRANCH=none
TEST=tested on glados and chell with modifed coreboot

Change-Id: Ic01888f7578e8e04bb39b38651bb646d1fc20750
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315223
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:49 -08:00
Duncan Laurie
81efb83e95 ec: Add temporary secure storage for the host during boot
This adds a temporary secure storage interface for the EC to be able
to store small amounts of data from the host that is locked until the
chipset resets.  This is used by pre-memory verified boot on x86 systems
where we need to know which RW slot to boot and what the hash is to
ensure that we can resume from S3 safely.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I5fa91046437479bcae69a8fca4c989b0ef554bbf
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315222
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00
Duncan Laurie
97713dba84 ec: Add a chipset reset hook
There are hooks for chipset power sequencing but not one to indicate
that the system has reset at runtime.  Add a hook for this and
implement for lm4 and mec1322.  The hook is notified on any platform
reset, including those that happen on the way into S3/S5 state.

There is a new config variable added because the hook is notified in
the interrupt handler and needs a deferrable function that needs to
be added to every board.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I3be639414e18586344e0ec84632a50dfc1df586b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315221
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00