linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frieder Schrempf <frieder.schrempf@kontron.de>
To: mikhail.kshevetskiy@iopsys.eu, linux-kernel@vger.kernel.org,
	linux-mtd@lists.infradead.org
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	Richard Weinberger <richard@nod.at>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH 2/2] mtd: spinand: winbond: add Winbond W25N02KV flash support
Date: Mon, 10 Oct 2022 09:13:40 +0200	[thread overview]
Message-ID: <142333ae-2e47-11a0-22b8-139c6feaca9e@kontron.de> (raw)
In-Reply-To: <20221007104820.198938-2-mikhail.kshevetskiy@iopsys.eu>

On 07.10.22 12:48, mikhail.kshevetskiy@iopsys.eu wrote:
> From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>

Even if the subject line already describes the change, you should
probably add a short sentence here so the body of the commit message
isn't empty.

> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
> ---
>  drivers/mtd/nand/spi/winbond.c | 75 ++++++++++++++++++++++++++++++++++
>  1 file changed, 75 insertions(+)
> 
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index ed368a55d68f..3ad58cd284d8 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -74,6 +74,72 @@ static int w25m02gv_select_target(struct spinand_device *spinand,
>  	return spi_mem_exec_op(spinand->spimem, &op);
>  }
>  
> +static int w25n02kv_ooblayout_ecc(struct mtd_info *mtd, int section,
> +				  struct mtd_oob_region *region)
> +{
> +	if (section > 3)
> +		return -ERANGE;
> +
> +	region->offset = 64 + (16 * section);
> +	region->length = 13;
> +
> +	return 0;
> +}
> +
> +static int w25n02kv_ooblayout_free(struct mtd_info *mtd, int section,
> +				   struct mtd_oob_region *region)
> +{
> +	if (section > 3)
> +		return -ERANGE;
> +
> +	region->offset = (16 * section) + 2;
> +	region->length = 14;
> +
> +	return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
> +	.ecc = w25n02kv_ooblayout_ecc,
> +	.free = w25n02kv_ooblayout_free,
> +};
> +
> +static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
> +				   u8 status)
> +{
> +	struct nand_device *nand = spinand_to_nand(spinand);
> +	u8 mbf = 0;
> +	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
> +
> +	switch (status & STATUS_ECC_MASK) {
> +	case STATUS_ECC_NO_BITFLIPS:
> +		return 0;
> +
> +	case STATUS_ECC_UNCOR_ERROR:
> +		return -EBADMSG;
> +
> +	case STATUS_ECC_HAS_BITFLIPS:
> +		/*
> +		 * Let's try to retrieve the real maximum number of bitflips
> +		 * in order to avoid forcing the wear-leveling layer to move
> +		 * data around if it's not necessary.
> +		 */
> +		if (spi_mem_exec_op(spinand->spimem, &op))
> +			return nanddev_get_ecc_conf(nand)->strength;
> +
> +		mbf >>= 4;
> +
> +		if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
> +			return nanddev_get_ecc_conf(nand)->strength;
> +
> +		return mbf;
> +
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  static const struct spinand_info winbond_spinand_table[] = {
>  	SPINAND_INFO("W25M02GV",
>  		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xab, 0x21),
> @@ -94,6 +160,15 @@ static const struct spinand_info winbond_spinand_table[] = {
>  					      &update_cache_variants),
>  		     0,
>  		     SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)),
> +	SPINAND_INFO("W25N02KV",
> +		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xaa, 0x22),
> +		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
> +		     NAND_ECCREQ(8, 512),
> +		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> +					      &write_cache_variants,
> +					      &update_cache_variants),
> +		     0,
> +		     SPINAND_ECCINFO(&w25n02kv_ooblayout, w25n02kv_ecc_get_status)),
>  };
>  
>  static int winbond_spinand_init(struct spinand_device *spinand)

  reply	other threads:[~2022-10-10  7:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 10:48 [PATCH 1/2] mtd: spinand: winbond: fix winbond lashes identifications mikhail.kshevetskiy
2022-10-07 10:48 ` [PATCH 2/2] mtd: spinand: winbond: add Winbond W25N02KV flash support mikhail.kshevetskiy
2022-10-10  7:13   ` Frieder Schrempf [this message]
2022-10-10  7:11 ` [PATCH 1/2] mtd: spinand: winbond: fix winbond lashes identifications Frieder Schrempf
  -- strict thread matches above, loose matches on Subject: below --
2022-10-07 10:40 mikhail.kshevetskiy
2022-10-07 10:40 ` [PATCH 2/2] mtd: spinand: winbond: add Winbond W25N02KV flash support mikhail.kshevetskiy

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=142333ae-2e47-11a0-22b8-139c6feaca9e@kontron.de \
    --to=frieder.schrempf@kontron.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --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;
as well as URLs for NNTP newsgroup(s).