mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] omap gpmc nand autodetect
@ 2012-07-18 12:37 Jan Weitzel
  2012-07-18 12:37 ` [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC Jan Weitzel
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jan Weitzel @ 2012-07-18 12:37 UTC (permalink / raw)
  To: barebox


Jan Weitzel (3):
  OMAP GPMC NAND: use buswidth from GPMC
  gpmc: Add reset to gpmc_generic_init
  mtd omap nand: reconfigure buswidth

 arch/arm/boards/pcm049/board.c         |    4 ++--
 arch/arm/mach-omap/devices-gpmc-nand.c |   23 ++++++++++++++++++-----
 arch/arm/mach-omap/gpmc.c              |   29 ++++++++++++++++++++++++++++-
 arch/arm/mach-omap/include/mach/gpmc.h |    8 ++++++++
 drivers/mtd/nand/nand_omap_gpmc.c      |   30 ++++++++++++++++++++++++++++--
 5 files changed, 84 insertions(+), 10 deletions(-)


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
  2012-07-18 12:37 [PATCH 0/3] omap gpmc nand autodetect Jan Weitzel
@ 2012-07-18 12:37 ` Jan Weitzel
  2012-07-18 22:11   ` Sascha Hauer
  2012-07-18 12:37 ` [PATCH 2/3] gpmc: Add reset to gpmc_generic_init Jan Weitzel
  2012-07-18 12:37 ` [RFC 3/3] mtd omap nand: reconfigure buswidth Jan Weitzel
  2 siblings, 1 reply; 11+ messages in thread
From: Jan Weitzel @ 2012-07-18 12:37 UTC (permalink / raw)
  To: barebox

GPMC could be already configured by xloader or rom bootloader
Use the configured buswidth (width == 0) or set it explicit in the board file.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3] gpmc: Add reset to gpmc_generic_init
  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 12:37 ` Jan Weitzel
  2012-07-18 22:10   ` Sascha Hauer
  2012-07-18 12:37 ` [RFC 3/3] mtd omap nand: reconfigure buswidth Jan Weitzel
  2 siblings, 1 reply; 11+ messages in thread
From: Jan Weitzel @ 2012-07-18 12:37 UTC (permalink / raw)
  To: barebox

Add reset to gpmc_generic_init as proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for
NAND OMAP4460

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
 arch/arm/mach-omap/gpmc.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
index 399f68a..4649a1d 100644
--- a/arch/arm/mach-omap/gpmc.c
+++ b/arch/arm/mach-omap/gpmc.c
@@ -28,6 +28,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
+#include <clock.h>
 #include <init.h>
 #include <io.h>
 #include <mach/silicon.h>
@@ -48,13 +49,20 @@
  */
 void gpmc_generic_init(unsigned int cfg)
 {
+	uint64_t start;
 	unsigned int reg = GPMC_REG(CONFIG7_0);
 	char x = 0;
 
 	debug("gpmccfg=%x\n", cfg);
 	/* Generic Configurations */
+	/* reset gpmc */
+	start = get_time_ns();
 	/* No idle, L3 clock free running */
-	writel(0x10, GPMC_REG(SYS_CONFIG));
+	writel(0x12, GPMC_REG(SYS_CONFIG));
+	while (!readl(GPMC_REG(SYS_STATUS)))
+		if (is_timeout(start, MSECOND))
+			printf("timeout on gpmc reset\n");
+
 	/* No Timeout */
 	writel(0x00, GPMC_REG(TIMEOUT_CONTROL));
 	/* No IRQs */
-- 
1.7.0.4


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC 3/3] mtd omap nand: reconfigure buswidth
  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 12:37 ` [PATCH 2/3] gpmc: Add reset to gpmc_generic_init Jan Weitzel
@ 2012-07-18 12:37 ` Jan Weitzel
  2 siblings, 0 replies; 11+ messages in thread
From: Jan Weitzel @ 2012-07-18 12:37 UTC (permalink / raw)
  To: barebox

If nand_scan_ident fail try to reconfigure buswidth from 8bit to 16bit or
the other way around.

There are still the ugly debug messages like:
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xb3 (Micron NAND 1GiB 1,8V 16-bit)
NAND bus width 8 instead 16 bit
No NAND device found (-22)!
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xb3 (Micron NAND 1GiB 1,8V 16-bit)

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index d55dcaa..b80ac14 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -803,6 +803,27 @@ static int omap_gpmc_eccmode_set(struct device_d *dev, struct param_d *param, co
 	return omap_gpmc_eccmode(oinfo, i);
 }
 
+void gpmc_reconfigure_buswidth(struct gpmc_nand_info *oinfo)
+{
+	struct nand_chip *nand = &oinfo->nand;
+	struct gpmc_config cfg;
+
+	gpmc_get_config(oinfo->gpmc_cs, &cfg);
+
+	if (nand->options & NAND_BUSWIDTH_16) {
+		cfg.cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND;
+		nand->options ^= NAND_BUSWIDTH_16;
+	} else {
+		cfg.cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND |
+				GPMC_CONFIG1_DEVICESIZE_16;
+		nand->options |= NAND_BUSWIDTH_16;
+	}
+	debug("reconfigure buswidth to %d bit\n",
+		(nand->options & NAND_BUSWIDTH_16) ? 16 : 8);
+
+	gpmc_cs_config(oinfo->gpmc_cs, &cfg);
+}
+
 /**
  * @brief nand device probe.
  *
@@ -924,8 +945,13 @@ static int gpmc_nand_probe(struct device_d *pdev)
 
 	/* first scan to find the device and get the page size */
 	if (nand_scan_ident(minfo, 1)) {
-		err = -ENXIO;
-		goto out_release_mem;
+		/* retry with changed buswidth*/
+		gpmc_reconfigure_buswidth(oinfo);
+
+		if (nand_scan_ident(minfo, 1)) {
+			err = -ENXIO;
+			goto out_release_mem;
+		}
 	}
 
 	switch (pdata->device_width) {
-- 
1.7.0.4


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] gpmc: Add reset to gpmc_generic_init
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Sascha Hauer @ 2012-07-18 22:10 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

Hi Jan,

On Wed, Jul 18, 2012 at 02:37:12PM +0200, Jan Weitzel wrote:
> Add reset to gpmc_generic_init as proposed by TRM.
> This also fixes some strange timing issue while GPMC Initialization for
> NAND OMAP4460
> 
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> ---
>  arch/arm/mach-omap/gpmc.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
> index 399f68a..4649a1d 100644
> --- a/arch/arm/mach-omap/gpmc.c
> +++ b/arch/arm/mach-omap/gpmc.c
> @@ -28,6 +28,7 @@
>   * MA 02111-1307 USA
>   */
>  #include <common.h>
> +#include <clock.h>
>  #include <init.h>
>  #include <io.h>
>  #include <mach/silicon.h>
> @@ -48,13 +49,20 @@
>   */
>  void gpmc_generic_init(unsigned int cfg)
>  {
> +	uint64_t start;
>  	unsigned int reg = GPMC_REG(CONFIG7_0);
>  	char x = 0;
>  
>  	debug("gpmccfg=%x\n", cfg);
>  	/* Generic Configurations */
> +	/* reset gpmc */
> +	start = get_time_ns();
>  	/* No idle, L3 clock free running */
> -	writel(0x10, GPMC_REG(SYS_CONFIG));
> +	writel(0x12, GPMC_REG(SYS_CONFIG));
> +	while (!readl(GPMC_REG(SYS_STATUS)))
> +		if (is_timeout(start, MSECOND))
> +			printf("timeout on gpmc reset\n");

This will hang forever in the printk on timeout.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
  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     ` [PATCH 1/3] " Jan Weitzel
  0 siblings, 2 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-07-18 22:11 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

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?

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
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3 v2] OMAP GPMC NAND: use buswidth from GPMC
  2012-07-18 22:11   ` Sascha Hauer
@ 2012-07-19  7:54     ` Jan Weitzel
  2012-07-19  8:31     ` [PATCH 1/3] " Jan Weitzel
  1 sibling, 0 replies; 11+ messages in thread
From: Jan Weitzel @ 2012-07-19  7:54 UTC (permalink / raw)
  To: barebox

GPMC could be already configured by xloader or rom bootloader
Use the configured buswidth (width == 0) or set it explicit in the board file.
If gpmc register isn't configured for NAND, fallback to 8bit by gpmc reset
state.

Use autodetect on pcm049

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
v2: Update commit message

 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3 v2] gpmc: Add reset to gpmc_generic_init
  2012-07-18 22:10   ` Sascha Hauer
@ 2012-07-19  7:58     ` Jan Weitzel
  2012-07-20  7:20       ` Sascha Hauer
  0 siblings, 1 reply; 11+ messages in thread
From: Jan Weitzel @ 2012-07-19  7:58 UTC (permalink / raw)
  To: barebox

Add reset to gpmc_generic_init as proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for
NAND OMAP4460

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
v2: fix timeout endless loop

 arch/arm/mach-omap/gpmc.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
index 399f68a..b3fa56c 100644
--- a/arch/arm/mach-omap/gpmc.c
+++ b/arch/arm/mach-omap/gpmc.c
@@ -28,6 +28,7 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
+#include <clock.h>
 #include <init.h>
 #include <io.h>
 #include <mach/silicon.h>
@@ -48,13 +49,22 @@
  */
 void gpmc_generic_init(unsigned int cfg)
 {
+	uint64_t start;
 	unsigned int reg = GPMC_REG(CONFIG7_0);
 	char x = 0;
 
 	debug("gpmccfg=%x\n", cfg);
 	/* Generic Configurations */
+	/* reset gpmc */
+	start = get_time_ns();
 	/* No idle, L3 clock free running */
-	writel(0x10, GPMC_REG(SYS_CONFIG));
+	writel(0x12, GPMC_REG(SYS_CONFIG));
+	while (!readl(GPMC_REG(SYS_STATUS)))
+		if (is_timeout(start, MSECOND)) {
+			printf("timeout on gpmc reset\n");
+			break;
+		}
+
 	/* No Timeout */
 	writel(0x00, GPMC_REG(TIMEOUT_CONTROL));
 	/* No IRQs */
-- 
1.7.0.4


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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
  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
  2012-07-19 13:09       ` Sascha Hauer
  1 sibling, 1 reply; 11+ messages in thread
From: Jan Weitzel @ 2012-07-19  8:31 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
  2012-07-19  8:31     ` [PATCH 1/3] " Jan Weitzel
@ 2012-07-19 13:09       ` Sascha Hauer
  0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-07-19 13:09 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

On Thu, Jul 19, 2012 at 10:31:28AM +0200, Jan Weitzel wrote:
> 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?

Probably better to add a NAND_BUSWIDTH_UNKNOWN flag which can be passed
via platformdata and let the core handle this. I think for this you also
need a callback to the nand driver to select the bus width.

Sascha

> 
> 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
> > > 
> > 
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3 v2] gpmc: Add reset to gpmc_generic_init
  2012-07-19  7:58     ` [PATCH 2/3 v2] " Jan Weitzel
@ 2012-07-20  7:20       ` Sascha Hauer
  0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-07-20  7:20 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

Hi Jan,

On Thu, Jul 19, 2012 at 09:58:18AM +0200, Jan Weitzel wrote:
> Add reset to gpmc_generic_init as proposed by TRM.
> This also fixes some strange timing issue while GPMC Initialization for
> NAND OMAP4460
> 
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>

Applied this one. I think the rest needs another round.

Sascha

> ---
> v2: fix timeout endless loop
> 
>  arch/arm/mach-omap/gpmc.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
> index 399f68a..b3fa56c 100644
> --- a/arch/arm/mach-omap/gpmc.c
> +++ b/arch/arm/mach-omap/gpmc.c
> @@ -28,6 +28,7 @@
>   * MA 02111-1307 USA
>   */
>  #include <common.h>
> +#include <clock.h>
>  #include <init.h>
>  #include <io.h>
>  #include <mach/silicon.h>
> @@ -48,13 +49,22 @@
>   */
>  void gpmc_generic_init(unsigned int cfg)
>  {
> +	uint64_t start;
>  	unsigned int reg = GPMC_REG(CONFIG7_0);
>  	char x = 0;
>  
>  	debug("gpmccfg=%x\n", cfg);
>  	/* Generic Configurations */
> +	/* reset gpmc */
> +	start = get_time_ns();
>  	/* No idle, L3 clock free running */
> -	writel(0x10, GPMC_REG(SYS_CONFIG));
> +	writel(0x12, GPMC_REG(SYS_CONFIG));
> +	while (!readl(GPMC_REG(SYS_STATUS)))
> +		if (is_timeout(start, MSECOND)) {
> +			printf("timeout on gpmc reset\n");
> +			break;
> +		}
> +
>  	/* No Timeout */
>  	writel(0x00, GPMC_REG(TIMEOUT_CONTROL));
>  	/* No IRQs */
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-20  7:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [PATCH 1/3] " Jan Weitzel
2012-07-19 13:09       ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox