diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-10-23 13:43:36 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-10-26 13:06:02 +0100 |
commit | 011f6dca8980f3fd3391c9a7963dc877d1592edf (patch) | |
tree | c491257673e4144744d0dbd28a02eec5bffa2290 | |
parent | 9a9477323daea4f3453ebab5f4f87d33180b53f8 (diff) | |
download | barebox-011f6dca8980f3fd3391c9a7963dc877d1592edf.tar.gz barebox-011f6dca8980f3fd3391c9a7963dc877d1592edf.tar.xz |
mxc_nand: determine page and block size depending on NFMS bit
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | board/eukrea_cpuimx27/eukrea_cpuimx27.c | 10 | ||||
-rw-r--r-- | board/pcm037/pcm037.c | 4 | ||||
-rw-r--r-- | board/pcm038/pcm038.c | 9 | ||||
-rw-r--r-- | board/phycard-i.MX27/pca100.c | 2 | ||||
-rw-r--r-- | drivers/nand/nand_imx.c | 42 | ||||
-rw-r--r-- | include/asm-arm/arch-imx/imx-nand.h | 2 |
6 files changed, 34 insertions, 35 deletions
diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c index 038a3fcaef..f4b278395c 100644 --- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c +++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c @@ -174,15 +174,7 @@ late_initcall(eukrea_cpuimx27_late_init); #ifdef CONFIG_NAND_IMX_BOOT void __bare_init nand_boot(void) { - int pagesize = 512; - - switch ((GPCR & GPCR_BOOT_MASK) >> GPCR_BOOT_SHIFT) { - case GPCR_BOOT_8BIT_NAND_2k: - case GPCR_BOOT_16BIT_NAND_2k: - pagesize = 2048; - } - - imx_nand_load_image((void *)TEXT_BASE, 256 * 1024, pagesize, 16384); + imx_nand_load_image((void *)TEXT_BASE, 256 * 1024); } #endif diff --git a/board/pcm037/pcm037.c b/board/pcm037/pcm037.c index e265ca4efb..8fc5162485 100644 --- a/board/pcm037/pcm037.c +++ b/board/pcm037/pcm037.c @@ -303,8 +303,6 @@ console_initcall(imx31_console_init); #ifdef CONFIG_NAND_IMX_BOOT void __bare_init nand_boot(void) { - int pagesize = (readl(IMX_CCM_BASE + CCM_RCSR) & RCSR_NFMS) ? 2048 : 512; - - imx_nand_load_image((void *)TEXT_BASE, 256 * 1024, pagesize, 16384); + imx_nand_load_image((void *)TEXT_BASE, 256 * 1024); } #endif diff --git a/board/pcm038/pcm038.c b/board/pcm038/pcm038.c index 78815a985f..995844838d 100644 --- a/board/pcm038/pcm038.c +++ b/board/pcm038/pcm038.c @@ -459,16 +459,9 @@ late_initcall(pcm038_power_init); #ifdef CONFIG_NAND_IMX_BOOT void __bare_init nand_boot(void) { - int pagesize = 512; PCCR1 |= PCCR1_NFC_BAUDEN; /* FIXME: Really needed? Probably not */ - switch ((GPCR & GPCR_BOOT_MASK) >> GPCR_BOOT_SHIFT) { - case GPCR_BOOT_8BIT_NAND_2k: - case GPCR_BOOT_16BIT_NAND_2k: - pagesize = 2048; - } - - imx_nand_load_image((void *)TEXT_BASE, 256 * 1024, pagesize, 16384); + imx_nand_load_image((void *)TEXT_BASE, 256 * 1024); } #endif diff --git a/board/phycard-i.MX27/pca100.c b/board/phycard-i.MX27/pca100.c index 8515977765..317c19c9eb 100644 --- a/board/phycard-i.MX27/pca100.c +++ b/board/phycard-i.MX27/pca100.c @@ -233,7 +233,7 @@ console_initcall(pca100_console_init); #ifdef CONFIG_NAND_IMX_BOOT void __bare_init nand_boot(void) { - imx_nand_load_image((void *)TEXT_BASE, 256 * 1024, 512, 16384); + imx_nand_load_image((void *)TEXT_BASE, 256 * 1024); } #endif diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c index 03f8b69e7f..fd299d78c8 100644 --- a/drivers/nand/nand_imx.c +++ b/drivers/nand/nand_imx.c @@ -29,9 +29,6 @@ #include <asm/io.h> #include <errno.h> -#define NFMS (*((volatile u32 *)(IMX_SYSTEM_CTL_BASE + 0x14))) -#define NFMS_BIT 5 - #define DVR_VER "2.0" /* @@ -902,14 +899,35 @@ static int __nand_boot_init block_is_bad(struct imx_nand_host *host, u32 offs) return (readw(host->regs + SPARE_AREA0 + 4) & 0xff) == 0xff ? 0 : 1; } -void __nand_boot_init imx_nand_load_image(void *dest, int size, int pagesize, - int blocksize) +void __nand_boot_init imx_nand_load_image(void *dest, int size) { struct imx_nand_host host; - u32 tmp, page, block; + u32 tmp, page, block, blocksize, pagesize; + +#ifdef CONFIG_ARCH_IMX27 + tmp = readl(IMX_SYSTEM_CTL_BASE + 0x14); + if (tmp & (1 << 5)) + host.pagesize_2k = 1; + else + host.pagesize_2k = 0; +#endif +#ifdef CONFIG_ARCH_IMX31 + tmp = readl(IMX_CCM_BASE + CCM_RCSR); + if (tmp & RCSR_NFMS) + host.pagesize_2k = 1; + else + host.pagesize_2k = 0; +#endif + + if (host.pagesize_2k) { + pagesize = 2048; + blocksize = 128 * 1024; + } else { + pagesize = 512; + blocksize = 16 * 1024; + } host.regs = (void __iomem *)IMX_NFC_BASE; - host.pagesize_2k = (pagesize == 2048); send_cmd(&host, NAND_CMD_RESET); @@ -965,23 +983,21 @@ void __nand_boot_init imx_nand_load_image(void *dest, int size, int pagesize, static int do_nand_boot_test(cmd_tbl_t *cmdtp, int argc, char *argv[]) { void *dest; - int size, pagesize, blocksize; + int size; - if (argc < 4) + if (argc < 3) return COMMAND_ERROR_USAGE; dest = (void *)strtoul_suffix(argv[1], NULL, 0); size = strtoul_suffix(argv[2], NULL, 0); - pagesize = strtoul_suffix(argv[3], NULL, 0); - blocksize = strtoul_suffix(argv[4], NULL, 0); - imx_nand_load_image(dest, size, pagesize, blocksize); + imx_nand_load_image(dest, size); return 0; } static const __maybe_unused char cmd_nand_boot_test_help[] = -"Usage: nand_boot_test <dest> <size> <pagesize> <blocksize>\n"; +"Usage: nand_boot_test <dest> <size>\n"; U_BOOT_CMD_START(nand_boot_test) .cmd = do_nand_boot_test, diff --git a/include/asm-arm/arch-imx/imx-nand.h b/include/asm-arm/arch-imx/imx-nand.h index 026c07299b..0e9d6510fa 100644 --- a/include/asm-arm/arch-imx/imx-nand.h +++ b/include/asm-arm/arch-imx/imx-nand.h @@ -3,7 +3,7 @@ #include <linux/mtd/mtd.h> -void imx_nand_load_image(void *dest, int size, int pagesize, int blocksize); +void imx_nand_load_image(void *dest, int size); struct imx_nand_platform_data { int width; |