diff options
author | Scott Sweeny <scott.sweeny@timesys.com> | 2009-04-29 16:12:02 -0400 |
---|---|---|
committer | Scott Sweeny <scott.sweeny@timesys.com> | 2009-04-29 16:12:02 -0400 |
commit | 13c7c993f472eec5b9961750056c57f4f1494c0f (patch) | |
tree | 08d4b92a1bc3ee0d806e3c0e8f647b7a77bc906f /common | |
parent | 1ef67de43fb51c00f5e355f8ed03352e67b89fc9 (diff) |
Improved NAND support and environment options for OMAP3430LV SOM
This patch originally from LogicPD OMAP35x Release 1.5.0
Original Patch Name: u-boot-1.1.4-omap3430-lv-som-06.patch
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_nand.c | 14 | ||||
-rw-r--r-- | common/env_nand.c | 39 |
2 files changed, 51 insertions, 2 deletions
diff --git a/common/cmd_nand.c b/common/cmd_nand.c index f8133009d5..5c76ec46cd 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -130,6 +130,7 @@ arg_off_size(int argc, char *argv[], ulong *off, ulong *size, ulong totsize) } #if defined(CONFIG_OMAP) && (defined(CONFIG_3430LABRADOR) || defined(CONFIG_3430LV_SOM)) extern void omap_nand_switch_ecc(nand_info_t *nand, int hardware); +extern int omap_nand_get_ecc(nand_info_t *nand); extern int nand_unlock(nand_info_t *nand, ulong off, ulong size); #else #define omap_nand_switch_ecc(x, y) do {} while(0) @@ -239,7 +240,18 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } if (strncmp(cmd, "ecc", 3) == 0) { - if (argc < 3) + if (argc < 3) { +#if defined(CONFIG_3430LV_SOM) + int ecc; + ecc = omap_nand_get_ecc(nand); + if (ecc) + printf("Hardware ECC\n"); + else + printf("Software ECC\n"); +#else + goto usage; +#endif + } else if (argc > 4) goto usage; if (strncmp(argv[2], "hw", 2) == 0) omap_nand_switch_ecc(nand, 1); diff --git a/common/env_nand.c b/common/env_nand.c index 376154d591..b00d649197 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -149,9 +149,13 @@ int saveenv(void) puts ("Writing to Nand... "); ret = nand_write(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*) env_ptr); + if (ret || total != CFG_ENV_SIZE) + printf("%s:%d ret %d, total %d size %d\n", __FUNCTION__, __LINE__, ret, total, CFG_ENV_SIZE); } - if (ret || total != CFG_ENV_SIZE) + if (ret || total != CFG_ENV_SIZE) { + printf("%s:%d\n", __FUNCTION__); return 1; + } puts ("done\n"); gd->env_valid = (gd->env_valid == 2 ? 1 : 2); @@ -167,6 +171,31 @@ int saveenv(void) ulong total; int ret = 0; +#if defined(CONFIG_OMAP) + extern void omap_nand_switch_ecc(nand_info_t *nand, int hardware); + extern int omap_nand_get_ecc(nand_info_t *nand); + + int mode; + + // Switch to soft ECC for environment + mode = omap_nand_get_ecc(&nand_info[0]); + omap_nand_switch_ecc(&nand_info[0], 0); + +#if defined(CONFIG_3430LV_SOM) + // Unlock the entire NAND chip + { + struct nand_chip *this; + this = (struct nand_chip *)nand_info[0].priv; + puts("Unlocking NAND..."); + ret = nand_unlock(&nand_info[0], 0, this->chipsize); + + if (ret) { + printk("NAND unlock of entire chip failed\n"); + } + } +#endif +#endif + puts ("Erasing Nand..."); if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE)) return 1; @@ -175,6 +204,13 @@ int saveenv(void) total = CFG_ENV_SIZE; ret = nand_write(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); if (ret || total != CFG_ENV_SIZE) + printf("%s:%d ret %d, total %d size %d\n", __FUNCTION__, __LINE__, ret, total, CFG_ENV_SIZE); + +#if defined(CONFIG_OMAP) + omap_nand_switch_ecc(&nand_info[0], mode); +#endif + + if (ret || total != CFG_ENV_SIZE) return 1; puts ("done\n"); @@ -255,6 +291,7 @@ void env_relocate_spec (void) ulong total; int ret; + // printf("%s: off 0x%x size 0x%x read %p\n", __FUNCTION__, CFG_ENV_OFFSET, CFG_ENV_SIZE, nand_info[0].read); total = CFG_ENV_SIZE; ret = nand_read(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr); if (ret || total != CFG_ENV_SIZE) |