mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 12/14] ARM: i.MX: xload nand: Move mxs_nand_mode_fcb_62bit() to header file
Date: Wed, 2 Nov 2022 09:37:36 +0100	[thread overview]
Message-ID: <20221102083736.jiv24nf55ohdkeod@pengutronix.de> (raw)
In-Reply-To: <20221101153048.772146-13-s.hauer@pengutronix.de>

Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> mxs_nand_mode_fcb_62bit() can be shared between the regular MTD NAND
> driver and the upcoming i.MX7 xload driver. Move to header file.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mtd/nand/nand_mxs.c | 34 ++--------------------------------
>  include/soc/imx/gpmi-nand.h | 27 +++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
> index b162c23743..79a8fbdefa 100644
> --- a/drivers/mtd/nand/nand_mxs.c
> +++ b/drivers/mtd/nand/nand_mxs.c
> @@ -1123,36 +1123,6 @@ static int mxs_nand_block_markbad(struct nand_chip *chip , loff_t ofs)
>  	return 0;
>  }
>  
> -#define BCH62_WRITESIZE		1024
> -#define BCH62_OOBSIZE		838
> -#define BCH62_PAGESIZE		(BCH62_WRITESIZE + BCH62_OOBSIZE)
> -
> -static void mxs_nand_mode_fcb_62bit(struct mxs_nand_info *nand_info)
> -{
> -	void __iomem *bch_regs;
> -	u32 fl0, fl1;
> -
> -	bch_regs = nand_info->bch_base;
> -
> -	/* 8 ecc_chunks */
> -	fl0 = FIELD_PREP(BCH_FLASHLAYOUT0_NBLOCKS, 7);
> -	/* 32 bytes for metadata */
> -	fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_META_SIZE, 32);
> -	/* using ECC62 level to be performed */
> -	fl0 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT0_ECC0, 0x1f);
> -	/* 0x20 * 4 bytes of the data0 block */
> -	fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_DATA0_SIZE, 0x20);
> -	writel(fl0, bch_regs + BCH_FLASH0LAYOUT0);
> -
> -	/* 1024 for data + 838 for OOB */
> -	fl1 = FIELD_PREP(BCH_FLASHLAYOUT1_PAGE_SIZE, BCH62_PAGESIZE);
> -	/* using ECC62 level to be performed */
> -	fl1 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT1_ECCN, 0x1f);
> -	/* 0x20 * 4 bytes of the data0 block */
> -	fl1 |= FIELD_PREP(BCH_FLASHLAYOUT1_DATAN_SIZE, 0x20);
> -	writel(fl1, bch_regs + BCH_FLASH0LAYOUT1);
> -}
> -
>  int mxs_nand_read_fcb_bch62(unsigned int block, void *buf, size_t size)
>  {
>  	struct nand_chip *chip;
> @@ -1174,7 +1144,7 @@ int mxs_nand_read_fcb_bch62(unsigned int block, void *buf, size_t size)
>  
>  	page = block * (mtd->erasesize / mtd->writesize);
>  
> -	mxs_nand_mode_fcb_62bit(nand_info);
> +	mxs_nand_mode_fcb_62bit(nand_info->bch_base);
>  
>  	nand_read_page_op(chip, page, 0, NULL, 0);
>  
> @@ -1238,7 +1208,7 @@ int mxs_nand_write_fcb_bch62(unsigned int block, void *buf, size_t size)
>  	nand_info = chip->priv;
>  	channel = nand_info->dma_channel_base;
>  
> -	mxs_nand_mode_fcb_62bit(nand_info);
> +	mxs_nand_mode_fcb_62bit(nand_info->bch_base);
>  
>  	nand_select_target(chip, 0);
>  
> diff --git a/include/soc/imx/gpmi-nand.h b/include/soc/imx/gpmi-nand.h
> index f7a2caa1d6..8c30dee8ab 100644
> --- a/include/soc/imx/gpmi-nand.h
> +++ b/include/soc/imx/gpmi-nand.h
> @@ -111,4 +111,31 @@
>  
>  #define	MXS_NAND_BCH_TIMEOUT			10000
>  
> +#define BCH62_WRITESIZE		1024
> +#define BCH62_OOBSIZE		838
> +#define BCH62_PAGESIZE		(BCH62_WRITESIZE + BCH62_OOBSIZE)
> +

Nit: Maybe put a small comment here so we can easily see why we are
doing this.

Regards,
  Marco

> +static void mxs_nand_mode_fcb_62bit(void __iomem *bch_regs)
> +{
> +	u32 fl0, fl1;
> +
> +	/* 8 ecc_chunks */
> +	fl0 = FIELD_PREP(BCH_FLASHLAYOUT0_NBLOCKS, 7);
> +	/* 32 bytes for metadata */
> +	fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_META_SIZE, 32);
> +	/* using ECC62 level to be performed */
> +	fl0 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT0_ECC0, 0x1f);
> +	/* 0x20 * 4 bytes of the data0 block */
> +	fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_DATA0_SIZE, 0x20);
> +	writel(fl0, bch_regs + BCH_FLASH0LAYOUT0);
> +
> +	/* 1024 for data + 838 for OOB */
> +	fl1 = FIELD_PREP(BCH_FLASHLAYOUT1_PAGE_SIZE, BCH62_PAGESIZE);
> +	/* using ECC62 level to be performed */
> +	fl1 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT1_ECCN, 0x1f);
> +	/* 0x20 * 4 bytes of the data0 block */
> +	fl1 |= FIELD_PREP(BCH_FLASHLAYOUT1_DATAN_SIZE, 0x20);
> +	writel(fl1, bch_regs + BCH_FLASH0LAYOUT1);
> +}
> +
>  #endif /* __SOC_IMX_GPMI_NAND_H */
> -- 
> 2.30.2
> 
> 
> 



  reply	other threads:[~2022-11-02  8:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 15:30 [PATCH 00/14] Add i.MX7 NAND xload support Sascha Hauer
2022-11-01 15:30 ` [PATCH 01/14] mtd: nand: nand-mxs: Move register definitions to separate file Sascha Hauer
2022-11-02  8:08   ` Marco Felsch
2022-11-01 15:30 ` [PATCH 02/14] ARM: i.MX: xload nand: Use common register defines Sascha Hauer
2022-11-02  8:10   ` Marco Felsch
2022-11-01 15:30 ` [PATCH 03/14] ARM: i.MX: xload nand: add common readid Sascha Hauer
2022-11-02  8:23   ` Marco Felsch
2022-11-01 15:30 ` [PATCH 04/14] dma: apbh-dma: Simplify code Sascha Hauer
2022-11-01 15:30 ` [PATCH 05/14] dma: apbh-dma: unify register defines Sascha Hauer
2022-11-01 15:30 ` [PATCH 06/14] ARM: i.MX: xload-gpmi-nand: refactor for more SoC support Sascha Hauer
2022-11-01 15:30 ` [PATCH 07/14] imx-bbu-nand-fcb: pull printing debug info out of get_fcb() Sascha Hauer
2022-11-01 15:30 ` [PATCH 08/14] ARM: i.MX: xload nand: Pull ECC status checking out of read page Sascha Hauer
2022-11-02  8:33   ` Marco Felsch
2022-11-01 15:30 ` [PATCH 09/14] ARM: i.MX: xload nand: Use final page layout from FCB Sascha Hauer
2022-11-01 15:30 ` [PATCH 10/14] imx-bbu-nand-fcb: Fix reading FCB information from BCH registers Sascha Hauer
2022-11-01 15:30 ` [PATCH 11/14] ARM: i.MX: xload nand: reset NAND before accessing it Sascha Hauer
2022-11-01 15:30 ` [PATCH 12/14] ARM: i.MX: xload nand: Move mxs_nand_mode_fcb_62bit() to header file Sascha Hauer
2022-11-02  8:37   ` Marco Felsch [this message]
2022-11-01 15:30 ` [PATCH 13/14] ARM: i.MX: xload nand: Implement i.MX7 support Sascha Hauer
2022-11-02  8:41   ` Marco Felsch
2022-11-02  8:46     ` Sascha Hauer
2022-11-01 15:30 ` [PATCH 14/14] imx-bbu-nand-fcb: Add fcb command Sascha Hauer
2022-11-02  8:44   ` Marco Felsch
2022-11-02 10:55     ` Sascha Hauer
2022-11-02 11:01       ` Marco Felsch
2022-11-02 11:29         ` Sascha Hauer

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=20221102083736.jiv24nf55ohdkeod@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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