Commit Graph

4908 Commits

Author SHA1 Message Date
Mary Ruthven
c3ce180fb0 vboot_hash: check the current hash is for the right region
With the RO region being added to software sync, up to two hashes will
be requested during boot. Currently if vboot_hash has a valid hash when
the EC gets an EC_VBOOT_HASH_GET host command then it will return that
hash. When the EC gets a request for the RO hash after it has calculated
the RW hash it returns the RW hash in the response.

This change will add a check that the EC not only has a valid hash, but
that it is for the correct region.

BRANCH=none
BUG=none
TEST=Try to get the RO and RW hashes from depthcharge and make sure they
match the values gotten using ectool

Change-Id: I2449c8d79b4a74f4865dd1234fb253bcdac66a31
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/318861
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-05 23:39:09 -08:00
Bruce
7b3032b1c7 Chell: modify led setting for OEM spec
Modify the led blink white at battery capacity less than 12%.

BUG=None
BRANCH=None
TEST=check the led blink white at battery capacity less than 12%

Change-Id: I3494ed7d207e769fe081b4442fd298b4e481e0a7
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/319729
Commit-Ready: Bruce Wan <Bruce.Wan@quantatw.com>
Tested-by: Bruce Wan <Bruce.Wan@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-05 23:39:06 -08:00
Aseda Aboagye
9fce7075d9 util: ec3po: Add served PTY to logging.
Some devices have multiple ECs (main EC and PD MCU) and therefore there
are multiple consoles and interpreters running concurrently.  This
commit prepends each log message with the served PTY to identify which
of the console or interpreter instances the log message comes from.

BUG=None
BRANCH=None
TEST=Ran ec3po in servo for samus. Noticed each debug print with the
different PTYs for the main EC as well as the PD MCU.
TEST=util/ec3po/run_tests.sh

Change-Id: Icc69d2257172f4fedc217572ad0b6d15dac40387
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/320597
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
2016-01-05 21:14:44 -08:00
Aseda Aboagye
5f18982f67 util: ec3po: Change interrogation timeouts.
In testing, it was found that certain ECs couldn't respond to the EC_SYN
in less than 0.1s.  Therefore, this commit changes the interrogation
timeouts.  For non-enhanced EC images, the timeout has been increased to
0.3 seconds.  This is small enough that there's not too much of a delay,
but long enough that enhanced EC images can respond in time.  With an
enhanced EC image on veyron_jerry, EC_ACKs were arriving after ~0.2s.

BUG=None
BRANCH=None
TEST=Flash enhanced EC image on veyron_jerry, start console/interpreter
pair and verify that the console is functional.
TEST=util/ec3po/run_tests.sh

Change-Id: I4931aaee908653ae302a8e57941444e5f0b6ce2b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/320594
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-05 21:14:42 -08:00
Icarus Sparry
077e545662 cortex-m: proper handling of input parameters to SVC handler
According to section 2.7 of Cortex-M3 Application Note 179: A Cortex-M3
processor can get a "late arriving exception" and this will corrupt the
values of the r0, r1, r2 and r3 registers passed in an svc call.

http://infocenter.arm.com/help/topic/com.arm.doc.dai0179b/AppsNote179.pdf

The fix is to reload the two registers we care about, r0 and r1, from
the stack to ensure the input parameters to SVC handler, desched (r0)
and resched (r1), are valid.

BUG=chrome-os-partner:48499
BRANCH=none
TEST=Used assert to verify resched is a valid TASK ID.

Change-Id: Ie2229472e709febe16eee3c2cd986e3815fda076
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/319849
Commit-Ready: Icarus W Sparry <icarus.w.sparry@intel.com>
Tested-by: Icarus W Sparry <icarus.w.sparry@intel.com>
Reviewed-by: Icarus W Sparry <icarus.w.sparry@intel.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-05 17:26:10 -08:00
Mulin Chao
3d752a3bf6 nuc: Get more accurate value of deep idle time.
We should consider the interval between the calling __hw_clock_event_set and
entering deep idle. In order to get more accurate value of deep idle time, FW
should record the time-stamp before entering deep idle and calculate the deep
idle time based on it.

Modified drivers:
1. hwtimer_chip.h: Add new function declarations for deep idle time caculation.
2. hwtimer.c: Add new functionsfor deep idle time caculation.
3. clock.c: Modified for calculating more accurate deep idle time.

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

Change-Id: Id037c4dc3564659e4ad493f2fc3ffc5d06c18b06
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/320071
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-05 15:30:48 -08:00
Aseda Aboagye
c6773e6765 util: ec3po: Add presubmit check for ec3po.
Added presubmit check to make sure that when any ec3po files are
modified, the unit tests should be run as well.

BUG=None
BRANCH=None
TEST=Touched a unit test file, tried repo upload and received an error
about running unit tests.  Ran run_tests.sh and all tests passed.  Tried
to repo upload again and this time it succeeded.
TEST=Created a failure in one unit test, ran run_tests.sh and verified
that the failure was caught and the CL wouldn't pass the presubmit
check.

Change-Id: I4df4a0fd1107292f693749188491f6286360f557
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/319211
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-04 16:26:22 -08:00
Douglas Anderson
ec7927a20d keyboard: Fix kbpress after recent keyboard change
After commit 98ab7484d331 ("keyboard: prevent races enabling/disabling
kb scanning") kbpress was totally broken, which wasn't so good for
FAFT.  Fix it by making sure we go into polling mode for simulated
keyboard presses.

BUG=chrome-os-partner:48849
TEST=kbpress works

Change-Id: Icd663c2ee7a184e6af4438368595087b35724a4f
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319586
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-04 16:26:21 -08:00
Mulin Chao
8d99bd9345 wheatley: Add CONFIG_LTO definition to reduce FW size.
Add CONFIG_LTO definition to reduce the size of FW image.

Modified drivers:
1. board.h: Add CONFIG_LTO definition.
2. header.c: Add __keep keyword to prevent linker ignore header during
optimization.

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

Change-Id: I6205af37572a68f35f90dbd9b28d86230533ca8b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/319799
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-30 20:40:48 -08:00
Kevin K Wong
eebef1b8fd kunimitsu: add debug assert flag
Restore debug assert flag which was previously removed due to limited
code space.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I9617b1221bc6217e8f8ed745ea0ce12418233440
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/319606
Reviewed-by: Icarus W Sparry <icarus.w.sparry@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-30 15:29:06 -08:00
Shawn Nematbakhsh
d85c7d3f1b util: npcx: Fix build for ARM host boards
ecst is used at build / link time, so it should be compiled for the
build machine architecture, not the architecture of the host board.

BUG=chromium:567232
TEST=Verify 'cros_sdk ... cros_run_unit_tests --board=oak' passes with
CL:319256.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic7f6aa989d0760eda1fe64221e41d3230c9ab9b9
Reviewed-on: https://chromium-review.googlesource.com/319633
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-12-30 13:52:45 -08:00
Shawn Nematbakhsh
2c0843e845 chell / chell_pd: Use power-optimized GPIO defaults
Pull floating pins high, don't duplicate external pull ups, and make a
few other minor changes.

BUG=chrome-os-partner:48109
TEST=Verify chell continues to boot and S5 power is reduced to
~5.5 mW.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Iaee0cc926149dae1f4189e6b9e4f7e3a4da6ba1c
Reviewed-on: https://chromium-review.googlesource.com/319165
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-24 01:43:00 -08:00
Mary Ruthven
8b3090c1bd lucid: add LED support
Implement LED control for lucid with red, blue, and green LEDs.

BUG=chrome-os-partner:48661
BRANCH=none
TEST=make sure lucid builds

Change-Id: I97ed56daa8fdb40daf8ab06e53913dcff2e41dea
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319224
Commit-Ready: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-22 21:07:25 -08:00
Mary Ruthven
68a4b3a4b2 lucid: implement fast charging
Use custom charging profile to enable charging at a faster rate.

BUG=chrome-os-partner:48662
BRANCH=none
TEST=load on lucid and charge at room temp. Use "chgstate" command to
verify that battery current matches the expected fast charging current
for the given temp range and voltage.

Change-Id: Ie508d29db091593ff2cfda9d135c73f6a3de5a9a
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319493
Commit-Ready: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-22 21:07:24 -08:00
Alec Berg
861ead29bb lucid: remove some unnecessary features to save space
Remove ADC watchdog and i2cscan console command to save
flash space.

BUG=none
BRANCH=none
TEST=make BOARD=lucid

Change-Id: I3da8a13fdd962041ccdc830cb1b9b5803917bc2b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319611
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2015-12-22 21:07:24 -08:00
nagendra modadugu
617fb66fc7 Move rand_bytes implementation from tpm2 to chip/g.
BRANCH=none
TEST=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
Signed-off-by: nagendra modadugu <ngm@google.com>

Change-Id: Ic7a850fdf2594ac1981237edda8dceb16cc7cbe6
Reviewed-on: https://chromium-review.googlesource.com/319155
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-12-22 13:12:53 -08:00
CHLin
e415307589 nuc: Enable lower core CLK for power consumption
Support lower core CLK frequency and configure the baudrate parameter of console
UART for current core CLK.

Modified drivers:
1. clock.c: Support lower core CLK frequency.
2. uart.c: Add baudrate setting for differenct core CLK.
3. clock_chip.h: Set default core CLK to 16MHz.

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

Change-Id: Id83ecf92c19bec508ec84e2d271d7e1fa278774f
Signed-off-by: CHLin <chlin56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/319030
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-21 14:58:57 -08:00
Shawn Nematbakhsh
8038e5f146 stm32: adc: Add support for DMA continuous mode
Add support for continuously writing ADC samples to a circular buffer.
CONFIG_ADC_PROFILE_FAST_CONTINUOUS should be defined and an
appropriate sized buffer must be passed to adc_read_all_channels().

BUG=chromium:569994
TEST=Manual on snoball. Verify 'adc' continues to function (single
mode). With pending commit, verify that continuous conversion interrupt
is called at appropriate frequency and values look consistent.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I025825d72a698f8f1f4f95a89477df791bd5e67e
Reviewed-on: https://chromium-review.googlesource.com/318505
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-21 14:58:56 -08:00
Ewout van Bekkum
34f2264227 cr50: adds the SPI master driver
Adds the SPI master driver with support for both SPI masters with
support for using GPIOs as chip selects or using the hardware's
dedicated chip selects.

Note this has not been enabled in the cr50 board.

BRANCH=none
BUG=none
TEST=verified through use of the SPI_FLASH module on cr51

Change-Id: I88719f8d03e217ab44249172b1340011fdcfdad5
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317329
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-12-21 14:58:54 -08:00
Shawn Nematbakhsh
ee4e0763a1 common: Include host/console commands based on HAS_TASK_HOSTCMD/CONSOLE
Don't build a table of host / console commands if the HOSTCMD or CONSOLE
task is not present. This saves space in the .hcmds / .cmds section and
allows the linker to prune command handler functions which will never be
called.

BUG=chrome-os-partner:41959
TEST=Verify ec.RO.flat shrinks on snoball and glados_pd, and remains the
same size on chell and samus. Also verify basic functions are still
working on snoball and glados_pd.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I79975c18ec1d87fedda8d1f299f30ffc43c24f69
Reviewed-on: https://chromium-review.googlesource.com/319112
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-18 12:43:50 -08:00
Ryan Zhang
8623942335 Lars: Update battery settings
Update battery settings from battery spec.

BUG=chrome-os-partner:48571
BRANCH=lars
TEST=`make -j BOARD=lars`, OS and EC shutdown normally without AC,
Charging normally.

Change-Id: I4b8fad8ab993f2ea5190898088bd1bd8c2bd7abb
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/318611
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-12-18 04:45:40 -08:00
Aseda Aboagye
4bad633cb9 ec3po: Add graceful exit.
The console and interpreter are usually killed by KeyboardInterrupt
whether or not it's run standalone or by servod.  This commit tries to
make the exit graceful by closing pipes, file descriptors, and exiting
each process.

BUG=chromium:570526
BRANCH=None
TEST=Run ec3po standalone and hit Ctrl+C to kill it.  Observe no
traceback and no leftover processes.
TEST=Repeat above test, but inside servod
TEST=cros lint --debug util/ec3po/console.py
TEST=cros lint --debug util/ec3po/interpreter.py
TEST=python2 -b util/ec3po/console_interpreter.py
TEST=python2 -b util/ec3po/console_interpreter.py

Change-Id: Ia151b9ede8adf7f8dec6c07277f62d097c13e63e
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/319252
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
2015-12-17 23:45:18 -08:00
nagendra modadugu
6a29ca187a Refactor crypto subcommands into their own python module.
BRANCH=none
TEST=tpmtest.py passes
BUG=chrome-os-partner:43025,chrome-os-partner:47524
Signed-off-by: nagendra modadugu <ngm@google.com>

Change-Id: I48f426176f17c57c723104d19c963b228f16d985
Reviewed-on: https://chromium-review.googlesource.com/318915
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-12-17 15:46:39 -08:00
Bill Richardson
f72decc804 Cr50: Implement USB according to Programmer's Guide
This is a rewrite of the Cr50 USB Device Control Endpoint
implementation, using the instructions in the DWC USB 2.0 OTG
Programmer's Guide (such as they are). Some of the major
differences:

* Not every USB interrupt indicates the receipt of an incoming
  packet. Many merely provide updates on packet transfer status,
  transaction stages, or other activity. We handle those
  cases correctly.

* We may need to start a new Control transaction at any point,
  even in the middle of an existing transaction.

* Large IN data transfers can be handled with one interrupt by
  chaining multiple together.

* Logical separation of the phases of each transaction (Setup,
  Data, Status).

That said, while this CL matches the Programmer's Guide fairly
closely, that Guide is pretty crappy and this is just the first
commit. There is still a fair amount to do (marked with comments
and bug reports). However, it works at least as well as the
previous version and is much closer to what the supplier claims
is the correct implementation.

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

We also connected this device to Windows, and Mac laptops (and a
Chromebook) and used a USB bus analyzer to monitor the behavior.
It works on machines those, too.

Change-Id: Ic515ea83e217a8d0552d61ac5eb19693661fcd15
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/318864
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2015-12-17 15:46:38 -08:00
Dino Li
11c2c92236 nds32: start_irq_handler() use system stack
[symptom]
The 'vboot_hash_start()' always return busy error and variable 'in_progress'
got a strange value(should be 0 or 1).

'start_irq_handler()' causes scratchpad overflow in first context switch.
It must be called after SP switch to system stack in ISR.

NOTE:
The scratchpad is still also need more size even if
'start_irq_handler()' is using system stack. following is detail:

1. uint32_t scratchpad[19] 0x81d34 ~ 0x81d7f
[__task_start:]
2. /* put the dummy stack pointer at the top of the stack in scratchpad */
   addi $sp, $r3, 4 * 18
   -> SP 0x81d7c
3. syscall push return address (-4)
   -> SP 0x81d78
[ISR:]
4. push r15, fp, lp, and sp (-0x10)
   -> SP 0x81d68
5. push r0 ~ r5 (-0x18)
   -> SP 0x81d50
[__switch_task:]
6. /* save ipsw, ipc, r6, r7, r8, r9, r10 on the current process stack */ (-0x1C)
-> SP 0x81d34

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

BRANCH=none
BUG=none
TEST=1. hash done.
     2. console command 'taskinfo'.
     3. the scratchpad does not overflow after first context switch.

Change-Id: If5d89ff5c945a777010492fcfb54bf41f434ed69
Reviewed-on: https://chromium-review.googlesource.com/317468
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>
2015-12-16 21:49:34 -08:00
li feng
51811325d2 Kunimitsu: enable power threshold checking in power up
In 0% battery case, if the charger can provide power at least
15 Watt(CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW), will allow system to
boot up.

BUG=chrome-os-partner:48339
BRANCH=none
TEST=Verified in Kunimitsu system, system with 0% battery can boot up
normally once charger power is 15 Watt.

Change-Id: I0c7b23d4ac1e7bd2807ceeb068fc9018a99a03c4
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/318891
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 21:49:26 -08:00
li feng
6f4146f962 skylake: increase retry count in power up
During power up, system will wait at most CHARGER_INITIALIZED_TRIES
delay to check if battery percentage or negociated charger power can
meet minimum requirement. In some cases, it takes longer time(observed
negotiated to min power took 2 seconds). So increase
CHARGER_INITIALIZED_TRIES from 10 to 40 to give total 4 seconds delay.

BUG=chrome-os-partner:48339
BRANCH=none
TEST=Verified in Kunimitsu system, negotiation to 5V@3A is done within
retry/delay.

Change-Id: I18c5fc676076f8d37d0a5360543f54aa85f48f77
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/318652
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 21:49:26 -08:00
li feng
e74b3cc6c2 charger: fix coding error in charge_prevent_power_on()
BUG=none
BRANCH=none
TEST=make -j buildall

Change-Id: If60902ab0176435b41f70ca11e0f73b430b65fe5
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/318650
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 15:07:21 -08:00
Bill Richardson
8895f2a3a3 Cr50: Revise FIFO SRAM settings
This allocates more space for FIFO buffers, according to the
instructions in the Programmer's Guide. Many more comments and
some slight refactoring was added to explain the configuration
more clearly.

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I1a870a4b1dc628729f7cd1b80bab7ec6dfd11f37
Reviewed-on: https://chromium-review.googlesource.com/318262
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2015-12-16 15:07:20 -08:00
Ryan Zhang
c14a2c3e72 Lars: Update LED settings
LEDs are high active now.

BUG=chrome-os-partner:48552
BRANCH=lars
TEST=`make -j BOARD=lars`, LEDs blink normally.

Change-Id: I9a96d4347ebfaa698c762f3c55db0c8d2133ec73
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/318603
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 15:07:20 -08:00
Bruce
c48f8c3af3 Chell: modify led setting for led test command.
BUG=None
BRANCH=None
TEST=the test command can control led.

Change-Id: Iaae49f35953448e2472196ba9b6411fe8d9487b4
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/318165
Commit-Ready: Bruce Wan <Bruce.Wan@quantatw.com>
Tested-by: Bruce Wan <Bruce.Wan@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 03:35:41 -08:00
li feng
77998f1c54 skylake: fix retry counter checking in power up
BUG=none
BRANCH=none
TEST=`make buildall -j`

Change-Id: If015f655c4ccaba147fb886452d5fe756ec54425
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/317644
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 03:35:35 -08:00
Shaunak Saha
eac6480a2c mec1322: Fix uninitialized variable.
This patch fixes a reported error for an uninitialized return variable.

BUG=none
TEST=Build and Test EC.
BRANCH=none

Change-Id: I43a6678049070ef1ee6c71dfbac1fcb21de88957
Signed-off-by: Shaunak Saha <shaunak.saha@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/317352
Commit-Ready: Divya Jyothi <divya.jyothi@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 03:35:26 -08:00
Ryan Zhang
d270d40d10 Lars: Add ALS console-command
To make debug easier.

BUG=None
BRANCH=lars
TEST=`make -j BOARD=lars`, OS can boot up normally

Change-Id: I9f73342e3201fef79b99426939f1a2b308be3cb7
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/318143
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-16 03:35:14 -08:00
Dino Li
57e703ea24 it8380dev: Implement GPIO mode for KBS pins and fix gpio_set_level()
1. KSO[0-15] and KSI[0-7] can be used as GPIO input if they are not set for
keyboard scan function.
2. Critical section for gpio_set_level().

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

BRANCH=none
BUG=none
TEST=console commands: gpioset, gpioget, and version.

Change-Id: I8edae122525e6dcebaa3489116642d8e48520569
Reviewed-on: https://chromium-review.googlesource.com/318112
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>
2015-12-14 20:04:54 -08:00
Dino Li
313f2ab8c5 it8380dev: To config register 'GCR' in gpio_pre_init()
The double-mapping modules(CIR, BRAM, SSPI, PECI, and UART) won't work
if GPD2 pin's status is low and GCR register's setting is at default.
We move 'IT83XX_GPIO_GCR = 0x06;' to 'gpio_pre_init()'
to prevent this case.

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

BRANCH=none
BUG=none
TEST=1. Register 'GCR'=0x6 after init.
     2. GPD2 is low and UART works.

Change-Id: I71b4436ab6c2a8f9e77e0d6f5116e5327a3167e7
Reviewed-on: https://chromium-review.googlesource.com/318131
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>
2015-12-14 20:04:53 -08:00
Douglas Anderson
a6e82c3acd keyboard: prevent races enabling/disabling kb scanning
keyboard_scan_enable() is called from several contexts.  From a skim of
the code I found:
* keyboard_lid_change(), which is called from HOOK_LID_CHANGE
* enable_keyboard(), which is called from HOOK_CHIPSET_RESUME
* lidangle_keyscan_update(), which is called from motion_sense_task.
* check_for_power_off_event() which is called from power_handle_state()
  which is called from chipset_task.
* power_button_interrupt(), which is an interrupt
* power_button_change_deferred(), which is a deferred function

So, ummm, it's probably not a good idea to do a read-modify-write of a
variable without any locking.  ...and then to act on the resultant state
in various different contexts.

It's presumed that's just what happened to poor Julius.  Julius found
himself in the unfortunate situation where he resumed his device (with
the power button, I believe) and that everything worked (including
reading the battery state and including the accelerometer) but the
keyboard didn't work.  Now, it should be noted that Julius is a little
strange.  Well, maybe he's not strange and maybe just the way he uses
his laptop is strange.  He uses his veyron_minnie device as a smart
keyboard/trackpad.  Said another way: it is in tablet mode but is docked
to an HDMI monitor, the screen is face flat on his table, and he uses
the builtin keyboard and trackpad.  Nobody else that I know does this.
It's pretty darn cool, but I just don't think anyone else would think of
it.  Anyway, that might have something to do with how he reproduced
this.  ...or it might not.  He does that a lot and hasn't seen the
problem before now.

Anyway, I managed to reproduce a number of problems similar to what poor
Julius saw by adding a 200ms sleep in keyboard_scan_enable() after we
read disable_scanning_mask but before we did anything to it (I skipped
the sleep if this happened to be one of those people who was calling
from interrupt).

Since there appears to be no spin_lock_irqsave() in the EC, let's just
have the EC use atomic operations to mess with its masks.  Then we'll
leave all heavy lifting to the task.

This requires thinking through the task code a bit.

Conflicts:
    common/keyboard_scan.c
...due to commit 6112f20679 ("common: keyboard_scan: Add items to
.bss.slow.") in ToT.

BRANCH=ToT
BUG=chrome-os-partner:48470
TEST=Poke a lot with power button and lid; NTF.

Change-Id: I61b906505100186b0ca2c48e7b1a7ffaaa8a7d3e
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317896
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 98ab7484d331a78fced870b58b4d82e79e2e0f4e)
Reviewed-on: https://chromium-review.googlesource.com/318292
2015-12-14 16:34:02 -08:00
Bill Richardson
1ed496813c Cr50: clean up usb_init()
No new functionality, just a little refactoring and general
cleanup of the USB initialization steps.

BUG=chrome-os-partner:34893
BRANCH=none
CQ-DEPEND=CL:317376
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Change-Id: Ia6922acf82a793759870a61217562f4e63608a80
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317319
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2015-12-14 13:35:13 -08:00
Shawn Nematbakhsh
3a1b5d5acb stm32: Don't use HSI48 clock for chips which don't support it
stm32f03x and stm32f070 officially do not support an HSI48 clock, so
configure our 48MHz clock using HSI8 and PLL.

BUG=chromium:568717
BRANCH=None
TEST=Verify snoball 1us timer is accurate and we can execute
approximately 48 million NOPs in a second.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ice74de98f18908e53e94f2d95a2ec3cae53e2347
Reviewed-on: https://chromium-review.googlesource.com/317459
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-12-11 17:03:22 -08:00
Bill Richardson
0ad9bd623c Cr50: USB: Add stubs for additional EP0 interrupts
No new functionality, just adding stub handlers for some
additional USB interupts that we'll eventually need to deal with.

BUG=chrome-os-partner:34893
BRANCH=none
CQ-DEPEND=CL:317354
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Change-Id: I805ac00432c31735d2904227c5d19ad53cfa7ccb
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317376
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2015-12-11 13:09:17 -08:00
Bill Richardson
30f8fdaa91 Cr50: Cleaner API for USB_DECLARE_IFACE callbacks
The control endpoint (EP0) can receive some Setup packets that
are specific to individual Interfaces. The USB_DECLARE_IFACE
macro is used to register the callbacks that an interface
implementation provides to handle those Setup packets.

This change cleans up the callback API a bit, so that we don't
have to export the internal workings of the Cr50's EP0 interrupt
handler.

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Change-Id: I9ac22f6a74f360f201c58e9ef39e3576834578a8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317269
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2015-12-11 11:22:02 -08:00
Jagadish Krishnamoorthy
56385a0567 ALS: wake up ALS task when switched to RW mode
Enabling of ALS is done during resume hook.
During EC sw sync, resume hook is not called
and hence ALS task wont run.
Adding init hook to wake up the ALS task.

BUG=chrome-os-partner:48418
BRANCH=none
TEST= On Kunimitsu board, ensure sw sync is enabled.
In OS, cat /sys/bus/iio/devices/iio:devicesx/in_illuminace_input
should output valid value and not zero.

Change-Id: Iba1a3ab2cf7bfc2d8aa36cf9bb9b762f398882c3
Signed-off-by: Jagadish Krishnamoorthy <jagadish.krishnamoorthy@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/317030
Commit-Ready: Freddy Paul <freddy.paul@intel.com>
Reviewed-by: Freddy Paul <freddy.paul@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-12-11 11:22:01 -08:00
Bill Richardson
5618054f95 Cr50: Add a few more symbolic names for constants
No functional changes, just making the code prettier.

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Change-Id: I1301c035eafc054567c1f317a80539197fcdeef4
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317354
2015-12-11 11:22:01 -08:00
Vincent Palatin
229bc28b06 honeybuns: enable updates over USB-PD
Enable the RSA verification of the RW partition,
so we are using the RW partition by default and
the USB PD flashing VDMs are able to update
the firmware over the Control Channel.

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

BRANCH=samus
BUG=chrome-os-partner:47823
TEST=run the following sequence on a Samus connected to Honeybuns :
ectool --name=cros_pd infopddev 1
ectool --name=cros_pd flashpd 5 1 ec.RW.bin
ectool --name=cros_pd version
and see the honeybuns properly updated and running the new version.

Change-Id: I8f1612ee153a412620bae5822d1b354ad8072916
Reviewed-on: https://chromium-review.googlesource.com/312998
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
2015-12-11 00:47:56 -08:00
Bill Richardson
8acf3ebe2e Cr50: tweaks to debug output and a comment or two
No functional changes, just some additional debug stuff that's
not normally compiled.

BUG=none
BRANCH=none
TEST=make buildall, manual

Connect the Cr50 to my workstation via USB:
* /bin/dmesg reports no errors
* verify EP0 with lsusb -v -d 18d1:5014
* verify EP1 with './extra/usb_console -e 1 -p 5014' (reverses
  case of input text)
* verify EP2 with the 'hid' command on the EC console (types a 'g')

Change-Id: I32b4944c01006f2e9c8cdb2e732a4b1710a60e19
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317560
2015-12-10 14:01:15 -08:00
Vadim Bendebury
55e5649494 cr50: fix calculations determining the image type
The startup message includes the type of the image it is running (RO
vs RW currently). cr50 reports RW as RO, which this patch fixes. This
issue requires a bit more attention though: first, the RO type can be
deduced at compile time. Second, RW and RW_B should be accommodated.
RW_B should also be accounted in other places in the code where now
only two options are considered: RO vs RW.

BRANCH=none
BUG=chromium:567938
TEST=the startup message now reads:
  --- UART initialized after reboot ---
  [Reset cause: power-on]
  [Image: RW, cr50_v1.1.4162-f1e71a6-dirty 2015-12-08 16:39:00 vbendeb@eskimo.mtv.corp.google.com]

Change-Id: I0db2db4413a13ebe915e1081b47cd4a6f85cbdd8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/316922
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-12-09 06:36:26 -08:00
Vadim Bendebury
432ea75d92 cr50: add ability to include two identical RW sections in the EC image
A typical EC image includes two similar in their functionality
subsections, RO and RW. CR50 has a small RO subsection, all it does -
detects a proper RW image to run and starts it up. To provide for
reliable firmware updates, the CR50 image needs to include two RW
sections, while the code is running from one RW subsection, the other
one can be upgraded.

This patch adds the ability to generate two identical RW sections,
mapped half flash size apart, and include them into the resulting EC
image.

To keep things simple the previously existing RW section's name is not
being changed, while the new (identical) RW section is named RW_B.

Two configuration options need to be defined to enable building of the
new image type: CONFIG_RW_B to enable the feature and
CONFIG_RW_B_MEM_OFF to define where RW_B should be mapped into the
flash.

A new rule added to Makefile.rules allows to generate a different lds
file from the same source (core/cortex-m/ec.lds.S) by defining a
compile time variable to pick a different base address for the
rewritable section, when RW_B is built.

BRANCH=none
BUG=chromium:43025
TEST=as follows:
    - make buildall -j still succeeds
    - verified that regular CR50 image starts successfully

    - modified chip/g/loader/main.c to launch RW_B first, re-built and
      re-run the image, observed on the console:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  cr50 bootloader, 20151118_11218@80881, no USB, full crypto
  Valid image found at 0x00084000, jumping

  --- UART initialized after reboot ---
  [Reset cause: power-on]
  [Image: unknown, cr50_v1.1.4160-4c8a789-dirty 2015-12-07 18:54:27 vbendeb@eskimo.mtv.corp.google.com]
  [0.001148 Inits done]
  This FPGA image has no USB support
  Console is enabled; type HELP for help.
  > [0.002212 task 2 waiting for events...]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    (note that the image base address is 0x840000, which is RW_B).

Change-Id: Ia2f90d5e5b7a9f252ea3ecf3ff5babfad8a97444
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/316703
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-12-09 06:36:22 -08:00
Duncan Laurie
a41d5c84ca glados/chell: Do not pull-up RSMRST to PCH in hibernate
If deep sleep S5 is supported RSMRST to the PCH should not be high
when the PCH is in S5 unless the board is sequencing out of deep sleep
and S5 state. Therefore, ensure RSMRST is low when the EC goes into
hibernate. This assumes deep sleep S5 is employed. A more appropriate
fix is to honor RMSRST state prior to going into hibernate state.
Without this change the behavior on certain platforms do not sequence
out of S5 when coming out of hibernate.

BUG=chrome-os-partner:48133
BRANCH=none
TEST=tested on a failing EVT chell board at the factory

Change-Id: Ia4a1cdb59c25a3fc704c64fbe6beb01ede90d777
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/317070
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-12-09 05:14:14 +00:00
Aseda Aboagye
f5773e74d5 ec3po: Add setup script.
This commit adds a setup script for the ec3po package.  This is
necessary such that ec3po can be included as a part of ec-devutils.

BUG=chrome-os-partner:46054
BRANCH=None
TEST=Update the ec-devutils ebuild to install the ec3po package.
sudo emerge ec-devutils; `python -c 'import ec3po'; print ec3po`
in the chroot.  Verify that ec3po is installed in the site-packages.
TEST=Verify that interpreter and console modules are exported in the
package.

CQ-DEPEND=CL:316479

Change-Id: I5c8856b530936dc4ce3b09e38802f1e015c4576b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/316701
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2015-12-08 20:05:05 -08:00
Aseda Aboagye
c665d557cb ec3po: Clean up and stylistic changes.
It was brought to my attention that there were some issues with the
ec3po code.  This commit addresses those issues raised.

 - executable bits dropped from __init__.py and interpreter.py.
 - sys.argv[1:] is now passed into console.py:main().
 - Added blank lines at top of header.
 - Removed dummy exception class (MoveCursorError).
 - Added name of modules in the logger, so that it's not just 'root'
     when included in other modules.

BUG=chrome-os-partner:46054
BRANCH=None
TEST=./util/ec3po/console_unittest.py -b
TEST=./util/ec3po/interpreter_unittest.py -b
TEST=cros lint --debug ./util/ec3po/console.py
TEST=cros lint --debug ./util/ec3po/console_unittest.py
TEST=cros lint --debug ./util/ec3po/interpreter.py
TEST=cros lint --debug ./util/ec3po/interpreter_unittest.py

Change-Id: I00db368906958d1089c3662eb253be23f81cc70c
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/316479
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2015-12-08 12:28:58 -08:00