summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2011-09-13 22:41:24 -0700
committerVadim Bendebury <vbendeb@chromium.org>2011-09-15 11:00:47 -0700
commit7ca2ded36434d388b872e548726f590c69c25c92 (patch)
tree3e1ca62f9e37b868bc412e7a6d3fbc3155486a9d /include
parentf23e5f319d6bcdd869571ddd96e01ec780806648 (diff)
Report SPI driver write errors.
The ICH SPI controller can't handle more than 64 bytes in one write transaction, but the SPI chips' drivers routinely invoke controller transfer function (spi_xfer()) trying to write a full SPI chip page, which often exceeds the ICH SPI controller capacity. This condition goes unnoticed, resulting in only the first 64 bytes of the data written into the flash, the rest gets dropped on the floor. With this change an error value will be returned to the caller and an error message will be printed on the screen. Also, it turned out that the chip level flash drivers interpret as errors only the negative values returned by the SPI interface driver. But the SPI interface driver in ich.c was returning +1 to report errors. This CL takes care of this discrepancy too. BUG=chromium-os:20105 TEST=manual . modify the '#ifdef CONFIG_ICH_SPI' line to read '#ifdef CONFIG_ICH_SPIxx' in include/spi_flash.h . build x86-alex bootloader image . program the image on an alex device . restart the device . at the 'boot>' prompt run the 'saveenv' command Observe the command failed and the error message printed on the console. . restore include/spi_flash.h . build x86-alex bootloader image . program the image on an alex device . restart the device . at the 'boot>' prompt run the following commands: setenv xyz 'this is a string' saveenv . reboot the device . at the 'boot>' prompt run 'printenv' Observe the environment include the new variable (xyz) Change-Id: I528a85b208213c10fdf8cf3e908caf7bea94bc62 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/7697 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/spi_flash.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 525a3497cd..f8b177a4e3 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -33,7 +33,8 @@
#ifdef CONFIG_ICH_SPI
#define CONTROLLER_PAGE_LIMIT 64
#else
-#define CONTROLLER_PAGE_LIMIT MAX_INT
+/* any number larger than 4K would do, actually */
+#define CONTROLLER_PAGE_LIMIT ((int)(~0U>>1))
#endif
struct spi_flash {