All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wilson Lee <wilson.lee@ni.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mtd: zynq: nand: Move board_nand_init() function to board.c
Date: Wed, 8 Nov 2017 09:24:48 +0000	[thread overview]
Message-ID: <1510133088.2337.2.camel@ni.com> (raw)
In-Reply-To: <d2351edc-9725-02e3-ee1a-5af2cf8356b2@xilinx.com>

Hi Michal,

On Wed, 2017-11-08 at 08:54 +0100, Michal Simek wrote:
> On 8.11.2017 03:44, Wilson Lee wrote:
> > 
> > Putting board_nand_init() function inside NAND driver was not
> > appropriate
> > due to it doesn't allow board vendor to customise their NAND
> > initialization code such as adding NAND lock/unlock code.
> > 
> > This commit was to move the board_nand_init() function from NAND
> > driver
> > to board.c file. This allow customization of board_nand_init()
> > function.
> > 
> > Signed-off-by: Wilson Lee <wilson.lee@ni.com>
> > Cc: Joe Hershberger <joe.hershberger@ni.com>
> > Cc: Keng Soon Cheah <keng.soon.cheah@ni.com>
> > Cc: Chen Yee Chew <chen.yee.chew@ni.com>
> > Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> > Cc: Michal Simek <michal.simek@xilinx.com>
> > Cc: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> > Cc: Scott Wood <oss@buserror.net>
> > ---
> >  arch/arm/mach-zynq/include/mach/nand.h |  9 +++++++++
> >  board/xilinx/zynq/board.c              | 10 ++++++++++
> >  drivers/mtd/nand/zynq_nand.c           | 12 +-----------
> >  3 files changed, 20 insertions(+), 11 deletions(-)
> >  create mode 100644 arch/arm/mach-zynq/include/mach/nand.h
> > 
> > diff --git a/arch/arm/mach-zynq/include/mach/nand.h
> > b/arch/arm/mach-zynq/include/mach/nand.h
> > new file mode 100644
> > index 0000000..61ef45f
> > --- /dev/null
> > +++ b/arch/arm/mach-zynq/include/mach/nand.h
> > @@ -0,0 +1,9 @@
> > +/*
> > + * Copyright (C) 2017 National Instruments Corp.
> > + *
> > + * SPDX-License-Identifier:	GPL-2.0+
> > + */
> > +
> > +#include <nand.h>
> > +
> > +void zynq_nand_init(void);
> > diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
> > index 90ef542..8bcb830 100644
> > --- a/board/xilinx/zynq/board.c
> > +++ b/board/xilinx/zynq/board.c
> > @@ -9,6 +9,7 @@
> >  #include <fpga.h>
> >  #include <mmc.h>
> >  #include <zynqpl.h>
> > +#include <asm/arch/nand.h>
> >  #include <asm/arch/hardware.h>
> >  #include <asm/arch/sys_proto.h>
> >  
> > @@ -156,3 +157,12 @@ int dram_init(void)
> >  	return 0;
> >  }
> >  #endif
> > +
> > +static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
> > +void board_nand_init(void)
> > +{
> > +	struct nand_chip *nand = &nand_chip[0];
> > +
> > +	if (zynq_nand_init(nand, 0))
> > +		puts("ZYNQ NAND init failed\n");
> > +}
> This is probably not enough for platforms which don't enable NAND.
> 
> > 
> > diff --git a/drivers/mtd/nand/zynq_nand.c
> > b/drivers/mtd/nand/zynq_nand.c
> > index dec2c41..9be6856 100644
> > --- a/drivers/mtd/nand/zynq_nand.c
> > +++ b/drivers/mtd/nand/zynq_nand.c
> > @@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct
> > mtd_info *mtd)
> >  	return 0;
> >  }
> >  
> > -static int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
> > +int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
> >  {
> >  	struct zynq_nand_info *xnand;
> >  	struct mtd_info *mtd;
> > @@ -1191,13 +1191,3 @@ fail:
> >  	free(xnand);
> >  	return err;
> >  }
> > -
> > -static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
> > -
> > -void board_nand_init(void)
> > -{
> > -	struct nand_chip *nand = &nand_chip[0];
> > -
> > -	if (zynq_nand_init(nand, 0))
> > -		puts("ZYNQ NAND init failed\n");
> > -}
> > 
> What's the sequence which you want to add?

Actually we wish to perform a NAND unlock right after the NAND was
begin initialized. So that, we can do some write operation (ubifs table
R/W) when we mount it as ubifs.

> Isn't it better just to include this there or create a hook here?

I was thinking for adding a hook here before. But, it will be more make
sense to me if we correct the NAND driver by moving board_nand to
board.c file.

> 
> Definitely some platforms moved this to board file and not a problem
> with moving it because it shouldn't be in nand driver.
> 
> Thanks,
> Michal
> 

Thanks, Michal.

Best Regards,
Wilson Lee

  reply	other threads:[~2017-11-08  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  2:44 [U-Boot] [PATCH] mtd: zynq: nand: Move board_nand_init() function to board.c Wilson Lee
2017-11-08  7:54 ` Michal Simek
2017-11-08  9:24   ` Wilson Lee [this message]
2017-11-09 14:08     ` Michal Simek
2018-01-13 19:07     ` Ezequiel Garcia

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=1510133088.2337.2.camel@ni.com \
    --to=wilson.lee@ni.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.