omap gpmc nand autodetect
Subsystems (5)
PATCH 2/3 gpmc: Add reset to gpmc_generic_init
In reply to Jan WeitzelAdd reset to gpmc_generic_init as proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for NAND OMAP4460
--- arch/arm/mach-omap/gpmc.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
arch/arm/mach-omap/gpmc.c +9 -1
@@ -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 */
Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 3/3 mtd omap nand: reconfigure buswidth
In reply to Jan WeitzelIf 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)
--- drivers/mtd/nand/nand_omap_gpmc.c | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_omap_gpmc.c +28 -2
@@ -803,6 +803,27 @@ static int omap_gpmc_eccmode_set(struct device_d *dev, struct param_d *param, coreturn 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) {
Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
cover omap gpmc nand autodetect
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 OMAP GPMC NAND: use buswidth from GPMC
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
--- 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(-)
arch/arm/boards/pcm049/board.c +2 -2
@@ -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" );
arch/arm/mach-omap/devices-gpmc-nand.c +18 -5
@@ -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;
arch/arm/mach-omap/gpmc.c +19 -0
@@ -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);
arch/arm/mach-omap/include/mach/gpmc.h +8 -0
@@ -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 */
Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] gpmc: Add reset to gpmc_generic_init
In reply to Jan WeitzelHi Jan,
Quoted 29 lines · Jan Weitzel
Add reset to
gpmc_generic_initas proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for NAND OMAP4460Signed-off-by Jan Weitzel <[email protected]>--- arch/arm/mach-omap/gpmc.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)arch/arm/mach-omap/gpmc.c +2
-0@@ -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 ;
arch/arm/mach-omap/gpmc.c line 64
Quoted 10 lines
arch/arm/mach-omap/gpmc.c +6
-1debug ("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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
In reply to Jan WeitzelHi Jan,
Quoted 2 lines · Jan Weitzel
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
Quoted 137 lines
Use autodetect on pcm049
Signed-off-by Jan Weitzel <[email protected]>--- 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(-)arch/arm/boards/pcm049/board.c +2
-2@@ -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" );arch/arm/mach-omap/devices-gpmc-nand.c +18
-5@@ -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;arch/arm/mach-omap/gpmc.c +19
-0@@ -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);arch/arm/mach-omap/include/mach/gpmc.h +8
-0@@ -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 */ Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/3 OMAP GPMC NAND: use buswidth from GPMC
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
---
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(-)
arch/arm/boards/pcm049/board.c +2 -2
@@ -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" );
arch/arm/mach-omap/devices-gpmc-nand.c +18 -5
@@ -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;
arch/arm/mach-omap/gpmc.c +19 -0
@@ -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);
arch/arm/mach-omap/include/mach/gpmc.h +8 -0
@@ -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 */
Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 gpmc: Add reset to gpmc_generic_init
In reply to Sascha HauerAdd reset to gpmc_generic_init as proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for NAND OMAP4460
---
v2: fix timeout endless loop
arch/arm/mach-omap/gpmc.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
arch/arm/mach-omap/gpmc.c +11 -1
@@ -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 */
Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
In reply to Sascha HauerAm Donnerstag, den 19.07.2012, 00:11 +0200 schrieb Sascha Hauer:
Quoted 8 lines
Hi Jan,
Quoted 2 lines · Jan Weitzel
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
Quoted 134 lines
Sascha
Quoted 132 lines
Use autodetect on pcm049
Signed-off-by Jan Weitzel <[email protected]>--- 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(-)arch/arm/boards/pcm049/board.c +2
-2@@ -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" );arch/arm/mach-omap/devices-gpmc-nand.c +18
-5@@ -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;arch/arm/mach-omap/gpmc.c +19
-0@@ -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);arch/arm/mach-omap/include/mach/gpmc.h +8
-0@@ -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 */ Signature · 1 line
1.7.0.4
Quoted 6 lines
Quoted 5 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/3] OMAP GPMC NAND: use buswidth from GPMC
Quoted 7 lines · Jan Weitzel
Am Donnerstag, den 19.07.2012, 00:11 +0200 schrieb Sascha Hauer:
Quoted 6 lines
Hi Jan,
Quoted 2 lines · Jan Weitzel
GPMC could be already configured by xloader or rom bootloader
Use the configured buswidth (width == 0) or set it explicit in the board file.
Quoted 8 lines
Quoted 2 lines
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 innand_base.ctry to fix it after return togpmc_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
Quoted 145 lines
Jan
Quoted 140 lines
Sascha
Quoted 137 lines
Use autodetect on pcm049
Signed-off-by Jan Weitzel <[email protected]>--- 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(-)arch/arm/boards/pcm049/board.c +2
-2@@ -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" );arch/arm/mach-omap/devices-gpmc-nand.c +18
-5@@ -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;arch/arm/mach-omap/gpmc.c +19
-0@@ -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);arch/arm/mach-omap/include/mach/gpmc.h +8
-0@@ -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 */ Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3 v2] gpmc: Add reset to gpmc_generic_init
In reply to Jan WeitzelHi Jan,
Quoted 5 lines · Jan Weitzel
Add reset to
gpmc_generic_initas proposed by TRM.
This also fixes some strange timing issue while GPMC Initialization for NAND OMAP4460Signed-off-by Jan Weitzel <[email protected]>
Applied this one. I think the rest needs another round.
Sascha
Quoted 51 lines
---
v2: fix timeout endless looparch/arm/mach-omap/gpmc.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)arch/arm/mach-omap/gpmc.c +11
-1@@ -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 */ Signature · 7 lines
1.7.0.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox