Commit Graph

2347 Commits

Author SHA1 Message Date
Nicolas Boichat
76927bdc5a stm32/usb: Add HOOK_USB_PM_CHANGE, called when USB is resumed/suspended
In particular, this will allow touchpad driver and keyboard matrix
scanning to be powered off/disabled when the USB interface is
disabled without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be
ignored anyway.

BRANCH=none
BUG=b:72683995
TEST=With next CLs, touchpad and keyboard matrix scanning are disabled
     when lid is closed.

Change-Id: I3750bfaf8c31cde075adf9da4fef39753b8981c5
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-02 10:17:30 -08:00
Jett Rink
74e2f686a9 cleanup: formatting debug message
Adding newline to separate messages better

BRANCH=none
TEST=none
BUG=none

Change-Id: Ie454dfc532310c480f350c9b15280bf96634b322
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897909
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-02-01 18:08:48 -08:00
Vadim Bendebury
cdd2c95284 g: protect flash operations
Flash operations in do_flash_op() involve waiting polling for the chip
to complete the operation. If a concurrent operation is started while
another operation is in progress, flash gets confused and locks up.

Let's add a mutex to ensure that flash operation runs to completion
before another operation starts.

BRANCH=cr50
BUG=b:67651754
TEST=multiple times ran firmware update while the device was coming up
     and saving TPM status in NVMEM. Observed no failures.

Change-Id: I777a38f8a63cf17d60edb11cc3f916a4ea904741
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/894180
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2018-01-31 13:47:15 -08:00
Anatol Pomazau
5a910a86be Add support for HW alerts
- Add a vendor command that provides alert counter. Userspace can use
   it e.g. for user metric analysis.
 - Add 'alerts' debug console command. It provides information about
   chip alerts: supported alerts, fuse status, interrupt status, alert
   counter.
 - Add 'alerts fire [INT]' command to fire a software defined alert
   (globalsec/fwN where N is 0,1,2,3).

Signed-off-by: Anatol Pomazau <anatol@google.com>

BUG=b:63523947
TEST=ran the FW at Pyro and checked alerts data sent to host

Change-Id: I7cec0c451ed71076b44dad14a151b147ff1337e8
Reviewed-on: https://chromium-review.googlesource.com/817639
Commit-Ready: Anatol Pomazau <anatol@google.com>
Tested-by: Anatol Pomazau <anatol@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-31 13:47:15 -08:00
Wei-Han Chen
b245e71e82 stm32: add usb_isochronous
Templates for USB isochronous implementation.  Current implementation
only supports TX transmit.  Example of usage can be found in CL:803414.

Basically, declare an USB isochronous interface by

USB_ISOCHRONOUS_CONFIG_FULL(<NAME>,
                            <INTERFACE_NUM>,
                            <USB_CLASS>,
                            <USB_SUBCLASS>,
                            <SUB_PROTOCOL>,
                            <USB_STR_FOR_INTERFACE_NAME>,
                            <USB_EP_NUM>,
                            <PACKET_SIZE>,
                            <TX_CALLBACK>,
                            <SET_INTERFACE>)

where <PACKET_SIZE> is size of each USB packet, <TX_CALLBACK> is called
when USB hardware has completed a packet.  The buffer that USB is not
currently using will be passed to <TX_CALLBACK>, allow applications to
write next packet to it.

When a SET_INTERFACE packet is received, <SET_INTERFACE> will be called
with bAlternateSetting and bInterfaceNumber.

We will declare interface descriptor with bAlternateSetting = 0 and 1
for you, if you need more alternate settings, you need to declare by
yourself.

BUG=b:70482333
TEST=manually on reworked staff board
Signed-off-by: Wei-Han Chen <stimim@google.com>

Change-Id: Ic6d41da6ddd7945edf0bdfff55ede38a97661783
Reviewed-on: https://chromium-review.googlesource.com/818853
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-01-31 08:29:46 -08:00
Vincent Palatin
924d21d904 test: store persistence files in RAM
On VM-based builders, the nvmem unittest was sometimes missing the
10-second deadline, likely being stuck in slow I/Os.
Try to move the persistent storage files used for flash 'emulation' on
host from the build directory to a RAM-backed filesystem in /dev/shm
in order to mitigate this bottleneck.

Store the new backing files in a path like:
/dev/shm/EC_persist__mnt_host_source_src_platform_ec_build_host_nvmem_nvmem.exe_flash
in order to keep the properties of the old system:
subsequent runs of the same build will use the same persistent storage
but 2 different trees won't mix up.

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

BRANCH=none
BUG=chromium:715011
TEST=make runtests
TEST=run the following command with and without this change:
'for i in 0 1 2 3 4 5 6 7 8 9 ; do time make run-nvmem ; done'
and see the average test time around 500 ms without the change
and around 320 ms with it on an idle and beefy workstation.

Change-Id: Ic2ff6511b81869171efc484ca805f8c0d6008595
Reviewed-on: https://chromium-review.googlesource.com/893380
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-31 05:58:03 -08:00
Shawn Nematbakhsh
8d29b3dae7 stm32: Fix bkpdata accounting
stm32f0 has 20 bytes (not 20 words) of VBAT-backed RAM. Make more
efficient use of our limited storage to prevent trying to use storage
that doesn't exist.

BUG=b:71333840
BRANCH=None
TEST=Negotiate PD, run "reboot" on scarlet EC console, verify reset path
is taken in pd_partner_port_reset().

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie4c303b74a1b82b84ec971cdcc19c2b21a0032e7
Reviewed-on: https://chromium-review.googlesource.com/885461
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-30 14:54:17 -08:00
Elmo_Lan
87a1268ef5 Nami: force to set RESET_FLAG_RESET_PIN
Like other KBL designs (eve, poppy and followers).
EC is not able to distinguish between power up and reset.

BUG=b:71839731
BRANCH=none
TEST=Verify Nami power on flag by EC console.

Change-Id: Ice8b80259b8405f28b508918d5b3cfe37a8b1eb9
Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/891042
Commit-Ready: Raymond Chou <raymond_chou@compal.corp-partner.google.com>
Tested-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
2018-01-30 06:32:38 -08:00
Wei-Han Chen
9a7e82bac8 stm32: make half-duplex SPI works on STM32F0
According to RM0091, steps for using DMA for SPI peripheral should be:

1. enable DMA RX / TX
2. enable SPI
3. wait for DMA to complete
4. disable DMA RX / TX
5. disable SPI

BUG=b:70482333
TEST=tested on reworked staff (half-duplex)
TEST=tested elm (full-duplex)

Change-Id: I095409195cd1e0379995f0bfa6605c2e1a0dfd3c
Reviewed-on: https://chromium-review.googlesource.com/853715
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2018-01-25 00:15:48 -08:00
Nicolas Boichat
9ef3e91bdd stm32/usb: Add logic to detect stuck controller in usb_wake
When we tried to go back to sleep immediately after receiving a
spurious USB resume event, the controller would get stuck in an
unrecoverable state. Hopefully we fixed the resume logic, but
this code would catch other cases, and recover the base.

BRANCH=none
BUG=b:35775088
BUG=b:67766202
BUG=b:71688150
TEST=With badly implemented resume logic (e.g. call
     usb_resume_deferred directly from usb_resume), with USB
     autosuspend enabled on soraka, short D+/D- lines.
     Next wake event from staff shows "USB stuck", and then
     USB interface recovers.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Change-Id: I7463a37682723be195bd6a72ea5d76c21bb6cb9a
Reviewed-on: https://chromium-review.googlesource.com/868094
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-18 10:11:49 -08:00
Nicolas Boichat
0270e9db62 stm32/usb: Handle spurious wakes in usb_resume
Sometimes, usb_resume gets called, but the D+/D- lines do not
indicate an actual resume event (e.g. during ESD discharge).

Reference manual tells we should go back to sleep if state is 10 or
11. However, setting FSUSP and LP_MODE in this interrupt routine
seems to lock the USB controller (see b/35775088 and b/71688150).
Instead, we do it in a deferred routine. The host must assert the
reset condition for 20ms, so reading D+/D- after ~3ms should be safe
(there is no chance we end up sampling during a bus transaction).

BRANCH=none
BUG=b:35775088
BUG=b:67766202
BUG=b:71688150
TEST=On staff, with USB autosuspend enabled on soraka, short
     D+/D- lines, which causes a spurious wake event. After that
     remote wake-up still works.
TEST=Repeat test with ESD discharge.
TEST=Repeat test with plugging/unplugging of USB-C monitor.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Change-Id: I0f2697d1fa5b68356fd8a4fc16eaab5eadad9086
Reviewed-on: https://chromium-review.googlesource.com/868093
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-18 10:11:48 -08:00
CHLin
a0f25e398e npcx7: Add definition/configuration for npcx7m6xb/npcx7m7w
In this CL, we add the following changes to support the CHIP_VARIANT
npcx7m6xb and npcx7m7w:
1. Define the code RAM, data RAM, BBRAM base address/size.
2. Initialize the wov.c file for WoV driver development. (It will be
compiled only when CHIP_VARIANT=npcx7m7w in the build.mk and
CONFIG_WAKE_ON_VOICE is defined in board.h)
3. Fix the the incorrect offset of PWDWN_CTRL7 register.

BRANCH=none
BUG=none
TEST=No build errors for make buildall.
TEST=Change CHIP_VARIANT to npcx7m7w/npcx7m6xb in
board/npcx7_evb/build.mk; "BOARD=npcx7_evb make"; Check ec image can be
built. Flash the image on EVB; make sure EVB bootup.

Change-Id: I87bccb9097f8f0a6c67f96a8d90adf201ae9e773
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/858637
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-17 23:37:27 -08:00
Nicolas Boichat
6432c52a72 stm32/usb: usb_wake: Update STM32_USB_CNTR with interrupts off
STM32_USB_CNTR may be written from both interrupt context, and
usb_wake (not necessarily in interrupt context). Let's disable
interrupts to make sure the operation is atomic.

BRANCH=none
BUG=b:35775088
BUG=b:67766202
BUG=b:71688150
TEST=Flash hammer, hammer can wake from USB autosuspend

Change-Id: I9c2a3259902ecb759a6d0d89c7746c7aa72ae73d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/744282
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-17 23:37:26 -08:00
Vincent Palatin
47c7e189b9 stm32: add SPI slave support for STM32H7
Update the host command support on the STM32 SPI slave for the STM32H7
silicon.

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

BRANCH=none
BUG=b:67081508
TEST=with a servo v2 connected to ZerbleBarn,
send host commands v3 through the servo FTDI SPI interface.

Change-Id: I26ff4b6a3a45e446cd16e9da43c6932c24c37256
Reviewed-on: https://chromium-review.googlesource.com/839864
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-12 14:31:07 -08:00
Shawn Nematbakhsh
7bc128f7d1 chip/host: uart: Run uart_monitor_stdin() before task scheduling
After a call to pthread_create(), it is indeterminate which thread  the
caller or the new thread  will next execute. Synchronize with the new
thread and allow it to initialize (and print to console, before the
print can potentially interfere with other prints) before proceeding.

BUG=chromium:715011
BRANCH=None
TEST=Run 'make runtests', verify 'Console input initialized' is seen
before '--- Emulator initialized after reboot ---':

====== Emulator output ======
No flash storage found. Initializing to 0xff.
No RAM data found. Initializing to 0x00.
Console input initialized

--- Emulator initialized after reboot ---

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ieb622e9b7eea2d11d4a11a98bb503a44534f676c
Reviewed-on: https://chromium-review.googlesource.com/854989
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-10 18:20:01 -08:00
Scott Worley
d1443721df ec_chip_mchp: Add chip flash image generator
Add Microchip MEC17xx compatible Python script
used by build process to generate the SPI flash
image.

Change-Id: I0e68c7bfb8633051840910a6000270c3b929c3e9
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840651
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 15:44:52 -08:00
Vincent Palatin
d56195cfdb stm32: add SPI master for STM32H7
Add the driver for the new silicon used in STM32H7 SPI controller,
including its bad errata when used with DMA.

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

BRANCH=none
BUG=b:67081508
TEST=on ZerbleBarn, do finger image acquisition on the SPI fingerprint
sensor.

Change-Id: Ieaf4a09e961d3e0ef78b58886c409a7dfb63aaf3
Reviewed-on: https://chromium-review.googlesource.com/836617
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 17:22:48 -08:00
Vincent Palatin
e24a3953c2 stm32: Add STM32H7 family
Start adding support for the STM32H7 family of device and the first
available one the STM32H743.

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

BRANCH=none
BUG=b:67081508
TEST=manual, run on stm32h743i-eval and zerblebarn boards
get a stable serial console.

Change-Id: I9ae10f0d843e5318451713c21ed22d455a23758c
Reviewed-on: https://chromium-review.googlesource.com/806168
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 05:41:23 -08:00
Nicolas Boichat
51b6222520 npcx/uart: Pull up communication line during transaction
Boards needs to define GPIO_EC_COMM_PU, which needs to be driven
high during EC-EC transaction. This makes sure that the line does
not go low, even when the base goes away during the transaction.

BRANCH=none
BUG=b:68954760
TEST=EC-EC communication works with this change.
TEST=With signal analyzer, check that UART line is always kept
     high while transaction is in progress.

Change-Id: Iad7b26a9a93b674aa4fff0bc3a72a13e6782515d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845544
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:01 -08:00
Marius Schilder
1c1af98e40 g: fix flaky timeout check for spi transfer.
Typically this routine runs on low priority hook task.
A pre-emption by a higher priority task might be mistaken for timeout.
Double check the transfer done status after the timeout time has passed.

Also clear the TXDONE status before starting a fresh transaction to make sure
we wait for the current transaction to complete; an errand TXDONE status
at start of the transaction will pre-empt waiting for the current transaction
and return stale data.

BRANCH=none
TEST=mn50 stress test fails within minutes vs. now stable.
	Main test component is higher priority console task
	that does intermittent compute during usb-spi transfers.
Change-Id: Ide4390e42d3957bc45eea8160617a52dd31ed866
Reviewed-on: https://chromium-review.googlesource.com/849662
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 14:35:21 -08:00
Marius Schilder
c69f4dfad5 g: allow for other values of DCRYPTO_CALL_TIMEOUT_US
Some dependent projects use larger RSA keys, which require
larger timeout values.
Let them pick their timeouts in their board.h

BRANCH=none
TEST=make buildall
Change-Id: I7cf018938f76daccd79e8bed49d48ffb5fbebe21
Reviewed-on: https://chromium-review.googlesource.com/849757
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 12:31:29 -08:00
Marius Schilder
5c8b6391e4 g: allow for other values of RSA_MAX_BYTES
Some dependent projects need larger than 2K RSA computation.
Allow their board.h to pre-define RSA_MAX_BYTES to suit their needs.

BRANCH=none
TEST=make buildall
Change-Id: Ia00def60ea359e150285e7851a462531f40f5b18
Reviewed-on: https://chromium-review.googlesource.com/849756
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 12:31:29 -08:00
CHLin
5b1c4868d7 npcx: modify the npcxspiflash little firmware to support UUT
The original ec_npcxspiflash lfw is used by the openocd to program SPI
flash via Servo JTAG. In order to support UUT mode to program SPI flash,
this CL modified the lfw with the following changes:
1. Rename the lfw ec_npcxflash to npcx_monitor to unify the naming.
2. The npcx_monitor will read the first 4 bytes from the area of monitor
header. If the monitor identifies the first 4 bytes is a UUT tag, it
will read parameters(SPI_OFFSET/IMAGE_SIZE) from the relative offset of
monitor header. Otherwise, it will read parameter from the general
register r0/r1 which will be restored by openocd script in advance.
3. Add monitor_hdr.c to generate the monitor header binary files
(monitor_hdr_ro.bin/monitor_hdr_rw.bin)) automatically after compiled.

The memory layout to restore the reuqired binaries are listed below:
ec firmware(RO/RW) - the start address of Code RAM area.
monitor header - 0x200C3000
npcx_monitor - 0x200C3020

BRANCH=none
BUG=none
TEST=No build errors for "make buildall".
TEST=Follow instructions in CL:826763; make sure the ec firmware is
updated and ec can boot up.
CQ-DEPEND=CL:828341

Change-Id: I5de997a4dee5449d578972e2f929c6e08c5dff67
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/826909
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-03 22:42:59 -08:00
Vadim Bendebury
5789d69257 g: simulate open drain GPIO behavior
Some upcoming designs based on the g chip require GPIOs connected to
open drain circuits.

Even though the chip explicitly provides only two open drain GPIOs,
the desired behavior of the rest of the pins when configured as 'open
drain' could be simulated by software if when 'high' is required the
output is disabled instead of driving the pin value.

To make sure there is no fallout from RO driving the pins, also add an
explicit 'disable output' initialization in case a GPIO is configured
for open drain and the initial output value is 'high'.

BRANCH=cr50
BUG=none
TEST=verified that Cr50 booted successfully, also confirmed that on
     the test board that GPIOs defined as Open Drain allow we set
     output to 1 only if pulled up.

Change-Id: Id2daa19b992bab7fb01148b6fa7b57fd0728b33d
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848152
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-03 16:54:35 -08:00
Scott Worley
f4700dac61 ec_chip_mchp: Add I2C controller
Add Microchip MEC17xx family I2C controller.
Controller supports master/slave but is used
as master only.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I66c130943de6574a5f4acff56b88fca69bbb2663
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840646
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-02 15:48:23 -08:00
Scott Worley
a92647b9ce ec_chip_mchp: Add LPC and eSPI files.
Add Microchip MEC17xx family LPC and eSPI
support files. Fix fault when host sends
old style command packet.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I35c33be407e093b19c456b5a78c2c4e19a267b95
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840647
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-02 15:48:21 -08:00
Scott Worley
9f5a155650 ec_chip_mchp: Add MCHP TFDP trace debug files
Add Microchip MEC17xx family trace fifo debug
(TFDP) files. TFDP is a MCHP specific two pin,
output only software message port.
Added TFDP module ID.

Change-Id: Ibe2399a8c3618b207a89552450d80b7901e85f23
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 19:21:31 -08:00
Scott Worley
c56df0d831 ec_chip_mchp: Add other hardware files
Add Micorchip MEC17xx family files for
hardware timers, keyboard scan, host
port 80h, UART, and watch dog timer.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: Iac8a912af4d29521964f606637041b06fa7238ee
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:32 -08:00
Scott Worley
eb29ab7acd ec_chip_mchp: Add PWM and fan files
Add Microchip MEC17xx family PWM and fan
source files for review

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I91439ab999a4662d690b58b0fbbb887f643b3673
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:31 -08:00
Scott Worley
0a6a7be572 ec_chip_mchp: Add SPI files
Add Microchip MEC17xx family SPI master
controllers and flash files. SPI implements
public interface wrapper for QMSPI and GPSPI.
MEC17xx family uses QMSPI for loading
EC firmware. GPSPI is for general use (sensor).

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I23001e254dd437caa0917949f4dd2eb903f1adb1
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:30 -08:00
Scott Worley
4e9588ddcf ec_chip_mchp: Add MCHP chip folder
BRANCH=none
BUG=
TEST=Review only. Committing small pieces until
all code passes review.

Change-Id: I9d16f95314a7c97b11c4fe61602c6db2621e6024
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:07 -08:00
Scott Worley
c334f648bd ec_chip_mchp: Add ADC and DMA files
Add Microchip MEC17xx family ADC and DMA
source files for review.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: Iccf19223ddd3f6774b90d5fca32079be9b0c4bcc
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:06 -08:00
Scott Worley
2f1f5a5551 ec_chip_mchp: Add LFW files
Add Microchip MEC17xx family little-firmware
(LFW) folder and files.

Change-Id: I9142266d41234574730fadccd5a2cc27fe3d8fd7
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:06 -08:00
Vincent Palatin
90d735c3c3 stm32: re-factor registers.h addresses
Move all the peripheral blocks base addresses in a common block rather
than spread among the register definitions.
This will help making a cleaner STM32H7 implementation whose base
addresses are all different from other families.

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

BRANCH=none
BUG=b:67081508
TEST=compare all the ec.bin generated by 'make buildall' and verify
they are bit-identical with and without the change.

Change-Id: I52cafd2f3c9145dbcd585166df3fc78e38573bb4
2017-12-25 17:17:26 -08:00
Nicolas Boichat
bbb40ce21d consumer: Remove flush operation
Nobody is calling the flush function for consumer_ops structure,
so let's remove it to save flash space, until we find a use for it.

CQ-DEPEND=CL:*529221
BRANCH=none
BUG=chromium:795624
TEST=make buildall -j, saves from 40 to 128 bytes on some boards.

Change-Id: Iad18b30f419ccebc54a90914ec46da84b8d19601
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/826905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-18 20:32:58 -08:00
Nicolas Boichat
575c03f31c chip/stm32: Add support for half-duplex UART
BRANCH=none
BUG=b:65697962
TEST=make BOARD=wand -j

Change-Id: I2af4acb5cce6da6ce2f01d6d60cf5e806c9a4ed2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/821891
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-15 05:32:29 -08:00
Marius Schilder
0059070b22 g: tweak usart queuing for stream signing
Guarded by CONFIG_STREAM_SIGNING
Comes at 10K cost in SRAM
Used by nm50

Signed-off-by: mschilder@google.com
BRANCH=cr50
BUG=none
TEST=sign nm50 target dump_state 115200 output w/o overruns

Change-Id: I4db2dec4de8afbeba68d1bc72f43a91fc134ff85
Reviewed-on: https://chromium-review.googlesource.com/823264
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-12-13 17:26:11 -08:00
li feng
8412404545 ish i2c: use i2c_ports[] to set bus speed
BUG=None
BRANCH=None
TEST=Tested on Soraka ISH modified board, measured I2C speed for std,
fast, fast plus mode.

Change-Id: I0e07c3c73f5f0302fba41ad8e7f83e10e8f0af99
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/817899
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-13 00:32:23 -08:00
Dino Li
5fd8fead54 it83xx: espi: workaround for changing PLL
We need to change PLL settings if host apply eSPI operating
frequency higher than 50MHz, because FND clock is required
to be higher than half of operating frequency.

BRANCH=none
BUG=b:70537592
TEST=Change PLL succeed with chip select is low.

Change-Id: Ieba62f33ed024aed7a8e7f4cc48b1398ed781170
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/817717
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-12-12 22:00:36 -08:00
Wei-Ning Huang
4ced1d7d6a chip/stm32/usb_hid_keyboard: add dynamic backlight detection support
In order to make a single hammer image support both base with and
without keyboard backlight. We need a way to dynamically determine if
backlight is present, and send the correct HID descriptors. This is done
through declaring two HID descriptors and return the correct one
depending on whether or not the backlight is present.

BRANCH=none
BUG=b:67722756
TEST=On reworked board with pull-down on backlight pin,
     USB descriptor has backlight HID report descriptor, and is
     functional.
TEST=On old board with both pull-up and pull-down (equivalent to
     having pull-up only, i.e. no backlight)
     USB descriptor does not have backlight HID report descriptor

Change-Id: Ie3eac9b3d4cd749308ccfb96a7db469701f9793b
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/770600
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-12 03:57:19 -08:00
Nicolas Boichat
e3c1e2265c stm32/usb: Patching framework for USB descriptors
In some cases, we want to be able to dynamically modify a few bytes
in the USB descriptor (in our case, length of referenced items),
but it could also be other things like flags.

These 2 new functions allow to keep all the USB descriptor in flash, and
modify these few bytes before writing them in the USB buffer.

BRANCH=none
BUG=b:37447752
TEST=Flash hammer, USB descriptors are valid.

Change-Id: I8624255fa43f52a0aaa21d20e963f3974f236912
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/771057
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-12 03:57:19 -08:00
Dino Li
a7c08b257f it83xx: adc: add support ADC13-16
IT8320 can support extra four ADC channels (ADC13-16).

BRANCH=none
BUG=none
TEST=Run console command 'adc' and check the results.

Change-Id: Ia9a259f54fa28d43dc0050c6e20885c0b3914f9c
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/808125
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-12 01:05:29 -08:00
Philip Chen
0037fb8dfc system: Log PC and task id on watchdog
For debug, in common code let's log the watchdog PC
and task id as our SW panic params.

BUG=chromium:790006
BRANCH=none
TEST=manually test scarlet rev2 from a1-a3, b1-b2:

(a1) Add 'while(1);' in button ISR
(a2) Boot and press the button
(a3) When watchdog is triggeried, check with 'panicinfo'
that saved R5 is the PC for button ISR.

(b1) 'crash watchdog' in EC console
(b2) Check with 'panicinfo' that CONSOLE task id is saved in
EXCEPTION and PC is saved in R5.

Change-Id: I64d2fcf594dd24b0951e002ab8e80ebcac2d1def
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/803618
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 15:16:23 -08:00
Shawn Nematbakhsh
01e43230ca stm32f0 / stm32f3: rtc: Fix register <-> time conversion
us_to_rtcss() could return an invalid value when us approached 1 sec
due to precision loss in the divisor. Change the calculation order to
divide last to eliminate precision loss.

BUG=b:68185182
BRANCH=None
TEST=On scarlet, Verify hw clock closely matches reality w/ low-power idle.
Verify EC doesn't watchdog for 5 hours in S5 / G3 w/ low-power idle. Verify
suspend-stress-test still succeeds to wake device on alarm.

Change-Id: Id40797dd4291e94a54a09bbbdbc1a7f7a00a01b4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/818332
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 12:47:48 -08:00
Shawn Nematbakhsh
316a8cb398 stm32: Add proper flash erase timeout
stm32f0 / f3 can take up to 40ms to erase a single sector of flash. Also
add a note about instruction fetch being blocked on flash operation
completion.

TEST=`make buildall -j`
BUG=b:70193071
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Icb6c199a975b31f4fa7c73ceb6ad8ec06150abb1
Reviewed-on: https://chromium-review.googlesource.com/815276
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-08 20:37:25 -08:00
Dino Li
1956a98ad4 it83xx: espi: Don't reset PNPCFG while PLTRST_L asserted
The PNPCFG (EC2I control module) is used to set I/O port base
address and IRQ number.
On it8320, PNPCFG will be reset while system event PLTRST_L
is asserted. This means we can't decode I/O cycles correctly
until we re-initialize PNPCFG.
We disable this reset source, then we don't need to re-initialize
PNPCFG for each PLTRST_L asserted.

BRANCH=none
BUG=none
TEST=MECC board with it8320 + Intel SKL-Y RVP3 and boot to shell.

Change-Id: I7efe8f726939245424237c1d153df4f83b39ae6b
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/810428
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-12-06 23:22:18 -08:00
Philip Chen
e2a9ede352 chip/stm32/clock: Handle illegal alarm timeout gracefully
Even if we set the rtc alarm timeout for more than 86400 secs,
we should not crash the system.

BUG=chromium:768042
BRANCH=none
TEST=on AP console, do 'ectool rtcsetalarm 99999' and
then see 'EC result 3 (INVALID_PARAM)' without crash.

Change-Id: Ic0fa92ff101bce1f4791221c4e1eadaf7a005355
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/807624
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 17:30:47 -08:00
Daisuke Nojiri
23149261dc system: Allow hibernate to clear AP_OFF flag
After firmware update, cr50 toggles the EC's reset line, expecting
the system will boot. This isn't the case for Chromebox because it
sets AP_OFF flag on a clean shutdown (to restore the previous power
state after power loss & restore).

This patch adds EC_REBOOT_HIBERNATE_CLEAR_AP_OFF to EC reboot
command. It makes EC first clear AP_OFF then hibernate.

BUG=b:69721737
BRANCH=none
TEST=Verify Fizz reboot after cr50 update.

Change-Id: If3207d7284f244ca1adf0d516ef744dbc739a9c1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/802632
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-12-05 18:00:38 -08:00
li feng
39efbc3ada ish i2c: add I2C Fast Mode Plus 1Mbps speed option
Also added CONFI_ISH_I2C_PORT0_SPEED, CONFI_ISH_I2C_PORT1_SPEED, and
CONFI_ISH_I2C_PORT2_SPEED to define speed for each ISH I2C port. By
default, those are set to fast mode, 400kbps, I2C_SPEED_FAST.
The values can be modified in board.h.

BUG=None
BRANCH=None
TEST=On Soraka modified board for ISH, set I2C stardard mode, fast mode
and fast mode plus, measured I2C clock freq using scope respectively and
confirmed the freq matched I2C mode.

Change-Id: I426b50dc935c3760903360a50f6069e99bd0abff
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/784091
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-12-04 20:02:58 -08:00
Vincent Palatin
c2bafec03c stm32: update USB version for BOS descriptors
Bump the USB version (aka bcdUSB) for BOS descriptors to 2.1 (rather
than 2.01) to be compatible with Chrome implementation.

The CL 664813 was intending to do this, but I screw up and only changed
it for chip/g and let chip/stm32 unchanged :
https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/664813

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

BRANCH=twinkie
BUG=none
TEST=manual, plug an updated Twinkie and see the WebUSB pop-up on
Chrome.

Change-Id: Ia81fa91b6d7790af6f6683c0da7ca1d794b4e4df
Reviewed-on: https://chromium-review.googlesource.com/789934
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2017-11-30 11:48:57 -08:00