[PATCH 3/3] mtd/nand : workaround for Freescale FCM to support large-page Nand chip

Li Yang-R58472 r58472 at freescale.com
Thu Nov 24 18:37:21 EST 2011


> Subject: [PATCH 3/3] mtd/nand : workaround for Freescale FCM to support
> large-page Nand chip
> 
> From: Liu Shuo <b35362 at freescale.com>
> 
> Freescale FCM controller has a 2K size limitation of buffer RAM. In order
> to support the Nand flash chip whose page size is larger than 2K bytes,
> we read/write 2k data repeatedly by issuing FIR_OP_RB/FIR_OP_WB and save
> them to a large buffer.
> 
> Signed-off-by: Liu Shuo <b35362 at freescale.com>
> Signed-off-by: Li Yang <leoli at freescale.com>
> ---
>  drivers/mtd/nand/fsl_elbc_nand.c |  211
> +++++++++++++++++++++++++++++++++++---
>  1 files changed, 194 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
> index d634c5f..c96e714 100644
> --- a/drivers/mtd/nand/fsl_elbc_nand.c
> +++ b/drivers/mtd/nand/fsl_elbc_nand.c

[snip]

> +static void io_to_buffer(struct mtd_info *mtd, int subpage, int oob)
> +{
> +	struct nand_chip *chip = mtd->priv;
> +	struct fsl_elbc_mtd *priv = chip->priv;
> +	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
> +	void *src, *dst;
> +	int len = (oob ? 64 : 2048);
> +
> +	if (oob)
> +		dst = elbc_fcm_ctrl->buffer + mtd->writesize + subpage * 64;
> +	else
> +		dst = elbc_fcm_ctrl->buffer + subpage * 2048;
> +
> +	src = elbc_fcm_ctrl->addr + (oob ? 2048 : 0);
> +	memcpy_fromio(dst, src, len);

Might be safer to use _memcpy_fromio()

> +}
> +
> +static void buffer_to_io(struct mtd_info *mtd, int subpage, int oob)
> +{
> +	struct nand_chip *chip = mtd->priv;
> +	struct fsl_elbc_mtd *priv = chip->priv;
> +	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
> +	void *src, *dst;
> +	int len = (oob ? 64 : 2048);
> +
> +	if (oob)
> +		src = elbc_fcm_ctrl->buffer + mtd->writesize + subpage * 64;
> +	else
> +		src = elbc_fcm_ctrl->buffer + subpage * 2048;
> +
> +	dst = elbc_fcm_ctrl->addr + (oob ? 2048 : 0);
> +	memcpy_toio(dst, src, len);
> +
> +	/* See the in_8() in fsl_elbc_write_buf() */
> +	in_8(elbc_fcm_ctrl->addr);

Should be safer to read back the last char.

- Leo


More information about the Linuxppc-dev mailing list