From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Wed, 12 Mar 2014 06:14:12 +0100 Subject: [U-Boot] [PATCH] cfi_flash: Micron Nor flash don't support read operation after send write command In-Reply-To: <71CF8D7F32C5C24C9CD1D0E02D52498A770D0A29@NTXXIAMBX02.xacn.micron.com> References: <71CF8D7F32C5C24C9CD1D0E02D52498A770D0A29@NTXXIAMBX02.xacn.micron.com> Message-ID: <531FED24.10004@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Qi Wang, please don't send this patch so often. On 11.03.2014 09:46, Qi Wang ?? (qiwang) wrote: > Micron Nor flash don't support read operation after send write command. Are all Micon NOR flash chips affected by this? Or only some chips? Please list the chips/families and best add a link to the description of this unsupported operation mode (chapter in data-sheet or errata). Find a few more comments below. > As below, > > flash_write_cmd(info, sector, offset, AMD_CMD_WRITE_TO_BUFFER); > cnt = len >> shift; > flash_write_cmd(info, sector, offset, cnt - 1); > > switch (info->portwidth) { > case FLASH_CFI_8BIT: > while (cnt-- > 0) { > flash_write8(flash_read8(src), dst); > src += 1, dst += 1; > } > break; > > If the src address locate in NOR flash, flash_read operation will be failed. > So, read out the data to DRAM before send write command operation. > > Signed-off-by: Qi Wang > --- > drivers/mtd/cfi_flash.c | 70 +++++++++++++++++++++++++++++++---------------- > 1 file changed, 46 insertions(+), 24 deletions(-) > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index a389cd1..0f532c0 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -25,6 +25,8 @@ > #include > #include > #include > +#include > +#include > > /* > * This file implements a Common Flash Interface (CFI) driver for @@ -855,6 +857,8 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, > int cnt; > int retcode; > void *src = cp; > + void *src2; > + void *src2_bak; > void *dst = (void *)dest; > void *dst2 = dst; > int flag = 1; > @@ -880,29 +884,45 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, > goto out_unmap; > } > > + src2 = malloc(len); Naming is not optimal, at least for my taste. My not use "src_buf"? > + if(!src2) > + { > + free(src2); > + return -ENOMEM; > + } Incorrect coding style. Please use something like this instead: if (!src2) { free(src2); return -ENOMEM; } Thanks, Stefan