summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorVikas Manocha <vikas.manocha@st.com>2016-04-04 16:49:02 -0700
committerTom Rini <trini@konsulko.com>2016-04-11 20:48:23 -0400
commit9082517a85930740f59966fcf13293c38792afe8 (patch)
treed8ad6f8b0c3b1d64edadd7291938f80019447f22 /drivers
parent3ba1352b97999546610cc9b8708281b60d660e48 (diff)
downloadu-boot-imx-9082517a85930740f59966fcf13293c38792afe8.zip
u-boot-imx-9082517a85930740f59966fcf13293c38792afe8.tar.gz
u-boot-imx-9082517a85930740f59966fcf13293c38792afe8.tar.bz2
stm32: stm32_flash: add memory barrier during flash write
After writing data to flash space, next instruction is checking if flash controller is busy writing to the flash memory. Memory barrier is required here to avoid transaction re-ordering for data write and busy status check. Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/stm32_flash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mtd/stm32_flash.c b/drivers/mtd/stm32_flash.c
index 71f4854..e16b6cd 100644
--- a/drivers/mtd/stm32_flash.c
+++ b/drivers/mtd/stm32_flash.c
@@ -137,6 +137,10 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/* To make things simple use byte writes only */
for (i = 0; i < cnt; i++) {
*(uchar *)(addr + i) = src[i];
+ /* avoid re-ordering flash data write and busy status
+ * check as flash memory space attributes are generally Normal
+ */
+ mb();
while (readl(&STM32_FLASH->sr) & STM32_FLASH_SR_BSY)
;
}