diff mbox

[U-Boot] sf: Poll both the read status and flag status

Message ID BN1AFFO11FD027DC0F5D9F70497E8D4EA5C0190@BN1AFFO11FD027.protection.gbl
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Siva Durga Prasad Paladugu March 11, 2015, 9:17 a.m. UTC
Poll both the Read status and Flag status registers
for sucessful erase and program operations for the
Micron devices with E_FSR flag set in params table.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
---
 drivers/mtd/spi/sf_ops.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

Comments

Jagan Teki April 10, 2015, 12:13 p.m. UTC | #1
Hi Siva Durga Prasad,

On 11 March 2015 at 14:47, Siva Durga Prasad Paladugu
<siva.durga.paladugu@xilinx.com> wrote:
> Poll both the Read status and Flag status registers
> for sucessful erase and program operations for the
> Micron devices with E_FSR flag set in params table.

There is hw DIE transition from 256 to 512 and 1G, Did you test these?

>
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> ---
>  drivers/mtd/spi/sf_ops.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
> index 34bc54e..38592f5 100644
> --- a/drivers/mtd/spi/sf_ops.c
> +++ b/drivers/mtd/spi/sf_ops.c
> @@ -154,21 +154,17 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr)
>  }
>  #endif
>
> -int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
> +static int spi_flash_poll_status(struct spi_slave *spi, unsigned long timeout,
> +                                u8 cmd, u8 poll_bit)
>  {
> -       struct spi_slave *spi = flash->spi;
>         unsigned long timebase;
>         unsigned long flags = SPI_XFER_BEGIN;
>         int ret;
>         u8 status;
>         u8 check_status = 0x0;
> -       u8 poll_bit = STATUS_WIP;
> -       u8 cmd = flash->poll_cmd;
>
> -       if (cmd == CMD_FLAG_STATUS) {
> -               poll_bit = STATUS_PEC;
> +       if (cmd == CMD_FLAG_STATUS)
>                 check_status = poll_bit;
> -       }
>
>  #ifdef CONFIG_SF_DUAL_FLASH
>         if (spi->flags & SPI_XFER_U_PAGE)
> @@ -204,6 +200,28 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
>         return -1;
>  }
>
> +int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
> +{
> +       struct spi_slave *spi = flash->spi;
> +       int ret;
> +       u8 poll_bit = STATUS_WIP;
> +       u8 cmd = CMD_READ_STATUS;
> +
> +       ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
> +       if (ret < 0)
> +               return ret;
> +
> +       if (flash->poll_cmd == CMD_FLAG_STATUS) {
> +               poll_bit = STATUS_PEC;
> +               cmd = CMD_FLAG_STATUS;
> +               ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
> +               if (ret < 0)
> +                       return ret;
> +       }
> +
> +       return 0;
> +}
> +
>  int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
>                 size_t cmd_len, const void *buf, size_t buf_len)
>  {
> --
> 2.1.1

thanks!
Jagan Teki April 17, 2015, 11:51 a.m. UTC | #2
On 10 April 2015 at 17:43, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Hi Siva Durga Prasad,
>
> On 11 March 2015 at 14:47, Siva Durga Prasad Paladugu
> <siva.durga.paladugu@xilinx.com> wrote:
>> Poll both the Read status and Flag status registers
>> for sucessful erase and program operations for the
>> Micron devices with E_FSR flag set in params table.
>
> There is hw DIE transition from 256 to 512 and 1G, Did you test these?
>
>>
>> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
>> ---
>>  drivers/mtd/spi/sf_ops.c | 32 +++++++++++++++++++++++++-------
>>  1 file changed, 25 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
>> index 34bc54e..38592f5 100644
>> --- a/drivers/mtd/spi/sf_ops.c
>> +++ b/drivers/mtd/spi/sf_ops.c
>> @@ -154,21 +154,17 @@ static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr)
>>  }
>>  #endif
>>
>> -int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
>> +static int spi_flash_poll_status(struct spi_slave *spi, unsigned long timeout,
>> +                                u8 cmd, u8 poll_bit)
>>  {
>> -       struct spi_slave *spi = flash->spi;
>>         unsigned long timebase;
>>         unsigned long flags = SPI_XFER_BEGIN;
>>         int ret;
>>         u8 status;
>>         u8 check_status = 0x0;
>> -       u8 poll_bit = STATUS_WIP;
>> -       u8 cmd = flash->poll_cmd;
>>
>> -       if (cmd == CMD_FLAG_STATUS) {
>> -               poll_bit = STATUS_PEC;
>> +       if (cmd == CMD_FLAG_STATUS)
>>                 check_status = poll_bit;
>> -       }
>>
>>  #ifdef CONFIG_SF_DUAL_FLASH
>>         if (spi->flags & SPI_XFER_U_PAGE)
>> @@ -204,6 +200,28 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
>>         return -1;
>>  }
>>
>> +int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
>> +{
>> +       struct spi_slave *spi = flash->spi;
>> +       int ret;
>> +       u8 poll_bit = STATUS_WIP;
>> +       u8 cmd = CMD_READ_STATUS;
>> +
>> +       ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
>> +       if (ret < 0)
>> +               return ret;
>> +
>> +       if (flash->poll_cmd == CMD_FLAG_STATUS) {
>> +               poll_bit = STATUS_PEC;
>> +               cmd = CMD_FLAG_STATUS;
>> +               ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
>> +               if (ret < 0)
>> +                       return ret;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>>  int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
>>                 size_t cmd_len, const void *buf, size_t buf_len)
>>  {
>> --

Applied to  u-boot-spi/master

thanks!
diff mbox

Patch

diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 34bc54e..38592f5 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -154,21 +154,17 @@  static void spi_flash_dual_flash(struct spi_flash *flash, u32 *addr)
 }
 #endif
 
-int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
+static int spi_flash_poll_status(struct spi_slave *spi, unsigned long timeout,
+				 u8 cmd, u8 poll_bit)
 {
-	struct spi_slave *spi = flash->spi;
 	unsigned long timebase;
 	unsigned long flags = SPI_XFER_BEGIN;
 	int ret;
 	u8 status;
 	u8 check_status = 0x0;
-	u8 poll_bit = STATUS_WIP;
-	u8 cmd = flash->poll_cmd;
 
-	if (cmd == CMD_FLAG_STATUS) {
-		poll_bit = STATUS_PEC;
+	if (cmd == CMD_FLAG_STATUS)
 		check_status = poll_bit;
-	}
 
 #ifdef CONFIG_SF_DUAL_FLASH
 	if (spi->flags & SPI_XFER_U_PAGE)
@@ -204,6 +200,28 @@  int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
 	return -1;
 }
 
+int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
+{
+	struct spi_slave *spi = flash->spi;
+	int ret;
+	u8 poll_bit = STATUS_WIP;
+	u8 cmd = CMD_READ_STATUS;
+
+	ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
+	if (ret < 0)
+		return ret;
+
+	if (flash->poll_cmd == CMD_FLAG_STATUS) {
+		poll_bit = STATUS_PEC;
+		cmd = CMD_FLAG_STATUS;
+		ret = spi_flash_poll_status(spi, timeout, cmd, poll_bit);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
 int spi_flash_write_common(struct spi_flash *flash, const u8 *cmd,
 		size_t cmd_len, const void *buf, size_t buf_len)
 {