summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2011-04-04 08:10:21 +0200
committerStefan Roese <sr@denx.de>2011-04-07 10:20:22 +0200
commit6ee1416e8184b4d9ebe6087d396a60bcecf3551c (patch)
treea110bf71d130969b8cdeebff2839f1e036f66f3c
parent2c9f48af7315ab7eeba739bec37256b246c64819 (diff)
downloadu-boot-imx-6ee1416e8184b4d9ebe6087d396a60bcecf3551c.zip
u-boot-imx-6ee1416e8184b4d9ebe6087d396a60bcecf3551c.tar.gz
u-boot-imx-6ee1416e8184b4d9ebe6087d396a60bcecf3551c.tar.bz2
mtd, cfi: introduce void flash_protect_default(void)
collect code which protects default sectors in a function, called flash_protect_default. So boardspecific code can call it too. Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: Stefan Roese <sr@denx.de>
-rw-r--r--drivers/mtd/cfi_flash.c77
-rw-r--r--include/flash.h1
2 files changed, 42 insertions, 36 deletions
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index d5e67ea..5788328 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2086,6 +2086,46 @@ static void cfi_flash_set_config_reg(u32 base, u16 val)
/*-----------------------------------------------------------------------
*/
+
+void flash_protect_default(void)
+{
+ /* Monitor protection ON by default */
+#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
+ (!defined(CONFIG_MONITOR_IS_IN_RAM))
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_SYS_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
+ flash_get_info(CONFIG_SYS_MONITOR_BASE));
+#endif
+
+ /* Environment protection ON by default */
+#ifdef CONFIG_ENV_IS_IN_FLASH
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_ENV_ADDR,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
+ flash_get_info(CONFIG_ENV_ADDR));
+#endif
+
+ /* Redundant environment protection ON by default */
+#ifdef CONFIG_ENV_ADDR_REDUND
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_ENV_ADDR_REDUND,
+ CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
+ flash_get_info(CONFIG_ENV_ADDR_REDUND));
+#endif
+
+#if defined(CONFIG_SYS_FLASH_AUTOPROTECT_LIST)
+ for (i = 0; i < (sizeof(apl) / sizeof(struct apl_s)); i++) {
+ debug("autoprotecting from %08x to %08x\n",
+ apl[i].start, apl[i].start + apl[i].size - 1);
+ flash_protect(FLAG_PROTECT_SET,
+ apl[i].start,
+ apl[i].start + apl[i].size - 1,
+ flash_get_info(apl[i].start));
+ }
+#endif
+}
+
unsigned long flash_init (void)
{
unsigned long size = 0;
@@ -2172,42 +2212,7 @@ unsigned long flash_init (void)
#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
- /* Monitor protection ON by default */
-#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
- (!defined(CONFIG_MONITOR_IS_IN_RAM))
- flash_protect (FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
- flash_get_info(CONFIG_SYS_MONITOR_BASE));
-#endif
-
- /* Environment protection ON by default */
-#ifdef CONFIG_ENV_IS_IN_FLASH
- flash_protect (FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
- flash_get_info(CONFIG_ENV_ADDR));
-#endif
-
- /* Redundant environment protection ON by default */
-#ifdef CONFIG_ENV_ADDR_REDUND
- flash_protect (FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR_REDUND,
- CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
- flash_get_info(CONFIG_ENV_ADDR_REDUND));
-#endif
-
-#if defined(CONFIG_SYS_FLASH_AUTOPROTECT_LIST)
- for (i = 0; i < (sizeof(apl) / sizeof(struct apl_s)); i++) {
- debug("autoprotecting from %08x to %08x\n",
- apl[i].start, apl[i].start + apl[i].size - 1);
- flash_protect (FLAG_PROTECT_SET,
- apl[i].start,
- apl[i].start + apl[i].size - 1,
- flash_get_info(apl[i].start));
- }
-#endif
-
+ flash_protect_default();
#ifdef CONFIG_FLASH_CFI_MTD
cfi_mtd_init();
#endif
diff --git a/include/flash.h b/include/flash.h
index 1b6821a..0ca70d9 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -92,6 +92,7 @@ typedef unsigned long flash_sect_t;
/* Prototypes */
extern unsigned long flash_init (void);
+extern void flash_protect_default(void);
extern void flash_print_info (flash_info_t *);
extern int flash_erase (flash_info_t *, int, int);
extern int flash_sect_erase (ulong addr_first, ulong addr_last);