Storm does not need EC mentioned in the fmap

There is no EC on storm, no need to mention it in the flash map. Let's
remove the EC sections and increase the preceding sections to avoid
creating more gaps in the flash memory map.

BUG=chrome-os-partner:30111
TEST=manual
   emerge-strom depthcharge chromeos-bootimage

Change-Id: I72bc618d72692dce75ed801f4c00bdc4388abf4a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207012
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
cli: add command to test timer implementation

The new command, 'time' accepts one argument, number of seconds to
run. counting down with each second. This allows to crudely check
microsecond timer implementation.

BUG=none
TEST=manual

   storm: time 10
    9 8 7 6 5 4 3 2 1 0
   storm: time 30
    29 28 27
   storm:

  (hit a key after a few seconds in the latest invocation)

Change-Id: I6dd46cbd4c7ea7c1a1d969ae211e856a90f63412
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207354
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Trevor Bourget <tbourget@quicinc.com>
Support vendor string based machine id

We want to be able to pass different machine ID to the 3.4 kernel on
ap148 versus proto0 hardware. One way to do it is to key the machine
ID choice by the 'part name' field in the mainboard coreboot table
structure.

In particular, part name 'AP148' uses previously configured value of
4704, and part name 'Storm' uses a new value, 4936. The kernel changes
are to follow.

BUG=chrome-os-partner:30440
TEST=booted kernel on AP148 and proto0, observed expected machine IDs
     reported on the console.

Change-Id: I2edea0fa5681c92e54ca2304906db7f041c5fc0f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207458
Reviewed-by: Trevor Bourget <tbourget@codeaurora.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
rush: use 2MiB coreboot region size

The coreboot region conatins the MTS microcode which is at least
1.5MiB in size. Therefore the rest of the regions need to be
adjusted accordingly. The fallout for this is tha the legacy
region is removed.

BUG=chrome-os-partner:30569
TEST=Built and booted rush through end of coreboot using image.bin.

Change-Id: I32ab040c35e9105fd6e352548fd7e2fe83eee440
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208352
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
rush: ensure board Kconfig gets included

BUG=chrome-os-partner:30569
TEST=Built depthcharge for rush.

Change-Id: I2826a12f4fe78250f98e4e15e95e87363e10fee9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208353
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
rush_ryu: add support for rush_ryu

This adds the bits for rush_ryu. Notable differences
from rush. This is a clone of rush aside from autoselecting
rush_ryu in the defconfig and the fmap uses an 8MiB rom.

BUG=chrome-os-partner:30569
TEST=Built bootimage for rush_ryu

Change-Id: Ia94992150b07e13d8d67568e0d86902688f8d8ad
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208354
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
storm: increase coreboot blob size in fmap

With recent driver additions depthcharge causes CBFS spillover beyond
the room allocated in the image for the coreboot blob. Let's increase
the room.

BUG=chromium:394068
TEST=manual
  . there is no failures to decompress depthcharge on storm anymore

Change-Id: I4a9e57f5983da45344a6dd622b6fad2ad9cf1afb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208128
Reviewed-by: David Hendricks <dhendrix@chromium.org>
ipq806x: Remove duplicate definition from SPI header

We already have a setbits_le32() in libpayload, so remove the duplicate
definition here. The only reason this didn't blow up before is because
the old libpayload setbits_le32() depended on having libpayload-config.h
included before arch/io.h, which is now fixed.

CQ-DEPEND=CL:208713
BUG=None
TEST=emerge-storm libpayload depthcharge

Change-Id: I97549e6f60a4d3b6b4451de6e083a4a20938e837
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208712
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
vboot: change VbExEc implementations to support devidx parameter

This will be used in subsequent CLs to support PD software sync.  For
now, only devidx=0 is used, and other values return error.  This makes
static analysis of the change easy.

This must be checked in at the same time as changes to the
vboot_reference project and u-boot implementation.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=emerge-samus depthcharge
CQ-DEPEND=CL:208210,CL:208196

Change-Id: I19c88e6d443841866fced360045b49ea610ce5f5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208195
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
samus: Add PD firmware to image

This must be committed at the same time as the corresponding coreboot
change which updates the firmware blob indices for samus.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=Build samus firmware.
     dump_fmap -h /build/samus/firmware/image.bin shows PD_MAIN_A and
       PD_MAIN_B sections.
     Boot samus.  'crossystem mainfw_act' -> A
     As root, 'crossystem fwb_tries=1'
     Reboot samus.  'crossystem mainfw_act' -> B
CQ-DEPEND=CL:208984,CL:*169850,CL:208899

Change-Id: I786180fc93b05569a7b0fb33c79b335dc84a6706
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/208989
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
rush: Update CONFIG_FMAP_OFFSET to match the fmap.dts change

BUG=None
BRANCH=None
TEST=Compiles successfully and fmap offset error gone while booting

Change-Id: I63598a8513cf69414f032d00ed70187c4f4c5af6
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/209005
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
rush: Pull in flash_set_ops from nyan

Depthcharge on rush got stuck on flash_ops missing. Thus, pulled in
flash_set_ops and required changes into rush.

BUG=None
BRANCH=None
TEST=Compiles successfully and depthcharge booting goes ahead and stops on vboot
handle is NULL

Change-Id: I1ac5b12f01b161f648fbb49cefc6c96e2d934816
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/209006
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Tom Warren <twarren@nvidia.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
ec: Update commands.h to current version

Bring over the most recent version of the ec commands header file from
the Chromium EC repo.  No functional changes.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=build depthcharge; boot samus

Change-Id: I6ff294bbb8d82e69e26da48ebce09b1be96597da
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209210
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
ipq806x: i2c, gsbi and qup driver

This driver provides interfaces to initialize the GSBI QUP block for i2c
protocol. I2C transfer interface can be used to read and write the slave.
The driver sets up the QUP in FIFO mode for i2c transfers.

BUG=chrome-os-partner:27944
TEST=Tested I2C slave on GSBI4 for readb, writeb, read_raw and write_raw
     operations.

Change-Id: Id602eac86a76ce1c92073c2ccb50fcc1ac110e87
Signed-off-by: Sourabh Banerjee <sbanerje@codeaurora.org>
Reviewed-on: https://chromium-review.googlesource.com/203723
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
storm: initialize tpm

With the i2c driver availability there is no need to mock TPM
anymore. This patch adds TPM initialization code following the suit of
other depthcharge boards.

BUG=chrome-os-partner:27944
TEST=with TPM support enabled proto0 firmware proceeds all the way to
     booting the kernel while in verified boot mode.

Change-Id: I8ad71390726d1ff92941be23ec04276a355938ff
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209351
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Refactor out duplicated binary linking code from Makefiles

This patch moves the code that builds the final image back from
vboot/Makefile.inc and netboot/Makefile.inc to a common top level
directory, and replaces the often-duplicated recipes to build images
with a few shared functions. This makes it easier to see which parts
correspond and which are different between multiple images (despite the
unfortunate atrocities that getting variable substitution right in make
functions requires you to commit), and helps in preparation of adding
yet another image type that will combine normal boot and netboot.

BUG=chrome-os-partner:18390
TEST=Built images for Nyan_Blaze, Falco, Daisy and Storm. Confirmed that
all stripped output binaries are byte-for-byte identical.

Change-Id: Ib12bd6a6b9b57712b1b2e186da1ba21abcb0a4d1
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209270
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Revert "need to be able to build and boot without USB support"

This reverts commit dd204133d024db01edf476239a1089f7ba195f1d.

Storm now has correct USB support and doesn't need this patch anymore,
so it's just dead code right now. It doesn't fit very well with
depthcharge's philosophy to only ever turn things *on* with Kconfigs
(and have everything disabled by default). It also creates a redundancy
with libpayload Kconfig, putting the decision of whether USB is enabled
in two different places (even though we could just include
libpayload-config.h).

There should be generally no need for an option like this. On finished
ChromeOS devices, we always need USB support of some sort. As a
temporary measure during bring-up, one can simply disable every
libpayload USB Kconfig except for CONFIG_LP_USB, and depthcharge's calls
into USB code will always just return without doing anything.

BUG=None
TEST=None (option is disabled everywhere).

Change-Id: Ie9bb82ce7c7c0730595f1044b023e71161a2d914
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209271
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Create developer binary that combines depthcharge and netboot for GDB

This patch changes depthcharge to link a new type of output binary
(dev.elf or dev.ro.elf) that includes both the normal depthcharge/vboot
code and netboot. To do this, the existing netboot main() function is
redefined as netboot_entry() with a weak alias to "main". Thereby, a
normal netboot binary will still pick it up as its entry point, but the
dev binary will use the definition from src/vboot/(ro_|rw_|)main.c. For
those images netboot_entry() is explicitly exempted from garbage
collection, so it (and every netboot function it depends on) is
available to be called from a remote GDB session.

Also splits the netboot code apart into initialization, parameter
parsing and actual netbooting parts. This way, external callers like
remote GDB can override some or all netboot parameters.

BUG=chrome-os-partner:18390
TEST=Flash image.bin and image.net.bin to confirm that they still work
as expected. objdump depthcharge.elf to make sure no netboot code
managed to sneak in. Flash image.dev.bin, execute "fwgdb -e 'call
netboot((u8[4]){192,168,42,1}, "path/to/vmlinuz", NULL, "my kernel
command line")'" and behold the magic.

Change-Id: I5fe501130814f3e7f396356f19df04a3fb5bf7b9
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209272
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Add CTRL+N (netboot) to dev images and allow more precise building

Now that we link netboot code into dev images, we are so close to be
able to just offer a "Press CTRL+N for netboot" that it would be silly
not to do it. Kernel folks have been asking for this feature a lot.

Unfortunately, this is still a bit tricky in the details: we cannot just
guard the new key combination with a Kconfig, since those are evaluated
only once (when vboot/callbacks/keyboard.o is built), but we are
building three different images from it. For GDB this worked since we
linked directly to libpayload symbols, but for netboot that is not the
case.

The solution is to move the distinction completely into the linker: we
move all entry points for "debug" functionality into wrapper functions,
and add empty stub implementations with weak symbols for all of them.
This way, production images will recognize CTRL+N and call
dc_dev_netboot(), but that function simply returns without doing
anything... we fall through to the next case and have exactly the same
behavior as if the code hadn't been there at all. In debug builds we
link in the real code for those functions, overriding the weak symbols
and making the key combination work.

We still have the problem that we cannot link to libpayload symbols that
aren't there, which is the case for gdb_enter() and gdb_exit(). Rather
than #ifdef hacking, this patch changes the Makefile to not build any
image by default and require the caller to explicitly build one of the
three image types. With this route we no longer need to build
depthcharge twice from the ebuild... we just build all the code once,
and then link it three times (against different libpayload builds). This
also means we do not need to link both the legacy trampoline image and
the unified EFS image for every board, and can get rid of some hacks
because trampolines do not (seem to?) work on ARMv8.

CQ-DEPEND=CL:209260
BUG=chrome-os-partner:18390
TEST=Boot image.bin, make sure it still boots but CTRL+G and CTRL+N do
nothing. Boot image.dev.bin, make sure it boots normally but can also
netboot (CTRL+N) and enter GDB (CTRL+G/fwgdb). Tested on Nyan_Blaze,
Falco and Daisy to cover ARM+trampoline, ARM+EFS and x86.

Change-Id: I569f417877c23f0ad63ca524c307e31b542afbf7
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209273
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
tegra spi: Set Tx and Rx TRIG to 0x0 which is 1 packet

Since the driver initializes 32-bit bus, we need to set Tx and Rx TRIG to 1
packet i.e. 0x0.

BUG=chrome-os-partner:30779
BRANCH=None
TEST=Compiles successfully and boots till vboot handler. Earlier hang on
flash_read removed because of this change

Change-Id: I05aa1d999760478ca0cab38b49edbaf56ed5f9f3
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/209503
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Aaron Durbin <adurbin@chromium.org>