From: Pratyush Yadav <p.yadav@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 3/9] mtd: spi-nor-core: Add support for Read/Write Any Register
Date: Fri, 29 Jan 2021 23:47:22 +0530 [thread overview]
Message-ID: <20210129181720.vwamv3dbd2pwh5c2@ti.com> (raw)
In-Reply-To: <02ee6a8ce8a95f8324d760e872b6c0f58375f251.1611729896.git.Takahiro.Kuwano@infineon.com>
On 28/01/21 01:36PM, tkuw584924 at gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Some of Spansion/Cypress chips support Read/Write Any Register commands.
> These commands are mainly used to write volatile registers and access to
> the registers in second and subsequent die for multi-die package parts.
>
> The Read Any Register instruction (65h) is followed by register address
> and dummy cycles, then the selected register byte is returned.
>
> The Write Any Register instruction (71h) is followed by register address
> and register byte to write.
>
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
> drivers/mtd/spi/spi-nor-core.c | 25 +++++++++++++++++++++++++
> include/linux/mtd/spi-nor.h | 4 ++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index 34c15f1561..2803536ed5 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -211,6 +211,31 @@ static int spi_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
> return spi_nor_read_write_reg(nor, &op, buf);
> }
>
> +#ifdef CONFIG_SPI_FLASH_SPANSION
> +static int spansion_read_any_reg(struct spi_nor *nor, u32 addr, u8 dummy,
> + u8 *val)
> +{
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDAR, 1),
> + SPI_MEM_OP_ADDR(nor->addr_width, addr, 1),
> + SPI_MEM_OP_DUMMY(dummy / 8, 1),
> + SPI_MEM_OP_DATA_IN(1, NULL, 1));
> +
> + return spi_nor_read_write_reg(nor, &op, val);
> +}
> +
> +static int spansion_write_any_reg(struct spi_nor *nor, u32 addr, u8 val)
> +{
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRAR, 1),
> + SPI_MEM_OP_ADDR(nor->addr_width, addr, 1),
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_DATA_OUT(1, NULL, 1));
> +
> + return spi_nor_read_write_reg(nor, &op, &val);
> +}
> +#endif
> +
> static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len,
> u_char *buf)
> {
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index 89e7a4fdcd..e31073eb24 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -121,6 +121,10 @@
> #define SPINOR_OP_BRWR 0x17 /* Bank register write */
> #define SPINOR_OP_BRRD 0x16 /* Bank register read */
> #define SPINOR_OP_CLSR 0x30 /* Clear status register 1 */
> +#define SPINOR_OP_RDAR 0x65 /* Read any register */
> +#define SPINOR_OP_WRAR 0x71 /* Write any register */
> +#define SPINOR_REG_ADDR_STR1V 0x00800000
> +#define SPINOR_REG_ADDR_CFR1V 0x00800002
These two defines are not used by this patch. Remove them from this one
and add them to the one that actually uses them for the first time.
With this fixed,
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
>
> /* Used for Micron flashes only. */
> #define SPINOR_OP_RD_EVCR 0x65 /* Read EVCR register */
> --
> 2.25.1
>
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
next prev parent reply other threads:[~2021-01-29 18:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 4:36 [PATCH v4 0/9] mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-01-28 4:36 ` [PATCH v4 1/9] mtd: spi-nor: Add Cypress manufacturer ID tkuw584924 at gmail.com
2021-01-29 17:52 ` Pratyush Yadav
2021-01-28 4:36 ` [PATCH v4 2/9] mtd: spi-nor-ids: Add Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-01-29 18:08 ` Pratyush Yadav
2021-02-09 5:44 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 3/9] mtd: spi-nor-core: Add support for Read/Write Any Register tkuw584924 at gmail.com
2021-01-29 18:17 ` Pratyush Yadav [this message]
2021-02-09 5:51 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 4/9] mtd: spi-nor-core: Add support for volatile QE bit tkuw584924 at gmail.com
2021-01-29 18:40 ` Pratyush Yadav
2021-02-09 5:57 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 5/9] mtd: spi-nor-core: Add the ->ready() hook tkuw584924 at gmail.com
2021-01-29 18:49 ` Pratyush Yadav
2021-02-09 6:10 ` Takahiro Kuwano
2021-01-28 4:36 ` [PATCH v4 6/9] mtd: spi-nor-core: Add overlaid sector erase feature tkuw584924 at gmail.com
2021-02-01 18:56 ` Pratyush Yadav
2021-02-10 2:37 ` Takahiro Kuwano
2021-01-28 4:37 ` [PATCH v4 7/9] mtd: spi-nor-core: Add Cypress manufacturer ID in set_4byte tkuw584924 at gmail.com
2021-01-28 4:37 ` [PATCH v4 8/9] mtd: spi-nor-core: Add fixups for Cypress s25hl-t/s25hs-t tkuw584924 at gmail.com
2021-02-01 19:22 ` Pratyush Yadav
2021-02-15 7:45 ` Takahiro Kuwano
2021-01-28 4:37 ` [PATCH v4 9/9] mtd: spi-nor-tiny: " tkuw584924 at gmail.com
2021-02-01 19:40 ` Pratyush Yadav
2021-02-10 9:20 ` 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=20210129181720.vwamv3dbd2pwh5c2@ti.com \
--to=p.yadav@ti.com \
--cc=u-boot@lists.denx.de \
/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