Commit Graph

1711 Commits

Author SHA1 Message Date
Nicolas Boichat
ef0f355e47 common/rsa: Add support for exponent 3 RSA keys
These keys are much quicker to verify (259ms to 51ms on a -M0 at
48 Mhz), so they can be used when timing is critical and
verification needs to be performed on the board.

BRANCH=none
BUG=chromium:663631
TEST=make buildall -j && make run-rsa
TEST=make run-rsa3 (next commit)

Change-Id: I0da4b3e21543bb6f7b18e8b6ddc5e153046a61b8
Reviewed-on: https://chromium-review.googlesource.com/408006
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-10 21:28:28 -08:00
Nicolas Boichat
de0f53afef driver/touchpad_elan: Basic elan touchpad driver
BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && bash flash_hammer

Change-Id: I0ff4f48ff1399e054f745ac13ffacf81dffedeab
Reviewed-on: https://chromium-review.googlesource.com/407740
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-08 23:24:52 -08:00
Furquan Shaikh
e3298150ea ec_commands: Add a new host event for extended events
Since we are out of host event bits, add a bit to indicate extended host
event exists. This is put in as a placeholder for now so that we don't
lose out the last available hostevent bit.

BUG=chrome-os-partner:59352
BRANCH=None
TEST=Compiles successfully

Change-Id: If35a246f3da511fde9f8c0bba419afb76a1a9827
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407804
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-08 20:30:09 -08:00
Furquan Shaikh
2fc7ba9df1 common: Add new recovery mode button combination
This adds new key combination (Left_Shift+Esc+Refresh+Power) that triggers
recovery mode by setting a new host event
EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT. This host event can be used
whenever user wants to request entry into recovery mode by
reinitializing all the hardware state (e.g. memory retraining).

BUG=chrome-os-partner:56643,chrome-os-partner:59352
BRANCH=None
TEST=Verified that device retrains memory in recovery mode
with (Left_Shift+Esc+Refresh+Power) on reef.

Change-Id: I2e08997acfd9e22270b8ce7a5b589cd5630645f8
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407827
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-08 20:30:07 -08:00
Gwendal Grignou
bf4e1db093 driver: sensor: Remove set_interrupt
Remove set_interrupt(), was always a noop.
Unused, interrupt is done inside the init routine.

BUG=none
BRANCH=none
TEST=buildall

Change-Id: I0ff4843212ea8140be41dcd17af130991117e3da
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407968
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-08 17:12:18 -08:00
Gwendal Grignou
9b67ffcd52 common: Add tablet_mode API
Simple API to set/get the tablet mode. It can be set via lid angle
calculation or if a board has a dedicated HAL sensor/GPIO.

Merged from glados branch, add MKBP switch support.

BUG=chromium:606718
BRANCH=gru
TEST=Check with Cave that both mode works.

Reviewed-on: https://chromium-review.googlesource.com/402089
Reviewed-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit c940f36ceabcf2425284001298f03ebdb4c3079e)
Change-Id: I2ee5130f3e0a1307ec3ea543f7a32d66bc32b31d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404915
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-08 17:11:28 -08:00
Shawn Nematbakhsh
1f6600fd34 mkbp_event: Properly queue events during host sleep
Don't queue non-wake events, and ensure wake events (and all subsequent
events) always get queued.

BUG=chrome-os-partner:59248, chrome-os-partner:59336
BRANCH=gru
TEST=Manual on kevin, go to suspend, press volume keys dozens of times,
press 'shift', verify device wakes. Place cursor on URL bar, go to
suspend, type "google" quickly, verify device wakes and "google" appears
on URL bar. Go to suspend, press 'VolUp' key 5 times, press keyboard,
verify device wakes and no volume meter is seen on display.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ibe761187fbcefd686776a512786550970a6fc067
Reviewed-on: https://chromium-review.googlesource.com/405717
Commit-Queue: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit aa2f01566314604404e104d7975c6c755c22a601)
Reviewed-on: https://chromium-review.googlesource.com/407958
Commit-Ready: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2016-11-04 18:31:37 -07:00
Nick Sanders
a04fc68e72 usb_i2c: refactor into common
This combines stm32 and chip/g usb_i2c interfaces so they
will not diverge. Note that this fixes the chip/g implementation
to use 8-bit i2c addresses.

BUG=chrome-os-partner:57059
BRANCH=none
TEST=servod interacts with servo_micro and servo_v4

Change-Id: Ibff217d84b132556202c8a71e3d42c07d546c634
Reviewed-on: https://chromium-review.googlesource.com/405108
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-11-02 17:39:56 -07:00
Kevin K Wong
180ac77e16 reef: enable tcpc-controlled drp toggle
BUG=chrome-os-partner:54668
BRANCH=none
TEST=Verified SNK is detected in S0 (toggle on), S3 (toggle off),
and S5 (force sink). SRC is detect in S0 only, stays detected when
entered S3, but unplug/plug while in S3 will not re-detect until
system back in S0. When go to S5, SRC will get disconnected until
back in S0, and hotplug SRC in S5 will not get detected. Checked
power role swap with another chromebook in the above scenario also.

Change-Id: I2a487fca5cb04c45524aa3efde84fcd10ff0579e
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/396918
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-11-02 06:42:04 -07:00
Vincent Palatin
cf7ff32b92 kevin: set accurate current limit on USB load switch
When sourcing current on the type-C port, set the OCP limit on the VBUS
load switch according to current dynamic capability.
(3.0A when only one port is a power source, 1.5A else)

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

BRANCH=gru
BUG=chrome-os-partner:56110
TEST=manual: connect Caroline to Kevin with Twinkie in between,
ask Caroline to sink current through the UI.
without anything else connected on Kevin, see 3A flowing when measuring
with Twinkie ('tw vbus'), plug a dangling C-to-A receptacle dongle on
the other Kevin port and see 1.5A flowing through Twinkie.
Force the input current limit on Caroline to 3.0A and see Kevin cutting
VBUS.

Change-Id: Ib879b1ed720b20aa702c5f3643948ba0575d1193
Reviewed-on: https://chromium-review.googlesource.com/403869
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-31 03:27:49 -07:00
Vincent Palatin
fffea303b4 pd: fix contract negotiation with dynamic PDOs
When the board is using dynamic source PDOs, we need to ensure that we
are checking the incoming sink power request against the right set of
PDOs else we might reject a valid request (e.g. with high-power source,
we need to check against the 3.0A limit if we only have one port
connected).

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

BRANCH=gru
BUG=chrome-os-partner:56110
TEST=Connect Kevin to Caroline, ask Caroline to charge from the other
side and see it negotiating successfully a 5V/3A contract.

Change-Id: Ie1aa5746776be5946422bf07c08ae0f22faddd8c
Reviewed-on: https://chromium-review.googlesource.com/403088
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-26 01:45:17 -07:00
Duncan Laurie
5cfa02b03c lpc: Add function for host reset without RCIN GPIO
Prior x86 boards have had GPIO for toggling RCIN directly on the PCH,
although many likely had HW-assisted methods as well.

With eve we need to generate an eSPI Virtual Wire for RCIN, but in reality
software control over RCIN Virtual Wire is not available with the npcx EC,
so the legacy LPC interface for pulsing KBRST must be used instead as this
is the only way to generate RCIN.

This method will likely vary on different EC chips, but for skylake it
can just be abstracted into the LPC module.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=successful 'apreset warm' on eve EC console

Change-Id: I7f9e7544a72877f75d05593b5e41f2f09a50e1c9
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400037
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-26 01:44:08 -07:00
Duncan Laurie
b142b05465 power: Add board callback before RSMRST# state change
This board function allows workarounds to be applied to a board after all
power rails are up but before the AP is out of reset.

Most workarounds for power sequencing can go in board init hooks, but for
devices where the power sequencing is driven by external PMIC the EC may
not get interrupts in time to handle workarounds.

For x86 platforms and boards which support RSMRST# passthrough this board
callback will allow workarounds to be applied despite the PMIC sequencing
by ensuring that the function is executed before RSMRST# deassertion.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=test IMVP8 workaround on multiple eve boards

Change-Id: I0569494084000a4b1738ee18aafce5c96900dc4b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/402591
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-26 01:44:06 -07:00
Duncan Laurie
b8050224e5 include: Add default state for ESPI and VW_SIGNALS
Add the default undefined state for CONFIG_ESPI and rename
CONFIG_VW_SIGNALS to CONFIG_ESPI_VW_SIGNALS.

BUG=chrome-os-partner:58666
BRANCH=none
TEST=pass presubmit checks

Change-Id: I45242d545915c16bb46f751532a01ab937cee5f0
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400032
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-25 17:33:42 -07:00
Randall Spangler
5e1c63f6eb Support alignment for EC host command structures
The host command parameter and response buffers should be explicitly
aligned by the LPC/SPI/I2C drivers.  But the host command handlers don't
know that, and the structs are all __packed, so the compiler generates
horribly inefficient ARM Cortex-M code to cope with unaligned accesses.

Add __ec_align{1,2,4} to force the param / response structs to be
aligned.  Use it in a few structs now which were straightforward to
test.  It should be added to more structs as space is needed, but that
would make this change unwieldy to review and test.

Add CONFIG_HOSTCMD_ALIGNED to enable the additional alignment.
Currently, this is enabled only for LM4 and samus_pd, so that EC code
can be tested without affecting other non-samus ToT development (none of
which uses LM4).

Fix the two handlers that weren't actually aligned (despite one of
them having comments to the contrary).

Also, add a CHROMIUM_EC define that can be used to determine if a file
is being compiled for an EC target.  We need that so that we only force
structure alignment for EC binaries.  On the AP side, buffers may not be
aligned, so we should not force alignment.

BUG=chromium:647727
BRANCH=none
TEST=Flash samus and samus_pd.  Boot samus and run a bunch of ectool
     commands (with and without --dev=1, so it tests both EC and PD).
     System boots and all commands return expected results.

Change-Id: I4537d61a75cf087647e24281288392eb85f22eba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/387126
2016-10-19 20:07:09 -07:00
Kevin K Wong
09ad7536ce pd_task: print pd state name
Shifted pd_task debug level by 1 so that debug level 1 will
enable printing the pd state name.

Added a CONFIG flag to remove ability to change debug_level
during runtime and debug print level will be fixed.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I545813bafa8084355cedc2d8334c3aec5a2b6739
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/339935
Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-19 02:45:36 -07:00
Shawn Nematbakhsh
08498eab99 pd: Initialize pd comms and dual role state from PD task
Don't call into tcpm_*() functions from HOOKs since these functions may
manipulate common sets of TCPC registers.

BUG=chrome-os-partner:57691
BRANCH=gru
TEST=On kevin, boot to S0, verify 5V is sourced to legacy peripheral.
Drop to G3, verify role is back to sink and charging is functional. Back
to S0, verify 5V is sourced.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9ade9de068589dce6995cda6b106217aa85aa793
Reviewed-on: https://chromium-review.googlesource.com/394809
(cherry picked from commit 18e9e3870722d57efd232bd7f0a0300003b46ad6)
Reviewed-on: https://chromium-review.googlesource.com/396137
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-10-14 18:49:38 -07:00
Vijay Hiremath
6f5489e18e cleanup: Rename charge_temp_sensor_get_val() to charge_get_battery_temp()
charge_temp_sensor_get_val() is used to get the battery temperature value
hence renamed it to charge_get_battery_temp().

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

Change-Id: I2b52cac57dcde12a6b7405e7d712240e278954e2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/397962
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-14 18:49:36 -07:00
Mary Ruthven
4aa7cd72cf g: use devid 0 and 1 to create a serial number
To be able to identify different cr50 devices connected to the same
machine we need a serial number. This change uses dev id 0 and 1 to come
up with one.

BUG=chrome-os-partner:56641
BUG=chrome-os-partner:58342
BRANCH=none
TEST=lsusb -vd 18d1:5014 | grep iSerial shows different numbers for
different devices. Verify when ccd is disabled the serial number is 0.

Change-Id: I85c54af4a21bdfd0542019c02aa8420d9a879fae
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/395633
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-10-11 23:01:59 -07:00
Gwendal Grignou
da558fc833 TABLET_MODE_SWITCH: set as undef by default
CONFIG_TABLET_MODE_SWITCH was incorrectly defined by default.

BUG=none
TEST=Kevin still have TABLET_MODE_SWITCH included.
BRANCH=none

Change-Id: I0748151e61eab5370be50be4512d2a851f705011
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/396384
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-10-11 19:09:55 -07:00
Vijay Hiremath
bc34c98edd smart_battery: Remove smart charger unreachable code
Smart battery code has I2C read/write code for smart chargers
which is an unreachable code for few boards hence removed it.

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

Change-Id: I79933f61893c66447c686a81073c92f6a16e2d48
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/396279
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-11 01:47:52 -07:00
Scott
8c370fedba g: Added I2CM driver to support chip_i2c_xfer()
Added i2cm driver to support chip_i2c-xfer function. The initial use
case is for INA chips on the Reef/Gru platforms. Note that this CL
does not include any board specific changes and therefore does not
include an I2C port definition or required pinmux settings.

BRANCH=none
BUG=chrome-os-partner:57059,chrome-os-partner:58355
TEST=manual
Used console command "i2cxfer r16 0 0x40 0" to read the config
register. Read 0x2771 [10097] which is the default value. In addition
wrote register 14 and read back the value.

Change-Id: If9e377da4c8f4835d4676281872a0f079fe56aa6
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388794
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-10-11 01:47:46 -07:00
Vadim Bendebury
0ff799bb75 cr50: add reset extension command
While USB updates have a mechanism to trigger the target reset, SPI
updates do not have it.

This patch adds an extension command to cause the device reset.

BRANCH=none
BUG=chrome-os-partner:58226
TEST=with the rest of the patches applied verified that the system
     gets reset and the new image version kicks in on both gru (over
     SPI) and reef (over USB).

Change-Id: I498538670e2c43d17b13510288eb9ae75eb7b761
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/395628
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-10-08 01:04:50 -07:00
Gwendal Grignou
ce92dd27df Use CONFIG_KEYBOARD_DEBUG for keyboard debug printf
Remove keyboard printk like:  KB wait/poll when not debugging keyboard.

BUG=none
BRANCH=none
TEST=compile.

Change-Id: I9743eab4597d2b661ae7b21c0aab4e1ffdcdb9a4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394068
2016-10-08 01:04:45 -07:00
Gwendal Grignou
0ea4603143 driver: bmi160: Add config variable for INT2 setting
BMI INT2 can be input or output.
It is not used currently, but configure it properly nevertheless.

BUG=none
BRANCH=none
TEST=On cave, (int2 is output), ensure FIFO headers are free of
interrupt information.

Change-Id: I9c058689a8676593aad542e33601cc11da105838
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394066
2016-10-07 21:51:22 -07:00
Bill Richardson
5681c83244 Add CONFIG_CMD_SYSINFO and CONFIG_CMD_SYSLOCK
The sysinfo and syslock commands aren't needed by all boards that
compile common/system.c, so let's make them individually
selectable.

BUG=none
BRANCH=none
TEST=make buildall; try on Gru

Confirm that by default these commands are still present
everywhere that they were before (since they're #defined by
default). Also confirm that it's possible to #undef them and
still build.

Change-Id: I7a5d21d1f0b9887f3562b9410063616ed8f41163
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/395366
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-10-07 16:47:06 -07:00
Daisuke Nojiri
c0c66cdd12 stm32l4: Add i2c driver
This patch adds master and slave drivers for stm32l4 family. Only slave
functionality is tested.

BUG=none
BRANCH=none
TEST=Run cts.py -m i2c. Make buildall.

Change-Id: Ied77081ca0333ab3fec055cd4f0fcbdf8a79d388
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/393329
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 20:58:17 -07:00
Daisuke Nojiri
5f70312a26 i2c: Move I2C_MAX_HOST_PACKET_SIZE to i2c.h
This patch moves I2C_MAX_HOST_PACKET_SIZE to include/i2c.h. It's currently
used only by i2c-stm32*.c but should be commonly available for other chips.
It also moves i2c_get_protocol_info to common/i2c.c for the same reason.

BUG=none
BRANCH=none
TEST=make runtest

Change-Id: I28d8bca0167bb7b2ce99574601a6efb62fc20eca
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/393328
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-05 17:11:37 -07:00
Scott
9cd10a5a47 Cr50: Removed Reef EVT workarounds
- changed the pad assignment for plt_rst_l from DIOA13 to DIOM3;
- removed the board property used to keep uart rx disabled, Uart0 is
  now enabled by default on Cr50.
- removed resetting fallback counter on USB updates for reef boards,
  they are going to use the same mechanism as kevin and gru.

BRANCH=none
BUG=chrome-os-partner:56540
TEST=Tested on Reef Board ID 1 and Gru Board ID 1. Verfied that
     plt_rst_l signal is being detected and that there are no
     interrupt storms related to not having a pullup resistor on the
     uart rx line. Verified that both platforms successfully boot into
     chrome OS using cr50 TPM.

Change-Id: I300a0c75e60acbecf93500b46aced303955a192a
Signed-off-by: Scott <scollyer@chromium.org>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391140
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-10-04 05:55:50 -07:00
Bill Richardson
fd88db3e9a g: CONFIG_FLASH should be optional
The application may need to read/write/erase the flash memory,
but we not want console users to do so. This CL adds
CONFIG_FLASH_PHYSICAL, which allows the higher-level CONFIG_FLASH
to be undefined while still providing the chip-specific
flash_physical_* accessor functions.

There aren't many board.h files that needed changes, since
CONFIG_FLASH_PHYSICAL is enabled by default, just like CONFIG_FLASH.

BUG=chrome-os-partner:57408
BRANCH=none
TEST=make buildall; try on Gru with and without CR50_DEV=1

See that it still boots, updates, wipes, restores, etc. without
linking common/flash.o in the production image; and that the
flash commands are still there in the dev build.

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I7eb1bbcb414b1c70ee427c4fcb5cea899dbb9e93
Reviewed-on: https://chromium-review.googlesource.com/391188
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-10-02 15:19:21 -07:00
Bill Richardson
0a4bb34bcd Add more CONFIG_CMD_* options for console commands
We have a large number of config.h options to enable/disable
specific console commands. This adds a few more that we will want
to control.

BUG=chrome-os-partner:57408
BRANCH=none
TEST=make buildall; try on Gru with and without CR50_DEV=1

Change-Id: Id41f0e9f44fc77feaf56853f357a6b33bb685b0c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391614
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-01 00:02:01 -07:00
Bill Richardson
f715b8b865 Sort CONFIG_CMD_* options in config.h
We have a bunch of options to enable/disable individual console
commands, but they're not quite sorted. Now they are.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I186b9f82dc40c2f9fc66f493b4b6cccda020224c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391613
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-01 00:02:00 -07:00
Vadim Bendebury
d6d12ec67b cr50: tpm: ignore sys_rst_l/plt_rst_l when TPM reset is in progress
There is no point in invoking TPM reset while the current invocation
is in progress. One of the cases when this is happening is early start
up on Kevin/Gru: the device starts booting, the EC comes around to
pulsing sys_rst_l when TPM is already busy installing endorsement
certificates.

There is no point in issuing another reset at that point, just let the
process continue.

BRANCH=none
BUG=chrome-os-partner:52366
TEST=firmware_TPMKernelVersion firmware_TPMExtend autotests still pass
     on kevin. Certificate installation during startup does not get
     interrupted any more.

Change-Id: Ibdface9f7a76186e210ef0f4111cd5fe9905bba9
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/389811
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-09-27 00:27:37 -07:00
Vadim Bendebury
5a6bb19a88 tpm: reset communications channels when resetting TPM
TPM resets happen asynchronously, conceivably there is some interface
(i2cs or sps) activity under way when TPM is reset.

Sps driver provides a means of disconnecting the client of the driver,
while the i2cs driver does not. Come to think of it, there is no real
need to provide a special function to disconnect a client, this makes
API simpler and allows to add driver initialization to the client
registration function.

To make tpm_registers.c more flexible - allow to register a callback
for interface initialization, this way when TPM is reset, the
interface can be also re-initialized and is guaranteed to start from
scratch after reset.

BRANCH=none
BUG=chrome-os-partner:52366
TEST=both firmware_TPMExtend and firmware_TPMKernelVersion autotests
     pass

Change-Id: I212166a23f9cd512d8f75315377d1f5620aea070
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388886
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-09-26 22:16:45 -07:00
Bill Richardson
2446e3bfc0 Cr50: Clear NVMEM before unlocking the console
The Cr50 console provides access to all sorts of dangerous
commands. To protect user secrets, we must erase the persistent
storage before unlocking the console.

Note that this will not powerwash the AP, leaving you with the
impression that you've just forgotten your password. You'll have
to manually powerwash (Ctrl+Alt+Shift+R) afterwards. That will be
addressed in a future CL.

BUG=chrome-os-partner:55728
BRANCH=none
TEST=make buildall, test on Gru

Lock the console if it's not already ("lock enable"), then unlock
it with "lock disable". Confirm that the NVMEM region is erased
following a successful unlock process.

Change-Id: Iebcd69c9f757f5ab5d496218f065197d3f1f746c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382666
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-24 16:22:18 -07:00
Bill Richardson
4250da3ba9 Cr50: Add mostly-synchronous tpm_reset() function.
To reset the TPM task, we send it an event so that it will reset
only when it's not busy doing actual TPM stuff that might fiddle
with the stack or shared memory. But that means that we can't
always know when the task finally gets around to resetting
itself.

This CL adds a tpm_reset() function that blocks until the reset
actually occurs. Obviously it can't do that if it's being called
in interrupt context or from the TPM task itself, but otherwise
it does.

BUG=chrome-os-partner:52366
BRANCH=none
CQ-DEPEND=CL:361680
TEST=make buildall, test on Gru, manual tests

In addition to the normal rebooting, logging in/out, and so
forth. I added a temporary console command to call tpm_reset()
and scattered a bunch of ccprintfs around it. When called due to
SYS_RST_L, it didn't block. When invoked with the console
command, it did.

Change-Id: I51e8b1299dbdcd1a12273cf48a890e93ed32a8c8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/388125
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-24 16:22:14 -07:00
Randall Spangler
b94747d501 cr50: reset only the TPM state on SYS_RST_L
Rather than doing a full cr50 reset when the system reset SYS_RST_L is
asserted, just reset the state of the TPM task and library.  Re-clear
.bss for those modules, then re-initialize.

BRANCH=none
BUG=chrome-os-partner:52366
CQ-DEPEND=CL:366792
TEST=make buildall; test on Gru

Trigger a SYS_RST_L by using the AP's reboot command, power
off/on, log in/out/in.

See that the Cr50 does not reboot and the firmware and userspace
are still happy about the TPM.

Change-Id: I32cd2bb72316f68c74db77a20a8d09112b402d4b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361680
2016-09-24 13:53:26 -07:00
Aseda Aboagye
0567596eb1 system: Add print_system_rtc().
This commit adds a function that allows the real-time clock to be
printed on the EC console.  This could be helpful in trying to correlate
events between the EC's log and the kernel's.

BUG=chrome-os-partner:57731
BRANCH=gru
TEST=make -j buildall

Change-Id: I5e20692a173bddea3dc5c20cc0f2061cc170ce7d
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/388856
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-23 21:08:54 -07:00
Vijay Hiremath
f9272713da i2c: Add i2ctest console command
Added i2ctest console command to test the reliability of the I2C.
By reading/writing to the known registers this tests provides the
number of successful read and writes.

BUG=chrome-os-partner:57487
TEST=Enabled the i2ctest config on Reef and tested the
     i2c read/writes.
BRANCH=none

Change-Id: I9e27ff96f2b85422933bc590d112a083990e2dfb
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/290427
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-23 15:10:08 -07:00
Randall Spangler
818dea4a07 flash: Add command to get SPI flash chip info
Previously, there was no way to identify which flash chip was used by
the EC, for ECs using an external SPI flash.  Now, 'ectool flashinfo'
will print more information about the SPI flash chip in these cases.

BUG=chrome-os-partner:56765
BRANCH=any EC with MEC1322 or NPCX still going through factory
TEST=define CONFIG_HOSTCMD_FLASH_SPI_INFO, then
     'ectool flashspiinfo' on samus indicates no SPI flash info,
     and prints additional info on chell and kevin.  Without
     the config defined, all platforms report no spi flash info.
CQ-DEPEND=CL:386368

Change-Id: I3c162f7ad12ed4b30ab951c03f24476683382114
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385702
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-23 12:21:51 -07:00
Scott
f4cd079d05 Cr50: Add gpio input for platform reset (plt_rst_l)
For TPM operation with Intel chipset APs, the signal PLT_RST_L needs
to trigger a TPM reset. For current Reef boards, this signal is
connected to DIOA13. The next version will have it on DIOM3.

This CL adds support for platform reset connected on DIOA13 and uses a
new board property so that it doesn't affect Kevin/Gru.

BRANCH=none
BUG=chrome-os-partner:55115
TEST=manual
Used H1 dev board configured as Reef. Created high to low transisition
on to verify that platform reset was detected. Tested on Kevin to
ensure that resets were not occurring.

Change-Id: I58f02b7ffa644a9197f4303ae6e640df181040bd
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/380336
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-09-23 12:21:40 -07:00
Mary Ruthven
96b7e491e8 cr50: notify chipset hooks when the AP state changes
Cr50 monitors UART1 RX to sense the state of the AP. This signal can be
used to tell if it is in S0. If the signal is pulled up then the AP is
on. If it is not pulled up then the AP is not in S0. This change
notifies HOOK_CHIPSET_SUSPEND when UART1 RX is not pulled up, and then
notifies HOOK_CHIPSET_RESUME when the signal is high again.

The AP usb can be disabled during suspend, so this change changes the
hook that triggers disabling the AP usb to be attached to
HOOK_CHIPSET_SUSPEND instead of HOOK_CHIPSET_RESUME.

BUG=chrome-os-partner:55747
BRANCH=none
TEST=buildall

Change-Id: I47fb38a4bbcd72424ec2535d61e87f820cf1bcd7
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/383978
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-09-22 18:04:57 +00:00
Vijay Hiremath
420b423096 BD9995X: Rename common code of BD99955 and BD99956 as BD9995X
Except the CHIP_ID and charger name code is common between BD99955
and BD99956. Hence renamed the code to BD9995X so that valid
output is printed from console commands.

BUG=chrome-os-partner:57519
BRANCH=none
TEST=Manually tested on Reef. 'charger' console command prints
     charger name as 'bd99956'

Change-Id: I3c995757941bcc5a6a8026dd807d76a7a47c9911
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/387119
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-21 19:38:13 -07:00
Shawn Nematbakhsh
0821405e40 charger v2: Don't set charger current limit if capability is unknown
If charge_manager has not decided on a current limit, don't set a
minimum current limit, since we may brown-out in the no / low-battery
case.

BUG=chrome-os-partner:56139
BRANCH=None
TEST=Manual on kevin, attach cut-off battery, attach OEM charger, verify
system doesn't brown-out due to OC.

Change-Id: Id53eb32c4a8ac9c6d9a0d3f1d700f089a50fcb0f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/386793
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-09-21 19:38:00 -07:00
Divya Sasidharan
70bea45fa7 reef: Print tcpc firmware version
BUG=chrome-os-partner:56866
BRANCH=master
TEST=prints firmware version at boot up;make buildall -j

Change-Id: Idb067186924e6706ccfc69a64f2febd61f396074
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/380317
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-21 19:37:32 -07:00
Mary Ruthven
05d387da78 cr50: remove unused detect_off interrupt
The interrupts to detect when the falling edge on the UART signals are
currently disabled and never reenabled. Power off is detected by polling
and not through interrupts. This change removes all of those falling
edge interrupts.

BUG=none
BRANCH=none
TEST=cr50 can detect when the EC, AP, and Servo are off or on

Change-Id: I0fd8a0d970f3235b26af6b90dd395ea7c75e0c17
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385192
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-09-21 19:37:03 -07:00
Shawn Nematbakhsh
fd41823595 flash: Call lock function prior to mapped external read
Mapped read access to external flash may conflict with direct access
through SPI commands, so call a chip-level function to lock access prior
to doing such reads.

BUG=chrome-os-partner:55781
BRANCH=Gru
TEST=Verify 'ver' still works fine on kevin, and vboot hashing completes
successfully.

Change-Id: I009d6d5ee61c83260fb49ad4ee137fa3f4cd625a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/385165
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
(cherry picked from commit a7f3e3fa376731709f4823a0c1d464b4d1deae14)
Reviewed-on: https://chromium-review.googlesource.com/386446
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-16 21:59:08 -07:00
Kevin K Wong
ab967a1c77 tcpc: Enable vbus discharge using PD discharge registers
BUG=chrome-os-partner:56040
BRANCH=none
TEST=Manually tested on Reef.
     Used scope to monitor VBUS & it dropped to 0.8V within 650ms.

Change-Id: Icaea1dc11a7342a5cc1493d6d3c2ec3408d6d37b
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/367482
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-13 22:21:33 -07:00
Shawn Nematbakhsh
9229c795b0 charger: bd99955: Enable VBUS discharge when appropriate
Use a custom VBUS threshold of 3.9V for enable / disable of our VBUS
discharge circuit.

BUG=chrome-os-partner:55584
BRANCH=None
TEST=Plug Apple charge-thru accessory into kevin, plug zinger into
accessory, verify charging occurs at PD-negotiated current / voltage.

Change-Id: I25f6f68cfe55e8bae2071cda39618b2bfadcb355
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/379475
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-09-13 22:21:31 -07:00
Shawn Nematbakhsh
94f2bc0740 charge_manager: Pass uncapped / max current to current limit callback
charge_manager may request a charge current limit less than the
capability of the supply in certain cases (eg. during PD voltage
transition, to make an effort to comply with reduced load spec).
Depending on the battery / system state, setting a reduced charge
current limit may result in brownout.

Pass the uncapped / max negotiated current to board_set_charge_limit()
so that boards may use it instead of the requested limit in such
circumstances.

BUG=chrome-os-partner:56139
BRANCH=gru
TEST=Manual on kevin with subsequent commit, boot system with zinger +
low-charge battery, verify devices powers up to OS without brownout.

Change-Id: I2b8e0d44edcf57ffe4ee0fdec1a1ed35c6becbbd
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/383732
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-09-13 22:21:23 -07:00