]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
x86: fsp: Configure SPI opcode registers before SPI is locked down
authorBin Meng <bmeng.cn@gmail.com>
Wed, 16 Aug 2017 05:38:31 +0000 (22:38 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 24 Aug 2017 03:00:47 +0000 (11:00 +0800)
Some Intel FSP (like Braswell) does SPI lock-down during the call
to fsp_notify(INIT_PHASE_BOOT). But before SPI lock-down is done,
it's bootloader's responsibility to configure the SPI controller's
opcode registers properly otherwise SPI controller driver doesn't
know how to communicate with the SPI flash device.

This introduces a Kconfig option CONFIG_FSP_LOCKDOWN_SPI for such
FSPs. When it is on, U-Boot will configure the SPI opcode registers
before the lock-down.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
arch/x86/Kconfig
arch/x86/lib/fsp/fsp_common.c

index c26710b484c1b3454032ea86c98d31b8eed6fb17..537308295714428c151e703bfec4d023ab6bcab2 100644 (file)
@@ -401,6 +401,15 @@ config FSP_BROKEN_HOB
          do not overwrite the important boot service data which is used by
          FSP, otherwise the subsequent call to fsp_notify() will fail.
 
+config FSP_LOCKDOWN_SPI
+       bool
+       depends on HAVE_FSP
+       help
+         Some Intel FSP (like Braswell) does SPI lock-down during the call
+         to fsp_notify(INIT_PHASE_BOOT). This option should be turned on
+         for such FSP and U-Boot will configure the SPI opcode registers
+         before the lock-down.
+
 config ENABLE_MRC_CACHE
        bool "Enable MRC cache"
        depends on !EFI && !SYS_COREBOOT
index 3397bb83eaf1191bc7a5cffdab3bf216fb10e174..1714d13228e375cc59b0a45aa4d618a8d08f26a3 100644 (file)
@@ -19,6 +19,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+extern void ich_spi_config_opcode(struct udevice *dev);
+
 int checkcpu(void)
 {
        return 0;
@@ -49,6 +51,28 @@ void board_final_cleanup(void)
 {
        u32 status;
 
+#ifdef CONFIG_FSP_LOCKDOWN_SPI
+       struct udevice *dev;
+
+       /*
+        * Some Intel FSP (like Braswell) does SPI lock-down during the call
+        * to fsp_notify(INIT_PHASE_BOOT). But before SPI lock-down is done,
+        * it's bootloader's responsibility to configure the SPI controller's
+        * opcode registers properly otherwise SPI controller driver doesn't
+        * know how to communicate with the SPI flash device.
+        *
+        * Note we cannot do such configuration elsewhere (eg: during the SPI
+        * controller driver's probe() routine), because:
+        *
+        * 1). U-Boot SPI controller driver does not set the lock-down bit
+        * 2). Any SPI transfer will corrupt the contents of these registers
+        *
+        * Hence we have to do it right here before SPI lock-down bit is set.
+        */
+       if (!uclass_first_device_err(UCLASS_SPI, &dev))
+               ich_spi_config_opcode(dev);
+#endif
+
        /* call into FspNotify */
        debug("Calling into FSP (notify phase INIT_PHASE_BOOT): ");
        status = fsp_notify(NULL, INIT_PHASE_BOOT);