From fb032398d262ff7594c35c65b6f14897bb331a39 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Thu, 15 Jan 2015 15:28:46 -0800 Subject: spi: Add function to read flash status register Add a function that allows reading of the status register from the SPI chip. This can be used to determine whether write protection is enabled on the chip. BUG=chrome-os-partner:35209 BRANCH=haswell TEST=build and boot on peppy Signed-off-by: Duncan Laurie Reviewed-on: https://chromium-review.googlesource.com/240702 Reviewed-by: Shawn N (cherry picked from commit c58f17689162b291a7cdb57649a237de21b73545) Change-Id: Ib7fead2cc4ea4339ece322dd18403362c9c79c7d Signed-off-by: Patrick Georgi Original-Commit-Id: 9fbdf0d72892eef4a742a418a347ecf650c01ea5 Original-Change-Id: I2541b22c51e43f7b7542ee0f48618cf411976a98 Original-Signed-off-by: Duncan Laurie Original-Reviewed-on: https://chromium-review.googlesource.com/241128 Original-Reviewed-by: Shawn N Reviewed-on: http://review.coreboot.org/9730 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/drivers/spi/spi_flash.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/drivers/spi/spi_flash.c') diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 8213e852be..d40f72a852 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -234,6 +234,11 @@ out: return ret; } +int spi_flash_cmd_status(struct spi_flash *flash, u8 *reg) +{ + return spi_flash_cmd(flash->spi, flash->status_cmd, reg, sizeof(*reg)); +} + /* * The following table holds all device probe functions * @@ -372,6 +377,7 @@ flash_detected: tseg_relocate((void **)&flash->read); tseg_relocate((void **)&flash->write); tseg_relocate((void **)&flash->erase); + tseg_relocate((void **)&flash->status); tseg_relocate((void **)&flash->name); #endif -- cgit v1.2.3