summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/soc/intel/common/block/fast_spi/fast_spi.c12
-rw-r--r--src/soc/intel/common/block/fast_spi/fast_spi_def.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi.c b/src/soc/intel/common/block/fast_spi/fast_spi.c
index dd21143798..fe0217adad 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi.c
@@ -134,15 +134,19 @@ void fast_spi_set_opcode_menu(void)
/*
* Lock FAST_SPIBAR.
+ * Use 16bit write to avoid touching two upper bytes what may cause the write
+ * cycle to fail in case a prior transaction has not completed.
+ * While WRSDIS is lockable with FLOCKDN, writing both in the same
+ * cycle is guaranteed to work by design.
+ *
+ * Avoid read->modify->write not to clear RW1C bits unintentionally.
*/
void fast_spi_lock_bar(void)
{
void *spibar = fast_spi_get_bar();
- uint32_t hsfs;
+ const uint16_t hsfs = SPIBAR_HSFSTS_FLOCKDN | SPIBAR_HSFSTS_WRSDIS;
- hsfs = read32(spibar + SPIBAR_HSFSTS_CTL);
- hsfs |= SPIBAR_HSFSTS_FLOCKDN;
- write32(spibar + SPIBAR_HSFSTS_CTL, hsfs);
+ write16(spibar + SPIBAR_HSFSTS_CTL, hsfs);
}
/*
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_def.h b/src/soc/intel/common/block/fast_spi/fast_spi_def.h
index d28f39cdf3..8e06df28de 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi_def.h
+++ b/src/soc/intel/common/block/fast_spi/fast_spi_def.h
@@ -70,6 +70,7 @@
#define SPIBAR_HSFSTS_FLOCKDN (1 << 15)
#define SPIBAR_HSFSTS_FDV (1 << 14)
#define SPIBAR_HSFSTS_FDOPSS (1 << 13)
+#define SPIBAR_HSFSTS_WRSDIS (1 << 11)
#define SPIBAR_HSFSTS_SAF_CE (1 << 8)
#define SPIBAR_HSFSTS_SAF_ACTIVE (1 << 7)
#define SPIBAR_HSFSTS_SAF_LE (1 << 6)