[U-Boot] [PATCH 1/5] mtd: nand: add initialization flag

Z.Q. Hou zhiqiang.hou at nxp.com
Tue Mar 7 13:56:06 UTC 2017


Hi Prabhakar,

Thanks for your comments!

> -----Original Message-----
> From: Prabhakar Kushwaha
> Sent: Tuesday, March 07, 2017 6:05 PM
> To: Z.Q. Hou <zhiqiang.hou at nxp.com>; u-boot at lists.denx.de;
> oss at buserror.net; york sun <york.sun at nxp.com>;
> Mingkai.hu at freescale.com; sjg at chromium.org; Xiaobo Xie
> <xiaobo.xie at nxp.com>
> Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
> 
> 
> > -----Original Message-----
> > From: Z.Q. Hou
> > Sent: Tuesday, March 07, 2017 12:27 PM
> > To: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>; u-
> > boot at lists.denx.de; oss at buserror.net; york sun <york.sun at nxp.com>;
> > Mingkai.hu at freescale.com; sjg at chromium.org; Xiaobo Xie
> > <xiaobo.xie at nxp.com>
> > Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
> >
> > Hi Prabhakar,
> >
> > Thanks for your comments!
> >
> > > -----Original Message-----
> > > From: Prabhakar Kushwaha
> > > Sent: Tuesday, March 07, 2017 11:17 AM
> > > To: Z.Q. Hou <zhiqiang.hou at nxp.com>; u-boot at lists.denx.de;
> > > oss at buserror.net; york sun <york.sun at nxp.com>;
> > > Mingkai.hu at freescale.com; sjg at chromium.org; Xiaobo Xie
> > > <xiaobo.xie at nxp.com>
> > > Cc: Z.Q. Hou <zhiqiang.hou at nxp.com>
> > > Subject: RE: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
> > >
> > >
> > > > -----Original Message-----
> > > > From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of
> > > > Zhiqiang Hou
> > > > Sent: Friday, March 03, 2017 7:01 PM
> > > > To: u-boot at lists.denx.de; oss at buserror.net; york sun
> > > > <york.sun at nxp.com>; Mingkai.hu at freescale.com; sjg at chromium.org;
> > > Xiaobo
> > > > Xie <xiaobo.xie at nxp.com>
> > > > Cc: Z.Q. Hou <zhiqiang.hou at nxp.com>
> > > > Subject: [U-Boot] [PATCH 1/5] mtd: nand: add initialization flag
> > > >
> > > > From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> > > >
> > > > Add initialization flag to avoid initializing NAND Flash multiple
> > > > times, otherwise it will calculate a wrong total size.
> > > >
> > > > Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> > > > ---
> > > >  drivers/mtd/nand/nand.c | 10 ++++++++++
> > > >  1 file changed, 10 insertions(+)
> > > >
> > > > diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> > > > index 0551241..3ea2dcf 100644
> > > > --- a/drivers/mtd/nand/nand.c
> > > > +++ b/drivers/mtd/nand/nand.c
> > > > @@ -133,6 +133,16 @@ static void create_mtd_concat(void)
> > > >
> > > >  void nand_init(void)
> > > >  {
> > > > +	static int initialized;
> > > > +
> > > > +	/*
> > > > +	 * Avoid initializing NAND Flash multiple times,
> > > > +	 * otherwise it will calculate a wrong total size.
> > > > +	 */
> > > > +	if (initialized)
> > > > +		return;
> > > > +	initialized = 1;
> > > > +
> > > >  #ifdef CONFIG_SYS_NAND_SELF_INIT
> > > >  	board_nand_init();
> > > >  #else
> > >
> > > If I am correct, above has done to avoid nand_init() if already done
> > > from SPL boot.
> > > I will suggest to use compile time option to skip nand_init from
> > > board_r.c instead of global variable
> > >
> >
> > It is not the SPL's matter.
> > When PPA is loaded from NAND flash, the nand_init() will be called by
> > ppa_init(), which is called earlier than the initr_nand(), so it will
> > calculate a wrong total size without this flag.
> >
> 
> This means you have to use CONFIG_LS_PPA to avoid initr_nand() calling if
> nand_init() has been used earlier.

I think the run time determination is more reasonable, because if another function will call nand_init(), it doesn't need to add any other macro.

Thanks,
Zhiqiang



More information about the U-Boot mailing list