[U-Boot] [PATCH] cfi_flash: Micron Nor flash don't support read operation after send write command

Stefan Roese sr at denx.de
Wed Mar 12 06:14:12 CET 2014


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<qiwang at micron.com>
> ---
> 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 <environment.h>
>   #include <mtd/cfi_flash.h>
>   #include <watchdog.h>
> +#include <malloc.h>
> +#include <asm-generic/errno.h>
>
>   /*
>    * 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



More information about the U-Boot mailing list