diff options
author | Terry Lv <r65388@freescale.com> | 2010-04-28 15:27:59 +0800 |
---|---|---|
committer | Terry Lv <r65388@freescale.com> | 2010-04-29 15:42:17 +0800 |
commit | cfb0209bfd87b6076f6f8708c49796bf1a472f9b (patch) | |
tree | 22349d9715dad33c739252a52cc19bc40a3006b1 | |
parent | 4656abc886843e162f5c2538baffe57135281480 (diff) | |
download | u-boot-imx-cfb0209bfd87b6076f6f8708c49796bf1a472f9b.zip u-boot-imx-cfb0209bfd87b6076f6f8708c49796bf1a472f9b.tar.gz u-boot-imx-cfb0209bfd87b6076f6f8708c49796bf1a472f9b.tar.bz2 |
ENGR00122980: Change default env dev to mmc for bbg
As customer usually mmc to save env data.
Change default env device to mmc for bbg.
Signed-off-by: Terry Lv <r65388@freescale.com>
-rw-r--r-- | board/freescale/mx51_bbg/mx51_bbg.c | 1 | ||||
-rw-r--r-- | common/env_mmc.c | 56 | ||||
-rw-r--r-- | include/configs/mx51_bbg.h | 4 |
3 files changed, 22 insertions, 39 deletions
diff --git a/board/freescale/mx51_bbg/mx51_bbg.c b/board/freescale/mx51_bbg/mx51_bbg.c index 32bfde8..43fe121 100644 --- a/board/freescale/mx51_bbg/mx51_bbg.c +++ b/board/freescale/mx51_bbg/mx51_bbg.c @@ -60,7 +60,6 @@ DECLARE_GLOBAL_DATA_PTR; static u32 system_rev; static enum boot_device boot_dev; -static u32 voltage_setup; u32 mx51_io_base_addr; static inline void setup_boot_device(void) diff --git a/common/env_mmc.c b/common/env_mmc.c index 79b5ed3..88db336 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -1,12 +1,6 @@ /* * (C) Copyright 2008-2010 Freescale Semiconductor, Inc. - - * (C) Copyright 2000-2006 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * - * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> - * Andreas Heppel <aheppel@sysgo.de> - * See file CREDITS for list of people who contributed to this * project. * @@ -36,16 +30,6 @@ #include <malloc.h> #include <mmc.h> -#if defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_MMC) -#define CMD_SAVEENV -#elif defined(CONFIG_ENV_OFFSET_REDUND) -#error Cannot use CONFIG_ENV_OFFSET_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_MMC -#endif - -#if defined(CONFIG_ENV_SIZE_REDUND) && (CONFIG_ENV_SIZE_REDUND < CONFIG_ENV_SIZE) -#error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE -#endif - /* references to names in env_common.c */ extern uchar default_environment[]; @@ -79,7 +63,7 @@ int env_init(void) return 0; } -inline int init_mmc_for_env(struct mmc *mmc) +int init_mmc_for_env(struct mmc *mmc) { if (!mmc) { puts("No MMC card found\n"); @@ -94,18 +78,18 @@ inline int init_mmc_for_env(struct mmc *mmc) return 0; } -#ifdef CMD_SAVEENV +#ifdef CONFIG_CMD_SAVEENV inline int write_env(struct mmc *mmc, unsigned long size, - unsigned long offset, const void *buffer) + unsigned long offset, const void *buffer) { - uint blk_start = 0, blk_cnt = 0, n = 0; + uint blk_start, blk_cnt, n; + + blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; + blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; - blk_start = (offset & (0x200 - 1)) \ - ? ((offset >> 9) + 1) : (offset >> 9); - blk_cnt = (size & (0x200 - 1)) \ - ? ((size >> 9) + 1) : (size >> 9); - n = mmc->block_dev.block_write(0, blk_start , blk_cnt, (u_char *)buffer); + n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start, + blk_cnt, (u_char *)buffer); return (n == blk_cnt) ? 0 : -1; } @@ -118,8 +102,7 @@ int saveenv(void) return 1; printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV); - if (write_env(mmc, CONFIG_ENV_SIZE, \ - CONFIG_ENV_OFFSET, env_ptr)) { + if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, env_ptr)) { puts("failed\n"); return 1; } @@ -127,19 +110,18 @@ int saveenv(void) puts("done\n"); return 0; } -#endif /* CMD_SAVEENV */ +#endif /* CONFIG_CMD_SAVEENV */ inline int read_env(struct mmc *mmc, unsigned long size, - unsigned long offset, const void *buffer) + unsigned long offset, const void *buffer) { - uint blk_start = 0, blk_cnt = 0, n = 0; + uint blk_start, blk_cnt, n; - blk_start = (offset & (0x200 - 1)) ? \ - ((offset >> 9) + 1) : (offset >> 9); - blk_cnt = (size & (0x200 - 1)) ? \ - ((size >> 9) + 1) : (size >> 9); + blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len; + blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len; - n = mmc->block_dev.block_read(0, blk_start, blk_cnt, (uchar *)buffer); + n = mmc->block_dev.block_read(CONFIG_SYS_MMC_ENV_DEV, blk_start, + blk_cnt, (uchar *)buffer); return (n == blk_cnt) ? 0 : -1; } @@ -157,7 +139,9 @@ void env_relocate_spec(void) if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) return use_default(); -#endif /* ! ENV_IS_EMBEDDED */ + + gd->env_valid = 1; +#endif } #if !defined(ENV_IS_EMBEDDED) diff --git a/include/configs/mx51_bbg.h b/include/configs/mx51_bbg.h index 117e506..252b1d8 100644 --- a/include/configs/mx51_bbg.h +++ b/include/configs/mx51_bbg.h @@ -240,8 +240,8 @@ #define CONFIG_SYS_NO_FLASH /* Monitor at beginning of flash */ -#define CONFIG_FSL_ENV_IN_SF -/* #define CONFIG_FSL_ENV_IN_MMC */ +/* #define CONFIG_FSL_ENV_IN_SF */ +#define CONFIG_FSL_ENV_IN_MMC #define CONFIG_ENV_SECT_SIZE (128 * 1024) #define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE |