From a8aef3acbc0aea2dd594f7133a7024f3babf764a Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Tue, 24 Nov 2015 09:43:27 -0800 Subject: cbfs_spi: Initialize spi_flash when initializing cbfs_cache Most devices do not use SPI before they initialize CBMEM. This change initializes spi_flash in the CBMEM_INIT_HOOK to initialize the postram cbfs cache so it is not overwritten when boot_device_init is called later. BUG=chromium:210230 BRANCH=none TEST=confirm that the first cbfs access can occur before RAM initialized and after on panther and jerry. Change-Id: If3b6efc04082190e81c3773c0d3ce116bb12421f Signed-off-by: Patrick Georgi Original-Commit-Id: 0ab242786a16eba7fb423694f6b266e27d7660ec Original-Change-Id: I5f884b473e51e6813fdd726bba06b56baf3841b0 Original-Signed-off-by: Mary Ruthven Original-Reviewed-on: https://chromium-review.googlesource.com/314311 Original-Reviewed-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/12601 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/lib/cbfs_spi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/cbfs_spi.c b/src/lib/cbfs_spi.c index 82c3b834d3..ffa0628b05 100644 --- a/src/lib/cbfs_spi.c +++ b/src/lib/cbfs_spi.c @@ -45,7 +45,14 @@ static struct mmap_helper_region_device mdev = static void initialize_mdev(int unused) { - mmap_helper_device_init(&mdev, _dram_cbfs_cache, _dram_cbfs_cache_size); + /* + * Call boot_device_init() to ensure spi_flash is initialized before + * backing mdev with postram cache. This prevents the mdev backing from + * being overwritten if spi_flash was not accessed before dram was up. + */ + boot_device_init(); + mmap_helper_device_init(&mdev, _postram_cbfs_cache, + _postram_cbfs_cache_size); } ROMSTAGE_CBMEM_INIT_HOOK(initialize_mdev); -- cgit v1.2.3