mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jan Weitzel <J.Weitzel@phytec.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
Date: Thu, 19 Jul 2012 10:31:28 +0200	[thread overview]
Message-ID: <1342686688.4849.21.camel@lws-weitzel> (raw)
In-Reply-To: <20120718221127.GS30009@pengutronix.de>

Am Donnerstag, den 19.07.2012, 00:11 +0200 schrieb Sascha Hauer:
> Hi Jan,
> 
> On Wed, Jul 18, 2012 at 02:37:11PM +0200, Jan Weitzel wrote:
> > GPMC could be already configured by xloader or rom bootloader
> > Use the configured buswidth (width == 0) or set it explicit in the board file.
> 
> What happens if it hasn't been configured by the ROM or xloader, for
> example when booting from MMC?
It will fall back to 8bit (GPMC register reset state). Have added this
to the commit message.
Booting from MMC is a problem for xloader and boards with 16bit NANDS.
We see the wrong buswidth in nand_base.c try to fix it after return to
gpmc_nand_probe. See the RFC mtd omap nand: reconfigure buswidth.
Did you see a better way?

Jan
> Sascha
> 
> > 
> > Use autodetect on pcm049
> > 
> > Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> > ---
> >  arch/arm/boards/pcm049/board.c         |    4 ++--
> >  arch/arm/mach-omap/devices-gpmc-nand.c |   23 ++++++++++++++++++-----
> >  arch/arm/mach-omap/gpmc.c              |   19 +++++++++++++++++++
> >  arch/arm/mach-omap/include/mach/gpmc.h |    8 ++++++++
> >  4 files changed, 47 insertions(+), 7 deletions(-)
> > 
> > diff --git a/arch/arm/boards/pcm049/board.c b/arch/arm/boards/pcm049/board.c
> > index 3a2b574..4f056e0 100644
> > --- a/arch/arm/boards/pcm049/board.c
> > +++ b/arch/arm/boards/pcm049/board.c
> > @@ -112,9 +112,9 @@ static int pcm049_devices_init(void)
> >  
> >  	pcm049_network_init();
> >  
> > -	gpmc_generic_nand_devices_init(0, 8,
> > +	/* Autodetect buswidth*/
> > +	gpmc_generic_nand_devices_init(0, 0,
> >  			OMAP_ECC_BCH8_CODE_HW, &omap4_nand_cfg);
> > -
> >  #ifdef CONFIG_PARTITION
> >  	devfs_add_partition("nand0", 0x00000, SZ_128K,
> >  			DEVFS_PARTITION_FIXED, "xload_raw");
> > diff --git a/arch/arm/mach-omap/devices-gpmc-nand.c b/arch/arm/mach-omap/devices-gpmc-nand.c
> > index cf87b57..06f9576 100644
> > --- a/arch/arm/mach-omap/devices-gpmc-nand.c
> > +++ b/arch/arm/mach-omap/devices-gpmc-nand.c
> > @@ -35,9 +35,7 @@
> >  #include <mach/silicon.h>
> >  #include <mach/gpmc.h>
> >  #include <mach/gpmc_nand.h>
> > -
> > -#define GPMC_CONF1_VALx8	0x00000800
> > -#define GPMC_CONF1_VALx16	0x00001800
> > +#include <mach/xload.h>
> >  
> >  /** NAND platform specific settings settings */
> >  static struct gpmc_nand_platform_data nand_plat = {
> > @@ -51,15 +49,30 @@ static struct gpmc_nand_platform_data nand_plat = {
> >   *
> >   * @return success/fail based on device function
> >   */
> > +
> >  int gpmc_generic_nand_devices_init(int cs, int width,
> >  		enum gpmc_ecc_mode eccmode, struct gpmc_config *nand_cfg)
> >  {
> >  	nand_plat.cs = cs;
> >  
> > +	if (width == 0) {
> > +		struct gpmc_config cfg;
> > +		/* try to get buswidth from gpmc */
> > +		gpmc_get_config(cs, &cfg);
> > +		width = (cfg.cfg[0] & GPMC_CONFIG1_DEVICETYPE_NAND) ? 16 : 8;
> > +
> > +		if (!(cfg.cfg[0] & GPMC_CONFIG1_DEVICETYPE_NAND))
> > +			debug("GPMC not configured for NAND, "
> > +					"try width %d bit\n", width);
> > +
> > +		debug("%s cfg0 %x width %d\n", __func__, cfg.cfg[0], width);
> > +	}
> > +
> >  	if (width == 16)
> > -		nand_cfg->cfg[0] = GPMC_CONF1_VALx16;
> > +		nand_cfg->cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND |
> > +					GPMC_CONFIG1_DEVICESIZE_16;
> >  	else
> > -		nand_cfg->cfg[0] = GPMC_CONF1_VALx8;
> > +		nand_cfg->cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND;
> >  
> >  	nand_plat.device_width = width;
> >  	nand_plat.ecc_mode = eccmode;
> > diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
> > index e8946d7..399f68a 100644
> > --- a/arch/arm/mach-omap/gpmc.c
> > +++ b/arch/arm/mach-omap/gpmc.c
> > @@ -115,3 +115,22 @@ void gpmc_cs_config(char cs, struct gpmc_config *config)
> >  	mdelay(1);		/* Settling time */
> >  }
> >  EXPORT_SYMBOL(gpmc_cs_config);
> > +
> > +void gpmc_get_config(char cs, struct gpmc_config *config)
> > +{
> > +	unsigned int reg = GPMC_REG(CONFIG1_0) + (cs * GPMC_CONFIG_CS_SIZE);
> > +	unsigned int cfg7;
> > +	unsigned char i;
> > +
> > +	/* Read the CFG1-6 regs */
> > +	for (i = 0; i < 6; i++) {
> > +		config->cfg[i] = readl(reg);
> > +		reg += GPMC_CONFIG_REG_OFF;
> > +	}
> > +
> > +	cfg7 = readl(reg);
> > +
> > +	config->size = (cfg7 >> 8) & 0xf;
> > +	config->base = (cfg7 & 0x3F) << 24;
> > +}
> > +EXPORT_SYMBOL(gpmc_get_config);
> > diff --git a/arch/arm/mach-omap/include/mach/gpmc.h b/arch/arm/mach-omap/include/mach/gpmc.h
> > index 3ddc5f5..84260fc 100644
> > --- a/arch/arm/mach-omap/include/mach/gpmc.h
> > +++ b/arch/arm/mach-omap/include/mach/gpmc.h
> > @@ -140,6 +140,11 @@
> >  
> >  #define NAND_WP_BIT		0x00000010
> >  
> > +#define GPMC_CONFIG1_DEVICESIZE(val)	((val & 3) << 12)
> > +#define GPMC_CONFIG1_DEVICESIZE_16	GPMC_CONFIG1_DEVICESIZE(1)
> > +#define GPMC_CONFIG1_DEVICETYPE(val)	((val & 3) << 10)
> > +#define GPMC_CONFIG1_DEVICETYPE_NAND	GPMC_CONFIG1_DEVICETYPE(2)
> > +
> >  #ifndef __ASSEMBLY__
> >  
> >  /** Generic GPMC configuration structure to be used to configure a
> > @@ -157,6 +162,9 @@ void gpmc_generic_init(unsigned int cfg);
> >  /** Configuration for a specific chip select */
> >  void gpmc_cs_config(char cs, struct gpmc_config *config);
> >  
> > +/** Get Configuration for a specific chip select */
> > +void gpmc_get_config(char cs, struct gpmc_config *config);
> > +
> >  #endif
> >  
> >  #endif /* __ASM_ARCH_OMAP_GPMC_H */
> > -- 
> > 1.7.0.4
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-07-19  8:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 12:37 [PATCH 0/3] omap gpmc nand autodetect Jan Weitzel
2012-07-18 12:37 ` [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC Jan Weitzel
2012-07-18 22:11   ` Sascha Hauer
2012-07-19  7:54     ` [PATCH 1/3 v2] " Jan Weitzel
2012-07-19  8:31     ` Jan Weitzel [this message]
2012-07-19 13:09       ` [PATCH 1/3] " Sascha Hauer
2012-07-18 12:37 ` [PATCH 2/3] gpmc: Add reset to gpmc_generic_init Jan Weitzel
2012-07-18 22:10   ` Sascha Hauer
2012-07-19  7:58     ` [PATCH 2/3 v2] " Jan Weitzel
2012-07-20  7:20       ` Sascha Hauer
2012-07-18 12:37 ` [RFC 3/3] mtd omap nand: reconfigure buswidth Jan Weitzel

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=1342686688.4849.21.camel@lws-weitzel \
    --to=j.weitzel@phytec.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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