chromiumos/third_party/flashrom.git
6 days agokb94x: Make EC reset error handling on write more robust. 85/51385/4 master
Shawn Nematbakhsh [Thu, 16 May 2013 00:07:13 +0000 (17:07 -0700)]
kb94x: Make EC reset error handling on write more robust.

Prior to writing data to the SPI ROM, it's necessary to send kb94x to a
reset state, otherwise the system will behave in unpredictable ways.
Previously, our error checking prior to issuing SPI write commands was
not sufficient. Upon error, we continued with the write anyway, which
led to incomplete flashes and bricked platforms.

The follow changes are implemented here:

- Make three attempts at resume / reset before giving up.
- Place the EC state status back to IDLE upon failure, so the next write
  attempt will always attempt another reset. This should ensure that the
  EC is always in a reset state before any SPI write occurs.

BUG=chrome-os-partner:19105.
TEST=Manual. Verify AU success for 1000 trials on Butterfly.
BRANCH=Butterfly.

Change-Id: Ifbdab1e750702f3d492c7946d87196798fee733d
Reviewed-on: https://gerrit.chromium.org/gerrit/51385
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
8 days agoCorrect fdtmap code which scans over sub-nodes 41/51241/2
Simon Glass [Wed, 15 May 2013 01:51:37 +0000 (18:51 -0700)]
Correct fdtmap code which scans over sub-nodes

There was a break instead of a continue in this code, meaning it stops
when it reaches a sub-node. Fix this, and a compiler warning about malloc().

BUG=chrome-os-partner:19409
BRANCH=none
TEST=:manual
FEATURES=test sudo -E emerge flashrom
On snow:

$ /tmp/flashrom -p linux_spi:dev=/dev/spidev1.0 -r /tmp/x -i RO_VPD
flashrom v0.9.4  :  :  on Linux 3.8.0+ (armv7l), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Unable to open FDT property fmap-offset
Reading flash... SUCCESS

See that it correctly finds the region now.

Change-Id: Ibef3212b4d61bf3fec831a912c9f95825867d050
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51241
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 days agoAdd addition test for final region of fdtmap 40/51240/2
Simon Glass [Wed, 15 May 2013 01:47:54 +0000 (18:47 -0700)]
Add addition test for final region of fdtmap

Add a test which uses the last region of fdtmap. At the same time, improve
the code which prints out failure information and use InsertData() instead
of ad-hoc code to insert data into the image.

BUG=chrome-os-partner:19409
BRANCH=none
TEST=:manual
FEATURES=test sudo -E emerge flashrom

Change-Id: I938a69dfc3e40403734057caff6ae2bea475c785
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51240
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 days agoRevert "Add a ROM caching buffer" 53/51053/3 factory-4128.B factory-spring-4131.B
David Hendricks [Mon, 13 May 2013 23:05:36 +0000 (16:05 -0700)]
Revert "Add a ROM caching buffer"

This reverts commit 363152461dfdc8cb67c826addd77469046c3c297

Change-Id: Ic5e21e713aaba9a72d3dbdd2d2639a0bda9b0593
See: https://code.google.com/p/chromium/issues/detail?id=240284
Reviewed-on: https://gerrit.chromium.org/gerrit/51053
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 days agoRevert "add missing "void" return type from cache_invalidate()" 52/51052/2
David Hendricks [Mon, 13 May 2013 23:05:25 +0000 (16:05 -0700)]
Revert "add missing "void" return type from cache_invalidate()"

This reverts commit 66e651d7cd6cd8ab0af037cafc0caded84f953b0

Change-Id: Ic8c9a0c082907c448a9a7df1bc0077e1ffc566b7
See: https://code.google.com/p/chromium/issues/detail?id=240284
Reviewed-on: https://gerrit.chromium.org/gerrit/51052
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 days agoadd missing "void" return type from cache_invalidate() 06/50906/2
David Hendricks [Fri, 10 May 2013 22:48:32 +0000 (15:48 -0700)]
add missing "void" return type from cache_invalidate()

This adds a missing return type. GCC did not complain when
emerge-${OVERLAY} was used, but errs out when building for the
host machine.

BUG=none
BRANCH=none
TEST=locally compiled for host machine.

Change-Id: I61aa08c7c404dcead484e90d282f4703a84e99a4
Reviewed-on: https://gerrit.chromium.org/gerrit/50906
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 weeks agoAdd a ROM caching buffer 31/49131/7
David Hendricks [Sat, 27 Apr 2013 00:32:34 +0000 (17:32 -0700)]
Add a ROM caching buffer

This adds a caching buffer to reduce the time for repeated reads.
This is intended to improve worst-case scenario performance of
flashrom where sections of the ROM may be read more than once. This
typically happens when searching for a flashmap, especially if the
flashmap is aligned on a low power-of-2 boundary.

The method is dead-simple: Keep a copy of anything which has been read
from ROM in a buffer and track the entries in another buffer of the
same size. read_flash() will check if the bytes requested have been
cached and, if so, will simply memcpy the bytes into the user-supplied
buffer. Erase and write operations will "invalidate" bytes from the
cache.

BRANCH=all
BUG=chrome-os-partner:18851
TEST=See notes below

Partial reads were tested using util/partial_reads.sh script.
Partial writes were tested as follows:
1. create test image
dd if=/dev/urandom of=random_128k.bin bs=1k count=128
cp ec-ec-3833.B test.bin
dd if=random_128k.bin of=test.bin bs=1 seek=$((0x10000)) \
count=$((0x4000)) conv=notrunc

2. create layout.txt
for i in `seq 0 3`; do
printf "%x:%x r%d\n" $((0x10000 + $i*0x1000)) \
$((0x10000 + $i*0x1000 + 0xfff)) $i >> layout.txt
done

3. Do partial write and verify using known-good flashrom:
./flashrom-test -p internal:bus=i2c -l layout.txt \
-i r0 -i r1 -i r2 -i r3 -V -w test.bin
flashrom -p internal:bus=i2c -v test.bin

To measure performance impact, a partial read of the EC_RW section
(0x10000 to 0x1ffff) on spring-3833.B firmware was done. The FMAP
for this firmware image is located at 0xcf40 and thus takes many
iterations to find using the binary search algorithm.

Results:
- Full read of all 128KB: ~21.5s
- Partial read of EC_RW using ToT flashrom: ~28.5s
- Partial read with this patch: ~21.9s

Conclusion: ToT flashrom read most of the ROM finding the FMAP and
then re-read the EC_RW section. Using this patch, most of the EC_RW
section was cached and so only a small amount of work was needed
after finding the FMAP.

Change-Id: I534e394bb3ffdf48825960bc8a15d188708db8db
Reviewed-on: https://gerrit.chromium.org/gerrit/49131
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2 weeks agouse read_flash() when searching for fmap header 22/49422/3
David Hendricks [Sat, 27 Apr 2013 02:56:42 +0000 (19:56 -0700)]
use read_flash() when searching for fmap header

read_flash() will soon be used to handle caching which will speed
things up substantially when flashmap is used (ie during partial
reads/writes).

BRANCH=none
BUG=chrome-os-partner:18851
TEST=Tested this patch on Snow. The caching stuff comes later...

Change-Id: I55f1667b7e6f1f3afc8fbd5fd0682d682c7556cb
Reviewed-on: https://gerrit.chromium.org/gerrit/49422
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 weeks agoadd a wrapper for writing to the flash 21/49421/3
David Hendricks [Sat, 27 Apr 2013 02:14:44 +0000 (19:14 -0700)]
add a wrapper for writing to the flash

This adds a wrapper around flash->write() so that higher-level policy
can be implemented for writes. For now this is a trivial wrapper,
but follow-up patches will add some caching logic that will require
this.

BUG=chrome-os-partner:18851
BRANCH=none
TEST=Tested this wrapper on spring. The cachhing stuff comes later.

Change-Id: Iab450509ad26ec3ddd6c6af004c65c6e41fb5c25
Reviewed-on: https://gerrit.chromium.org/gerrit/49421
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
3 weeks agogec: Don't use the pass-through bus; use force mode of i2c 49/49549/2
Doug Anderson [Mon, 29 Apr 2013 23:00:20 +0000 (16:00 -0700)]
gec: Don't use the pass-through bus; use force mode of i2c

On snow we've got a special i2c 'pass through' bus that just creates
an i2c bus that mirrors all commands sent to that bus over to the same
bus that the EC is on.

There are a couple of properties of that bus:

1. Devices on this new bus aren't marked as BUSY by Linux, so you can
   open them without force mode.
2. This new bus can be found by its name, so if you want to find the
   i2c bus that contains the ec then you can search for this bus.

We are planning to remove the 'pass through' bus on snow in kernel 3.8
and redesign it a little on other devices that need to tunnel i2c
commands to other side of the ec.  In preparation, fix flashrom not to
need the i2c pass through bus.  This is done by:

1. Open up the i2c device using "force" mode.  This is really no worse
   than what we were doing before with the pass through but at least
   is straightforward about the fact that we're talking to the EC
   behind the kernel's back.
2. Find the proper bus by looking for the EC device, not the
   pass-through bus.

BUG=chrome-os-partner:18941
BRANCH=snow
TEST=On snow with kernel-next and UPSTREAM cros-ec can read EC with
flashrom -p internal:bus=lpc -r /tmp/ec.bin

Change-Id: I41d4b9cea0b90cb210be8d65f0b8cd1909f0da85
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49549
Reviewed-by: David Hendricks <dhendrix@chromium.org>
3 weeks agoadd missing "break" if fmap is found 20/49420/2 stabilize-4068.0.B
David Hendricks [Wed, 24 Apr 2013 21:51:38 +0000 (14:51 -0700)]
add missing "break" if fmap is found

This adds a missing "break" which caused "no fmap present" to be
displayed even if it were found.

BUG=none
BRANCH=none
TEST=tested on snow

Change-Id: Ib38a835358cabe765d4f8e3182856a8d1508bbd7
Reviewed-on: https://gerrit.chromium.org/gerrit/49420
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
4 weeks agoFix a bug that '-l' option is overriden by fdtmap 72/48472/2 stabilize-4035.0.B
Vic Yang [Thu, 18 Apr 2013 05:07:10 +0000 (13:07 +0800)]
Fix a bug that '-l' option is overriden by fdtmap

The count of romimages shouldn't be cleared. Otherwise the layout read
before that will be lost.

BUG=none
BRANCH=none
TEST=read VBLOCK_A section with/without layout file.

Change-Id: I07439c63e998eee46353d07b473a7eb96e9cc53c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48472
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
5 weeks agosupport building with libftdi 1.0 52/48252/4
Vincent Palatin [Tue, 16 Apr 2013 19:21:01 +0000 (12:21 -0700)]
support building with libftdi 1.0

Update the Makefile to build properly when we have only libftdi 1.0
installed.
libftdi 1.0 has a new pkg-config name and its header is no longer
including standard headers and no longer in the base include directory.

BRANCH=none
BUG=none
TEST=sudo emerge flashrom && emerge-daisy_spring flashrom
with both only libftdi1.0 installed and only libftdi 0.19 installed.

Change-Id: If8c910c44d11b4bd288ba13c55da8d06acdc67e4
Reviewed-on: https://gerrit.chromium.org/gerrit/48252
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
7 weeks agoflashrom: Refactor search code to look for fdtmap and fmap simultaneously 14/47214/3 stabilize-4008.0.B
Simon Glass [Wed, 3 Apr 2013 02:43:29 +0000 (19:43 -0700)]
flashrom: Refactor search code to look for fdtmap and fmap simultaneously

If there is no FDTMAP available in the image, we end up doing an exhaustive
search for it before we try looking for an FMAP. It makes more sense to look
for both at the same time, since we don't expect to have more than one in
the same image.

Adjust the code to handle this.

BUG=chromium:224871
BRANCH=none
TEST=FEATURES=test sudo -E emerge flashrom

Change-Id: I88b1ad47063f14460db8b01923a0f741457e1c09
Reviewed-on: https://gerrit.chromium.org/gerrit/47214
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
7 weeks agoCorrect printf() strings in layout 13/47213/2
Simon Glass [Wed, 3 Apr 2013 03:07:23 +0000 (20:07 -0700)]
Correct printf() strings in layout

These parameters are long ints, so should use %lx.

BUG=none
BRANCH=none
TEST=FEATURES=test sudo -E emerge flashrom

Change-Id: Ie7c9f02be9ecb451a468d9f1f757f5eca0b4bfce
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47213
Reviewed-by: David Hendricks <dhendrix@chromium.org>
7 weeks agoAdd CONFIG_FDTMAP to read flashmap from FDT 10/43010/12
Simon Glass [Mon, 11 Feb 2013 01:00:38 +0000 (17:00 -0800)]
Add CONFIG_FDTMAP to read flashmap from FDT

Chrome OS uses a more powerful flashmap format with support for compression,
description of each section and so on. Flashrom doesn't really need this
information - it just need a section name and start/size. But by making
flashrom understand the Chrome OS format natively, we can avoid having
two copies of the flashmap in the image, with the confusion of which is
correct.

Add a new config for this option and implement it using libfdt and some
simple code from U-Boot.

BUG=chromium-os:38794
BRANCH=none
TEST=Just build it:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom

Then run the unit tests:

 * Running flashrom unit tests
Testing fdtmap
dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.
----------------------------------------------------------------------
Ran 6 tests in 14.639s

OK

Change-Id: I52044515f4fb95368d5cc4b44a51543d354f1f46
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43010

2 months agoMove flash search code into a separate file (2nd attempt) 76/45276/6 release-R27-3912.B stabilize-3912.79.B toolchainA
Simon Glass [Mon, 4 Mar 2013 23:34:46 +0000 (15:34 -0800)]
Move flash search code into a separate file (2nd attempt)

At present we have an algorithm which searches through the flash looking
for an FMAP signature. We want to use it to search for other things also,
such as an FDTMAP.

Move this useful algorithm into its own module, and adjust the API so that
callers can repeatedly call it and it will return a new offset to check,
each time. Then adjust the fmap code to use this new function.

Note: This is a re-hash of Simon's original CL. This version uses
read_flash() to avoid aborting prematurely due to searching locked
regions on Intel platforms with a management engine.

BUG=chromium-os:38794
BRANCH=none
TEST=Partial read of FRID region on Stumpy, observed ME region access
     errors being ignored.

Change-Id: I344ae9998ae65cc45b8b35024adb4bd224571814
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45276

2 months agofix get_crossystem_fmap_base() for shadow ROM vs. physical ROM 63/45263/4
David Hendricks [Tue, 12 Mar 2013 21:35:02 +0000 (14:35 -0700)]
fix get_crossystem_fmap_base() for shadow ROM vs. physical ROM

Early x86 Chrome OS platforms exposed the fmap_base as the region in
shadow ROM (in host memory address space). For portability reasons,
and due to overlapping BIOS/EC areas in shadow ROM, we stopped relying
on shadow ROM and now describe fmap_base in terms of physical ROM
offset. This broke the sanity check, however the fallback method
continued to work thus masking this problem.

BRANCH=none
BUG=chromium-os:39818
TEST=Tested on Alex (which uses shadow ROM offset) and Butterfly
     (which uses physical ROM offset)

Change-Id: I5f5405b714819a5ff0797d6709eaf6cff340fd99
Reviewed-on: https://gerrit.chromium.org/gerrit/45263
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 months agoadd read_flash() to do error handling for flash->read() 07/46207/5
David Hendricks [Fri, 22 Mar 2013 00:23:29 +0000 (17:23 -0700)]
add read_flash() to do error handling for flash->read()

This adds read_flash() which acts as a wrapper around flash->read().
Its purpose is to make high-level decisions such as what to do in
case of an error.

When applicable, flash->read() call sites are updated to use this
wrapper in order to simplify the code.

BUG=chromium-os:38794
BRANCH=none
TEST=tested by doing partial read on Stumpy (with ME region locked),
     saw verbose output indicating ME region access error ignored

Change-Id: I4fe2a9a88d874783fbc1007f44434f7fafd08874
Reviewed-on: https://gerrit.chromium.org/gerrit/46207
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2 months agoRevert "Move flash search code into a separate file" 84/45184/2 factory-spring-3842.B firmware-spring-3833.B stabilize-3881.0.B
David Hendricks [Tue, 12 Mar 2013 05:41:54 +0000 (22:41 -0700)]
Revert "Move flash search code into a separate file"

This reverts commit 5ef86f092292d4d35e023c852935679ce1c5defc

Change-Id: I5bb5e99ca77a93b87b5e57175af5ad93536dc931
See: https://code.google.com/p/chromium-os/issues/detail?id=39818
Reviewed-on: https://gerrit.chromium.org/gerrit/45184
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 months agoMove flash search code into a separate file 79/44579/3 firmware-spring-3824.4.B firmware-spring-3824.B
Simon Glass [Mon, 4 Mar 2013 23:34:46 +0000 (15:34 -0800)]
Move flash search code into a separate file

At present we have an algorithm which searches through the flash looking
for an FMAP signature. We want to use it to search for other things also,
such as an FDTMAP.

Move this useful algorithm into its own module, and adjust the API so that
callers can repeatedly call it and it will return a new offset to check,
each time. Then adjust the fmap code to use this new function.

BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom
Also test flashrom on snow (flashrom -i gbb -r test.bin, to make sure it
can access sections)

Change-Id: I3c8b84a45c05719cc9536f43e324e9f82542181e
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44579
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 months agoRevert "fmap: Export the signature-finding algorithm" 78/44578/2
Simon Glass [Mon, 4 Mar 2013 23:30:10 +0000 (15:30 -0800)]
Revert "fmap: Export the signature-finding algorithm"

Actually, since we now need to deal with CRC32 in the FDTMAP case, this
exporting is no use. So choose a different approach.

BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom
This reverts commit 0382d05bb208dbeced1870dea4eba3d19264f418.

Change-Id: Icdedcad453566eddfa18239b24cbc409a403060a
Reviewed-on: https://gerrit.chromium.org/gerrit/44578
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
2 months agoAdd support for Lynx Point chipsets. 81/44281/2
Duncan Laurie [Thu, 28 Feb 2013 17:42:07 +0000 (09:42 -0800)]
Add support for Lynx Point chipsets.

This is the chipset used for Haswell systems.  The mobile/desktop
version of the chipset is not much changed from before, although
it does finally drop FWH support.

The Low Power variant of the chipset used in ULT systems has
more changes, including reducing the BBS field to 1 bit.

BUG=chrome-os-partner:18067
BRANCH=none
TEST=manual: update BIOS with flashrom on wtm2 board

Change-Id: I303a05baa80e4449e70d20adf78ebc7128b88d8e
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44281
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 months agoAdd support for Macronix MX25U3235 95/44395/4
Vincent Palatin [Thu, 28 Feb 2013 23:46:14 +0000 (15:46 -0800)]
Add support for Macronix MX25U3235

Macronix MX25U3235 is a 4MB (32Mbits) 1.8v SPI flash supporting QPI.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:18084
TEST=flash reworked spring board through servo and boot it :
sudo flashrom -p ft2232_spi:type=servo-v2 -w nv_image-spring.bin
on the board, read/write firmware :
flashrom -r current_image.bin / flashrom -w current_image.bin
test the write protect :
$ dut-control fw_wp_en:on fw_wp_vref:pp1800 fw_wp:on

crossystem wpsw_cur -> 1
flashrom --wp-status -> disabled, range clear
flashrom --wp-range 0x200000 0x200000
flashrom --wp-status -> range set
flashrom --wp-enable
flashrom --wp-status -> enabled
flashrom --wp-disable -> fail
flashrom --wp-range 0 0 -> fail
flashrom --wp-status -> range set, enabled

$ dut-control fw_wp_en:off fw_wp_vref:off fw_wp:off

crossystem wpsw_cur -> 0
flashrom --wp-disable
flashrom --wp-range 0 0
flashrom --wp-status -> disabled, range clear

Change-Id: I62c7db070254ba3ec68090e783f57b25a6e8d15a
Reviewed-on: https://gerrit.chromium.org/gerrit/44395
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>

2 months agoUPSTREAM: Update Macronix MX25L512, MX25L1005, MX25L2005, MX25L4005, MX25L8005. 94/44394/2
Vincent Palatin [Thu, 28 Feb 2013 22:31:12 +0000 (14:31 -0800)]
UPSTREAM: Update Macronix MX25L512, MX25L1005, MX25L2005, MX25L4005, MX25L8005.

Update MX25L512 with references to and data about
  MX25L512E, MX25V512, MX25V512C.
Update MX25L1005 with references to and data about
  MX25L1005C, MX25L1006E.
Update MX25L2005 with references to and data about
  MX25L2005C.
Update MX25L4005 with references to and data about
  MX25L4005A, MX25L4005C.
Update MX25L8005 with references to and data about
  MX25V8005.

Bonus: add chip IDs of MX25U1635E, MX25U3235E/F, MX25U6435E/F.

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
from flashrom upstream commit r1647 by stefanct on 2013-02-02 07:35:44 -0800

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:18084
TEST=sudo emerge flashrom

Change-Id: I092d98a7e294ac51f76875fcb95601fc4ee12957
Reviewed-on: https://gerrit.chromium.org/gerrit/44394
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
3 months agofmap: Export the signature-finding algorithm 09/43009/5
Simon Glass [Mon, 11 Feb 2013 01:05:33 +0000 (17:05 -0800)]
fmap: Export the signature-finding algorithm

We want to be able to look for signatures other than FMAP, so split this
function into two parts and export both. The functionality of fmap_find()
remains the same.

Signed-off-by: Simon Glass <sjg@chromium.org>
BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
1. Build it:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom

2. Use flashrom on snow to read and write part of the image.

Change-Id: I9ad0be33435f042841655f4ddb9053efe08c513c
Reviewed-on: https://gerrit.chromium.org/gerrit/43009
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
3 months agoRemove tegra2_spi driver 07/43007/4
Simon Glass [Sun, 10 Feb 2013 17:41:05 +0000 (09:41 -0800)]
Remove tegra2_spi driver

This is generating warnings so may not work. Also it directly accesses
hardware from within Linux which is not great. It really should use spidev.

We don't need this at present - if it is needed in the future it can use
the spidev support. So I suggest we remove it.

BUG=none
BRANCH=none
TEST=emerge-daisy flashrom

Change-Id: Ia901cb90ed1e093f87b493324e2fb0c3556abc9c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43007

3 months agolinux_spi: Fix compiler warning for unchecked return value 11/43011/4
Simon Glass [Mon, 11 Feb 2013 01:13:41 +0000 (17:13 -0800)]
linux_spi: Fix compiler warning for unchecked return value

The system() commands should print an error if they fail. Add this.

BUG=none
BRANCH=none
TEST=build flashrom, see tha the warnings are gone
Run flashrom and read/write a section on snow; see that it still
works correctly (snow uses spidev).

Change-Id: I01ac2a5d7508ae0bbd541cdffc8bc61e9b56d3c1
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43011

4 months agoStop managing powerm process. 70/41570/2 release-R26-3701.B stabilize-3658.0.0 stabilize-3701.30.0 stabilize-3701.30.0b stabilize-3701.46.B stabilize-3701.81.B stabilize-bluetooth-smart toolchain-3701.42.B
Daniel Erat [Thu, 17 Jan 2013 21:49:59 +0000 (13:49 -0800)]
Stop managing powerm process.

The powerm process doesn't do anything anymore and will be
removed soon.

BRANCH=none
BUG=chromium-os:36804
TEST=locally compiled

Change-Id: I7f8471595b35113d55d879e9067930b9e3512b55
Reviewed-on: https://gerrit.chromium.org/gerrit/41570
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
4 months agofix some compiler warnings in writeprotect.c 30/40030/5 factory-3536.B
David Hendricks [Tue, 30 Oct 2012 18:37:57 +0000 (11:37 -0700)]
fix some compiler warnings in writeprotect.c

This fixes some errors which cause manual compilation to fail.

BRANCH=none
BUG=none
TEST=locally compiled

Change-Id: I89717a8ed89765bea0e90a05452f9047779c1d37
Reviewed-on: https://gerrit.chromium.org/gerrit/40030
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

4 months agofix some compiler warnings in gec.c 31/40031/3
David Hendricks [Tue, 30 Oct 2012 18:39:12 +0000 (11:39 -0700)]
fix some compiler warnings in gec.c

This fixes some errors which cause manual compilation to fail.

BRANCH=none
BUG=none
TEST=locally compiled

Change-Id: I1e408b0766afefa1f9f09d4883453e7241de0c5c
Reviewed-on: https://gerrit.chromium.org/gerrit/40031
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
7 months agocache result of SPI probe functions release-R25-3428.B stabilize-3428.110.0 stabilize-3428.149 stabilize-3428.149.B stabilize-3428.193 stabilize2 toolchain-3428.65.B
David Hendricks [Fri, 12 Oct 2012 00:15:48 +0000 (17:15 -0700)]
cache result of SPI probe functions

This implements a simple means of caching probe results from REMS
and RDID (3 and 4-byte versions) commands. This makes probing of
SPI ROMs slightly faster (~10-50ms) depending on which
programmer is being used.

This also factors out some common code used for RDID3/4 and REMS
functions.

BRANCH=none
BUG=chromium-os:34601
TEST=Tested on Lumpy host firmware ROM with and without the delay
     loop, IDs shown in verbose output were identical

Change-Id: I71cd2b0c8c6017760a1ed52237e203076092cd9e
Reviewed-on: https://gerrit.chromium.org/gerrit/35376
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
7 months agoAlways initialize broken_timer to 0
David Hendricks [Thu, 27 Sep 2012 05:09:26 +0000 (22:09 -0700)]
Always initialize broken_timer to 0

This fixes a regression that causes broken_timer to be set to 1 for
all types of operations (including "short" ones like --wp-status).
broken_timer should only be set explicitly by "long" operations if
CONFIG_USE_OS_TIMER is set to 0.

BRANCH=none
BUG=none
TEST=Tested on Lumpy

Change-Id: If5f206bfa7193f885ed05ed1289d416043db5063
Reviewed-on: https://gerrit.chromium.org/gerrit/34170
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
7 months agoAdd additional W25Q functions and write-protect modes
David Hendricks [Wed, 3 Oct 2012 18:03:48 +0000 (11:03 -0700)]
Add additional W25Q functions and write-protect modes

This adds basic support for secondary status register read
on W25Q. All supported chips up to this point have used
older W25-series flash chips as a template and do not necessarily
support the same features as W25Q.

Since we are now examining the SRP1 bit, additional functions
were added for write-protect enable and status operations. The
--wp-enable command-line option has been augmented with an optional
argument to take advantage of additional modes that are now available:

--wp-enable=hardware    - WP controlled by hardware pin (default)
--wp-enable=power_cycle - WP enabled until power off/on cycle
--wp-enable=permanent   - Status registers permanently locked,
                          WP permanently held in current state.

BRANCH=stout
BUG=chrome-os-partner:14726
TEST=Tested power_cycle mode on stout (see notes below), regression
tested on Lumpy

1. Set WP range and --wp-enable=power_cycle. --wp-status shows WP
   enabled.
2. Attempt to overwrite to protected range failed.
3. Remove power and then re-insert power.
4. --wp-status shows WP disabled (range still set)
5. Attempt to overwrite to same range succeeded

Change-Id: I4d03897f6b56378affe676f800cd3b4d14cd8687
Reviewed-on: https://gerrit.chromium.org/gerrit/35084
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
7 months agoit8518: set WDT reset flag when writing ROM content (for Stout) factory-2993.B factory-3004.B
David Hendricks [Thu, 27 Sep 2012 23:39:37 +0000 (16:39 -0700)]
it8518: set WDT reset flag when writing ROM content (for Stout)

This patch adds an it8518 hack that will examine the SPI opcode to
determine if it will change ROM content and, if so, will use 0xd8
instead of 0xdd. This will cause the EC to set a flag indicating
that a watchdog reset should be done after the update.

FIXME: This is a pretty awful hack. The long-term solution is for
Flashrom to become more aware of its platform so we can apply this
stuff on a per-platform basis instead of a per-chip basis. That will
also allow us to choose the appropriate commands from the start of
execution rather than changing commands in-flight.

BRANCH=none
BUG=chrome-os-partner:14578
TEST=Regression tested on Cr48, Stout notes below

1. Write to unused space:
cp stout_ec.img stout_ec_modified.img
dd if=/dev/urandom of=stout_ec_modified.img bs=1k seek=192 count=832
flashrom -p internal:bus=lpc -w stout_ec_modified.img -V

Fan spins up and input is blocked as we see content being overwritten.
System returns to usable state afterward. In verbose log we see that
the copy_to_sram_cmd gets changed from its default once.

2. Read only:
Fan spins up, input blocked for a few seconds, read successful,
system returns to usable state, copy_to_sram_cmd is unchanged.

3. Checking write-protection
Input blocked momentarily, read successful, system returns to
usable state, copy_to_sram_cmd is unchanged.

Change-Id: I66325dc7d3f296c6755c1bc8768da1c859839ba2
Reviewed-on: https://gerrit.chromium.org/gerrit/34246
Reviewed-by: Shawn Nematbakhsh_ <shawnn@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
7 months agokb94x: enter/exit idle mode gracefully factory-2985.B
agnescheng [Wed, 26 Sep 2012 04:33:35 +0000 (12:33 +0800)]
kb94x: enter/exit idle mode gracefully

BRANCH=butterfly
ENE EC KB94X has hw limitation on WDT(maximum: 32 secs), which also
causes an interrupt at the 16th secs to wakeup EC from idle mode. This patch
implements a timer to exit idle mode when exceeding 12 secs -- EC would
be woke up by 64h port command and re-enter idle mode to continue EC ROM
reading.

BUG=chrome-os-partner:13986
TEST=manual
  VT2 console commands:
      flashrom -p internal:bus=lpc --wp-status
      flashrom -p internal:bus=lpc -r ec_bios.bin
  The fan should not spin up.

Change-Id: I449902af2afecb98cad0ef87d06264012d399edd
Reviewed-on: https://gerrit.chromium.org/gerrit/34096
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Agnes Cheng <agnescheng@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

7 months agoRevert "it85xx: add IRQ disable/enable hack for Stout"
David Hendricks [Fri, 21 Sep 2012 21:46:41 +0000 (14:46 -0700)]
Revert "it85xx: add IRQ disable/enable hack for Stout"

This reverts commit 36b8c992c4cf0280081a4c663644d46ceab2df32

Turns out the vendor fixed the underlying issue in the EC firmware, so this is no longer needed.

Change-Id: I4d5caeaedb7225412ce6a8aba40c40d75f9f7cba
Reviewed-on: https://gerrit.chromium.org/gerrit/33806
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
8 months agoit85xx: add IRQ disable/enable hack for Stout
David Hendricks [Fri, 21 Sep 2012 05:50:36 +0000 (22:50 -0700)]
it85xx: add IRQ disable/enable hack for Stout

This adds a hack to detect if we're running on Stout and, if so,
disable IRQs before doing anything and then re-enabling them at
the end.

The code flow is kind of weird since the return code for entering/
exiting scratch mode are typically ignored (!). So rather than
managing the IRQs around it85xx_{enter,exit}_scratch_rom, this
disables IRQs when we're initializing or EC and re-enabls them when
we're done with everything (it85xx_shutdown).

FIXME: This still needs some work to make it less hacky and reduce
UI jank.

BRANCH=none
BUG=chrome-os-partner:14081
TEST=EC flash read 10 times while mashing keyboard, machine remained
usable afterward (though unresponsive during the actual read)

Change-Id: Idd0cd2bcf5b595eece251ea243bd1d5a565a87e2
Reviewed-on: https://gerrit.chromium.org/gerrit/33757
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
8 months agoenable dmi_init() and force laptop_ok = 1
David Hendricks [Fri, 21 Sep 2012 05:21:54 +0000 (22:21 -0700)]
enable dmi_init() and force laptop_ok = 1

This enables DMI table scanning so we can use DMI info to apply board-
specific hacks.

It also sets laptop_ok to 1. This will go away once we have proper
laptop whitelisting enabled (hopefully next time we merge with
upstream).

BRANCH=none
BUG=chrome-os-partner:14081
TEST=Tested EC and SPI flash read on on cr48, zgb, alex, lumpy,
parrot, butterfly, and stout to ensure no unexpected DMI-related
warnings showed up.

Change-Id: I1d5048303c70995f6f4247ad819486ba704c5da5
Reviewed-on: https://gerrit.chromium.org/gerrit/33756
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
8 months agoDon't run the latest firmware copy after GEC is updated.
Louis Yung-Chieh Lo [Thu, 20 Sep 2012 02:39:35 +0000 (10:39 +0800)]
Don't run the latest firmware copy after GEC is updated.

Since the software sync is landed, we should leave the BIOS to decide
which EC firmware copy to run.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chromium-os:34594
TEST=build in chroot only.

Change-Id: Id599804383eaa0d52c8554aaebcba3559630f481
Reviewed-on: https://gerrit.chromium.org/gerrit/33664
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agoSupport write protection of A25L040. factory-2914.B
Louis Yung-Chieh Lo [Mon, 17 Sep 2012 09:38:35 +0000 (17:38 +0800)]
Support write protection of A25L040.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chrome-os-partner:14084,
TEST=on butterfly
flashrom -p internal:bus=lpc --wp-list
flashrom -p internal:bus=lpc --wp-status  # disabled, 0, 0
flashrom -p internal:bus=lpc --wp-range 0x40000 0x40000
flashrom -p internal:bus=lpc --wp-enable
flashrom -p internal:bus=lpc --wp-status  # enabled, 0x40000, 0x40000
flashrom -p internal:bus=lpc --wp-disable

Change-Id: I8c2d1281babefba8ce8640781301307eb1abc827
Reviewed-on: https://gerrit.chromium.org/gerrit/33422
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agoReturn error of write protection is not supported.
Louis Yung-Chieh Lo [Mon, 17 Sep 2012 09:52:20 +0000 (17:52 +0800)]
Return error of write protection is not supported.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chromium-os:34430
TEST=on butterfly (with an A25L040 flash chip).
flashrom -p internal:bus=lpc --wp-status  # expect Error and returns 1

Change-Id: I960a86082f99546c32893f9113f57a5d891082e0
Reviewed-on: https://gerrit.chromium.org/gerrit/33426
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agoFix a bug of gec_i2c protocol v2 (e06fcaa).
Louis Yung-Chieh Lo [Tue, 11 Sep 2012 05:02:01 +0000 (13:02 +0800)]
Fix a bug of gec_i2c protocol v2 (e06fcaa).

The error return value (ret) is always overwritten by response length.
Fix it by early-return.

BUG=chrome-os-partner:13908,
BRANCH=None
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
TEST=On snow,
% flashrom -p internal:bus=lpc -w another_ec.bin   # PASS
% flashrom -p internal:bus=lpc --wp-list           # PASS

Change-Id: I2086663d8034d5b0906c6b74ddb07166ea7b18d6
Reviewed-on: https://gerrit.chromium.org/gerrit/32901
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agogec: Apply gec_lock for i2c too.
Louis Yung-Chieh Lo [Thu, 6 Sep 2012 06:59:49 +0000 (14:59 +0800)]
gec: Apply gec_lock for i2c too.

gec_i2c.c would configure ioctl in multiple places. This could lead race-
condition if multiple programs are running at the same time. Thus, add a
semaphore to protect it.

Also fix a nit in gec_lpc.c.

BRANCH=snow
BUG=chrome-os-partner:12207
TEST=build only.
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I5a229392368e3d62f378b2755ec5415940652e76
Reviewed-on: https://gerrit.chromium.org/gerrit/32368
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
8 months agoAdd flashrom support for GD25Q64 SPI ROM.
Shawn Nematbakhsh [Sun, 2 Sep 2012 04:58:03 +0000 (21:58 -0700)]
Add flashrom support for GD25Q64 SPI ROM.

Add support for GD family of SPI ROMs. Taken from upstream change r1520.
Write protect geometry table added for GD25Q64 only.

BUG=chrome-os-partner:12103
TEST=flashrom read/write/wp operations on GD25Q64 device.
BRANCH=butterfly

Change-Id: I0f2b538c44f67c38d49920a8c852e17d271d91ff
Reviewed-on: https://gerrit.chromium.org/gerrit/32097
Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agoGEC i2c upgrades protocol to v2.
Louis Yung-Chieh Lo [Thu, 30 Aug 2012 06:45:25 +0000 (14:45 +0800)]
GEC i2c upgrades protocol to v2.

(Not urgent. Not going to cherry-pick.)

There are 2 kinds of version in the EC interface and I mixed up them.

In original code, protocol v2 is used only for command v1. However, this
is not enough because some v0 commands, like EC_CMD_GET_BUILD_INFO, need
the protocol v2 for variable-length response.

So, let's go protocol v2 anyway.

BUG=chrome-os-partner:12636,
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
TEST=on snow, and both command v0/v1 are working on protocol v2.
flashrom -p internal:bus=lpc -r /tmp/ec.bin  ; command v0
flashrom -p internal:bus=lpc --wp-list       ; command v1
flashrom -p internal:bus=lpc --wp-status     ; command v1

Change-Id: I1899c71b9232184564eb641b49ae0011b3e45d04
Reviewed-on: https://gerrit.chromium.org/gerrit/31839
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
8 months agoRevert "According to FMAP spec, it should be aligned to 64-byte." factory-2846.B factory-2848.B
Louis Yung-Chieh Lo [Wed, 29 Aug 2012 08:11:31 +0000 (16:11 +0800)]
Revert "According to FMAP spec, it should be aligned to 64-byte."

This reverts commit 2fc49b13d3e2fbe5db162e35bb483e76c66b1490.

BUG=chromium-os:33963,
TEST=None
BRANCH=None

Change-Id: Ibfa95baa726e31e8bded0b753b2cbee126ef4f76
Reviewed-on: https://gerrit.chromium.org/gerrit/31689
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
8 months agoAccording to FMAP spec, it should be aligned to 64-byte. firmware-stout-2817.B
Louis Yung-Chieh Lo [Mon, 27 Aug 2012 08:25:34 +0000 (16:25 +0800)]
According to FMAP spec, it should be aligned to 64-byte.

BUG=chrome-os-partner:13143
TEST=local build only
BRANCH=link,snow

Change-Id: I6e927a52d5296e3d7d9315781b6c7aeeb7594efe
Reviewed-on: https://gerrit.chromium.org/gerrit/31450
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
8 months agoImprove --wp-enable for link and snow.
Louis Yung-Chieh Lo [Fri, 24 Aug 2012 06:12:21 +0000 (14:12 +0800)]
Improve --wp-enable for link and snow.

On link, we didn't take effect of RO_NOW immediately. This CL enables
RW_NOW beside RO_AT_BOOT.

On snow, the RO_NOW is not supported, thus we use ALL_NOW instead.

BUG=chrome-os-partner:12951
BRANCH=link,snow
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I70e2e716c583717f8d719838ccb2225bc74f3085
TEST=tested on link and snow:
;
; assert WP pin
;
flashrom -p internal:bus=lpc --wp-status   ; is disabled
flashrom -p internal:bus=lpc --wp-enable   ; expect SUCCESS
flashrom -p internal:bus=lpc --wp-range \  ; ("0 0x10000" for snow)
                                0 0x14000  ; expect SUCCESS
flashrom -p internal:bus=lpc --wp-disable  ; expect FAILED
;
; host shutdown
; on snow, this leads the EC cold reset.
;
flashrom -p internal:bus=lpc --wp-status   ; expect still enabled
                                           ; expect the EC console shows
                                           ; the RW is NOT protected.
;
; deassert WP pin and host reboot
;
flashrom -p internal:bus=lpc --wp-status   # enabled, but range is (0,0)
flashrom -p internal:bus=lpc --wp-disable  # expect SUCCESS
flashrom -p internal:bus=lpc --wp-status   # expect disabled
Reviewed-on: https://gerrit.chromium.org/gerrit/31321
Reviewed-by: David Hendricks <dhendrix@chromium.org>
8 months agogec: add wait mechanism for in-progress commands
David Hendricks [Sat, 18 Aug 2012 04:14:48 +0000 (21:14 -0700)]
gec: add wait mechanism for in-progress commands

The EC can now indicate that a command has been accepted and is
in-progress. This was recently enabled for the flash write command:
https://gerrit.chromium.org/gerrit/#/c/30471/

This adds a retry mechanism which checks the status of the previous
command issued after an expected delay period for that command.

BRANCH=snow
BUG=none
TEST=tested on Snow using ToT EC image

Change-Id: I0c4522b351d84c13ff6873ceb85b1dce37b52efd
Reviewed-on: https://gerrit.chromium.org/gerrit/30801
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
9 months agoSwitch ENE to write mode on WREN and EWSR command firmware-butterfly-2788.B
Rong Chang [Sat, 18 Aug 2012 16:40:49 +0000 (00:40 +0800)]
Switch ENE to write mode on WREN and EWSR command

ENE EC need to switch from idle mode to reset mode on flash write.
The mode switching clears SPI rom write enable. Hence WREN and EWSR
should be added to erase/write detection.

BRANCH=parrot
BUG=chrome-os-partner:12501
TEST=manual: flashrom -p internal:bus=lpc -w ec_image.bin
  no warning/error message on sector erase
  flashrom does not try block erase

Change-Id: Ic1b7ed32d2dcfcf696673ba0bd43dc9add9865f9
Reviewed-on: https://gerrit.chromium.org/gerrit/30822
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
9 months agoupdate EC commands header
David Hendricks [Fri, 17 Aug 2012 23:01:32 +0000 (16:01 -0700)]
update EC commands header

BRANCH=snow,link
BUG=none
TEST=locally compiled

Change-Id: Ia2f98f9527ce3c3f48612ae3dd2447f4c7663511
Reviewed-on: https://gerrit.chromium.org/gerrit/30800
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
9 months agogec_i2c should return negative value for error.
Louis Yung-Chieh Lo [Fri, 17 Aug 2012 09:34:10 +0000 (17:34 +0800)]
gec_i2c should return negative value for error.

BUG=None
TEST=Build only
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I17e2a5ca01a87293e7595e1c4f9e943bcb922a07
Reviewed-on: https://gerrit.chromium.org/gerrit/30680
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agoFix a bug of checking return value of priv->ec_command().
Louis Yung-Chieh Lo [Thu, 16 Aug 2012 05:33:36 +0000 (13:33 +0800)]
Fix a bug of checking return value of priv->ec_command().

In the EC API v1, the return value of ec_command has been redefined:
< 0, failed
>=0, success

Most of code has been refined, but missed one.

BUG=chrome-os-partner:12716
TEST=tested on link.
flashrom -p internal:bus=lpc -w two_different_ec_images.
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: Ib713ba361d4509e20419dde7e06b054f2e3c8778
Reviewed-on: https://gerrit.chromium.org/gerrit/30520
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
9 months agoadd Carl-Daniel to copyright line
David Hendricks [Wed, 15 Aug 2012 22:23:12 +0000 (15:23 -0700)]
add Carl-Daniel to copyright line

The SVN portions of this script were derived from the mainstream
Makefile, although modified and rearranged pretty significantly.
In any case, it's fair to add Carl-Daniel to the authors.

BUG=none
TEST=none

Change-Id: I90b35e69bb0fecfd4a26895ef559d43a0870d5f2
Reviewed-on: https://gerrit.chromium.org/gerrit/30474
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 months agoSupport write protection (again).
Louis Yung-Chieh Lo [Mon, 13 Aug 2012 09:21:01 +0000 (17:21 +0800)]
Support write protection (again).

BUG=chrome-os-partner:11219
TEST=tested on link and snow:
F="flashrom -p internal:bus=lpc "
$F --wp-status            ; disabled
$F --wp-list              ; ranges supported by the EC chip
$F --wp-enable 11 22      ; random address, expect failed
$F --wp-enable 0 0x14000  ; enabled
$F --wp-enable 0 0        ; disabled
$F --wp-enable 0 0x14000  ; re-enabled again
$F --wp-disable           ; disabled again

Change-Id: I2520ea0d969338ae1d5889f54f9fa1839bbf5397
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29981
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agoUpgrade to Google EC API v1 (re-send).
Louis Yung-Chieh Lo [Mon, 30 Jul 2012 10:20:39 +0000 (18:20 +0800)]
Upgrade to Google EC API v1 (re-send).

Basically this is a re-send of 1c4b784 (which is reverted in cf6e3a3),
but added extra code:

1. add an extra wait_for_ec() before outb(cmd) in v1 API.

2. don't jump if EC is running the target copy. This is to fix the bug
   that REBOOT_EC would response 2 SUCCESSes.

3. upgrade i2c to v1 as well.

4. fix a bug in original CL that forgets to negative resp_buf[0] for
   return value.

BUG=chrome-os-partner:11320
TEST=build and tested on link and snow:
F="flashrom -p internal:bus=lpc -V "
for i in `seq 0 19`; do
        $F -w ec.bin.1 || exit 1
        $F -w ec.bin.2 || exit 2
done

Change-Id: I9a1364dcbcb8e9006b9b61fd72c20491900c5a12
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29874
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agoProbe ITE SuperIO/ECs conditionally
David Hendricks [Sat, 4 Aug 2012 00:38:48 +0000 (17:38 -0700)]
Probe ITE SuperIO/ECs conditionally

This forces ITE ECs and SuperIOs to be probed only if the user
specifies bus=lpc.

BUG=chrome-os-partner:12107
TEST=Tested on Stout and Mario (Cr48)

Change-Id: I446cc5b690f235b6617adcea28c9efea134fac28
Reviewed-on: https://gerrit.chromium.org/gerrit/29229
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
9 months agoAdd GEC lock mechanism.
Louis Yung-Chieh Lo [Thu, 9 Aug 2012 15:11:32 +0000 (23:11 +0800)]
Add GEC lock mechanism.

Basically re-use the big lock mechanism, but change the key value.

BUG=chrome-os-partner:12319
TEST=build and test on link.  Only build on snow.
flashrom -p internal:bus=lpc -r /tmp/1 &
flashrom -p internal:bus=lpc -r /tmp/2 &
Reading SUCCESS. /tmp/1 and /tmp/2 are identical.

Change-Id: I8b4ab2f1b84a4d6252951b0e9133da3e2f8ce47e
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29762
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agoupdate license header for ipc_lock.*
David Hendricks [Thu, 9 Aug 2012 23:23:48 +0000 (16:23 -0700)]
update license header for ipc_lock.*

These sholud've been included in the previous CL for big_lock.*.

BUG=none
TEST=none

Change-Id: I23d0a4b3a2e2b9f570f9ef44809f0a2b361bd157
Reviewed-on: https://gerrit.chromium.org/gerrit/29835
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 months agoupdate license header for big_lock
David Hendricks [Thu, 9 Aug 2012 18:05:20 +0000 (11:05 -0700)]
update license header for big_lock

The big lock was originally intended to be dual-licensed BSD/GPLv2
as part of mosys. It was later re-licensed as plain 'ol BSD to
simplify things. Note: the csem.* files have always been plain BSD-
licensed.

BUG=none
TEST=none

Change-Id: Ic8846afd4fd9cc0526044af00a474895d9dda2ff
Reviewed-on: https://gerrit.chromium.org/gerrit/29779
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 months agoflashrom: add an option to ignore big lock
Shik Chen [Tue, 7 Aug 2012 09:51:42 +0000 (17:51 +0800)]
flashrom: add an option to ignore big lock

Add an option to ignore big lock if we want to flashrom to two devices
simultaneously.

BUG=chrome-os-partner:12335
TEST=Simultaneously flashrom to two devices through servo.
     If used in original way, it still works.

Change-Id: I9aba07fc63472f3217a3c3bc6799c3aa16789e0d
Reviewed-on: https://gerrit.chromium.org/gerrit/29407
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Shik Chen <shik@chromium.org>
Tested-by: Shik Chen <shik@chromium.org>
9 months agoMake broken_timer flag configurable during compilation
David Hendricks [Mon, 6 Aug 2012 21:42:26 +0000 (14:42 -0700)]
Make broken_timer flag configurable during compilation

This patch allows the broken_timer option to be set via a CONFIG
variable that can be set on the command-line (and hence as a USE
flag). This will allow us to set the option according to board.

Related ebuild change: https://gerrit.chromium.org/gerrit/#/c/29326/

BUG=chrome-os-partner:12292
TEST=Built for Daisy/Snow, regression tested for Alex and Stumpy

Change-Id: I2b7988ccc92d94d90d37d9516645671e8165d93a
Reviewed-on: https://gerrit.chromium.org/gerrit/29327
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

9 months agoft2232: add an option to specify serial number
Shik Chen [Tue, 7 Aug 2012 07:09:37 +0000 (15:09 +0800)]
ft2232: add an option to specify serial number

When we have two servo board connected, we need to have an option to
specify the device.

BUG=chrome-os-partner:12329
TEST=Specify serial number and check we can flash firmware.
     If used in original way, it still works.

Change-Id: Ic11d97e80f750fa3d973b469623e241adef11c71
Reviewed-on: https://gerrit.chromium.org/gerrit/29397
Commit-Ready: Shik Chen <shik@chromium.org>
Tested-by: Shik Chen <shik@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
9 months agostub out write-protection commands for GEC. factory-2717.B
Louis Yung-Chieh Lo [Mon, 6 Aug 2012 11:10:39 +0000 (19:10 +0800)]
stub out write-protection commands for GEC.

Modify from david's CL https://gerrit.chromium.org/gerrit/#/c/25957/1,
but generalize to all platform since the EC has changed the API version
and unfortunately the flashrom is not ready yet.

The bad thing is the factory process is broken so that we need this
temporary hack to continue the factory test.

This should be fixed before MP (tracked in issue tracker already).

BUG=chrome-os-partner:11320,chrome-os-partner:11219
TEST=run on link.
; WP pin is asserted.
flashrom -p internal:bus=lpc --wp-status
flashrom -p internal:bus=lpc --wp-range 0x123456 0x789a
flashrom -p internal:bus=lpc --wp-enable
flashrom -p internal:bus=lpc --wp-status
flashrom -p internal:bus=lpc --wp-disable  # FAIL, expected
flashrom -p internal:bus=lpc --wp-status
; WP pin is de-asserted
flashrom -p internal:bus=lpc --wp-disable
flashrom -p internal:bus=lpc --wp-set-range
flashrom -p internal:bus=lpc --wp-status

Change-Id: Ifec93f83fb06ed687a60a7cd01eee0b52c678255
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29271
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agofix insize for gec_command_i2c
David Hendricks [Fri, 3 Aug 2012 20:10:41 +0000 (13:10 -0700)]
fix insize for gec_command_i2c

A long time ago, GEC commands that did not expect a response payload
only sent back 1 byte (error code). EC change 8a64004 simplified
the host_send_result() code such that all commands are processed the
same, but consequently 2 bytes are sent back to the host (error code
and zeroed-out payload checksum) even if there is no response payload.

This patch updates the Flashrom-side of the code to expect the correct
number of bytes (which also happens to simplify the logic). "TX
failed" messages no longer appear as a result of the wait_tx()
function timing out.

BUG=none
TEST="TX failed" messages no longer appear on EC console

Change-Id: If9abcf6940c13806724eeef3a1308f5a784ce1ef
Reviewed-on: https://gerrit.chromium.org/gerrit/29193
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 months agoRevert "Upgrade to Google EC API v1."
David Hendricks [Wed, 1 Aug 2012 23:13:02 +0000 (16:13 -0700)]
Revert "Upgrade to Google EC API v1."

This reverts commit 1c4b784a3b018f2b7664f666eb41b52b2a086fca.

BUG=none
TEST=Vadim reverted the CL and was able to flash successfully.

Change-Id: I0d48aeab86c0934247bd684d865b6bdd55b6f85f
Reviewed-on: https://gerrit.chromium.org/gerrit/28991
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

9 months agoUpgrade to Google EC API v1. firmware-link-2695.2.B firmware-link-2695.B
Louis Yung-Chieh Lo [Mon, 30 Jul 2012 10:20:39 +0000 (18:20 +0800)]
Upgrade to Google EC API v1.

Copy code from ec/util/comm-lpc.c. i2c will be in next CL.

BUG=chrome-os-partner:11320
TEST=build and tested on link:
flashrom -p internal:bus=lpc -w ec.2.different.images

Change-Id: Ibc4ac52c2019f8a93e096849fc824cf28b3586fd
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28691
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
9 months agoSet EC to RESET only when erase and write
Rong Chang [Fri, 27 Jul 2012 13:42:25 +0000 (21:42 +0800)]
Set EC to RESET only when erase and write

Previous ene support resets the EC 8051 on all SPI flash access.
This change adds EC IDLE mode, and resets EC only when erase
or write.

BUG=chrome-os-partner:11352,11613
TEST=manual
  VT2 console commands:
    flashrom -p internal:bus=lpc --wp-status
    flashrom -p internal:bus=lpc -r ec_bios.bin
  The fan should not spin up.
  Press power button for 8 seconds, system should power off and can
  be powered on by power button again.

Change-Id: I4cc76965f3fbe19853d68ef02d13b7cf7547f41a
Reviewed-on: https://gerrit.chromium.org/gerrit/28592
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
9 months agoAdd Micron/Numonyx N25Q064 flash chip
David Hendricks [Tue, 24 Jul 2012 19:47:59 +0000 (12:47 -0700)]
Add Micron/Numonyx N25Q064 flash chip

This adds Numonyx N25Q064 support (from upstream) with additional
modification for write protection capabilities. This includes
support for both 1.8V and 3V versions.

Note: Some naming is confusing because ST spun off Numonyx and
then Numonyx was acquired by Micron.

This patch also introduces a naming scheme which uses dots in place
of letters/numbers in the chip name which are expected to change,
e.g. those which represent process technology, packaging options,
and other attributes which do not affect flashrom functionality.

BUG=none
TEST=compiled only. I do not have hardware to test with.

Change-Id: Ib3e1d360af8951363bff2442ecd4a3e40ec82c88
Reviewed-on: https://gerrit.chromium.org/gerrit/28298
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
9 months agoTry to manually mknod spidev when it doesn't exist.
Louis Yung-Chieh Lo [Fri, 27 Jul 2012 10:24:37 +0000 (18:24 +0800)]
Try to manually mknod spidev when it doesn't exist.

In the platform using linux_spi, there is a situation that /dev/spidevX.Y
have not been created when flashrom is executing: at chromeos_startup.
Thus, we would manually create that.

BUG=chrome-os-partner:11843
TEST=tested on snow.
rm /tmp/machine /var/log/vpd.2.0.txt /var/cache/vpd/full-v2.cache
reboot
above removed files should be created and updated to VPD content.

Change-Id: I20bad2d45fdaed3f17ee2188550470365fa587d7
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28586
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
9 months agoflashrom: Add default pkg-config definition. firmware-parrot-2685.B
Hung-Te Lin [Mon, 30 Jul 2012 03:40:38 +0000 (11:40 +0800)]
flashrom: Add default pkg-config definition.

In static configuration, we need to declare default pkg-config explicitly.

BUG=none
TEST=sudo USE=static emerge flashrom

Change-Id: I28744af0fd2d2d0bcc4569a5fbef370321691267
Reviewed-on: https://gerrit.chromium.org/gerrit/28678
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
9 months agoAdd flashrom support for ITE IT8518 EC.
Shawn Nematbakhsh [Thu, 26 Jul 2012 22:19:58 +0000 (15:19 -0700)]
Add flashrom support for ITE IT8518 EC.

Modify generic ITE IT85XX code to support IT8518. Existing code was
reworked, leaving IT85XX support still functional.

BUG=chrome-os-partner:11196.
TEST=flashrom -p internal:bus=lpc -V on platform w/ IT8518.

Change-Id: Ic066c0b397a5d7cf2e9b23f6f250cf301d89a760
Reviewed-on: https://gerrit.chromium.org/gerrit/28526
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>

9 months agoAdd flashrom support for ENE KB94X EC.
Shawn Nematbakhsh [Thu, 26 Jul 2012 16:42:36 +0000 (09:42 -0700)]
Add flashrom support for ENE KB94X EC.

ENE KB94X closely resembles KB932. Two small changes to the protocol
were necessary, along with some misc. I/O address changes. Existing code
was refactored for reusability.

BUG=chrome-os-partner:11372.
TEST=emerge flashrom, test SPI ROM read on both KB932 and KB94X.

Change-Id: Id3c4205af2e990d64f357e6d7554f5710f3d2bdc
Reviewed-on: https://gerrit.chromium.org/gerrit/28401
Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Micah Catlin <micahc@chromium.org>
9 months agoTrigger Parrot EC to PCH interrupt after EC restart
Rong Chang [Sat, 21 Jul 2012 03:41:32 +0000 (11:41 +0800)]
Trigger Parrot EC to PCH interrupt after EC restart

BUG=chrome-os-partner:11486
TEST=manual
  Read EC write protect status:
    flashrom -p internal:bus=lpc --wp-status
  Then check ACPI battery communication:
    cat /sys/class/power_supply/BATX/uevent
  If 'cat' response within 1 second, pass.

Change-Id: I2a04060d5e3d1b17897d8fa20cc43456e96fb77a
Reviewed-on: https://gerrit.chromium.org/gerrit/28113
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>

9 months agoFix error when building flashrom from chroot.
Shawn Nematbakhsh [Tue, 24 Jul 2012 22:27:00 +0000 (15:27 -0700)]
Fix error when building flashrom from chroot.

Building flashrom w/ "make" inside chroot fails due to compiler
warnings. This change fixes the warnings.

BUG=None.
TEST="make" from chroot, also confirm emerge still works.

Change-Id: Ied4da260f43e2342975f9070da5e5f1e7154e747
Reviewed-on: https://gerrit.chromium.org/gerrit/28324
Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Micah Catlin <micahc@chromium.org>
10 months agoUpdate GEC flash regions
David Hendricks [Thu, 19 Jul 2012 19:13:17 +0000 (12:13 -0700)]
Update GEC flash regions

This updates the EC regions to be in tune with current ToT GEC as of
7a7d7b which removed unnecessary sections. The regions RO_SECTION and
RW_SECTION_A are now EC_RO and EC_RW, and there is no longer an RW_B
to worry about.

BUG=none
TEST=Tested on Snow by flashing current HEAD and HEAD^1 firmwares

Change-Id: Ib29da0b0d9e04b87ff1295374f0782e2e7ce06f8
Reviewed-on: https://gerrit.chromium.org/gerrit/27907
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

10 months agoFade out SUPPORT_CHECKSUM.
Louis Yung-Chieh Lo [Wed, 18 Jul 2012 07:42:23 +0000 (15:42 +0800)]
Fade out SUPPORT_CHECKSUM.

BUG=None
TEST=Build in chroot.

Change-Id: I7581cf5e8ea251bb54b35cf71f0807773f86ee4e
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27752
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>

10 months agoRemove commands unsupported by current Cros EC
Randall Spangler [Wed, 18 Jul 2012 16:36:25 +0000 (09:36 -0700)]
Remove commands unsupported by current Cros EC

Cros EC write protect is being refactored.  This involves removing the
old commands and replacing them with new ones which better reflect the
underlying EC write protect mechanism.  Keep flashrom from failing
when it can't talk to the EC.  This mostly affected flashrom
--wp-status, since the rest of the wp commands were only executed if
flashrom / firmware update needed to disable protection.

TODO: reimplement these commands using the new Cros EC write protect
commands once they're implemented/checked in.

BUG=chrome-os-partner:11219
TEST=manual

The following commands used by firmware update should succeed:

flashrom -p internal:bus=lpc --wp-status
  (should report status = srp = start = len = 0, disabled)
flashrom -p internal:bus=lpc --wp-list
  (should report 0 to 0x3f800, step size 0x800)
flashrom -p internal:bus=lpc --get-size
  (should report 260096)
flashrom -p internal:bus=lpc -r foo.bin
flashrom -p internal:bus=lpc -w foo.bin

The following commands should fail as unimplemented:

flashrom -p internal:bus=lpc --wp-enable
flashrom -p internal:bus=lpc --wp-disable
flashrom -p internal:bus=lpc --wp-range 0 0

Change-Id: I998b8412c9802c080cca571ffe7c90d8e33b7094
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27765
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
10 months agoupdate gec_read() for variable-sized read buffers
David Hendricks [Wed, 18 Jul 2012 03:39:38 +0000 (20:39 -0700)]
update gec_read() for variable-sized read buffers

This updates the gec_read() function to cope with variable-sized
response buffers that were added to the EC firmware recently.

BUG=chrome-os-partner:11263
TEST=Tested EC firmware write on Snow using EC

Change-Id: I7ba3ed897033672198e0d80007843feef1d23828
Reviewed-on: https://gerrit.chromium.org/gerrit/27738
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
10 months agoUpdate GEC parameter size
David Hendricks [Mon, 9 Jul 2012 01:37:43 +0000 (18:37 -0700)]
Update GEC parameter size

This will make flashrom use EC_LPC_PARAM_SIZE (128) instead of
EC_LPC_FLASH_SIZE_MAX (64) for GEC reads. GEC writes will use
64 bytes. This is to bring flashrom up to date with EC commit bbdc15.

This also fixes a size comparison in gec_lpc so that the insize and
outsize will be checked against EC_LPC_PARAM_SIZE individually.

(Note: EC_LPC is a misnomer, since it applies to both LPC and I2C
interfaces. TODO: cleanup the naming)

BUG=chrome-os-partner:11097
TEST=read from GEC on Snow (I2C) and Link (LPC)

Change-Id: I936e3989a221a1e7b4213d9a8262ffe08d78565a
Reviewed-on: https://gerrit.chromium.org/gerrit/26901
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

10 months agoAdd PRESUBMIT.cfg to disable some presubmit checks
David Hendricks [Sun, 8 Jul 2012 00:55:39 +0000 (17:55 -0700)]
Add PRESUBMIT.cfg to disable some presubmit checks

This adds a simple presubmit config to avoid err'ing out when using
tabs and licensing since Flashrom is third-party code and the license
does not necessarily match other portions of Chromium OS.

BUG=none
TEST=none

Change-Id: I9732b7d0518196a02e09be64876fcafef8661087
Reviewed-on: https://gerrit.chromium.org/gerrit/26882
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

10 months agoApply new EC firmware ASAP after update.
Louis Yung-Chieh Lo [Mon, 9 Jul 2012 09:07:43 +0000 (17:07 +0800)]
Apply new EC firmware ASAP after update.

The old code would stay in the RO code if the RO is not changed.
The new code would jump to new-updated copy (B is preferred than A).

BUG=chrome-os-partner:11156
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
TEST=on link.
prepare EC images a and b almost identical except the RW part.
% flashrom -w a
% flashrom -w b
% ectool version
running on A  (new firmware)

Change-Id: I4d0a10a73d52997f49caa641a03a3a592c8f14a1
Reviewed-on: https://gerrit.chromium.org/gerrit/26914
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
10 months agoAdd ENE KB932 support
Rong Chang [Thu, 21 Jun 2012 11:21:18 +0000 (19:21 +0800)]
Add ENE KB932 support

ENE ec chip has lpc to spi emulation. Internal micro controller
needs to be stopped before access SPI hardware.
This change contains the code to stop specific firmware before
flash operation. And restart the controller after all operations
are done.

BUG=none
TEST=manual
  flashrom -p internal:bus=lpc -V
  flashrom -p internal:bus=lpc -w NEW_FW.bin

Change-Id: Iddd5b2b413a6cb6cf950c29c67a64d084b891cb6
Reviewed-on: https://gerrit.chromium.org/gerrit/25833
Commit-Ready: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Jay Kim <yongjaek@chromium.org>
Tested-by: Jay Kim <yongjaek@chromium.org>
10 months agoDo not call show_id() for now
David Hendricks [Tue, 19 Jun 2012 17:29:37 +0000 (10:29 -0700)]
Do not call show_id() for now

This disables a sanity check that compares the vendor and mainboard
names from the ROM with the user-provided file for write operations.
The reason is because codenames which are in flux can cause failure.

BUG=chrome-os-partner:10414
TEST=Tested on Stumpy (notes below)

With this patch, the following text no longer appears on Stumpy
coreboot last image size (not ROM size) is 1048576 bytes.
Manufacturer: SAMSUNG
Mainboard ID: Stumpy

Change-Id: I759a2505d1944560dfec54157a9e9eaf28cdd56a
Reviewed-on: https://gerrit.chromium.org/gerrit/25633
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
10 months agoNM70 support on flashrom tool
Jay Kim [Fri, 22 Jun 2012 04:54:43 +0000 (21:54 -0700)]
NM70 support on flashrom tool

BUG=chrome-os-partner:10753
TEST=Running flashrom tool on Parrot DVT board

Change-Id: I4d3e12b26851287cf9e8b846f0b7b4849fce08e7
Reviewed-on: https://gerrit.chromium.org/gerrit/25909
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Jay Kim <yongjaek@chromium.org>
Commit-Ready: Jay Kim <yongjaek@chromium.org>

11 months agosearch for spidev instead of m25p80 factory-2475.B
David Hendricks [Tue, 12 Jun 2012 14:41:05 +0000 (23:41 +0900)]
search for spidev instead of m25p80

Kernel 3.4 does not seem to export the "m25p80" sysfs node,
only the "spidev" node.

This patch makes flashrom use the device matching "spidev" instead
of "m25p80" and with minor number 0 instead of 1. The major number
is what really matters.

BUG=chrome-os-partner:9861,chrome-os-partner:10420
TEST=Tested on Snow using kernels 3.3 and 3.4

Change-Id: If18b79a3e20fc7fcd6372d07b9ed6d749048080c
Reviewed-on: https://gerrit.chromium.org/gerrit/25091
Reviewed-by: Bryan Freed <bfreed@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
11 months agoAdd HM70(8086:1e5e) into the chipset table
Jay Kim [Thu, 14 Jun 2012 03:30:45 +0000 (20:30 -0700)]
Add HM70(8086:1e5e) into the chipset table

BUG=chrome-os-partner:10364
TEST=flashrom -p internal:bus=spi --wp-status

Change-Id: Idf1c15d257c93ce324a8d63284816059e0710bb8
Reviewed-on: https://gerrit.chromium.org/gerrit/25274
Tested-by: Jay Kim <yongjaek@chromium.org>
Commit-Ready: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
11 months agoSet GEC.page_size to EC_LPC_FLASH_SIZE_MAX (64-byte).
Louis Yung-Chieh Lo [Wed, 6 Jun 2012 13:29:33 +0000 (21:29 +0800)]
Set GEC.page_size to EC_LPC_FLASH_SIZE_MAX (64-byte).

In EC CL (https://gerrit.chromium.org/gerrit/#change,24375), reviewers
suggest using the buffer size of flash read/write.

BUG=None
TEST=only emerge-link flashrom, but d5c6969 had tested the 64-byte works.

Change-Id: I667457f3592b6fe81a7c1c77a1ff573c557e4da5
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24609
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
11 months agoGet GEC burst size if the EC can provide that information.
Louis Yung-Chieh Lo [Tue, 5 Jun 2012 07:01:06 +0000 (15:01 +0800)]
Get GEC burst size if the EC can provide that information.

The old way is using the write/erase block size, which the write size is
the "minimum" size for write. It makes the write quite slow.

The new EC firmware supports to query the burst size so that the
read/write go much faster. See the CL on the EC side:
  https://gerrit.chromium.org/gerrit/#change,24375

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BUS=None
TEST=emerge-daisy flashrom and run on link (3x faster):
full EC update:  49 secs --> 16.3 secs
full EC read:     8 secs -->  2.5 secs

Change-Id: I0cdfd3c26defcb5050453a7778c90cbcccd3cea1
Reviewed-on: https://gerrit.chromium.org/gerrit/24485
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>

11 months agoImprove the timeout mechanism on EC LPC command.
Louis Yung-Chieh Lo [Thu, 31 May 2012 14:45:34 +0000 (22:45 +0800)]
Improve the timeout mechanism on EC LPC command.

udelay() has terrible overhead. Improve that by doubling the interval.
This has been merged in ectool: https://gerrit.chromium.org/gerrit/23878

BUG=chrome-os-partner:8865
TEST=tested on link board.

Change-Id: If7f1b090883b51e1022809e540dac3ddeeae6c2e
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24367
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
11 months agoEnable gec_prepare() and gec_need_2nd_pass() on non-x86
David Hendricks [Fri, 1 Jun 2012 05:15:38 +0000 (22:15 -0700)]
Enable gec_prepare() and gec_need_2nd_pass() on non-x86

This removes some "#if defined" guards for x86, since we can now use
GEC on other platforms as well.

BUG=chrome-os-partner:10125
TEST=Tested on Snow (see notes below)

Able to do a update without the user specifying a layout:
flashrom -p internal:bus=i2c -w ec.bin -V
...
Reading old contents from flash chip... done.
Found 'RO_SECTION' in image.
Found 'RW_SECTION_A' in image.
GEC is jumping to [RO_SECTION]
GEC has jumped to [RO_SECTION]
Erasing and writing flash chip...
...
GEC is jumping to [RW_SECTION_A]
GEC has jumped to [RW_SECTION_A]
GEC needs 2nd pass.
...

Change-Id: I64053e7558fc5f762533fe9cf9efca802cd2146b
Reviewed-on: https://gerrit.chromium.org/gerrit/24291
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoInitial GEC I2C implementation
David Hendricks [Fri, 25 May 2012 03:21:03 +0000 (20:21 -0700)]
Initial GEC I2C implementation

Based off of Vincent's ectool work

This does the following:
- Adds some basic Linux I2C helper functions.
- Adds a ec_command function for GEC over I2C
- Allows user to specify "-p internal:bus=i2c" at the command-line
  which currently targets "opaque" programmers.
- Add a hack that will also use GEC on I2C for ARM platforms if
  -p internal:bus=lpc is used.

Caveat: There seem to be some regions that we need to skip for
the current EC firmware. 0x5800-0x6800 seems problematic.

BUG=chrome-os-partner:8865
TEST=Tested on Snow by reading flash content and doing a partial write
     (in this case, it was in region 0xe000-0xefff).

flashrom -p internal:bus=i2c -r /tmp/foo.bin 2>/dev/null
Reading flash... SUCCESS

flashrom -p internal:bus=i2c --ignore-fmap -l layout.txt -i foo \
-w random_64k.bin 2>/dev/null
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS

localhost ~ # ./flashrom -p internal:bus=i2c --get-size 2>/dev/null
65536

Change-Id: I2797e52b0e1c137cb2f4710619d5fde953b17da0
Reviewed-on: https://gerrit.chromium.org/gerrit/23601
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agogec: get max read/write size from programmer struct
David Hendricks [Tue, 29 May 2012 21:39:50 +0000 (14:39 -0700)]
gec: get max read/write size from programmer struct

This CL makes the gec_read() and gec_write() functions use the
max data read/write sizes from the programmer struct instead of
the #define. This allows us to set the max sizes for LPC and
I2C GEC seperately, and also simplifies the code a bit.

BUG=none
TEST=tested on Lucas

Change-Id: Ia93b3948794fdf5d94bcd62339f870a98eb8ef0f
Reviewed-on: https://gerrit.chromium.org/gerrit/23996
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoNULL pointer check in gec->priv. factory-2368.B
Louis Yung-Chieh Lo [Tue, 29 May 2012 07:28:58 +0000 (15:28 +0800)]
NULL pointer check in gec->priv.

Without this, flashrom would segmentation-fault.

BUG=none
TEST=tested on l*k board.

Change-Id: Idd40682095807ea4f4528df59d72bb4090902150
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/23866
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>

11 months agoSeparate LPC-centric GEC stuff into gec_lpc.c
David Hendricks [Mon, 21 May 2012 00:25:51 +0000 (17:25 -0700)]
Separate LPC-centric GEC stuff into gec_lpc.c

This CL attempts to isolate LPC-specific GEC routines into gec_lpc.c.
Eventually, gec.c will be generic and can be used by both gec_lpc
routines and gec_i2c routines.

One challenge this attempts to address is that GEC-specific functions
are used in higher-level logic in doit(), which does not have
programmer-specific knowledge. So a "gec_priv" struct was introduced
as the void * member of the programmer struct so that GEC functions
can always access their command function and state variables.

BUG=chrome-os-partner:8865
TEST=Tested on Link

Firmware read and write (both with same and different images)
succeeded and verified.

Setting a write-protect range and viewing status also worked:
localhost ~ # ./flashrom -p internal:bus=lpc --wp-range 0x00000 0x10000 2>/dev/null
SUCCESS

localhost ~ # ./flashrom -p internal:bus=lpc --wp-status 2>/dev/null
WP: status: 0x00
WP: status.srp0: 0
WP: write protect is disabled.
WP: write protect range: start=0x00000000, len=0x00010000

Change-Id: I36fb3c3ca72f75774645db01b03f8f4d0e00f5ef
Reviewed-on: https://gerrit.chromium.org/gerrit/23595
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoadd a void * member to the opaque_programmer struct
David Hendricks [Thu, 24 May 2012 21:14:14 +0000 (14:14 -0700)]
add a void * member to the opaque_programmer struct

This adds a void * member to the opaque_programmer struct which will
allow us to better abstract some details between GEC LPC and I2C
variants.

This change was actually made in upstream flashrom as well (r1475).

BUG=none
TEST=Tested on Arrow using the follow-up gec_lpc CL

Change-Id: Id20dfc76bc415835bef2695fd92c011de076821f
Reviewed-on: https://gerrit.chromium.org/gerrit/23594
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoAdd a file utility library
David Hendricks [Wed, 23 May 2012 03:55:29 +0000 (20:55 -0700)]
Add a file utility library

This adds a library for BSD-licensed helper functions for dealing
with files.

Currently the library only has scanft() which was ported over from
mosys. This function recursively scans files in a filesystem tree
and can optionally match the beginning content. This is particularly
useful for searching for devices in sysfs, which may be infinitely
recursive (due to symlinks) and typically contain single values, such
as a module alias.

BUG=none
TEST=used in follow-up CLs to find I2C and SPI buses and addresses

Example test output using /sys/bus/i2c/devices/ as root path,
following 2 levels of symbolic links, physical i2c bus is 4 but
got shifted to 6:
gec_i2c_probe_programmer: probing for GEC on I2C...
gec_i2c_probe_programmer: chromeos-ec found in \
                    "/sys/bus/i2c/devices/i2c-6/6-001e/name"
gec_i2c_probe_programmer: bus: 6, addr: 0x1e

Change-Id: I6c86ad3a50748e6bdbaa6675b05e75ef714b3994
Reviewed-on: https://gerrit.chromium.org/gerrit/23466
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoUpdate BSD-licensed files with appropriate header firmware-link-2348.B
David Hendricks [Thu, 24 May 2012 04:50:59 +0000 (21:50 -0700)]
Update BSD-licensed files with appropriate header

Upstream flashrom is GPLv2, but modules from Google are typically
released under a BSD or BSD-like license. This patch applies the
correct license header to the gec.c and gec_lpc_commands.h files.

BUG=none
TEST=none

Change-Id: Ia7b11b1837b66ff1c2ececcbe8545f44ac529dd9
Reviewed-on: https://gerrit.chromium.org/gerrit/23468
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
11 months agoSlightly change the spidev auto-detect logic.
Louis Yung-Chieh Lo [Thu, 24 May 2012 07:43:50 +0000 (15:43 +0800)]
Slightly change the spidev auto-detect logic.

The scan code is scanning /dev/spidevX.0 where X is from 0 to 9. The old
code stops while the first X makes stat() fails. This leads a bug if
the kernel spidev doesn't start from 0, for exmaple, bus 0 is skipped.

The new code is to keep trying even if stat() fails.

BUG=chrome-os-partner:9932
TEST=tested on daisy board. -r works.

Change-Id: Id7f4b7dc8bb15d7b8574eb830586d62daea4b88c
Reviewed-on: https://gerrit.chromium.org/gerrit/23485
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>