public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
@ 2008-04-18 14:29 Matthias Fuchs
  2008-04-18 16:01 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 12+ messages in thread
From: Matthias Fuchs @ 2008-04-18 14:29 UTC (permalink / raw)
  To: u-boot

This patch adds a configurable flash auto protection list that can be used
to make U-Boot protect flash regions in flash_init().

The idea has been discussed on the u-boot mailing list starting
on Nov 18th, 2007.

Even this patch brings a new feature it is used as a bugfix for 4xx
platforms where flash_init() does not completely protect the
monitor's flash range in all situations.

U-Boot protects the flash range from CFG_MONITOR_BASE to
(CFG_MONITOR_BASE + monitor_flash_len  - 1) by default. This does not
include the reset vector at 0xfffffffc.

Example:
#define CFG_FLASH_AUTOPROTECT_LIST {{0xfff80000, 0x80000}}

This config option will auto protect the last 512k of flash that
contains the bootloader on board like APC405 and PMC405.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
---
 drivers/mtd/cfi_flash.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e3cfb8a..68ab55f 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1873,6 +1873,12 @@ unsigned long flash_init (void)
 {
 	unsigned long size = 0;
 	int i;
+#if defined(CFG_FLASH_AUTOPROTECT_LIST)
+	struct apl_s {
+		ulong start;
+		ulong size;
+	} apl[] = CFG_FLASH_AUTOPROTECT_LIST;
+#endif
 
 #ifdef CFG_FLASH_PROTECTION
 	char *s = getenv("unlock");
@@ -1966,6 +1972,17 @@ unsigned long flash_init (void)
 		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
 		       flash_get_info(CFG_ENV_ADDR_REDUND));
 #endif
+
+#if defined(CFG_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
 	return (size);
 }
 
-- 
1.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-04-20 23:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-18 14:29 [U-Boot-Users] [PATCH] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST Matthias Fuchs
2008-04-18 16:01 ` Jean-Christophe PLAGNIOL-VILLARD
2008-04-19 11:30   ` Matthias Fuchs
2008-04-19 12:02     ` Stefan Roese
2008-04-19 14:50       ` Matthias Fuchs
2008-04-19 15:33         ` [U-Boot-Users] [PATCH] cfi-flash: Add?CFG_FLASH_AUTOPROTECT_LIST Jean-Christophe PLAGNIOL-VILLARD
2008-04-19 17:22           ` Matthias Fuchs
2008-04-20  3:54             ` [U-Boot-Users] [PATCH] cfi-flash:?Add?CFG_FLASH_AUTOPROTECT_LIST Jean-Christophe PLAGNIOL-VILLARD
2008-04-20 23:44               ` Wolfgang Denk
2008-04-20  1:14   ` [U-Boot-Users] [PATCH] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST Wolfgang Denk
2008-04-20 13:22     ` Matthias Fuchs
2008-04-20 21:52       ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox