Commit Graph

461 Commits

Author SHA1 Message Date
Gwendal Grignou
8cd6cb8d2b ectool: Add description for new sensors.
Add string for new sensors.

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

Change-Id: Ia41f845cd02ba7a1fd322c15692be0bb177eada4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295634
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-27 21:27:48 -07:00
Aseda Aboagye
9fc5ae515e util: More enhancements to config_option_check.py.
This commit enhances the config_option_check.py script a little bit
more.

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

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

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

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

Change-Id: I8702ad06d9856c14f7bcd4592e917a5d3fcb6b57
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/294620
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-08-27 01:49:38 +00:00
Vadim Bendebury
9005ddd4bc cr50: add plumbing for signing CR50 RO images
The signer utility needs to be built and the flat image needs to be
signed. The signer utility is written in C++, supporting this required
adding a new make command to Makefile.rules and a build file for the
utility.

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

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

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

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

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

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

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

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

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

Change-Id: I046b13d20f0dd8cff884e37ef966593e01dcb043
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295208
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2015-08-25 20:10:55 +00:00
Shawn Nematbakhsh
ad8ce3f806 usb_pd: Add host command to limit external charger voltage / current
PD charger voltage + current can now be limited with
EC_CMD_EXTERNAL_POWER_LIMIT. The limit is automatically cleared when the
AP transitions out of S0 into S3 / suspend.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6cd5377be91b3df75f99cb414fd3fa5a463b56cb
Reviewed-on: https://chromium-review.googlesource.com/293954
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-22 01:37:38 +00:00
Mulin Chao
9fdcfe00ca nuc:Using LRESET interrupt to re-initialize LPC settings after warm boot
Fixed bug during polling port 0x204 by BIOS.
We should set processing flag before reading command byte in ISR to prevent
EC_LPC_STATUS_FROM_HOST and EC_LPC_STATUS_PROCESSING bits are both low.

Modified drivers:
1. gpio.c: Add LRESET ISR.
2. lpc.c: Fixed bug during polling port 0x204 by BIOS.
3. flash_ec: Reset ec before flashing ec

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

Change-Id: I8e557f2e2be41a7a9d40c03c775313b12668f283
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/291210
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2015-08-12 18:12:27 +00:00
Alec Berg
756d7d3f84 lucid: add lucid support to flash_ec
BUG=chrome-os-partner:43619
BRANCH=none
TEST=none

Change-Id: I67699ff3904ee6d1196a812adc395d9d3ad7813f
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/290437
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-05 01:32:47 +00:00
Myles Watson
050db0510e flash_ec: add support for SWD, nrf51, and hadoken
BUG=none
TEST=manual
BRANCH=none

flash_ec --board=hadoken
flash_ec --board=npcx_evb
flash_ec --board=samus

Use openocd in SWD mode to flash the nRF51 chip.

Use warm_reset to exit DEBUG mode.

Change-Id: Iaf2827d4ce5be6d61431a3de7ab4f86aa4adde02
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/287039
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-08-04 19:22:12 +00:00
Tom Wai-Hong Tam
12495e2b40 flash_ec: Set a 10-minute timeout for flashing EC
The flash_ec script is called by the lab infrastructure to flash
the EC firmware of DUT. To prevent the EC flashing tool hanged
forever (may be caused by some bugs), set a 10-minute timeout to
force it to be killed.

BRANCH=none
BUG=chromium:514810
TEST=Patched the change to servo v3. Triggered flash_ec to flash EC
on Jerry. Set the timeout to a small value to force to kill itself.

test2:
  ./flash_ec --board=hadoken   # or samus, anything using openocd
  remove the USB cable half way through (openocd hangs)
  ps au | grep openocd

Change-Id: I39ad8659b41764fd0dba30a86eca301fbbc5243f
Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289247
Commit-Queue: Myles Watson <mylesgw@chromium.org>
2015-08-04 19:21:57 +00:00
Myles Watson
2476e6c9a4 Pinky: Remove obsolete board
Jerry is being used for FAFT in the lab.  Remove Pinky instead.

BUG=chromium:511324
TEST=make buildall -j
BRANCH=none0
CQ-DEPEND=CL:288258

Change-Id: I03ddc74a4e72353f3408da8e374ad925baf00a35
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/288237
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
2015-07-25 17:45:22 +00:00
Ian Chao
14bd917343 nuc:
Add ECST tool to modify the header used by npcx booter.

Modified drivers:
1. i2c.c: Modify for i2c_port design.
2. i2c.c: Fixed bugs when mutil-tasks use the same i2c port and pull-up issue.
3. hwtimer.c: Fixed bug whcih event expired time is behide current timer.
4. lpc.c: Add intializing host settings after pltrst is deasserted.
5. uart.c/clock.c/register.h: Fixed bug which cannot enter deep-idle
   when gpio is any-edge trigger mode.
6. task.c: Add workaround method for hard fault issue.
7. keyboard_raw.c: Modified for support CONFIG_KEYBOARD_KSO_BASE
8. lpc.c: Modified for support CONFIG_KEYBOARD_IRQ_GPIO
9. lpc.c: fixed obe interrupt bug during 8042 initialization
10.Adjust path of flat files for new Makefile rules
11.Fixed build error on lpc.c without CONFIG_KEYBOARD_IRQ_GPIO

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

Change-Id: Icf9494174b245b4026e396be877d578f36b6f6a5
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/284036
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
2015-07-25 01:22:32 +00:00
Aseda Aboagye
96888b2f9b util: Enhanced config_option_check.py.
This commit enhances the config option check python script to
significantly reduce the number of false positives.

 - Now only checks committed changes.
 - Only checks additions, not the whole file.
 - Only checks uses of CONFIG_* not in a comment for both C-style and
   Make-style files.
 - Suports a whitelist.

BUG=chromium:510672
BRANCH=None
TEST=Detected missing configs in Makefiles and C source files.
TEST=/* CONFIG_FOO */ was not detected.
TEST=' board-$(CONFIG_OPT)=board.o # CONFIG_OPT2' only CONFIG_OPT was
detected.
TEST=Changes in working dir were not detected.
TEST=Changes to config_option_check.py were not detected.
TEST=cros lint --debug util/config_option_check.py
TEST=CONFIG_FOO in a multi-line C comment was not detected.

Change-Id: I5fc2ccc77bb4f319a3c85b7d81c83027959dc96b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/287519
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-07-24 21:54:27 +00:00
Tom Wai-Hong Tam
e5f7583cc6 flash_ec: Add a chip argument
The flash_ec uses the given board name to select a proper flashing
method. It keeps a mapping from board name to chip name.
This approach is not scalable if we want this script to work on
all supported board variants, like the pinky family which has many
boards: jerry, minnie, speedy, etc.

This change adds a new argument of chip name, such that we can only
keep the mapping of major boards. Other boards not listed can use
the chip argument to select a proper flashing method.

BRANCH=none
BUG=chromium:505003
TEST=Ran the script on Beaglebone/Servo v3 connected with Jerry:
$ flash_ec --chip stm32 --image ec.bin

Change-Id: I553ee68f82a7985a37548dfb6e89b364eaffd0f1
Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/287445
Reviewed-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Myles Watson <mylesgw@chromium.org>
2015-07-22 22:29:54 +00:00
Vincent Palatin
aaafd2da28 Remove ryu P4/P5 support
Remove ryu_p4p5 EC board code along the "splitted" Sensor hub board
(ryu_sh/ryu_sh_loader): It's time to get rid of oldies.

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

BRANCH=smaug
BUG=chrome-os-partner:38333
TEST=make buildall
CQ-DEPEND=*I6df51d7b4be2be7217604da60462b8c9d0cde1d2

Change-Id: Iebc4022267afccb5057c856d624e56a850ecbd70
Reviewed-on: https://chromium-review.googlesource.com/286780
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-07-20 23:35:44 +00:00
Myles Watson
d737517db7 flash_ec: openocd-related fix for npcx.cfg
using_jtag is now a helper function, not a global variable.

BUG=none
BRANCH=none
TEST=flash the npcx evaluation board

sudo servod --vendor 0x18d1 --product 0x5002
./util/flash_ec –port=9999 –board=npcx_evb

Change-Id: Ied2c0808b2a12d18b8350e68d5825703b71edc5e
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/286531
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-07-20 22:09:34 +00:00
Vadim Bendebury
53a2bbace3 util: small config_option_check.py improvements
As of now this check results in false positives, for instance
'CONFIG_' found in the comments results in an error report.

This patch makes the script a bit more robust:
  - consider only those options mentioned in include/config.h as
    explicitly defined or undefined.
  - do not scan include/config.h for new added CONFIG_ options
  - ignore comments in .mk files

Ideally the script should be scanning only added lines of code and
much smarter about what should be considered a comment and what files
should be examined.

BRANCH=none
BUG=chromium:510672
TEST=the false positives triggered by comments in various build.mk
     files are gone now. Adding an undescribed CONFIG_xxx text still
     triggers the error.

Change-Id: Ib9858775bcd9899dec629682a1c7965e7c2fec96
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/285926
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-07-17 00:07:38 +00:00
Dino Li
5727da84de it8380dev: util/iteflash
1. change I2C frequency to 400K.
2. include the support for other it83xx series.
3. add "chip erase" command if the erase size equals to
   flash's physical size.
4. remove 50h command.
5. always check write enable bit of the status reg, after
   write enable command.

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

BRANCH=none
BUG=none
TEST=servo board + IT83xx EVB can erase, write, and read flash via i2c.
     (iteflash --e, --w, and --r)

Change-Id: I0ac1eeaed5c243215d8817eb45b4b4fe0a7df26a
Reviewed-on: https://chromium-review.googlesource.com/283265
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Dino Li <dino.li@ite.com.tw>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
2015-07-16 05:15:34 +00:00
Gwendal Grignou
5d970f4b53 command: Add sensor FIFO as an independant feature.
To ease driver loading in the kernel, add a bit in the feature field
to indicate the EC has an internal software FIFO for sensor events.

BRANCH=smaug
BUG=chrome-os-partner:39900
TEST=compile, kernel modules load as expected on Smaug.

Change-Id: I1ae0b9ebb587bb4939745e8a0e16d73d95ba31d7
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/285774
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-15 21:58:15 +00:00
Gwendal Grignou
9edc728d54 motion: FIFO: add lost per vector type
When FIFO overfills, keep track of the number of lost vectors per
vector types. This way, when we calculate timestamps in user space,
we can evaluate the number of empty slots to skip per vector type.
This is important when different types are samples at very different
frequencies.

BRANCH=smaug
TEST=Check that when we drop events, the timestamp are better than
without.
BUG=chrome-os-partner:39900

Change-Id: Ib9cb994ada38373e5a49dd4ba2123ca7534a169e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284615
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-15 02:06:23 +00:00
Gwendal Grignou
8c1d76e52c ectool: Fix compilation warning
Was comparting a int16_t with 0x8000 leading to:
error: comparison of constant 32768 with expression of
ec-utils-0.0.1-r2377:       type 'int16_t' (aka 'short') is always false
(Builder: Chromium OS (x86) Asan (stats) 7005)

BRANCH=smaug
TEST=On Smaug check that ectool does report invalid temperature
when EC returns 0x8000.
Check the temperature is correct when the EC returns a valid
temperature.
BUG=chromium:508674

Change-Id: I2a1414cf7bf018ecaa7ff8dd37c76804de4bce52
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284673
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
2015-07-10 03:40:34 +00:00
Gwendal Grignou
fc17034c52 motion: Add commands for calibration
Move calibration in the EC to returns raw value with offset already
applied, as recommended by iio interface.

BRANCH=smaug
TEST=On Samus, with kernel change CL:283103
Check raw value are returned properly.
BUG=chromium:506101

Change-Id: I3dcb4f2fcfff35639e3bfdcc6c1468bdb5e53c45
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/283161
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-09 06:01:00 +00:00
Myles Watson
52ff2e4c8d flash_ec: remove redundant code from lm4x_cmds.tcl
All boards in ToT have the same RO configuration.
Boards which define CONFIG_FLASH_PSTATE_BANK have pstate following RO.

BRANCH=none
BUG=chrome-os-partner:22990
TEST="git grep" to see that none of the affected functions are called.

Change-Id: Ie1eb9a726e1fa157852b0c55d474c9b4587c41f0
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273908
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-07-09 01:18:15 +00:00
Myles Watson
aaff361011 flash_ec: split interface config from chip configs
rename setup_openocd -> flash_openocd
refactor so that flash_npcx and flash_lm4 set OCD_CMDS and call flash_openocd

BRANCH=none
BUG=chrome-os-partner:22990
TEST=run flash_ec before and after and compare the sequence of calls to
dut-control and the command-line args to openocd

tested with ryu (non-lm4), samus, link, npcx_evb, and peppy

Change-Id: I7a05e3219d4b324bcf19a20f86b149f8e3377465
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273907
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-07-09 01:17:57 +00:00
Myles Watson
b793546316 flash_ec: move openocd configs from chip/ to util/
Avoid duplicating servo configurations for every chip.

BRANCH=none
BUG=chrome-os-partner:22990
TEST=None.  This is an intermediate step to make it clear what's happening.
CQ-DEPEND=CL:273950

Change-Id: I448543b6ab9d39423955e8d2589b6035c59e838a
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273906
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-07-09 01:17:52 +00:00
Dan Shi
d6a6c92724 Add jerry to the list of BOARDS_STM32 as a short-term fix
Board jerry was removed from the list in CL 276524. The board share the same
overlay as pinky. So ideally user can call flash_ec with board set to pinky.
This applies to other veyron boards in BUG 505003 as well.

However, servo in the lab runs on ToT, and it only updates firmware of the dut
by calling flash_ec with board name retrieved from the overlay file. Also, lab
has a tool to check the servod's board and the dut's board. That is, if we
change servod to return board name pinky for servo connected to a jerry dut,
the lab script will raise a warning that the servod is running with a wrong
board.

Before we have a good design to really address the issue, I'd like to add jerry
back to flash_ec so the board can run FAFT in the lab.

BUG=chromium:505003
BRANCH=None
TEST=None

Change-Id: I155e79710f2731701af0acdfeab6089701cf52a8
Reviewed-on: https://chromium-review.googlesource.com/283494
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
2015-07-08 01:44:13 +00:00
Kevin K Wong
882da45900 flash_ec: Add support for kunimitsu, kunimitsu_pd, and strago_pd
BUG=none
TEST=Verified EC and PD is able to flash on kunimitsu and strago
BRANCH=none

Change-Id: I31b9ed57d4cd7a1c09cedbf9c873e76770abd3c8
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/282000
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-06-30 12:22:13 +00:00
Aseda Aboagye
0ec956ea9d util: Add config option checker.
There are several cases in the EC code base where a CONFIG_* option is
used somewhere, but not defined within the include/config.h file.  This
script aims to fix that.  Eventually, it will become a presubmit hook to
actively prevent future offenses.

BUG=chrome-os-partner:26304
BRANCH=none
TEST=cros lint --debug util/config_option_check.py
TEST=Ran script and found offending config options.
TEST=make -j buildall tests

Change-Id: I999d32ebacc636b3fff9e857f3cc46feee475e80
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/281626
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
2015-06-27 19:29:29 +00:00
Ian Chao
957638c78c nuc: Add SHI driver for arm-based platform in chip folder.
Add npcx_evb_arm board-level driver for arm-based platform.
Add header.c: for booting from NPCX5M5G A3 Booter.
Remove lfw folder due to those functionalitie have been replaced with Booter

Modified drivers for
Patch Set 1:
1. flash.c: Implement UMA lock, tri-state and selection register lock functionalities
2. hwtimer.c: Add ITIM32 for hwtimer
3. lpc.c: Add checking for LRESET
4. system.c: Modified CODERAM_ARCH functions for NPCX5M5G A3 Booter.
5. uart.c: Add support for module 2
Patch Set 2:
6. lpc.c: Modified lpc_get_pltrst_asserted() func
Patch Set 3:
7. minimize the changes for CONFIG_CODERAM_ARCH in common layer
8. comments of Patch Set1/2
Patch Set 4:
9. Modified CONFIG_RO_MEM_OFF point to ro image and keep header as a part of ec.RO.flat.
10. Fixed RO_FRID and RW_FRID issues which caused by CONFIG_CODERAM_ARCH.
Patch Set 5:
11. Modified system.c in common folder for supporting *_STORAGE_OFF.
12. Use *_STORAGE_OFF in firmware_image.lds.S to indicate flat file layout in flash.
Patch Set 6:
13. rebase to newest version
14. system.c: Modified for the newest include/system.h
Patch Set 7:
15. Merge from version 0625

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

Change-Id: Ifd7c10b81b5781ccd75bb2558dc236486976e8ed
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/272034
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
2015-06-26 18:57:32 +00:00
Bill Richardson
104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00
Myles Watson
19cd951027 flash_ec: remove unused USB and unprotect options
There is no need for the usb flag, remove it.
There is no need for the unprotect flag, remove it.

BRANCH=none
BUG=chrome-os-partner:22990
TEST=run flash_ec before and after

Change-Id: I201bad7f5be63a90bb8168e21baef2c6fa8d85b4
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 17:31:04 +00:00
Todd Broch
9941f088d7 mec1322: Add servo serialname to flash_ec's flashrom call.
If host running flash_ec has multiple servo's connected it must use
the USB serialname to identify the proper FTDI device to run flashrom
on correctly.  CL adds serial param to flashrom call to do just that.

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

BRANCH=none
BUG=none
TEST=manual, successfully write glados EC w/ multiple servo V2's
connected to the same host.

Change-Id: I35c7d170f9bb80e96f69efae634cf70893eeef63
Reviewed-on: https://chromium-review.googlesource.com/276761
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-11 18:27:30 +00:00
Gwendal Grignou
e51399aae8 commands: Add EC FIFO commands
Add command to read the sensors events FIFO from the AP:
FIFO_INFO: get information on the FIFO state
FIFO_READ: read and update the consumer pointer
FIFO_FLUSH: insert a flush meta event and force a interrupt.

A new MKBP event is added to tell the host the FIFO needs processing.

BRANCH=smaug
TEST=Test on ryu
BUG=chrome-os-partner:39900

Change-Id: I11c0cf8cdc3087eb9e323f7d6780e6cf3a16257f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276264
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-11 18:27:24 +00:00
Randall Spangler
fe9e3bf565 Remove obsolete board-specific code
Now that we've removed boards from ToT, also delete board-specific
code used only by the removed boards.

There are still more things to remove (unused charging chips, LED
drivers, COMx support).  More CLs coming.

BUG=chromium:493866
BRANCH=none
TEST=make buildall -j

Change-Id: Ie6bdeaf96e61cadd77e3f6336c73b9b54ff4eabb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276524
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-10 18:24:05 +00:00
Rong Chang
a585141db0 stm32: switch to ec_boot_mode servo control
hdctools adds an alias ec_boot_mode and remaps spi1_vref with onoff
control. This change switches ARM systems with STM32 EC from
spi1_vref:pp3300 to ec_boot_mode:on.

CQ-DEPEND=CL:275251
BRANCH=none
BUG=chrome-os-partner:40479
TEST=manual
  cd ~/trunk/platform/ec
  util/flash_ec --board oak --image oak_ec.bin
  util/flash_ec --board oak_pd --image oak_pd.bin

Change-Id: I0f3a74eaa7fc937d1372cd51124c6b3d23351581
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274770
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
2015-06-10 14:19:29 +00:00
Todd Broch
339fe7245d mec1322: bugfix for flash_ec dut-control call.
Direct call to shell command 'dut-control' wouldn't account for port
argument in script.  Change to function 'dut_control' within script
that does.

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

BRANCH=none
BUG=none
TEST=none

Change-Id: Id4f77dedb57ce8097059c33371b5cd697fdbdb0d
Reviewed-on: https://chromium-review.googlesource.com/276534
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2015-06-10 05:04:01 +00:00
Gwendal Grignou
da1c425471 ectool: Fix cut and paste errors in motionsense
BUG=none
BRANCH=none
TEST=compile

Change-Id: Ie1e5a453f2ffa023599ca6357d1fd2bee95b271d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276263
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-09 20:17:16 +00:00
Gwendal Grignou
c70fb0f9eb motion: Add MOTIONSENSE_CMD_DATA: retrieve single sensor data
MOTIONSENSE_CMD_DATA return the value of a sinlge sensor.

BRANCH=none
BUG=chrome-os-partner:39900
TEST=On Smaug, using the new cros-ec-sensors driver,
check sensors data using iio sysfs interface.

Change-Id: I618ff050e0c7b4247ac56cfb0ca25e351270e1d6
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274824
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-03 19:46:19 +00:00
Sheng-Liang Song
7a54beba50 sb_firmware: fixed the last write delays
BUG=chrome-os-partner:40569
BRANCH=none
TEST=Begin
1. Install noraml linux images
2. Connected Battery which is having old firmware(100)
3. power on DUT and goto crosh (In normal mode)
4. run "battery_firmware update "
5. Remove AC to interrupt the update
6. Power OFF and power on the DUT again
7. Now seen critical firmware update screen.
8. Reboot around 4 min.
9. See login window.
End

Change-Id: I2090cfa9200a7402a5fba2e111073dd1d7e7b422
Signed-off-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273660
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-30 02:11:11 +00:00
Gwendal Grignou
c89ebdb66c ectool: query packet size and set them properly internally.
Allow to negotiate the packet command and responses to
whatever values the EC can support.
Set the buffer size including the necessary V3 header.

If the EC run v3 protocol with large packet support, but the kernel
does not have v3 support (3.10), we can not support sending or
receiving large commands.
Be aware that on 3.10, commands like ectool console will fail if
the EC wants to send command larger than the kernel can handle.

Copied kernel_version_ge from libusb-1.0.19/libusb/os/linux_usbfs.c.

BUG=chrome-os-partner:31989,chrome-os-partner:31660,chromium:454324,chrome-os-partner:39265
BRANCH=none
TEST=Build a special firmware to exchange 300 bytes.
Check ectool console works with the righ size.
Check that ectool is calling uname.
Check on Nyan_big: without change, "ectool version" crashes kernel. With
changes, "ectool version" works.

In conseuqence, it reverts commit be0bd9b835,
"ectool: Do not increase buffer size after probe max size from ec"

Change-Id: I54ffd43488ea81272f30789dc87a261085769fe0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274086
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-30 01:04:29 +00:00
Shawn Nematbakhsh
e216906c93 flash_ec: Add support for glados and glados_pd
BUG=None
BRANCH=None
TEST=`flash_ec --board=glados`

Change-Id: I8a23cbd0324d9a321a07bdfd182c996efac79f4c
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/273359
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-05-27 03:58:11 +00:00
Yunlian Jiang
a6d1e65cdf ec: fix -Wuninitialized warning.
BUG=chromium:488540
Signed-off-by: yunlian@chromium.org
BRANCH=none
TEST=FEATURES="test" CC=x86_64-cros-linux-gnu-clang
     CXX=x86_64-cros-linux-gnu-clang++ emerge-falco chromeos-ec

Change-Id: If70f7de921a2e973c093a92f03fa0f1603ee0b08
Reviewed-on: https://chromium-review.googlesource.com/271476
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Commit-Queue: Sheng-liang Song <ssl@chromium.org>
Tested-by: Sheng-liang Song <ssl@chromium.org>
2015-05-15 20:41:57 +00:00
Rong Chang
91b9c336ee oak: Add oak EC and PD flash_ec support
flash_ec script supports stm32 ec and usbpd. This change adds new board
name and MCU map.

BUG=none
TEST=manual
  flash_ec --board oak --image ec.bin
  flash_ec --board oak_pd --image pd.bin

Change-Id: I51a4a22b5188dda35d7b8c34a0115997f374f413
Reviewed-on: https://chromium-review.googlesource.com/267042
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
2015-05-15 10:32:40 +00:00
Sheng-Liang Song
6cd67659db sb_firmware: Fixed firmware version check
Added firmware version check to handle the following cases:
   - when the data table version is the same and fw version is newer
   or
   - when the fw version is the same and data table version is newer.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: If3d28f6ae7a89fc7c41fd60214ab3616f1abfe5a
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270387
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 15:42:35 +00:00
Sheng-Liang Song
764c3fa790 sb_firmware: enable retry for status.fw_update_supported
Added retry logic when see fw_update_supported=0.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I441c9763df9b1e91b3de08d2f30ecfa49c59f677
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270179
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 15:42:30 +00:00
Sheng-Liang Song
be99fa290e sb_firmware: Enable Updates for Simplo Battery Only.
If can get battery info, enable updates if it is Simplo Battery.
If can not get battery info, assume a Simplo Battery is a bad state.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I0db6b50b5a382b72fd9682621990d0a6dd9e6a2b
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266044
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 07:52:45 +00:00
Sheng-Liang Song
58382b98f2 sb_firmware: Use new delay values suggested by Simplo & TI.
Used fixed delay values suggested by Simplo & TI.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: Ibc2d135cfd5e4c01fce0f8fcc56f5f850fab3c16
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265754
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 07:52:38 +00:00
Sheng-Liang Song
b09bfe5946 sb_firmware: check if last full charge is zero
Detect if the last full charge is zero or not.

BUG=chrome-os-partner:36310
BRANCH=none
TEST=Verified on Glimmer.
crosh> battery_firmware check
crosh> battery_firmware update

Change-Id: I078b860acc96f60830c82af8f85cfb98e27095cb
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/263156
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-05-14 06:48:37 +00:00
Vincent Palatin
decd6a545f add hash for locally emerged builds
When the EC is built using "emerge-<board> chromeos-ec" on a developer
workstation with the chromeos-ec package "cros-worked'on", put
"1.1.9999-<git-sha1>" rather than "no_version" in the version string.

Emerge is exporting the current git SHA-1 hash in the VCSID id but the
.git repository is not available during the build.

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

BRANCH=none
BUG=none
TEST=try the following build setups:
- local emerge
$ emerge-smaug chromeos-ec
$ strings /build/smaug/firmware/ec.bin | grep ryu
ryu_p4p5_1.1.9999-ebe18ef
- local build
$ make BOARD=ryu_p4p5
$ strings build/ryu_p4p5/ec.bin | grep ryu
ryu_p4p5_v1.1.3127-ebe18ef-dirt
- trybot build
$ cbuildbot --remote -g 270554 smaug-firmware
$ tar xvjf firmware_from_sources.tar.bz2
$ strings ec.bin | grep ryu
ryu_p4p5_v1.1.3137-9b52578

Change-Id: I386f80d82d95b5e99a1660a1eb242c47c54d17ef
Reviewed-on: https://chromium-review.googlesource.com/270554
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-13 22:23:06 +00:00
Gwendal Grignou
17487510e3 ec: Add Inventory command
Add command that list supported features by the firmware.
Also let the firmware indicates if more features are expected in the RW
version.

This will help the cros_ec framework load the right driver(s) for
exposing information via sysfs.

BUG=chromium:428364
BRANCH=none
TEST=Test on samus on both ec and pd:
localhost ~ # ectool inventory
EC supported features:
1   : Flash support
2   : Direct Fan power management support
3   : Keyboard backlight support
4   : Lightbar support
6   : Motion Sensors support
7   : Keyboard support
9   : BIOS Port 80h access support
10  : Thermal management support
11  : Switch backlight on/off support
12  : Switch wifi on/off support
13  : Host event support
14  : GPIO support
15  : I2C master support
16  : Charger support
17  : Simple Battery support
18  : Smart Battery support
21  : Control downstream MCU support
localhost ~ # ectool --name cros_pd inventory
EC supported features:
1   : Flash support
14  : GPIO support
15  : I2C master support
22  : USB Cros Power Delievery support

Change-Id: Ib6eaac91fda86835e754c5316ecf81fbc27786e5
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/263463
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2015-05-07 22:25:25 +00:00
Vincent Palatin
13b555dc63 ryu: fork P4/P5 support
In preparation for Proto 6 board support which won't be backward
compatible, fork the EC for Proto 4 and Proto 5 for people who need to
support older boards.

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

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

Change-Id: I520bbf146cc1c1dc04e55283be57807ec19ebaa1
Reviewed-on: https://chromium-review.googlesource.com/266064
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-02 16:49:05 +00:00