Re: [PATCH 3/8] mtd: nand: create ONFI table parsing instance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shiva,

shiva.linuxworks@xxxxxxxxx wrote on Mon, 22 Jul 2019 07:56:16 +0200:

> From: Shivamurthy Shastri <sshivamurthy@xxxxxxxxxx>

"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@xxxxxxxxxx>
> ---
>  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

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




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux