[U-Boot] [PATCH 3/4] mtd: nand: add Freescale NFC driver

Bill Pringlemeir bpringlemeir at nbsps.com
Thu Aug 7 01:01:19 CEST 2014


On  6 Aug 2014, stefan at agner.ch wrote:

> This adds initial support for Freescale NFC (NAND Flash Controller).
> The IP is used in ARM based Vybrid SoCs as well as on some PowerPC
> devices. This driver is only tested on Vybrid.
> 
> Signed-off-by: Stefan Agner <stefan at agner.ch>
> ---
>  drivers/mtd/nand/Makefile  |   1 +
>  drivers/mtd/nand/fsl_nfc.c | 676
> ++++++++++++++++++++++++++++++++++++++++++++> +
>  2 files changed, 677 insertions(+)
>  create mode 100644 drivers/mtd/nand/fsl_nfc.c
 
> diff --git a/drivers/mtd/nand/fsl_nfc.c b/drivers/mtd/nand/fsl_nfc.c
> new file mode 100644
> index 0000000..df2c8be
> --- /dev/null
> +++ b/drivers/mtd/nand/fsl_nfc.c
> @@ -0,0 +1,676 @@

[snip]

> +#define NFC_TIMEOUT	(1000)
> +
> +/* ECC status placed at end of buffers. */
> +#define ECC_SRAM_ADDR	((PAGE_2K+256-8) >> 3)
> +#define ECC_STATUS_MASK	0x80
> +#define ECC_ERR_COUNT	0x3F
> +
> +struct fsl_nfc {
> +	struct mtd_info	  *mtd;
> +	struct nand_chip   chip;
> +	struct device	  *dev;
> +	void __iomem	  *regs;
> +	//wait_queue_head_t  irq_waitq;

I think u-boot doesn't like C++ comments?

> +	uint               column;
> +	int                spareonly;
> +	int                page;
> +	/* Status and ID are in alternate locations. */
> +	int                alt_buf;
> +#define ALT_BUF_ID   1
> +#define ALT_BUF_STAT 2
> +	struct clk        *clk;
> +};
> +
> +#define mtd_to_nfc(_mtd) (struct fsl_nfc *)((struct nand_chip
> *)_mtd->priv)->priv;

[snip]

> +static int nfc_correct_data(struct mtd_info *mtd, u_char *dat,
> +				 u_char *read_ecc, u_char *calc_ecc)
> +{
> +	struct fsl_nfc *nfc = mtd_to_nfc(mtd);
> +	u32 ecc_status;
> +	u8 ecc_count;
> +	int flip;
> +
> +	/* 

Some extra ws here  Ie, '/* ' with a space after the star.  Maybe that
is from me?

> +	 * Errata: ECC status is stored at NFC_CFG[ECCADD] +4 for
> +	 * little-endian and +7 for big-endian SOC.  Access as 32 bits
> +	 * and use low byte.
> +	 */

This appears to be documented in the latest Vybrid manual (Rev7).

> +	ecc_status = __raw_readl(nfc->regs + ECC_SRAM_ADDR * 8 + 4);
> +	ecc_count = ecc_status & ECC_ERR_COUNT;
> +	if (!(ecc_status & ECC_STATUS_MASK))
> +		return ecc_count;

[snip]

> +static void nfc_enable_hwecc(struct mtd_info *mtd, int mode)
> +{
> +}
> +
> +struct nfc_config {
> +	int hardware_ecc;
> +	int width;
> +	int flash_bbt;
> +};
> +
> +//static int nfc_probe(struct platform_device *pdev)

Another C++ comment.

All minor nits.  I am certainly ok with this code being included in
u-boot.

Regards,
Bill Pringlemeir.


More information about the U-Boot mailing list