From a1491574ef2c91ff8b89df70feba67ad34836c75 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 17 May 2017 19:14:06 -0700 Subject: drivers/spi/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. 3. Add spi_flash_probe to spi_ctrlr structure to allow platforms to provide specialized probe functions. With this change, the specialized spi flash probe functions are now associated with a particular spi ctrlr structure and no longer disconnected from the spi controller. BUG=b:38330715 Change-Id: I35f3bd8ddc5e71515df3ef0c1c4b1a68ee56bf4b Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/19708 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Julius Werner --- src/drivers/spi/spi_flash.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'src/drivers/spi') diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 096d7cd9bb..564d573a83 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -281,16 +281,7 @@ static struct { }; #define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) -int -__attribute__((weak)) spi_flash_programmer_probe(const struct spi_slave *spi, - int force, - struct spi_flash *flash) -{ - /* Default weak implementation. Do nothing. */ - 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,32 +321,29 @@ static int __spi_flash_probe(const struct spi_slave *spi, 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"); return -1; } - /* Try special programmer probe if any (without force). */ - if (spi_flash_programmer_probe(&spi, 0, flash) == 0) - goto flash_found; + /* Try special programmer probe if any. */ + if (spi.ctrlr->flash_probe) + ret = spi.ctrlr->flash_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; } -- cgit v1.2.3