[coreboot-gerrit] Change in coreboot[master]: drivers/spi/flash: Clean up SPI flash probe
Furquan Shaikh (Code Review)
gerrit at coreboot.org
Thu May 18 04:35:07 CEST 2017
Furquan Shaikh has uploaded a new change for review. ( https://review.coreboot.org/19758 )
Change subject: drivers/spi/flash: Clean up SPI flash probe
......................................................................
drivers/spi/flash: Clean up SPI flash probe
1. Rename __spi_flash_probe to spi_flash_generic_probe and export it
so that drivers can use it outside spi_flash.c.
2. Make southbridge intel spi driver use spi_flash_generic_probe if
spi_is_multichip returns 0.
BUG=b:38330715
Change-Id: I5ffe62fdb83b3c744f3779adacb77503352f6623
Signed-off-by: Furquan Shaikh <furquan at chromium.org>
---
M src/drivers/spi/spi_flash.c
M src/include/spi_flash.h
M src/southbridge/intel/common/spi.c
3 files changed, 27 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/19758/1
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 096d7cd..68ae378 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -290,7 +290,7 @@
return -1;
}
-static int __spi_flash_probe(const struct spi_slave *spi,
+int spi_flash_generic_probe(const struct spi_slave *spi,
struct spi_flash *flash)
{
int ret, i, shift;
@@ -330,6 +330,7 @@
int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash)
{
struct spi_slave spi;
+ int ret = -1;
if (spi_setup_slave(bus, cs, &spi)) {
printk(BIOS_WARNING, "SF: Failed to set up slave\n");
@@ -337,25 +338,20 @@
}
/* Try special programmer probe if any (without force). */
- if (spi_flash_programmer_probe(&spi, 0, flash) == 0)
- goto flash_found;
+ ret = spi_flash_programmer_probe(&spi, flash);
/* If flash is not found, try generic spi flash probe. */
- if (__spi_flash_probe(&spi, flash) == 0)
- goto flash_found;
-
- /* If flash is not yet found, force special programmer probe if any. */
- if (spi_flash_programmer_probe(&spi, 1, flash) == 0)
- goto flash_found;
+ if (ret)
+ ret = spi_flash_generic_probe(&spi, flash);
/* Give up -- nothing more to try if flash is not found. */
- printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n");
- return -1;
+ if (ret) {
+ printk(BIOS_WARNING, "SF: Unsupported manufacturer!\n");
+ return -1;
+ }
-flash_found:
printk(BIOS_INFO, "SF: Detected %s with sector size 0x%x, total 0x%x\n",
flash->name, flash->sector_size, flash->size);
-
return 0;
}
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index bc0318c..0c76555 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -65,6 +65,21 @@
* non-zero = error
*/
int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash);
+
+/*
+ * Generic probing for SPI flash chip based on the different flashes provided.
+ *
+ * Params:
+ * spi = Pointer to spi_slave structure
+ * flash = Pointer to spi_flash structure that needs to be filled.
+ *
+ * Return value:
+ * 0 = success
+ * non-zero = error
+ */
+int spi_flash_generic_probe(const struct spi_slave *slave,
+ struct spi_flash *flash);
+
/*
* Specialized probing performed by platform. This is a weak function which can
* be overriden by platform driver.
diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c
index 110c29c..5aa3efc 100644
--- a/src/southbridge/intel/common/spi.c
+++ b/src/southbridge/intel/common/spi.c
@@ -904,13 +904,9 @@
{
uint32_t flcomp;
- /*
- * Perform SPI flash probing only if:
- * 1. spi_is_multichip returns 1 or
- * 2. Specialized probing is forced by SPI flash driver.
- */
- if (!spi_is_multichip() && !force)
- return -1;
+ /* Try generic probing first if spi_is_multichip returns 0. */
+ if (!spi_is_multichip() && !spi_flash_generic_probe(spi, flash))
+ return 0;
memcpy(&flash->spi, spi, sizeof(*spi));
flash->name = "Opaque HW-sequencing";
--
To view, visit https://review.coreboot.org/19758
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ffe62fdb83b3c744f3779adacb77503352f6623
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
More information about the coreboot-gerrit
mailing list