From: Peng Fan <Peng.Fan@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands
Date: Wed, 25 Mar 2015 22:09:48 +0800 [thread overview]
Message-ID: <5512C1AC.3060001@freescale.com> (raw)
In-Reply-To: <1427286940-28551-1-git-send-email-haikun.wang@freescale.com>
Hi Haikun,
On 3/25/2015 8:35 PM, Haikun Wang wrote:
> From: Haikun Wang <Haikun.Wang@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@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.
next prev parent reply other threads:[~2015-03-25 14:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 12:35 [U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands Haikun Wang
2015-03-25 14:09 ` Peng Fan [this message]
2015-03-26 2:39 ` Haikun.Wang at freescale.com
2015-03-26 3:04 ` Peng Fan
2015-03-26 10:50 ` Haikun.Wang at freescale.com
2015-03-26 11:03 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5512C1AC.3060001@freescale.com \
--to=peng.fan@freescale.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox