[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190807110937.4dfe1746@xps13>
Date: Wed, 7 Aug 2019 11:09:37 +0200
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: shiva.linuxworks@...il.com
Cc: Richard Weinberger <richard@....at>,
David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Marek Vasut <marek.vasut@...il.com>,
Vignesh Raghavendra <vigneshr@...com>,
Boris Brezillon <bbrezillon@...nel.org>,
Marcel Ziswiler <marcel.ziswiler@...adex.com>,
Frieder Schrempf <frieder.schrempf@...tron.de>,
Shivamurthy Shastri <sshivamurthy@...ron.com>,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
Jeff Kletsky <git-commits@...ycomm.com>,
Chuanhong Guo <gch981213@...il.com>,
liaoweixiong <liaoweixiong@...winnertech.com>
Subject: Re: [PATCH 3/8] mtd: nand: create ONFI table parsing instance
Hi Shiva,
shiva.linuxworks@...il.com wrote on Mon, 22 Jul 2019 07:56:16 +0200:
> From: Shivamurthy Shastri <sshivamurthy@...ron.com>
"Create one generic ONFI table parsing instance"
>
> ONFI table parsing is common, as most of the variables are common
> between raw and SPI NAND. The parsing function is instantiated in
> onfi.c, which fills ONFI parameters into nand_memory_organization.
... into nand_memory_organization just as before.
>
> Signed-off-by: Shivamurthy Shastri <sshivamurthy@...ron.com>
> ---
> drivers/mtd/nand/onfi.c | 32 ++++++++++++++++++++++++++++++++
> drivers/mtd/nand/raw/nand_onfi.c | 22 ++--------------------
> include/linux/mtd/onfi.h | 2 ++
> 3 files changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/mtd/nand/onfi.c b/drivers/mtd/nand/onfi.c
> index 7aaf36dfc5e0..e78700894aea 100644
> --- a/drivers/mtd/nand/onfi.c
> +++ b/drivers/mtd/nand/onfi.c
> @@ -87,3 +87,35 @@ void sanitize_string(u8 *s, size_t len)
> strim(s);
> }
> EXPORT_SYMBOL_GPL(sanitize_string);
> +
> +/**
> + * fill_nand_memorg() - Parse ONFI table and fill memorg
^ parse_onfi_params() - Parse an ONFI table and fill a memory
organization structure
> + * @memorg: NAND memorg to be filled
memory organization core structure to be filled
> + * @p: ONFI table to be parsed
> + *
> + */
> +void parse_onfi_params(struct nand_memory_organization *memorg,
> + struct nand_onfi_params *p)
> +{
> + memorg->pagesize = le32_to_cpu(p->byte_per_page);
> +
> + /*
> + * pages_per_block and blocks_per_lun may not be a power-of-2 size
> + * (don't ask me who thought of this...). MTD assumes that these
> + * dimensions will be power-of-2, so just truncate the remaining area.
> + */
> + memorg->pages_per_eraseblock =
> + 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1);
> +
> + memorg->oobsize = le16_to_cpu(p->spare_bytes_per_page);
> +
> + memorg->luns_per_target = p->lun_count;
> + memorg->planes_per_lun = 1 << p->interleaved_bits;
> +
> + /* See erasesize comment */
> + memorg->eraseblocks_per_lun =
> + 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1);
> + memorg->max_bad_eraseblocks_per_lun = le32_to_cpu(p->blocks_per_lun);
> + memorg->bits_per_cell = p->bits_per_cell;
> +}
> +EXPORT_SYMBOL_GPL(parse_onfi_params);
> diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c
> index 2e8edfa636ef..263796d3298c 100644
> --- a/drivers/mtd/nand/raw/nand_onfi.c
> +++ b/drivers/mtd/nand/raw/nand_onfi.c
> @@ -181,30 +181,12 @@ int nand_onfi_detect(struct nand_chip *chip)
> goto free_onfi_param_page;
> }
>
> - memorg->pagesize = le32_to_cpu(p->byte_per_page);
> - mtd->writesize = memorg->pagesize;
> + parse_onfi_params(memorg, p);
>
> - /*
> - * pages_per_block and blocks_per_lun may not be a power-of-2 size
> - * (don't ask me who thought of this...). MTD assumes that these
> - * dimensions will be power-of-2, so just truncate the remaining area.
> - */
> - memorg->pages_per_eraseblock =
> - 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1);
> + mtd->writesize = memorg->pagesize;
> mtd->erasesize = memorg->pages_per_eraseblock * memorg->pagesize;
> -
> - memorg->oobsize = le16_to_cpu(p->spare_bytes_per_page);
> mtd->oobsize = memorg->oobsize;
>
> - memorg->luns_per_target = p->lun_count;
> - memorg->planes_per_lun = 1 << p->interleaved_bits;
> -
> - /* See erasesize comment */
> - memorg->eraseblocks_per_lun =
> - 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1);
> - memorg->max_bad_eraseblocks_per_lun = le32_to_cpu(p->blocks_per_lun);
> - memorg->bits_per_cell = p->bits_per_cell;
> -
> if (le16_to_cpu(p->features) & ONFI_FEATURE_16_BIT_BUS)
> chip->options |= NAND_BUSWIDTH_16;
>
> diff --git a/include/linux/mtd/onfi.h b/include/linux/mtd/onfi.h
> index 2c8a05a02bb0..4cacf4e9db6d 100644
> --- a/include/linux/mtd/onfi.h
> +++ b/include/linux/mtd/onfi.h
> @@ -183,5 +183,7 @@ void nand_bit_wise_majority(const void **srcbufs,
> void *dstbuf,
> unsigned int bufsize);
> void sanitize_string(u8 *s, size_t len);
> +void parse_onfi_params(struct nand_memory_organization *memorg,
> + struct nand_onfi_params *p);
>
> #endif /* __LINUX_MTD_ONFI_H */
Thanks,
Miquèl
Powered by blists - more mailing lists