summaryrefslogtreecommitdiff
path: root/src/include/spi_flash.h
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2024-11-06 00:38:13 +0100
committerFelix Held <felix-coreboot@felixheld.de>2024-11-12 15:40:24 +0000
commit3040e9967951c014d98a6d9c0b45a12777af6372 (patch)
treef3241ea4cb7549fa0a8b8e6f4b1eaf61b5ce29c1 /src/include/spi_flash.h
parent49e6be85cd1c87610ba6a44ee8d5ffe521d2cad3 (diff)
drivers/spi/spi_flash_sfdp: add basic SFDP support
Add basic support for the Serial Flash Discoverable Parameters (SFDP) standard which can be used to discover the parameters to interact with any SPI flash chip that supports this mechanism. This commit adds functionality to find specific SFDP parameter headers and print all SFDP parameter headers, but not to parse any SFDP parameter table. This is a preparation for a follow-up patch that adds support to parse the RPMC SFDP parameter table. Since 'find_sfdp_parameter_header' is only used in the next patch, it's marked as static inline in this commit so that the code still build; the 'inline' keyword will be removed again in that follow-up patch. For now, only the legacy access protocol using single bit SPI transfers is supported, but this should cover most of the SPI NOR flash chips. In any other case, the code will error out. It's also assumed that the SFDP data blocks read from the SPI flash chip are small enough to fit into the SPI host controller buffer and don't need to be broken up into multiple transfers. This limitation will be addressed in a follow-up patch. JESD216F.02 was used as a reference. TEST=On a board with a W74M12JW SPI flash chip, calling 'spi_flash_print_sfdp_headers' prints this on the console output: Manufacturer: ef SF: Detected ef 6018 with sector size 0x1000, total 0x1000000 SF: Exiting 4-byte addressing mode SFDP header found in SPI flash. major rev 0x1, minor rev 0x6, access protocol 0xff, number of headers 3 SFPD header with index 0: table ID 0xff00, major rev 0x1, minor rev 0x6 table pointer 0x80, table length DWORDS 0x10 SFPD header with index 1: table ID 0xff84, major rev 0x1, minor rev 0x0 table pointer 0xd0, table length DWORDS 0x2 SFPD header with index 2: table ID 0xff03, major rev 0x1, minor rev 0x0 table pointer 0xf0, table length DWORDS 0x2 Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I5a1706acf7d60fd64292e8f0677992ab4aebf46a Reviewed-on: https://review.coreboot.org/c/coreboot/+/84786 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Diffstat (limited to 'src/include/spi_flash.h')
-rw-r--r--src/include/spi_flash.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index e0d5b2b36d..7736a940f5 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -249,4 +249,7 @@ int spi_flash_vector_helper(const struct spi_slave *slave,
*/
uint32_t spi_flash_get_mmap_windows(struct flash_mmap_window *table);
+/* Print the SFDP headers read from the SPI flash */
+void spi_flash_print_sfdp_headers(const struct spi_flash *flash);
+
#endif /* _SPI_FLASH_H_ */