From 1b7f99bd6b52e3fd03653dca80af3faf6e7e8852 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Wed, 5 Jun 2019 16:34:01 -0700 Subject: spi_flash: Make .read() callback optional All SPI flash chip drivers currently in coreboot use the generic read functions (spi_flash_cmd_read_fast()/_slow()) as their read callback. The only use case for specialized read callbacks we have left is with specialized flash controllers like Intel fast_spi (which sort of impersonate the flash chip driver by implementing their own probe function). This patch unifies the behavior for all normal flash drivers by making the read callback optional and letting them all fall back to a default read implementation that handles normal fast/slow reading. Most of the drivers used to install the respective callback after checking CONFIG_SPI_FLASH_NO_FAST_READ, but some hardcoded either slow or fast writes. I have found no indications for why this is and spot-checked datasheets for affected vendors to make sure they all support both commands, so I assume this is just some old inaccuracy rather than important differences that need preserving. (Please yell if you disagree.) Also take the opportunity to refactor some of the common spi_flash.c code a bit because I felt there are too many nested functions that don't really do enough on their own, and centralizing stuff a bit should make it easier to follow the code flow. (Some of this is in preparation for the next patch.) Change-Id: I2096a3ce619767b41b1b0c0c2b8e95b2bd90a419 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/c/coreboot/+/33282 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/drivers/spi/stmicro.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/drivers/spi/stmicro.c') diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index fb24b27266..6625764268 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -351,7 +351,6 @@ out: static const struct spi_flash_ops spi_flash_ops = { .write = stmicro_write, .erase = spi_flash_cmd_erase, - .read = spi_flash_cmd_read_fast, }; int spi_flash_probe_stmicro(const struct spi_slave *spi, u8 *idcode, -- cgit v1.2.3