public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 4/4] MXC: Reorganize 16 bit nand detection.
Date: Mon, 9 Nov 2009 14:12:27 -0600	[thread overview]
Message-ID: <20091109201227.GA4312@loki.buserror.net> (raw)
In-Reply-To: <e20f8213d5fff95e8a9d89ba83eed477a07ae1be.1257676418.git.lilja.magnus@gmail.com>

On Sun, Nov 08, 2009 at 11:55:39AM +0100, Magnus Lilja wrote:
> Alternative solution for supporting 16 bit NAND detection for the
> i.MX27 and i.MX31 SoCs. This moves the SoC specific code to the SoC header
> file leaving mxc_nand.c free from #ifdef's (in this respect).

OTOH, it moves more NAND stuff out of the NAND driver.

I guess it depends on how many more such alternatives you think will be
added in the future.

> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index 3e4254a..45d0024 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -808,8 +808,6 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
>  
>  int board_nand_init(struct nand_chip *this)
>  {
> -	struct system_control_regs *sc_regs =
> -		(struct system_control_regs *)IMX_SYSTEM_CTL_BASE;
>  	struct mtd_info *mtd;
>  	uint16_t tmp;
>  	int err = 0;
> @@ -871,15 +869,9 @@ int board_nand_init(struct nand_chip *this)
>  	writew(0x4, &host->regs->nfc_wrprot);
>  
>  	/* NAND bus width determines access funtions used by upper layer */
> -#ifdef CONFIG_MX27
> -	if (readl(&sc_regs->fmcr) & NF_16BIT_SEL)
> -		this->options |= NAND_BUSWIDTH_16;
> -#elif defined(CONFIG_MX31)
> -	if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B)
> +	if (mxc_nand_is_16bit())
>  		this->options |= NAND_BUSWIDTH_16;
> -#else
> -#warning "No autodetection of 8/16 bit NAND"
> -#endif
> +
>  	host->pagesize_2k = 0;
>  
>  	return err;
> diff --git a/include/asm-arm/arch-mx27/imx-regs.h b/include/asm-arm/arch-mx27/imx-regs.h
> index d36a6da..b88fe51 100644
> --- a/include/asm-arm/arch-mx27/imx-regs.h
> +++ b/include/asm-arm/arch-mx27/imx-regs.h
> @@ -516,4 +516,17 @@ struct iim_regs {
>  #define IIM0_SCC_KEY		11
>  #define IIM1_SUID		1
>  
> +#ifndef __ASSEMBLY__
> +static inline int mxc_nand_is_16bit(void)
> +{
> +	struct system_control_regs *sc_regs =
> +		(struct system_control_regs *)IMX_SYSTEM_CTL_BASE;
> +
> +	if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B)
> +		return 1;
> +	else
> +		return 0;
> +}
> +#endif
> +
>  #endif				/* _IMX_REGS_H */
> diff --git a/include/asm-arm/arch-mx31/mx31-regs.h b/include/asm-arm/arch-mx31/mx31-regs.h
> index 86c9975..613c632 100644
> --- a/include/asm-arm/arch-mx31/mx31-regs.h
> +++ b/include/asm-arm/arch-mx31/mx31-regs.h
> @@ -63,6 +63,19 @@ struct system_control_regs {
>  #define CCM_RCSR_NF16B	(1 << 31)
>  #define CCM_RCSR_NFMS	(1 << 30)
>  
> +#include <asm/io.h>
> +
> +static inline int mxc_nand_is_16bit(void)
> +{
> +	struct system_control_regs *sc_regs =
> +		(struct system_control_regs *)IMX_SYSTEM_CTL_BASE;
> +
> +	if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B)
> +		return 1;
> +	else
> +		return 0;
> +}
> +
>  #endif

It looks like you put the MX31 version in the MX27 file as well...

-Scott

  reply	other threads:[~2009-11-09 20:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-08 10:55 [U-Boot] [RFC 0/4] MXC: Add NAND support for i.MX31 Magnus Lilja
2009-11-08 10:55 ` [U-Boot] [RFC 1/4] MX31: Add struct definition for clock control module in i.MX31 Magnus Lilja
2009-11-08 10:55   ` [U-Boot] [RFC 2/4] mxc_nand: Update driver to work with i.MX31 Magnus Lilja
2009-11-08 10:55     ` [U-Boot] [RFC 3/4] MX31: Activate NAND support for i.MX31 Litekit board Magnus Lilja
2009-11-08 10:55       ` [U-Boot] [RFC 4/4] MXC: Reorganize 16 bit nand detection Magnus Lilja
2009-11-09 20:12         ` Scott Wood [this message]
2009-11-10 20:43           ` Magnus Lilja

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=20091109201227.GA4312@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