[U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands

Peng Fan Peng.Fan at freescale.com
Wed Mar 25 15:09:48 CET 2015


Hi Haikun,

On 3/25/2015 8:35 PM, Haikun Wang wrote:
> From: Haikun Wang <Haikun.Wang at freescale.com>
>
> Atmel AT45DB series devices commands is different from common spi flash
> commands. This patch add support for AT45DB special commands.
> Add a flag AT45DB_CMD to control whether use those commands.
>
> Signed-off-by: Haikun Wang <Haikun.Wang at freescale.com>
> ---
>
> Changes in v1: None
>
>   drivers/mtd/spi/sf_internal.h |  7 +++++++
>   drivers/mtd/spi/sf_ops.c      |  2 +-
>   drivers/mtd/spi/sf_probe.c    | 10 ++++++++++
>   3 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
> index 785f7a9..234af21 100644
> --- a/drivers/mtd/spi/sf_internal.h
> +++ b/drivers/mtd/spi/sf_internal.h
> @@ -43,6 +43,7 @@ enum {
>   	SST_BP		= 1 << 3,
>   	SST_WP		= 1 << 4,
>   	WR_QPP		= 1 << 5,
> +	AT45DB_CMD	= 1 << 6,
>   };
>   
>   #define SST_WR		(SST_BP | SST_WP)
> @@ -106,6 +107,12 @@ enum {
>   #define SPI_FLASH_PAGE_ERASE_TIMEOUT		(5 * CONFIG_SYS_HZ)
>   #define SPI_FLASH_SECTOR_ERASE_TIMEOUT	(10 * CONFIG_SYS_HZ)
>   
> +/* Atmel AT45DB specific */
> +#define CMD_ATMEL_PAGE_PROGRAM		0x82
Why not use 0x2 to align with current mtd/spi framework?
> +#define CMD_ATMEL_READ_STATUS		0xd7
> +#define CMD_ATMEL_FLAG_STATUS		0xd7
> +#define CMD_ATMEL_BLK_ERASE	        0x50
> +
>   /* SST specific */
>   #ifdef CONFIG_SPI_FLASH_SST
>   # define CMD_SST_BP		0x02    /* Byte Program */
> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
> index 34bc54e..27ce5f9 100644
> --- a/drivers/mtd/spi/sf_ops.c
> +++ b/drivers/mtd/spi/sf_ops.c
> @@ -165,7 +165,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
>   	u8 poll_bit = STATUS_WIP;
>   	u8 cmd = flash->poll_cmd;
>   
> -	if (cmd == CMD_FLAG_STATUS) {
> +	if (cmd == CMD_FLAG_STATUS || cmd == CMD_ATMEL_FLAG_STATUS) {
>   		poll_bit = STATUS_PEC;
>   		check_status = poll_bit;
>   	}
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index 4103723..2ccddf2 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -226,6 +226,16 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
>   		flash->poll_cmd = CMD_FLAG_STATUS;
>   #endif
>   
> +#ifdef CONFIG_SPI_FLASH_ATMEL
> +	if (params->flags & AT45DB_CMD) {
> +		flash->poll_cmd = CMD_ATMEL_READ_STATUS;
> +		flash->write_cmd = CMD_ATMEL_PAGE_PROGRAM;
> +		/* use block-erase command, eight pages */
> +		flash->erase_cmd = CMD_ATMEL_BLK_ERASE;
> +		flash->erase_size = flash->page_size * 8;
> +	}
> +#endif
> +
The SPI Flash's default page size is 264 bytes, but mtd/spi framework 
supports 256 and 512 bytes for one page. In your patch, you does not 
handle such case, can your driver works as expected?
>   	/* Configure the BAR - discover bank cmds and read current bank */
>   #ifdef CONFIG_SPI_FLASH_BAR
>   	u8 curr_bank = 0;
Regards,
Peng.


More information about the U-Boot mailing list