From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Wed, 25 Mar 2015 22:09:48 +0800 Subject: [U-Boot] [PATCH 1/2 v1] sf: probe: Add support Atmel AT45DB series devices special commands In-Reply-To: <1427286940-28551-1-git-send-email-haikun.wang@freescale.com> References: <1427286940-28551-1-git-send-email-haikun.wang@freescale.com> Message-ID: <5512C1AC.3060001@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Haikun, On 3/25/2015 8:35 PM, Haikun Wang wrote: > From: Haikun Wang > > 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 > --- > > 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.