From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Wed, 19 Aug 2015 00:03:42 +0200 Subject: [U-Boot] [PATCH v2 7/7] sf: Add FSR support to spi_flash_cmd_wait_ready In-Reply-To: <1439807574-26767-8-git-send-email-jteki@openedev.com> References: <1439807574-26767-1-git-send-email-jteki@openedev.com> <1439807574-26767-8-git-send-email-jteki@openedev.com> Message-ID: <201508190003.42475.marex@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 On Monday, August 17, 2015 at 12:32:54 PM, Jagan Teki wrote: > This patch adds flag status register reading support to > spi_flash_cmd_wait_ready. > > Signed-off-by: Jagan Teki > Cc: Simon Glass > Cc: Marek Vasut > Cc: Michal Simek > Cc: Siva Durga Prasad Paladugu > Cc: Stefan Roese > Cc: Tom Warren > Cc: Bin Meng > Cc: Tom Rini > Cc: Hou Zhiqiang > Tested-by: Jagan Teki > --- > drivers/mtd/spi/sf_internal.h | 1 + > drivers/mtd/spi/sf_ops.c | 66 > +++++++++++++++++++++++++++++++++++++++---- drivers/mtd/spi/sf_probe.c > | 4 +-- > include/spi_flash.h | 2 -- > 4 files changed, 62 insertions(+), 11 deletions(-) > > diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h > index e97c716..4ecfd0c 100644 > --- a/drivers/mtd/spi/sf_internal.h > +++ b/drivers/mtd/spi/sf_internal.h > @@ -49,6 +49,7 @@ enum { > > enum spi_nor_option_flags { > SNOR_F_SST_WR = (1 << 0), > + SNOR_F_USE_FSR = (1 << 1), > }; > > #define SPI_FLASH_3B_ADDR_LEN 3 > diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c > index 7d7c264..a5487ad 100644 > --- a/drivers/mtd/spi/sf_ops.c > +++ b/drivers/mtd/spi/sf_ops.c > @@ -40,6 +40,21 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, > u8 *rs) return 0; > } > > +static int read_fsr(struct spi_flash *flash, u8 *fsr) > +{ > + int ret; > + u8 cmd; > + > + cmd = CMD_FLAG_STATUS; > + ret = spi_flash_read_common(flash, &cmd, 1, fsr, 1); > + if (ret < 0) { > + debug("SF: fail to read flag status register\n"); > + return ret; > + } > + > + return 0; > +} > + > int spi_flash_cmd_write_status(struct spi_flash *flash, u8 ws) > { > u8 cmd; > @@ -138,24 +153,63 @@ static void spi_flash_dual_flash(struct spi_flash > *flash, u32 *addr) } > #endif > > +static inline int spi_flash_sr_ready(struct spi_flash *flash) > +{ > + u8 sr; > + int ret; > + > + ret = spi_flash_cmd_read_status(flash, &sr); > + if (ret < 0) > + return ret; > + > + if (sr < 0) Have you ever seen u8 value that's < 0 ? :-) > + return sr; > + else > + return !(sr & STATUS_WIP); > +} [...]