From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] Monahan/PXA3xx: integrate Linux NAND controller driver
Date: Thu, 7 Jan 2010 13:44:05 -0600 [thread overview]
Message-ID: <20100107194405.GD28859@loki.buserror.net> (raw)
In-Reply-To: <1261625629.3706.57.camel@com-21>
On Thu, Dec 24, 2009 at 04:33:49AM +0100, Marcel Ziswiler wrote:
> +/* XXX U-BOOT XXX */
> +#define __U_BOOT__
> +
> +#ifndef __U_BOOT__
I don't think we need this.
In fact, it could make it harder to spot conflicts when merging new versions
of the file from linux, since patch could find the context it's looking for
in the middle of an #ifndef __U_BOOT__ section when the change really needs
to be applied to the other side of the #else.
Plus, it makes it harder to read the code. Let's share what we reasonably
can, and get rid of the rest.
> +#undef DEBUG
Don't undef it, just don't define it. Maybe someone wants to turn debugging
on system-wide.
> +#ifdef DEBUG
> +#define DEBUGF(fmt, args...) printf(fmt, ##args)
> +#else /* DEBUG */
> +#define DEBUGF(x...)
> +#endif /* DEBUG */
We've already got MTDDEBUG.
> +#define CONFIG_MTD_NAND_PXA3xx_BUILTIN
This is marked deprecated in Linux; perhaps we should take the preferred
approach of platform-specified data here as well?
> +#define CONFIG_MTD_NAND_PXA3xx_POLLING
I don't see this upstream.
> +#ifdef CONFIG_NAND_SPL
> +/**
> + * memset - Fill a region of memory with the given value
> + * @s: Pointer to the start of the area.
> + * @c: The byte to fill the area with
> + * @count: The size of the area.
> + *
> + * Do not use memset() to access IO space, use memset_io() instead.
> + */
> +void *memset(void *s, int c, size_t count)
> +{
> + char *xs = (char *) s;
> +
> + while (count--)
> + *xs++ = c;
> +
> + return s;
> +}
> +
> +/**
> + * memcpy - Copy one area of memory to another
> + * @dest: Where to copy to
> + * @src: Where to copy from
> + * @count: The size of the area.
> + *
> + * You should not use this function to access IO space, use memcpy_toio()
> + * or memcpy_fromio() instead.
> + */
> +void *memcpy(void *dest, const void *src, size_t count)
> +{
> + char *tmp = (char *) dest, *s = (char *) src;
> +
> + while (count--)
> + *tmp++ = *s++;
> +
> + return dest;
> +}
> +#endif /* CONFIG_NAND_SPL */
> +
> +void msleep(int count)
> +{
> + int i;
> +
> + for (i = 0; i < count; i++)
> + udelay(1000);
> +}
Can we arrange to pull in the relevant functions from the rest of u-boot
rather than duplicate them?
Or try to avoid the need in the NAND loader -- for example, msleep is only
used in handling NAND_CMD_RESET, which you shouldn't need.
In fact, I'm not sure how this driver can be used at all with NAND_SPL. The
normal nand_spl/nand_boot.c uses cmd_ctrl. More complicated controllers
that can't use cmd_ctrl generally need their own nand_spl driver (such as
nand_spl/nand_boot_fsl_elbc.c). If you have a particularly large NAND boot
region, you might be able to create a nand_spl driver that uses this driver,
but typically space is too tight.
> +/* macros for registers read/write */
> +#ifdef __U_BOOT__
> +#define nand_writel(info, off, val) \
> + ((*(volatile u32 *) ((info)->mmio_base + (off))) = (val))
> +
> +static void nand_writesl(volatile u32 *dest, u8 *src, int size)
> +{
> + int i;
> + u32 *source = (u32 *)src;
> +
> + for (i = 0; i < size; i++)
> + *dest = *(source++);
> +}
> +
> +#define nand_readl(info, off) \
> + (*(volatile u32 *)((info)->mmio_base + (off)))
> +
> +static void nand_readsl(volatile u32 *source, u8 *dst, int size)
> +{
> + u32 *dest = (u32 *)dst;
> + int i;
> +
> + for (i = 0; i < size; i++)
> + *(dest++) = *source;
> +}
> +#else /* __U_BOOT__ */
> +#define nand_writel(info, off, val) \
> + __raw_writel((val), (info)->mmio_base + (off))
> +
> +#define nand_readl(info, off) \
> + __raw_readl((info)->mmio_base + (off))
> +#endif /* __U_BOOT__ */
You can (and should) use __raw_writel/__raw_readl in U-Boot as well.
There is also a prototype for__raw_writesl/__raw_readsl, but the
implementation seems to be missing -- perhaps you could add it generically,
rather than just in one driver.
-Scott
next prev parent reply other threads:[~2010-01-07 19:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-24 3:29 [U-Boot] [PATCH 0/3] Monahan/PXA3xx: integrate Linux NAND controller driver Marcel Ziswiler
2009-12-24 3:33 ` [U-Boot] [PATCH 1/3] " Marcel Ziswiler
2010-01-07 19:44 ` Scott Wood [this message]
2010-01-08 22:34 ` Marcel Ziswiler
2010-01-08 23:13 ` Scott Wood
2009-12-24 3:36 ` [U-Boot] [PATCH 2/3] delta: use new generic " Marcel Ziswiler
2009-12-24 3:38 ` [U-Boot] [PATCH 3/3] zylonite: " Marcel Ziswiler
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=20100107194405.GD28859@loki.buserror.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox