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/include/spi-generic.h | 9 +++++++++ src/include/spi_flash.h | 11 +++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/include') diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h index 56353bb692..783df0b917 100644 --- a/src/include/spi-generic.h +++ b/src/include/spi-generic.h @@ -94,6 +94,8 @@ struct spi_cfg { */ #define SPI_CTRLR_DEFAULT_MAX_XFER_SIZE (UINT32_MAX) +struct spi_flash; + /*----------------------------------------------------------------------- * Representation of a SPI controller. * @@ -108,6 +110,11 @@ struct spi_cfg { * deduct_cmd_len: Whether cmd_len should be deducted from max_xfer_size * when calculating max_data_size * + * Following member is provided by specialized SPI controllers that are + * actually SPI flash controllers. + * + * flash_probe: Specialized probe function provided by SPI flash + * controllers. */ struct spi_ctrlr { int (*claim_bus)(const struct spi_slave *slave); @@ -119,6 +126,8 @@ struct spi_ctrlr { struct spi_op vectors[], size_t count); uint32_t max_xfer_size; bool deduct_cmd_len; + int (*flash_probe)(const struct spi_slave *slave, + struct spi_flash *flash); }; /*----------------------------------------------------------------------- diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index bc0318c7a3..ab8155d8e7 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -65,20 +65,19 @@ void lb_spi_flash(struct lb_header *header); * non-zero = error */ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash); + /* - * Specialized probing performed by platform. This is a weak function which can - * be overriden by platform driver. + * Generic probing for SPI flash chip based on the different flashes provided. * * Params: - * spi = Pointer to spi_slave structure. - * force = Indicates if the platform driver can skip specialized probing. + * spi = Pointer to spi_slave structure * flash = Pointer to spi_flash structure that needs to be filled. * * Return value: - * 0 = success + * 0 = success * non-zero = error */ -int spi_flash_programmer_probe(const struct spi_slave *spi, int force, +int spi_flash_generic_probe(const struct spi_slave *slave, struct spi_flash *flash); /* All the following functions return 0 on success and non-zero on error. */ -- cgit v1.2.3