Commit Graph

1544 Commits

Author SHA1 Message Date
Scott
7184144012 Cr50: NvMem: Connected function stubs in /board/tpm2/NVMem.c
Used #define CONFIG_FLASH_NVMEM to have functions in
/board/tpm2/NVMem.c utlitize on chip Nvmem functions.
On chip NV Memory availability is tied to an internal nvmem
error state which itself only depends on finding at least one
valid partition.

Added nvmem_is_different and nvmem_move functions which were
needed to complete the tpm2 platform interface. In addition,
added unit tests to support these two new functions.

BUG=chrome-os-partner:44745
BRANCH=none
TEST=manual
make runtests TEST_LIST_HOST=nvmem and verify that all tests pass.
Tested with tcg_test utility to test reads/writes using the
command "build/test-tpm2/install/bin/compliance --ntpm
localhost:9883 --select CPCTPM_TC2_3_33_07_01".

Change-Id: I475fdd1331e28ede00f9b674c7bee1536fa9ea48
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/346236
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-05-26 18:08:57 -07:00
Scott
d80a5837c4 NvMem: Added NV Memory module to ec/common/
Full implementation of NvMem read, write, and commit functions.
Includes partition definitions, shared memory allocation, and
initialization function.

Includes a set of unit tests located in ec/test/nvmem.c which
verify functionality.

This module is required by Cr50, however this CL does not
include any Cr50 specific code.

BUG=chrome-os-partner:44745
BRANCH=none
TEST=manual
make runtests TEST_LIST_HOST=nvmem and verify that all tests pass

Change-Id: I515b094f2179dbcb75dd11ab5b14434caad37edd
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/345632
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-05-26 16:17:27 -07:00
Nick Sanders
56ee8aefc3 servo_micro: add programmable serial number
This change provides a console command for setting,
and loading a usb serial number from flash. This
feature adds CONFIG_USB_SERIALNO, and currently only
has a useful implementation when PSTATE is present.

BUG=chromium:571477
TEST=serialno set abcdef; serialno load; reboot
BRANCH=none

Change-Id: I3b24cfa2d52d54118bc3fd54b276e3d95412d245
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337359
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-26 16:17:26 -07:00
Nick Sanders
5cc3cac589 servo_v4: Fix ADC console command
The console adc command prints adc values in the
order they appear in hardware, however they are lableled
in the order they are enumerated in board.h, which is not
necessarily the same.

This prints the correct name and value pairs, and removes
the adc_read_all_channels function which is not otherwise
used.

BUG=chromium:571476
BRANCH=None
TEST="adc" command associates correct values with names now.

Change-Id: I688641953d20082224b4120eaefe0d634ad4c74c
Signed-off-by: Nick Sanders <nsanders@google.com>
Reviewed-on: https://chromium-review.googlesource.com/340892
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-26 16:17:26 -07:00
Shawn Nematbakhsh
798a50ca0e mkbp_event: Don't discard event source structures due to LTO
BUG=chrome-os-partner:53729
BRANCH=None
TEST=Manual on gru. Verify .rodata.evtsrcs section is non-empty in
ec.RO.map. Verify that we're no longer spammed with HC 0x67 (due to
constantly asserted interrupt).

Change-Id: I57ad1ba7fbdd99dfab84341560aff094ce9bc5b6
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/347415
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-05-25 22:55:43 -07:00
nagendra modadugu
e1dc48480f CR50: remove dependence of assert.h on util.h
Third party code includes standard system headers,
but may not have include paths configured for the
platform.

Remove the dependency between assert.h and
platform headers util.h, and panic.h.

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

Change-Id: Ic8d4dc1944765d2f0f80782afa574d7b8e54eb0f
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/347080
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-25 18:51:07 -07:00
Nicolas Boichat
f5bba241fd common/i2c: Add I2C passthru_protect command
This allows the AP to protect a I2C passthru bus. A board-specific
function then defines what I2C commands are allowed, so that we
can white/black list some addresses (e.g. I2C address allowing
PD chip FW updating).

BRANCH=none
BUG=chrome-os-partner:52431
TEST=Book elm-rev1

Change-Id: Ib106924418b16388ea8ea53c7b6bda6ef92e1d09
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Reviewed-on: https://chromium-review.googlesource.com/345761
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@google.com>
2016-05-24 19:23:27 -07:00
Vijay Hiremath
313355302b Driver: BD99955: Enable BC1.2 support
BUG=none
BRANCH=none
TEST=Manually tested on Amenia.
     Connected Zinger, Type-C, DCP & CDP chargers. Device can negotiate
     to desired current & voltage and the battery can charge.
     USB2.0 sync device is detected by Kernel.

Change-Id: I58cb69289eef9a966e06bef8fe31d35beaec5e27
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/341030
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-24 15:46:01 -07:00
Shelley Chen
a84aa5ace7 kevin: rk3399: enabling RTC wakeup
Enabled CONFIG_CMD_RTC_ALARM.  EC_HOST_EVENT_RTC
is enabled when the rtc_alarm goes off,
alerting the AP to transition from S3->S0.

BUG=chrome-os-partner:52218
BRANCH=None
TEST=rtc_alarm <num> and see event set in ec console
     after <num> seconds.  Also, check if new bit set
     through hostevent command in ec before/after
     rtc_alarm goes off.

Change-Id: I53b1705ce0925000f35b9f80752035d198db3310
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/345474
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-23 13:14:17 -07:00
David Hendricks
5219d2f86b spi_flash: Add protect_range table for W25Q40
BUG=chrome-os-partner:53035
BRANCH=none
TEST=needs testing

Change-Id: I4b2bc758a22c2c19ddf0438a2af26f8c76093081
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/339291
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-05-19 18:18:05 -07:00
Dino Li
f817140c3e chip: it83xx: Optimize interrupt usage of LPC access
LPC access interrupt only enabled when EC entering deep doze mode. This
will reduce interrupt of LPC access. Also, this interrupt is always
enabled for LPC platform to support "CONFIG_LOW_POWER_S0".

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

BRANCH=none
BUG=none
TEST=Tested ectool command 'version' x 10000.

Change-Id: I9053c4018b38a8a852c3c6254e1fcde625f3fa3a
Reviewed-on: https://chromium-review.googlesource.com/336112
Commit-Ready: Dino Li <dino0303@gmail.com>
Tested-by: Dino Li <dino0303@gmail.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-18 19:44:09 -07:00
Aman Kumar
e9501105c2 TCPM : Added driver for Analogix's anx74xx chips
Driver implements TCPC for ANX74xx chips. Enables Type C
port for USB and DP alt mode. Enable port role swap feature.
 Driver implements TCPC for ANX74xx chips firmware version 1.0 and later.
Please update to ANX74xx firmware to V1.0 or later version to work.

Change list:
1, modify the position of define and struct declare
which response the comment for patch 22.

BUG=chrome-os-partner:49510
BRANCH=none
TEST=tested compiled binary for pdeval-stm32f072 board with this patch.
Power contract establishment, port role swap, DP alt mode works fine.

Change-Id: Iae6322510605a08d3bdd08446116ef5f9e4f7a7c
Signed-off-by: Aman Kumar <akumar@analogixsemi.com>
Signed-off-by: Junhua Xia <jxia@analogixsemi.com>
Reviewed-on: https://chromium-review.googlesource.com/322433
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-18 18:11:32 -07:00
Vadim Bendebury
f2d57a8972 do not allow console commands with names longer than 14 characters
The maximum length of console command name is hardcoded to be 14 in a
few places in the code. In any case, 14 characters should be enough
for any command name, let's add compile time check to ensure that this
limit is honored.

BRANCH=none
BUG=none
TEST=tried adding a command with a name longer than 14 characters, got
     a compile error.

Change-Id: I11891fcd04983a5618400a602d4b80a478ecf3a9
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/345571
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-18 01:27:45 -07:00
Shawn Nematbakhsh
a4ef740391 usb_charger: Move part-specific code to usb_switch driver
Previously usb_charger.c supported only pi3usb9281, but now support for
additional parts is required. Move pericom-specific code (including the
usb_charger tasks that handles various quirks of that part) to the
pi3usb9281 usb_switch driver.

Going forward, usb_switch drivers must implement
usb_charger_set_switches() and must have some method (such as a task or
interrupt handler) to update charge_manager with information about
attached chargers.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I4df74e043d8cf2e532d48c39c73b7dc2930f7d3b
Reviewed-on: https://chromium-review.googlesource.com/344289
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Shawn Nematbakhsh
7d8964614d cleanup: Remove usb_switch_tsu6721 driver
This driver is not in use for any recent board and doesn't implement the
soon-to-be standard usb_switch interface routine.

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

Change-Id: I7469dab42e52d9d02425ad4e7bacb81b2489ffc4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344417
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Shawn Nematbakhsh
9494fc0dd1 pwm: Add generic PWM control host commands
Add generic PWM host commands for setting + getting duty cycle. PWMs can
be controlled through index (board-specific meaning) or by type
(currently KB backlight and display backlight are supported, more can be
added as needed).

BUG=chrome-os-partner:52002
BRANCH=None
TEST=Manual on chell.
`ectool pwmsetduty kb 100` - Verify KB backlight goes to 100%
`ectool pwmgetduty kb` - Prints 100
`ectool pwmgetduty 0` - Prints 100
`ectool pwmsetduty 0 0` - Verify KB backlight goes to 0%
`ectool pwmgetduty kb` - Prints 0
`ectool pwmgetduty disp` - Error res 3 (unsupported PWM type)
`ectool pwmsetduty 1` - Error res 3 (non-existent PWM index)

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I607c92a291e6c2e3af8238eaf22ad2bb81ffc805
Reviewed-on: https://chromium-review.googlesource.com/344012
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-05-11 18:24:30 -07:00
Shawn Nematbakhsh
b803590c27 hooks: Add relative HOOK_INIT priority for peripherals
Using HOOK_PRIO_DEFAULT for peripheral initialization necessitates using
HOOK_PRIO_DEFAULT+1 for board-level code. Instead, use a
higher-than-default relative priority for peripheral initialization
outside of board.

BUG=None
TEST=Verify PWM and ADC are functional on kevin.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ia8e90a7a866bdb0a661099dd458e3dfcaaa3f6bb
Reviewed-on: https://chromium-review.googlesource.com/342171
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-05 01:12:25 -07:00
Kevin K Wong
e83c06bf90 apollolake: ignore PLTRST# from SOC unless RSMRST# is deasserted
add optional chipset specific function to check if PLTRST# is valid

BUG=chrome-os-partner:52656
BRANCH=none
TEST=make buildall, able to boot to OS on amenia

Change-Id: I7a2747c4f77f50393c3250c2ab0e1625e64e5a41
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/341732
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-03 15:40:46 -07:00
Mary Ruthven
61e0653261 cr50: add basic rbox support
This change modifies the behavior of RBOX by blocking the key0 and key1
output, when the power button is pressed. It also adds support for
printing debug statements when various RBOX interrupts are triggered.

BUG=none
BRANCH=none
TEST=On cr50 test board verify key0 and key1 out are not asserted unless
the power button is pressed.

Change-Id: I67a3c1b8009279015bdc87bcf0995cffa9ab6f03
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/341470
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-29 16:07:13 -07:00
Shawn Nematbakhsh
ab27f42f56 pwm: Add PWM_CONFIG_DSLEEP config flag
Add PWM_CONFIG_DSLEEP PWM config flag, which can be set to keep a
channel active during low-power idle / deep sleep. Currently it's
supported by npcx and mec1322.

BUG=chrome-os-partner:52783
BRANCH=glados
TEST=Manual on chell w/ subsequent commit + CONFIG_LOW_POWER_S0. Verify
KB backlight does not flicker during idle.

Change-Id: Ib9df5879aaa7dfa5764de1583496de84d40d2bb5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/341002
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2016-04-27 23:58:04 -07:00
Nick Sanders
4e52ae607c servo_micro: add gpio mode get and set
GPIO console commands currently only show input voltage level,
and can only set level on predefined outputs.

This change allows GPIOs to be cycled between output, input,
and alternate function, as well as displaying the mode and
asserted level (if any) in gpioget.

This change creates CONFIG_CMD_GPIO_EXTENDED
as the internal gpio interface needs to be changed to support
this, and I can't test the other architectures. It may be
worthwhile to add this for all, or not.

This change is also necessary also for servo micro JTAG and PD
UART support, as several pins are tied together on the flex
and stm32 outputs need to be variously active or in high-z
depending on mode.

BUG=chromium:571477
TEST=gpioget <0|1|IN|A|ALT>; gpioget;
BRANCH=None

Change-Id: Iba32992db6244ee1e654db840d1c9c11dd2a0993
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338885
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-27 14:04:07 -07:00
Anton Staaf
307b8e5453 UART: Remove enable/disable interrupt functions
These were not being used and complicate changes to the UART API.

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

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

Change-Id: I73e256f09f7ea72f0cc4831cc7ce391a7125e555
Reviewed-on: https://chromium-review.googlesource.com/340841
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-27 10:10:02 -07:00
Mary Ruthven
2cab8b2081 cr50: enable AP and EC flash access
The cr50 SPI master can control the external AP and EC SPI ROM. This
change adds support for doing spi_transactions, but does not use the SPI
transactions for anything except console commands. This support will be
used for flashing the AP and EC through CCD. For now AP and EC flash
select must be done manually using the spi_flash_select console command.
Flash select should be disabled after use, because it will prevent the
system from booting.

BUG=chrome-os-partner:50701
BRANCH=none
TEST=Enable spi_flash commands. Select AP ROM and verify spi_flashinfo,
read, erase, and write commands work properly. Select EC ROM and verify
the same commands.

Change-Id: I16c55015794f8513effe0fa5712488a84bed2627
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/339844
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-26 14:21:00 -07:00
Daisuke Nojiri
40c02e3ff2 Bring up STM32L476G-Eval
This patch adds initial set of files to bring up STM32L476G-Eval board.

BUG=none
BRANCH=tot
TEST=Tested console. make buildall && make tests

Change-Id: I0c0f73f31e84099746fced4214c5ed7f45468cef
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340100
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-25 16:49:02 -07:00
nagendra modadugu
28827163c5 Move include/byteorder.h -> builtin/endian.h
Move endian routines to builtin/ so that portable third_party
code may build without glibc.

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

Change-Id: Icb900d1e9c56dc68ec1ef4b536ebc9dcf6ebcd69
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/340432
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-04-22 20:40:03 -07:00
nagendra modadugu
ee5d09823f CR50: add support for P256-ECIES (hybrid encryption)
Add support for P256 based hybrid encryption, and
corresponding tests.  Where hybrid encryption is:
P256 based DH + AES128 + HMAC-SHA256.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
CQ-DEPEND=CL:336091,CL:339561
TEST=ECIES tests in test/tpm/tpmtest.py pass

Change-Id: Ie091e278df72185a6896af0e498925e56404f87e
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/337340
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-04-19 22:47:36 -07:00
Anton Staaf
95858f385c Deferred: Remove hard coded number of deferreds
Previously the maximum number of deferred routines was specified by the
the default maximum number of deferred routines you had to override
this, and if you wanted fewer, you still payed the price of having the
defer_until array statically allocated to be the maximum size.

This change removes that define and instead creates the RAM state of
the deferred routine (the time to wait until to call the deferred) when
the deferred is declared.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     manually test on discovery-stm32f072

Change-Id: Id3db84ee1795226b7818c57f68c1f637567831dc
Reviewed-on: https://chromium-review.googlesource.com/335597
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-19 12:23:52 -07:00
Dino Li
69668a0443 chip: it83xx: add USBPD module
Add USBPD module for it8320 emulation board

BRANCH=none
BUG=none
TEST=manual
     plug zinger adapter, connect uart console and type commands:
       pd 1 dev [20|12|5]
       pd 1 charger
       pd 1 swap power
     and check PD states

Change-Id: I9ca1822deeb4b4dce1279a09490ed4175890cf3a
Signed-off-by: Leon-Lee <leon.lee@ite.com.tw>
Signed-off-by: Dino Li <dino.li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/326230
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-18 17:32:41 -07:00
Anton Staaf
068cd08506 Deferred: Use deferred_data instead of function pointer
Previously calls to hook_call_deferred were passed the function to call,
which was then looked up in the .rodata.deferred section with a linear
search.  This linear search can be replaced with a subtract by passing
the pointer to the deferred_data object created when DECLARE_DEFERRED
was invoked.

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

BRANCH=None
BUG=None
CQ-DEPEND=CL:*255812
TEST=make buildall -j

Change-Id: I951dd1541302875b102dd086154cf05591694440
Reviewed-on: https://chromium-review.googlesource.com/334315
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-18 17:32:40 -07:00
Kevin K Wong
b10d12f1c9 tcpm: update code to support multiple tcpm driver
BUG=chromium:593822
BRANCH=none
TEST=make buildall

Change-Id: Ic30c1b890da7639aa80a53040ecc5bebfb4be2e8
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/336030
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-17 12:23:07 -07:00
Bill Richardson
b28ed970c4 Cr50: Update the USB VID:PID:subclass constants
The device-specific subclass used for Non-HC firmware updates is
in the spreadsheet now, so we can rename the macros to be
"official".

BUG=chrome-os-partner:49962
BRANCH=none
TEST=make buildall; test on cr50

  make BOARD=cr50 (plus whatever signing magic works for you)
  make -C extra/usb_updater
  ./extra/usb_updater/usb_updater build/cr50/ec.bin  (sudo if needed)

Note that you may need to rebuild ec.bin in order to see any
difference after the update. If the A & B images are identical,
the RO bootloader always picks A.

Change-Id: I385ce89a9abe2059d52da2d82a0b92b9b3e3c93f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/339220
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-04-15 15:09:08 -07:00
nagendra modadugu
533a536140 CR50: add support for HKDF (RFC 5869)
Add support for SHA256 based HKDF key
derivation as specified in RFC 5869.  This
change includes test vectors from the RFC.

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

Change-Id: I7d0e4e92775b74c41643f45587fc08f56d8916aa
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/336091
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
2016-04-14 17:28:21 -07:00
Kyoung Kim
e6902404a2 Kunimitsu: remove console commands for code size
Remove following EC console commands to reduce code size:
- battfake
- apthrottle
And none of commands above are used in 'auto test'.

This is a squash of
- https://chromium-review.googlesource.com/337657
- https://chromium-review.googlesource.com/338018

BUG=none
BRANCH=firmware-glados-7820.B
TEST=make -j buildall

Change-Id: I11d2c5514f2714f0a46416feec2b2c47666fb462
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/338893
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-14 17:28:17 -07:00
Mary Ruthven
d281308b48 cr50: Detect debug cable and switch the PHY
This adds support for RD Detection on cr50. It can be used to detect a
debug device and signal the controller to switch from the AP PHY to the
to CCD PHY. When RDCC1 and 2 no longer detect the debug device, then
the controller switches back to using the USB to AP PHY.

BUG=chrome-os-partner:50700
BRANCH=none
TEST=change the value on RDCC1 and RDCC1 and check that the usb
controller connects to the right PHY.

Change-Id: Ice01a45a31fe1932945f89df2e3b851f4d287a17
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338454
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-13 20:10:38 -07:00
Bill Richardson
66af587cbc Cr50: Enable RW FW updates over USB
This enables the Cr50 to accept RW firmware updates over USB.

BUG=chrome-os-partner:50707, chrome-os-partner:50712
BRANCH=none
TEST=make buildall; test on Cr50

Build and run the extra/usb_updater utility. Watch the console,
and observe that the Cr50 updates and reboots into the new image
correctly.

Note that you'll have to rebuild the ec.bin image in order for
the update to take effect. Just reflashing the same image doesn't
cause the bootloader to change its selection.

All the previously existing endpoints continue to function normally.

Change-Id: I7bd22eae803c2ceeb14a767c06d3d5c9f1ac7c7a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338089
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
2016-04-12 19:00:31 -07:00
Bill Richardson
4246bfa62f Cr50: New usb_upgrade module for RW updates
This re-factors the existing firmware upgrade facility, which worked as
a TPM command extension.

The same code processing upgrade blocks prepended by the truncated
SHA1 and the load address is now used by both extended TPM command and
the USB upgrader.

To accommodate USB communications using a smaller message payloads a
reassembly layer is introduced which accumulates short USB payloads
into a single block which can be passed to the firmware upgrade
routine. USB encapsulation adds one 4 byte header at the beginning of
the block to hold the total block size. The reassembly layer keeps
receiving USB messages, concatenating their payloads until the full
block is received.

A config option is added to make sure the module is not compiled when
not needed.

BUG=chrome-os-partner:50707
BRANCH=none

TEST=make buildall; test on Cr50 - with the rest of the patches
     applied it is possible to upgrade firmware using the USB utility
     on the host..

Change-Id: Ib30b381c4ab196ea9d352f3c6b8f46dc23ddd599
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338087
2016-04-12 19:00:31 -07:00
Daisuke Nojiri
650d471674 Add header files needed by gpio_list.h
gpio_list.h needs to include compile_time_macros.h and gpio.h for
ARRAY_SIZE, BUILD_ASSERT, and struct gpio_info.

BUG=none
BRANCH=tot
TEST=make buildall && make tests

Change-Id: Ifa24b0e534065750a006bde8357a13fa1838f7f5
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338460
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@google.com>
2016-04-12 15:22:29 -07:00
Shawn Nematbakhsh
d2e77ddbc9 pd: Add config to disable PD communication in locked RO
The scheme to disable PD communication in locked RO needs to be
implemented on other platforms, so move it to common code, behind
CONFIG_USB_PD_COMM_LOCKED.

BUG=chrome-os-partner:52157
BRANCH=glados
TEST=Manual on chell. Lock system and boot to recovery, then verify PD
communication is functional. Enable CONFIG_USB_PD_COMM_LOCKED and verify
PD communication isn't functional under the same test conditions.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8d1f24c0b60cf1c54e329af003b7083ee55ffc40
Reviewed-on: https://chromium-review.googlesource.com/338064
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-04-11 14:36:40 -07:00
Bill Richardson
2c26cad2ad Support RW_B in sysjump command when applicable
If we #define CONFIG_RW_B, the firmware image can have two RW
components. This CL expands the "sysinfo" command so that we can
see which image we're running from when RW_B is also a
possibility.

BUG=chrome-os-partner:50701
BRANCH=none
TEST=make buildall; test RW update on Cr50

Using test/tpm_test/tpmtest.py, update the RW firmware and reboot
several times to switch between RW_A and RW_B. Note that the
"sysjump" command reports the correct image each time.

Change-Id: Iba3778579587f6df198728d3783cb848b4fd199d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337664
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-04-08 12:34:29 -07:00
Mary Ruthven
fa643a9fc7 cr50: add support for creating multiple serial endpoints
CR50 will need three serial endpoints for the streaming AP and EC UART
and exporting its own console through USB. This change adds a macro to
create endpoints that can be recognized by the usb_serial driver.

BUG=chrome-os-partner:50702
BRANCH=none
TEST=Verify "/dev/google/Cr50*/serial/Blob" prints capital letters when
lower case letters are input.

Change-Id: Iddf2c957a00dc3cd5448a6a00de2cf61ef5dd84c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336441
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-07 13:00:39 -07:00
Kevin K Wong
bf24d5b264 temp sensor: add support for G782
modify g781.c/.h to g78x.c/.h to suppor both G781/G782 temp sensor
based on CONFIG_TEMP_SENSOR_G781 or CONFIG_TEMP_SENSOR_G782

BUG=none
BRANCH=none
TEST=make buildall; able to get temperature data on board with G782

Change-Id: Ia32c85e9964bfd7c0c5263f04368bc001a27fe10
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334228
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-03 10:27:40 -07:00
Bill Richardson
9406cf384a Cr50: Sleep only when SPS has been quiet for a while
This adds the SPI slave bus and TPM task to the things that
can prevent deep sleep. Even when things are quiet, we wait at
least a second

With this CL, it will wait at least one second after the last SPS
transaction before sleeping. Since most TPM-protocol commands are
built up of a number of back-to-back SPS messages, if we don't
wait we'll keep trying to sleep in the middle of active commands.

Even if everything is quiet, we wait 0.2 seconds anyway to give
the UART buffers time to drain.

BUG=chrome-os-partner:49955, chrome-os-partner:50721
BRANCH=none
TEST=make buildall; extensive tests on Cr50

Testing is a pain.

In addition to ALL the steps listed in commit
d917d3f1867e96369ff25bf6906043a5f488a6fb, loading the firmware
with the spiflash tool leaves SPS_CS_L low, so you have to drive
it high manually. The easiest way is to build and run
test/tpm_test/tpmtest.py for a few seconds then interrupt it with
Ctrl-C.

Note that because the system wakes from deep sleep when it sees
SPS_CS_L go low but it can't get ready fast enough to capture the
incoming bits, that first SPI transaction will be garbled or
lost. You'll have to either retry it, or wake the system another
way first.

Change-Id: Iae2fe5ef33869c48e98a3afecd6b98991a51a488
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336690
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-04-03 10:27:39 -07:00
Shawn Nematbakhsh
33fd731ca1 charge_manager: Report UNKNOWN USB charger for 2 seconds after change
After a charger is attached, we may set a charge limit based upon BC1.2
or USB-C Rp before PD negotiation completes. Therefore, allow 2 seconds
for all negotiation to complete. Previously this behavior was implicit
when using SW charge ramp.

BUG=chrome-os-partner:51280
BRANCH=glados
TEST=Manual on chell. Insert stock charger, verify that it is detected
as TYPE_UNKNOWN until timeout.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I52f02de46fa92b66a9fbaddb94a062310688f028
Reviewed-on: https://chromium-review.googlesource.com/334312
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Shawn Nematbakhsh
257dab7491 console: Put additional console commands behind CONFIGs
Allow boards to save flash space by undef'ing CONFIGs which gate
'hcdebug' and 'md' console commands.

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

Change-Id: I583b98ff1e4d9d6a26958c6895fb0c0305dddceb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336813
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Devn Lu
93be0c3b0a ectool: Support keyboard factory scanning
This is keyboard test mechanism request for "multiple key press test",
we can thru the testing to scan out kso ksi pins shortting or keyboard has
multiple key pressing, below was the testing steps:

1. Turn off internal keyboard scan function.
2. Set all scan & sense pins to input and internal push up.
3. Set start one pin to output low.
4. check other pins status if any sense low level.
5. repeat step 3~4 for all keyboard KSO/KSI pins.
6. Turn on internal keyboard scan function.

BUG=chrome-os-partner:49235
BRANCH=ToT
TEST=manual
  Short any KSO or KSI pins and excute "ectool kbfactorytest", it shows failed.
  if no pins short together, it shows passed.

Change-Id: Id2c4310d45e892aebc6d2c0795db22eba5a30641
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/332322
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-01 00:21:35 -07:00
Kevin K Wong
55cd6e4c75 apollolake: initial chipset code
used chipset skylake as the initial code base for apollolake

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: If82f9bcd53ff44714f4b277637ff9f3c115ccc4d
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/331651
Reviewed-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-31 21:35:56 -07:00
Kevin K Wong
6711629163 sensor: update sensor driver to use I2C port from motion_sensor_t
this allow motion sensor devices to be locate on different I2C port

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Ia7ba2f5729ebb19561768ec87fdb267e79aafb6a
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334269
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-31 21:35:56 -07:00
Bill Richardson
9e0c450f72 Cr50: First attempt at USB suspend with deep sleep
This is still in testing mode, so you have to take special steps
to enable it (keep reading). But if you do the right dance, it
does go into deep sleep for USB suspend, and resumes correctly.

However, it doesn't yet wake for any other reason. That's coming next.

Normal sleep is not yet supported, either.

BUG=chrome-os-partner:49955, chrome-os-partner:50721
BRANCH=none
TEST=make buildall; extensive tests on Cr50

Testing is a pain.

First, you can't print anything in the idle task, because that
just makes it stop being idle, so the only way to detect when
it's triggered is by wiring up a GPIO and instrumenting things.

Second, you have to manually reenable USB suspend on the host
every time the Cr50 boots with

  echo auto > /sys/bus/usb/devices/<BLEH>/power/control

where <BLEH> is the correct device.

Third, for reasons probably related to the mysteries of HID
devices combined with crbug.com/431886, you have to build the
firmware without CONFIG_USB_HID (and the related items in
board.h)

Finally, because it's still a work in progress, you have to type

  idle d

at the serial console after every boot (or resume) to reenable
deep sleep in the idle task.

If you do all that, then you'll see that it does go into deep
sleep. Ping it again with "lsusb -v -d 18d1:5014" or
./test/usb_test/device_configuration, and it wakes up and
responds!

If you disconnect the USB while it's in deep sleep, it stays
asleep. When you plug it in again, it wakes up, but it correctly
recognizes that it shouldn't resume and does a normal reset
instead.

Change-Id: I3cc66e48ce671142a4d12edbe0eb9fdacecea0d9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336279
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2016-03-31 14:53:52 -07:00
Bill Richardson
70378b86b4 Cr50: Include low-power exit triggers in reset causes
Some of the reset causes are found in another register when
resuming from a low-power state. We know we'll need to
distinguish among them eventually, so we might as well decode
them now.

BUG=chrome-os-partner:49955
BRANCH=none
TEST=make buildall; test on Cr50

I forced the system into deep sleep and observed that the reset
cause is accurately recorded on resume. Doing that requires a
fair amount of hacks and manual effort, and can't happen by
accident. Future CLs will make use of this.

The current, normal behavior is completely unaffected.

Change-Id: I5a7b19dee8bff1ff1703fbbcc84cff4e374cf872
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-30 20:38:13 -07:00
chris wang
2295467659 usb_port_power_smart: Support variable port count
Use CONFIG_USB_PORT_POWER_SMART_PORT_COUNT to support more usb ports
(default 2).

BUG=None
BRANCH=firmware-strago-7287.B
TEST=build&flash ec,verify on wizpig,usb function work
Signed-off-by: Chris Wang <chriswang@ami.com.tw>

Change-Id: I2460d4a5755ef457249d728169c27fc6d00625d2
Reviewed-on: https://chromium-review.googlesource.com/333232
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: lehai deng <denglehai@ithaier.com>
Commit-Queue: Chris Wang <chriswang@ami.com.tw>
Tested-by: Chris Wang <chriswang@ami.com.tw>
(cherry picked from commit 1e7d3554f1bedbb839a0f4800286c9db0d27e4f1)
Reviewed-on: https://chromium-review.googlesource.com/334510
Commit-Ready: Chris Wang <chriswang@ami.com.tw>
2016-03-24 00:03:07 -07:00