diff mbox series

[v2,4/4] mtd: spi-nor-core: Fix the opcode extension for the software reset sequence

Message ID 20211103234950.202289-5-tudor.ambarus@microchip.com
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series mtd: spi-nor: Fix software reset; add mx66lm1g45g | expand

Commit Message

Tudor Ambarus Nov. 3, 2021, 11:49 p.m. UTC
It was always hardcoded to SPI_NOR_EXT_REPEAT, while there are
flashes that may use an SPI_NOR_EXT_INVERT opcode extension
(mx66lm1g45g). Remove the hardcoded value and let flashes use
their per flash opcode extension type.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/mtd/spi/spi-nor-core.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Pratyush Yadav Nov. 9, 2021, 7:29 p.m. UTC | #1
On 04/11/21 01:49AM, Tudor Ambarus wrote:
> It was always hardcoded to SPI_NOR_EXT_REPEAT, while there are
> flashes that may use an SPI_NOR_EXT_INVERT opcode extension
> (mx66lm1g45g). Remove the hardcoded value and let flashes use
> their per flash opcode extension type.

I suggested this exact patch, along with invert extension support for 
soft reset on boot in [0]. Once we decide on patch 3/4 this should be 
good to go.

[0] https://lore.kernel.org/u-boot/20211025194216.mpocldhlu3pdy63h@ti.com/

> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>  drivers/mtd/spi/spi-nor-core.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index caf764720c..cbdad335b3 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -3685,10 +3685,6 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  {
>  	struct spi_mem_op op;
>  	int ret;
> -	enum spi_nor_cmd_ext ext;
> -
> -	ext = nor->cmd_ext_type;
> -	nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
>  
>  	op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
>  			SPI_MEM_OP_NO_DUMMY,
> @@ -3698,7 +3694,7 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  	ret = spi_mem_exec_op(nor->spi, &op);
>  	if (ret) {
>  		dev_warn(nor->dev, "Software reset enable failed: %d\n", ret);
> -		goto out;
> +		return ret;
>  	}
>  
>  	op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0),
> @@ -3709,7 +3705,7 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  	ret = spi_mem_exec_op(nor->spi, &op);
>  	if (ret) {
>  		dev_warn(nor->dev, "Software reset failed: %d\n", ret);
> -		goto out;
> +		return ret;
>  	}
>  
>  	/*
> @@ -3719,9 +3715,7 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  	 */
>  	udelay(SPI_NOR_SRST_SLEEP_LEN);
>  
> -out:
> -	nor->cmd_ext_type = ext;
> -	return ret;
> +	return 0;
>  }
>  #endif /* CONFIG_SPI_FLASH_SOFT_RESET */
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index caf764720c..cbdad335b3 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3685,10 +3685,6 @@  static int spi_nor_soft_reset(struct spi_nor *nor)
 {
 	struct spi_mem_op op;
 	int ret;
-	enum spi_nor_cmd_ext ext;
-
-	ext = nor->cmd_ext_type;
-	nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
 
 	op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
 			SPI_MEM_OP_NO_DUMMY,
@@ -3698,7 +3694,7 @@  static int spi_nor_soft_reset(struct spi_nor *nor)
 	ret = spi_mem_exec_op(nor->spi, &op);
 	if (ret) {
 		dev_warn(nor->dev, "Software reset enable failed: %d\n", ret);
-		goto out;
+		return ret;
 	}
 
 	op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0),
@@ -3709,7 +3705,7 @@  static int spi_nor_soft_reset(struct spi_nor *nor)
 	ret = spi_mem_exec_op(nor->spi, &op);
 	if (ret) {
 		dev_warn(nor->dev, "Software reset failed: %d\n", ret);
-		goto out;
+		return ret;
 	}
 
 	/*
@@ -3719,9 +3715,7 @@  static int spi_nor_soft_reset(struct spi_nor *nor)
 	 */
 	udelay(SPI_NOR_SRST_SLEEP_LEN);
 
-out:
-	nor->cmd_ext_type = ext;
-	return ret;
+	return 0;
 }
 #endif /* CONFIG_SPI_FLASH_SOFT_RESET */