At the start of an smi_write, if the destination address is page aligned, the Write Enable command is getting issued twice. This patch fixes it by keeping a flag.
Signed-off-by: Vipin Kumar <vipin.ku...@st.com> --- drivers/mtd/st_smi.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/st_smi.c b/drivers/mtd/st_smi.c index a46b273..a84802a 100644 --- a/drivers/mtd/st_smi.c +++ b/drivers/mtd/st_smi.c @@ -374,7 +374,7 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr, u8 *src_addr8 = (u8 *)src_addr; u8 *dst_addr8 = (u8 *)dst_addr; int banknum; - int i; + int i, issue_we; switch (bank_addr) { case SMIBANK0_BASE: @@ -394,19 +394,16 @@ static int smi_write(unsigned int *src_addr, unsigned int *dst_addr, } writel(readl(&smicntl->smi_sr) & ~(ERF1 | ERF2), &smicntl->smi_sr); - - if (smi_wait_till_ready(banknum, CONFIG_SYS_FLASH_WRITE_TOUT)) - return -EBUSY; + issue_we = 1; /* Set SMI in Hardware Mode */ writel(readl(&smicntl->smi_cr1) & ~SW_MODE, &smicntl->smi_cr1); - if (smi_write_enable(banknum)) - return -EIO; - /* Perform the write command */ for (i = 0; i < length; i += 4) { - if (((ulong) (dst_addr) % SFLASH_PAGE_SIZE) == 0) { + if (issue_we || (((ulong)(dst_addr) % SFLASH_PAGE_SIZE) == 0)) { + issue_we = 0; + if (smi_wait_till_ready(banknum, CONFIG_SYS_FLASH_WRITE_TOUT)) return -EBUSY; -- 1.8.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot