Commit Graph

1542 Commits

Author SHA1 Message Date
Anton Staaf
8ae8dca6d4 cr50: Switch from ALTERNATE to PINMUX macros
Previously the g chip and cr50 board abused the ALTERNATE macro to
encode the pinmux configuration.  This switches them over to using a
PINMUX macro that is designed for this purpose.

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

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

Change-Id: I5c1f70b7aa92d87cc105e672aa66aee7f267c9a2
Reviewed-on: https://chromium-review.googlesource.com/328823
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-22 23:50:53 -08:00
Archana Patni
74615c1011 skylake: do not clear masks in S0ix -> S0 transition
EC clears the SCI/SMI/Wake masks in the resume sequence for S3
and S0ix. This works in the S3 case because Coreboot reprograms
the masks after EC. But in S0ix, these masks stay cleared forever.

This means that no further events are sent to the host.

This patch conditionally clears the masks only in the S3 transition.

BRANCH=glados
BUG=chrome-os-partner:48834
TEST=hostevent in EC console before and after S0ix to ensure SCI masks
are preserved

Change-Id: I23751680788ee7a239e321309a1334d37adc4f43
Signed-off-by: Archana Patni <archana.patni@intel.com>
Signed-off-by: Subramony Sesha <subramony.sesha@intel.com>
Signed-off-by: Jenny TC <jenny.tc@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/320191
Commit-Ready: Jenny Tc <jenny.tc@intel.com>
Tested-by: Jenny Tc <jenny.tc@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-22 09:00:52 -08:00
Bill Richardson
db4c248e4c Cr50: Slightly better USB error messages
Change the report_error() macro that we use to indicate unhandled
conditions so that it can take an integer argument. Sometimes
that's useful.

BUG=none
BRANCH=none
TEST=make buildall, try some USB stuff, everything still works

No functional difference, console error output only.

Change-Id: Icdfd1f9162bb5e557c711b6363b73ef55fbc272d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/328490
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-18 21:46:33 -08:00
Dino Li
15f6889c66 chip: it83xx: it8320 compatibility
To ensure it8320's compatibility on the LPC platform, we need to
disable SPI slave interface (default enabled) so that LPC module
will function normally.

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

BRANCH=none
BUG=none
TEST=LPC module of it8320 works normally.

Change-Id: I259651b32f41ebae498e13bf07ebb68e5e520058
Reviewed-on: https://chromium-review.googlesource.com/328142
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-18 19:57:36 -08:00
Dino Li
5c184565af chip: it83xx: disable fan control timer if all fans are off
Before the change was made, the fan control timer keeps running
even all of the fans are off.

reproduce the problem:
1. fanset 3333
2. fanset 0
fan is disabled but fan control timer keeps running.

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

BRANCH=none
BUG=none
TEST=1. fanset 3333
     2. fanset 0
     both fan and timer are off.

Change-Id: Id38f3a4c64bbb36e8b32baefd285dbb0bf14e47e
Reviewed-on: https://chromium-review.googlesource.com/327870
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-17 20:57:02 -08:00
Dino Li
5a7767a20e config: it83xx: remove "CONFIG_IT83XX_PECI_WITH_INTERRUPT"
IT839x and the new series all support interrupt of PECI, so we remove it.

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

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

Change-Id: Ib126cb418a4ba5ef313ee93948bc2fbb96bc936d
Reviewed-on: https://chromium-review.googlesource.com/327643
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-17 20:57:01 -08:00
Shawn Nematbakhsh
c505edb0b5 hibernate: Inform PD MCU before calling board hibernate callback
board_hibernate() may take alternate actions to place the chip into
hibernate, so inform the PD MCU that we're going to hibernate before
calling the function.

BUG=None
TEST=Run 'hibernate' on chell, verify that PD MCU goes to hibernate and
wakes when AC is attached.
BRANCH=glados

Change-Id: I71c12dcb416d54c79ac7d40e9bf430e268071fb2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327613
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-17 15:33:07 -08:00
Vadim Bendebury
ffd5819d32 cr50: allow board to provide flash configuration
The g chip is used in multiple designs, likely to have different flash
memory layout and access permissions.

This patch introduces a mechanism which allows the board layer to
provide flash configuration information to the flash driver.

The flash region which is going to be enabled for write access depends
on the area the code is executing from. If running from the bottom
half (A), the whole top half should be writeable (this includes both
NVRAM area and the B code space). If running from B, the writeable
area starts on top of RO and extends to the end of NVRAM.

CQ-DEPEND=CL:*248190
BRANCH=none
BUG=chrome-os-partner:37754
TEST=with the rest of the patches applied verified that software
     update can happen in both spaces, A and B.

Change-Id: Iab1c1a2766ae9bcfe04ff170c010f180cd1f770f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327412
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Nadim Taha <ntaha@chromium.org>
2016-02-17 12:01:31 -08:00
Vadim Bendebury
b37a7b7166 cr50: improve flash driver error reporting
It is difficult to tell what went wrong if a flash operation failed.
This patch adds printouts in cases of failure. The extension command
console channel is used.

BRANCH=none
BUG=chrome-os-partner:37754
TEST=observed error messages reported while debugging firmware update
     code.

Change-Id: I73d509ac5088249e8d34e32e760f3d2f063c91cd
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327411
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-17 12:01:31 -08:00
Mulin Chao
38c64408f7 wheatley / nuc: Modified the internal ref voltage of ADC to 2.816V
In order to prevent the influence of the deviation of AVCC during ADC
conversion, the internal reference voltage (Vref) of ADC is fixed to
2.816V even it derives from AVCC.

Modified sources:
1. wheatley/board.c: Modified max adc voltage of ADC to 28.160V.
2. adc_chip.h: Modified internal ref voltage of ADC to 2.816V.

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

Change-Id: Ib514f4bdc114802870eb3c77c650e18c05eb9617
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/327046
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-17 02:02:03 -08:00
Vadim Bendebury
7dd904b8d3 cr50: improve loader logic to consider build timestamp as well
When deciding which of the two images to start, A or B - consider the
image timestamp if everything else is equal. The later image should
take precedence.

Also, simplify the existing logic, and consider image A to be 'newer'
if both copies are the same otherwise.

BRANCH=none
BUG=chrome-os-partner:37754
TEST=with the rest of the patches applied, verified that the newer
     image of the two gets started

Change-Id: I2c7a50ecfc8d254498c8e96f8651b8d53005897c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327414
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-02-12 15:33:54 -08:00
Vadim Bendebury
758ef07150 cr50: write protect area where the code jumps to
The launcher should explicitly disable writes to the code space where
the loaded code is going to be running from.

BRANCH=None
BUG=chrome-os-partner:37554
TEST=with the rest of the patches applied firmware updates work as
     expected.

Change-Id: I744f7016e4427188f53e8fa3302e8c06cf836e2e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327413
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-02-12 15:33:54 -08:00
Mulin Chao
3d2ad2985a nuc: Modify divider of apb2 to 1 if it's freq isn't divisible by 1MHz
We found the deviation of ITIM32 is huge since apb2's clock isn't divisible
by 1MHz. (The default resolution of hwtimer is 1us.)

The solution is set the freq of apb2 the same as core clock. Note apb2 is
twice value of original one. It will increase power consumption slightly.
But we found the difference is acceptable no matter core clock is 15M
or 13MHz.

In this version, we also use the arrays to adjust i2c bus timing if
bus' freq is 400K or 1MHz for all source clock freqs of i2c.

Modified sources:
1. i2c.c: Support all source clock freqs of i2c for best bus timing.
2. clock.c: Set divider of apb2 if it's clock isn't divisible by 1MHz.
3. uart.c: Modified baud-rate for apb2 which is the same as core clock.

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

Change-Id: I6089caaaf9aa16186d7c6acf6f5fea0682a55655
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/327120
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-10 15:45:52 -08:00
Mulin Chao
71a8c02982 nuc: Fixed bug that some of DP80's data is skipping
Fixed the bug that some of DP80's data is skipping if the speed of writing
by host is high. The solution is grabbing all data and sending them to UART
until FIFO of DP80 is empty in ISR.

Modified sources:
1. lpc.c: Fixed the bug that some of DP80's data is skipping.

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

Change-Id: Ie53a5c7f0a80a1f836b571a00871cb57b42c87db
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/326931
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-10 15:45:51 -08:00
Nadim Taha
27ce00c164 Cr50: Fixes a glitching issue during GPIO initialization.
The output enable bit was being set before the output value was
initialized.

BRANCH=none
BUG=none
TEST=Confirmed the fix with a logic analyzer

Change-Id: If8228d716b4924b5fd65b8f59436f4b37f05644e
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327212
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-10 22:03:03 +00:00
nagendra modadugu
388a7fa8cf CR50: remove incorrect output length check in RSA decrypt
The required output length is not known until padding
verification completes (this check is already done
in the appropriate padding check functions).

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

Change-Id: I452244d052b7f334a6907bd653645671033a0890
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/327074
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-02-10 12:44:16 -08:00
Archana Patni
192806b8da skylake: set and clear wake masks in S0 <-> S0ix transitions
In the S0 <-> S3 transition, Coreboot sends EC messages to set/clear the
wake masks when the SMI is invoked. For S0ix, EC sets and clears the
wake mask via this patch.

These functions are directly invoked from the state machine transition states.
During S0ix entry, the wake mask for lid open is enabled. During S0ix exit,
the wake mask for lid open is cleared. All pending events are also cleared

BRANCH=none
BUG=chrome-os-partner:48834
TEST=test lidopen in S0ix

Signed-off-by: Archana Patni <archana.patni@intel.com>
Signed-off-by: Subramony Sesha <subramony.sesha@intel.com>
Change-Id: I52a15f502ef637f7b7e4b559820deecb831d818f
Reviewed-on: https://chromium-review.googlesource.com/320190
Commit-Ready: Divya Jyothi <divya.jyothi@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-10 12:44:15 -08:00
nagendra modadugu
cd5745f99c CR50: Include NUL byte from label for OAEP pad calculation
If a label is specified, then the NUL terminating
character is considered part of the label per the
TPM2 implementation.

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

Change-Id: If5fccc293f7ab52fd6c33e2f3c38695c2921d919
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/326910
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Marius Schilder <mschilder@chromium.org>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-02-09 19:51:05 -08:00
Icarus Sparry
5dca5807bd MEC1322 port80 Acknowledge interrupt
In normal operation the 16 bit timer number 1 is set up to count every
microsecond, and every 1000 counts (i.e. every millisecond) to assert an
IRQ (Interrupt Request). After a microsecond the IRQ is deasserted.when
the count is again not at its limit.

The IRQ handler ignores the IRQ from the timer itself.

If the clock is stopped or the autoreload of the counter is disabled
then the value of the count is left unchanged. If this count is the
limit then the IRQ will remain asserted. For stopping the clock this is
approximatly a 1 in 1000 chance, or is certain if the autoreload is
disabled.

If the IRQ from the timer continues to be asserted, then the NVIC will
continue to generate a fresh call to the IRQ handler as each previous
exception completes.

The fix is to do what almost every IRQ handler does for almost every
processor, and clear the request in the peripheral that is causing the
interrupt, rather than hoping that the timer will clear it itself. This
agrees with how the event timer is used. There may be a lurking bug in
the system timer handler as well as it also expects the timer to clear
its own IRQ.

BUG=chrome-os-partner:48499
TEST=Pass 2000s of continuous calls to port_80_interrupt_disable() /
port_80_interrupt_enable() without WDT being triggered. Stop the
autoreload and see it doesn't watchdog.
BRANCH=glados

Change-Id: I4726854b7784e2e4a39b8cb74c350206d71f90df
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/326781
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-09 19:51:04 -08:00
Shawn Nematbakhsh
0251aacd43 mec1322: i2c: Print port name on failure
Referring to i2c ports as i2c0 thru i2c4 is confusing, due to the
special naming of controller 0 ports, so use their actual names from the
datasheet.

BUG=None
TEST=Trigger failure on i2c0_1, verify that "i2c0_1 bad status .." is
seen on console.
BRANCH=glados, strago

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ibd0d638e5af1c0a64e6f4b1a709b790b6b10d5e6
Reviewed-on: https://chromium-review.googlesource.com/325822
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-09 19:51:01 -08:00
Shawn Nematbakhsh
9c053ea898 mec1322: clock: Use full-speed 48MHz processor clock during EC boot
EC boot / hash computing can be a bottleneck for system boot time.
Reduce this bottleneck by running our processor at 48 MHz through boot,
until vboot hashing of RW completes.

BUG=chrome-os-partner:49583
TEST=Boot chell, verify vboot hash completes within 1 sec of EC boot and
'cbmem' delta between 'vboot select&load kernel' and 'finished EC
verification' is reduced to ~250 ms (which includes sysjump time).
BRANCH=glados

Change-Id: I18d87e685b89decef761e51517bfcfc43dcf8ef0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/326792
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-09 19:51:00 -08:00
Vadim Bendebury
a766634323 cr50: integrate register definitions consistent with real silicon
The new register definitions file has been supplied, it is not
defining some fields which were present only in FPGA. Some tweaks are
required to accommodate this.

BRANCH=none
BUG=chrome-os-partner:50141
TEST=new code successfully boots on the evaluation board

Change-Id: Ie4158554e0aaf039d59669558861a763a23f0ceb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/326803
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-09 01:26:06 -08:00
nagendra modadugu
7ac69e594b CR50: Add initial elliptic curve crypto implementation.
This change adds support for NIST-P256 curve operations.

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

Change-Id: I03a35ff3ab8af3c52282d882937880bfa2bdcd32
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324540
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-08 15:24:29 -08:00
nagendra modadugu
e68019e349 CR50: enable the bignum library to handle word un-aligned keys
The TPM2 api does not require keys to be word-aligned,
so have the compiler generate alignment-safe reads where
necessary.

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

Change-Id: I247e29f2bec139ab7ed4010ffb58cdae77ba9e0b
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/326201
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-08 13:47:49 -08:00
Vadim Bendebury
c17c447a25 cr50: provide plumbing for prod mode RO signing
Creating bootloader for the chip involves signing the image with an
'air gap' - some physical presence action is required. We don't want
this to be required when the builder is building cr50 for test
purposes.

The solution is to keep using the dummy private key when building by
default, and invoking make differently when building an image which
would be accepted by the hardware.

Setting CR50_RO_KEY variable in the environment or in the make command
line will cause the signer use the value of this variable as the name
of the file containing the key to use for signing the RO image.

Should this file be a public key, the signer will stop and look for a
fob containing the matching private key, and will stream the RO image
through the fob for signing.

Using the fob requires that the signer runs under sudo, but we do not
want the generated files to belong to root, some more code is added to
change the generated files' ownership to user running the make.

BRANCH=none
BUG=chrome-os-partner:49950
TEST=ran the following tests:
 - verified that the build still succeeds by default.

 - invoked make as follows:

   CR50_RO_KEY=cr50_rom0-dev-blsign.pem.pub  make BOARD=cr50

  observed the signer stop to wait for the user to interact with the
  USB fob and proceed. Made sure that the generated image runs
  successfully on the evaluation board.

 - verified that 'make BOARD=cr50 clean' still works (i.e. none of the
   generated files is owned by root).

Change-Id: I733ec6386c1dfd838d83d22fb589fa64e5eeaced
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/326484
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-08 12:09:06 -08:00
Vadim Bendebury
c1117fb707 cr50: no need to check for USB inclusion
With transitioning to silicon there is no need to check if the
hardware includes USB subsystem or not.

BRANCH=none
BUG=chrome-os-partner:50141
TEST=the cr50 image successfully boots to the ec prompt

Change-Id: I593205cf307e0fce5e74ea695ed1cf5bfea8fde4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/326482
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-08 12:09:05 -08:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Shawn Nematbakhsh
8c9210b81e mec1322: hibernate: Don't reconfigure all GPIOs
Configuring all GPIOs to INPUT / PULL_UP in hibernate is not a good
idea:

- INPUT / PULL_UP is not necessarially the lowest-power state (for
  example, if there is an onboard pull-down).
- Most GPIOs should already be in lowest-power state when we're in S5.
- For the few GPIOs that need to be in a different state for hibernate,
  we can use a board-level callback.

In addition, remove mec1322 code related to restoring from hibernate
state, since we always reset coming out of hibernate.

BUG=chrome-os-partner:49608
BRANCH=glados, strago
TEST=`hibernate` on chell console when in S5 and AC removed. Verify that
EC power is roughly equivalent to low-power idle power. Attach Zinger,
verify that device wakes and boots, and charges from charger.

Change-Id: Ib00ef035bec32cea3847eb38d743f5c0cec896ca
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/322937
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2016-01-25 19:48:21 -08:00
Shawn Nematbakhsh
89bcc93547 stm32f0: flash: Don't check protect bits for flash that doesn't exist
Each pair of protect bits locks 4K, so for parts with 64K flash, don't
bother checking STM32_OPTB_WRP23.

BUG=chrome-os-partner:49354
TEST=Run flashrom to protect PD MCU (see repro steps on linked crbug),
reboot and verify system boots into dev mode with all_at_boot and
all_now protect flags set on PD MCU.
BRANCH=glados

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic375d97c30bfd68940350641c44d5535b0402a2f
Reviewed-on: https://chromium-review.googlesource.com/322823
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-01-21 12:43:04 -08:00
Mulin Chao
ebd29d4557 nuc: Adjust core clock from 16/12 MHz to 15/13 MHz.
We found the deviation of 115200 UART baud-rate is too large when core
clock is 16 or 12MHz. It causes failure during FAFT since sometime EC
could not receive correct commands to proceed test. We adjusted core
clock from 16/12 to 15/13 to reduce the deviation of 115200. Both of
them have run FAFT and stress tests for weeks and no UART issues were
found.

Since the lowest source clock of i2c is 6.5MHz, we modified tSCLL, tSCLH
and hold time directly for better i2c timing when freq is 400K. And if
freq is 100K, we introduced normal mode to handle it.

Modified sources:
1. clock.c: Adjust core clock from 16/12 MHz to 15/13 MHz.
2. clock_chip.h: Set target core clock as 15 MHz.
3. uart.c: Add baud-rate support for 15/13 MHz.
4. register.h: Add new register definitions of SMBus.
5. i2c.c: Modified tSCLL, tSCLH and hold time directly for better i2c
timing.

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

Change-Id: Ie5d22e87875c064b49338046c99a178f8fadf32b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/322320
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-20 20:36:53 -08:00
Anton Staaf
6e4e1ccc82 GPIO: Add gpio_reset function
The gpio_reset function returns a GPIO to its initialy configured state.
Using it removes a few more uses of gpio_list.

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

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

Change-Id: Ie24e8e8a96d0ff50f521a918e80ed2b379f8c1a9
Reviewed-on: https://chromium-review.googlesource.com/321951
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-19 14:24:40 -08:00