[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220429060852.whf5puyf6nkvm4jn@ti.com>
Date: Fri, 29 Apr 2022 11:38:53 +0530
From: Pratyush Yadav <p.yadav@...com>
To: Michael Walle <michael@...le.cc>
CC: Tudor Ambarus <tudor.ambarus@...rochip.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
<linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mtd: spi-nor: move spi_nor_write_ear() to winbond module
Hi Michael,
On 18/04/22 01:24PM, Michael Walle wrote:
> The "Extended Address Register" is winbond specific. If the flash is
> larger than 16MiB and is used in 3 byte address mode, it is used to set
> the remaining address bits. Move the write_ear() function the winbond
> module and rename it accordingly.
This patch no longer applies due to Tudor's patch c0abb861c5d0 ("mtd:
spi-nor: Introduce templates for SPI NOR operations") which changes the
contents of spi_nor_write_ear() to use a template. Please rebase and
resend so I can apply it.
>
> Signed-off-by: Michael Walle <michael@...le.cc>
> ---
> drivers/mtd/spi-nor/core.c | 34 ---------------------------------
> drivers/mtd/spi-nor/core.h | 1 -
> drivers/mtd/spi-nor/winbond.c | 36 ++++++++++++++++++++++++++++++++++-
> 3 files changed, 35 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index b4f141ad9c9c..848836535cdd 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -520,40 +520,6 @@ static int spansion_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
> return ret;
> }
>
> -/**
> - * spi_nor_write_ear() - Write Extended Address Register.
> - * @nor: pointer to 'struct spi_nor'.
> - * @ear: value to write to the Extended Address Register.
> - *
> - * Return: 0 on success, -errno otherwise.
> - */
> -int spi_nor_write_ear(struct spi_nor *nor, u8 ear)
> -{
> - int ret;
> -
> - nor->bouncebuf[0] = ear;
> -
> - if (nor->spimem) {
> - struct spi_mem_op op =
> - SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREAR, 0),
> - SPI_MEM_OP_NO_ADDR,
> - SPI_MEM_OP_NO_DUMMY,
> - SPI_MEM_OP_DATA_OUT(1, nor->bouncebuf, 0));
> -
> - spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
> -
> - ret = spi_mem_exec_op(nor->spimem, &op);
> - } else {
> - ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_WREAR,
> - nor->bouncebuf, 1);
> - }
> -
> - if (ret)
> - dev_dbg(nor->dev, "error %d writing EAR\n", ret);
> -
> - return ret;
> -}
> -
> /**
> * spi_nor_sr_ready() - Query the Status Register to see if the flash is ready
> * for new commands.
> diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
> index b7fd760e3b47..14bf28473cf3 100644
> --- a/drivers/mtd/spi-nor/core.h
> +++ b/drivers/mtd/spi-nor/core.h
> @@ -526,7 +526,6 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor,
> int spi_nor_write_enable(struct spi_nor *nor);
> int spi_nor_write_disable(struct spi_nor *nor);
> int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
> -int spi_nor_write_ear(struct spi_nor *nor, u8 ear);
> int spi_nor_wait_till_ready(struct spi_nor *nor);
> int spi_nor_global_block_unlock(struct spi_nor *nor);
> int spi_nor_lock_and_prep(struct spi_nor *nor);
> diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c
> index 1e8fb571680b..0ca96efee5c9 100644
> --- a/drivers/mtd/spi-nor/winbond.c
> +++ b/drivers/mtd/spi-nor/winbond.c
> @@ -130,6 +130,40 @@ static const struct flash_info winbond_nor_parts[] = {
> SPI_NOR_QUAD_READ) },
> };
>
> +/**
> + * winbond_nor_write_ear() - Write Extended Address Register.
> + * @nor: pointer to 'struct spi_nor'.
> + * @ear: value to write to the Extended Address Register.
> + *
> + * Return: 0 on success, -errno otherwise.
> + */
> +static int winbond_nor_write_ear(struct spi_nor *nor, u8 ear)
> +{
> + int ret;
> +
> + nor->bouncebuf[0] = ear;
> +
> + if (nor->spimem) {
> + struct spi_mem_op op =
> + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREAR, 0),
> + SPI_MEM_OP_NO_ADDR,
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_DATA_OUT(1, nor->bouncebuf, 0));
> +
> + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
> +
> + ret = spi_mem_exec_op(nor->spimem, &op);
> + } else {
> + ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_WREAR,
> + nor->bouncebuf, 1);
> + }
> +
> + if (ret)
> + dev_dbg(nor->dev, "error %d writing EAR\n", ret);
> +
> + return ret;
> +}
> +
> /**
> * winbond_nor_set_4byte_addr_mode() - Set 4-byte address mode for Winbond
> * flashes.
> @@ -156,7 +190,7 @@ static int winbond_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
> if (ret)
> return ret;
>
> - ret = spi_nor_write_ear(nor, 0);
> + ret = winbond_nor_write_ear(nor, 0);
> if (ret)
> return ret;
>
> --
> 2.30.2
>
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
Powered by blists - more mailing lists