public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: tkuw584924@gmail.com, linux-mtd@lists.infradead.org
Cc: pratyush@kernel.org, mwalle@kernel.org,
	miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
	Bacem.Daassi@infineon.com,
	Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Subject: Re: [PATCH] mtd: spi-nor: spansion: Fixup params->set_4byte_addr_mode for SEMPER
Date: Mon, 9 Jun 2025 16:19:59 +0100	[thread overview]
Message-ID: <0b0cc45f-e6c0-4020-9324-758cb815400b@linaro.org> (raw)
In-Reply-To: <20250605085535.17963-1-Takahiro.Kuwano@infineon.com>

Hi, Takahiro,

On 6/5/25 9:55 AM, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> 
> Infineon SEMPER flash family does not support E9h opcode as Exit 4-byte
> mode (EX4B). Therefore, params->set_4byte_addr_mode is not determined by
> BFPT parse. Fixup it up by introducing vendor specific EX4B opcode (B8h)
> and function.
> 
> Fixes: c87c9b11c53ce ("mtd: spi-nor: spansion: Determine current address mode")
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
>  drivers/mtd/spi-nor/spansion.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
> index bf08dbf5e742..9162b9297ce8 100644
> --- a/drivers/mtd/spi-nor/spansion.c
> +++ b/drivers/mtd/spi-nor/spansion.c
> @@ -17,6 +17,7 @@
>  
>  #define SPINOR_OP_CLSR		0x30	/* Clear status register 1 */
>  #define SPINOR_OP_CLPEF		0x82	/* Clear program/erase failure flags */
> +#define SPINOR_OP_CYPRESS_EX4B	0xB8	/* Exit 4-byte address mode */
>  #define SPINOR_OP_CYPRESS_DIE_ERASE		0x61	/* Chip (die) erase */
>  #define SPINOR_OP_RD_ANY_REG			0x65	/* Read any register */
>  #define SPINOR_OP_WR_ANY_REG			0x71	/* Write any register */
> @@ -58,6 +59,13 @@
>  		   SPI_MEM_OP_DUMMY(ndummy, 0),				\
>  		   SPI_MEM_OP_DATA_IN(1, buf, 0))
>  
> +#define CYPRESS_NOR_EN4B_EX4B_OP(enable)				\
> +	SPI_MEM_OP(SPI_MEM_OP_CMD(enable ? SPINOR_OP_EN4B :		\
> +					   SPINOR_OP_CYPRESS_EX4B, 0),	\

I wonder if it would make sense to have per vendor opcodes. Updating the
set_4byte_addr_mode() method wouldn't be needed in this case, you would
just need to use some nor->vendor->ops->ex4b opcode, right?

> +		   SPI_MEM_OP_NO_ADDR,					\
> +		   SPI_MEM_OP_NO_DUMMY,					\
> +		   SPI_MEM_OP_NO_DATA)
> +
>  #define SPANSION_OP(opcode)						\
>  	SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0),				\
>  		   SPI_MEM_OP_NO_ADDR,					\
> @@ -356,6 +364,20 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)
>  	return 0;
>  }
>  
> +static int cypress_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
> +{
> +	int ret;
> +	struct spi_mem_op op = CYPRESS_NOR_EN4B_EX4B_OP(enable);
> +
> +	spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
> +
> +	ret = spi_mem_exec_op(nor->spimem, &op);
> +	if (ret)
> +		dev_dbg(nor->dev, "error %d setting 4-byte mode\n", ret);
> +
> +	return ret;
> +}
> +
>  /**
>   * cypress_nor_determine_addr_mode_by_sr1() - Determine current address mode
>   *                                            (3 or 4-byte) by querying status
> @@ -424,6 +446,13 @@ static int cypress_nor_set_addr_mode_nbytes(struct spi_nor *nor)

>  	u8 addr_mode;
>  	int ret;
>  
> +	/*
> +	 * 4-byte address mode method is not determined by BFPT parse as SEMPER
> +	 * does not support EX4B(E9h). Assign device-specific method before
> +	 * spi_nor_set_4byte_addr_mode() is called.
> +	 */
> +	nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode;

not here please, but in the post_bfpt fixup hook.
addr_mode_nbytes is described in BFPT_DWORD[1], while
set_4byte_addr_mode in BFPT_DWORD[16], 2 different things.

Cheers,
ta

> +
>  	/*
>  	 * Read SR1 by RDSR1 and RDAR(3- AND 4-byte addr). Use write enable
>  	 * that sets bit-1 in SR1.


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2025-06-09 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05  8:55 [PATCH] mtd: spi-nor: spansion: Fixup params->set_4byte_addr_mode for SEMPER tkuw584924
2025-06-09 15:19 ` Tudor Ambarus [this message]
2025-06-12  7:01   ` Takahiro Kuwano
2025-06-12  7:04     ` Tudor Ambarus
2025-06-12  7:12       ` Takahiro Kuwano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b0cc45f-e6c0-4020-9324-758cb815400b@linaro.org \
    --to=tudor.ambarus@linaro.org \
    --cc=Bacem.Daassi@infineon.com \
    --cc=Takahiro.Kuwano@infineon.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=tkuw584924@gmail.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox