diff mbox series

[4/5] mtd: spi-nor: spansion: Octal DTR support in RD_ANY_REG_OP

Message ID 5322b787dc0a2943d2563d433216429b47ce7ff8.1686557139.git.Takahiro.Kuwano@infineon.com
State Changes Requested
Delegated to: Ambarus Tudor
Headers show
Series mtd: spi-nor: spansion: Add support for Infineon S28HS02GT | expand

Commit Message

Takahiro Kuwano June 12, 2023, 10:04 a.m. UTC
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>

S28HS02GT uses RD_ANY_REG_OP to read status of each die. In Octal DTR
mode, RD_ANY_REG_OP needs dummy cycles (same as params->rdsr_dummy) and
data length should be 2.

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
 drivers/mtd/spi-nor/spansion.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Tudor Ambarus June 12, 2023, 12:18 p.m. UTC | #1
On 6/12/23 11:04, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> 
> S28HS02GT uses RD_ANY_REG_OP to read status of each die. In Octal DTR
> mode, RD_ANY_REG_OP needs dummy cycles (same as params->rdsr_dummy) and
> data length should be 2.
> 
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
>  drivers/mtd/spi-nor/spansion.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
> index eda3731c17be..8b8512402639 100644
> --- a/drivers/mtd/spi-nor/spansion.c
> +++ b/drivers/mtd/spi-nor/spansion.c
> @@ -103,11 +103,17 @@ static void spansion_nor_clear_sr(struct spi_nor *nor)
>  
>  static int cypress_nor_sr_ready_and_clear_reg(struct spi_nor *nor, u64 addr)
>  {
> +	struct spi_nor_flash_parameter *params = nor->params;
>  	struct spi_mem_op op =
> -		CYPRESS_NOR_RD_ANY_REG_OP(nor->params->addr_mode_nbytes, addr,
> +		CYPRESS_NOR_RD_ANY_REG_OP(params->addr_mode_nbytes, addr,
>  					  0, nor->bouncebuf);
>  	int ret;
>  
> +	if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
> +		op.dummy.nbytes = params->rdsr_dummy;

yet another dummy nbytes nonsense.

$ git grep rdsr_dummy drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/core.h: * @rdsr_dummy:              dummy cycles
needed for Read Status Register command

rdsr_dummy is defined as number of cycles and here you assume it's in
bytes. Who's right?

> +		op.data.nbytes = 2;
> +	}
> +
>  	ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto);
>  	if (ret)
>  		return ret;
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
index eda3731c17be..8b8512402639 100644
--- a/drivers/mtd/spi-nor/spansion.c
+++ b/drivers/mtd/spi-nor/spansion.c
@@ -103,11 +103,17 @@  static void spansion_nor_clear_sr(struct spi_nor *nor)
 
 static int cypress_nor_sr_ready_and_clear_reg(struct spi_nor *nor, u64 addr)
 {
+	struct spi_nor_flash_parameter *params = nor->params;
 	struct spi_mem_op op =
-		CYPRESS_NOR_RD_ANY_REG_OP(nor->params->addr_mode_nbytes, addr,
+		CYPRESS_NOR_RD_ANY_REG_OP(params->addr_mode_nbytes, addr,
 					  0, nor->bouncebuf);
 	int ret;
 
+	if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
+		op.dummy.nbytes = params->rdsr_dummy;
+		op.data.nbytes = 2;
+	}
+
 	ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto);
 	if (ret)
 		return ret;