All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] nand: mxs_nand_spl: support use of env in SPL
Date: Wed, 13 May 2015 18:38:02 -0500	[thread overview]
Message-ID: <1431560282.3868.113.camel@freescale.com> (raw)
In-Reply-To: <1431121147-27733-1-git-send-email-tharvey@gateworks.com>

On Fri, 2015-05-08 at 14:39 -0700, Tim Harvey wrote:
> -int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
> +int mtd_read(struct mtd_info *mtd, loff_t offs, size_t size, size_t *retlen,
> +	     uchar *buf)
>  {
>  	struct nand_chip *chip;
>  	unsigned int page;
>  	unsigned int nand_page_per_block;
>  	unsigned int sz = 0;
> +	nand_info_t *info = &nand_info[0];

Any reason not to use the passed-in mtd pointer (and fix the
nand_spl_load_image wrapper to pass in &nand_info[0])?

> +/* setup mtd and nand structs and init mxs_nand driver */
> +static int mxs_nand_init(void)
> +{
> +	nand_info_t *info = &nand_info[0];
> +
> +	/* return if already initalized */
> +	if (nand_chip.numchips)
> +		return 0;
> +
> +	/* init mxs nand driver */
> +	board_nand_init(&nand_chip);
> +	info->priv = &nand_chip;
> +	/* set mtd functions */
> +	nand_chip.cmdfunc = mxs_nand_command;
> +	nand_chip.numchips = 1;
> +
> +	/* identify flash device */
> +	puts("NAND : ");
> +	if (mxs_flash_ident(info)) {
> +		printf("Failed to identify\n");
> +		return -1;
> +	}
> +
> +	/* allocate and initialize buffers */
> +	nand_chip.buffers = memalign(ARCH_DMA_MINALIGN,
> +				     sizeof(*nand_chip.buffers));
> +	nand_chip.oob_poi = nand_chip.buffers->databuf + info->writesize;
> +	/* setup flash layout (does not scan as we override that) */
> +	info->size = nand_chip.chipsize;
> +	nand_chip.scan_bbt(info);
> +
> +	printf("%llu MiB\n", (info->size / (1024 * 1024)));
> +	return 0;
> +}

Why did this function need to be moved?

> +int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
> +{
> +	return mtd_read(NULL, offs, size, NULL, buf);
> +}

It'd be nice to keep the wrapper near the function it wraps.

I don't see any other such wrappers; is there no other driver that
currently works with SPL env?

>  int nand_default_bbt(struct mtd_info *mtd)
>  {
>  	return 0;
> @@ -223,6 +232,7 @@ int nand_default_bbt(struct mtd_info *mtd)
>  
>  void nand_init(void)
>  {
> +	mxs_nand_init();
>  }

Do you still need the "return if already initialized" check with this
change?  How is this change related to the rest?

-Scott

  parent reply	other threads:[~2015-05-13 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 21:39 [U-Boot] [PATCH] nand: mxs_nand_spl: support use of env in SPL Tim Harvey
2015-05-13 16:56 ` Tim Harvey
2015-05-13 23:38 ` Scott Wood [this message]
2015-05-14 15:12   ` Tim Harvey
2015-05-14 18:10     ` Scott Wood

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=1431560282.3868.113.camel@freescale.com \
    --to=scottwood@freescale.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.