[U-Boot-Users] [PATCH: ecb: 1/2] Move at91rm9200dk initialization out of dataflash.c

Nelson Castillo nelsoneci at gmail.com
Tue Jun 12 02:37:25 CEST 2007


Hi.

There is some initialization specific to the
at91rm9200dk in flash.c : the protected zones in
the dataflash driver.

We made an initializer for that. We need it
because we need to use the same driver. We also added
more information to be printed for the protected sectors
of the dataflash. IMHO the comments wanted to be part of
the code.

Thus:

  {0, 0x7fff, FLAG_PROTECT_SET} /* ROM Code */

becomes

  {0, 0x7fff, FLAG_PROTECT_SET, "ROM code"}

The string is printed in "dataflash_print_info", if you
don't want an informational message to be printed, just
set to "".

Move at91rm9200dk initialization out of dataflash.c
Signed-off-by: Nelson Castillo <nelson at emqbit.com>
diff --git a/drivers/dataflash.c b/drivers/dataflash.c
index 17eb859..2528a46 100644
--- a/drivers/dataflash.c
+++ b/drivers/dataflash.c
@@ -26,19 +26,10 @@
 AT91S_DATAFLASH_INFO dataflash_info[CFG_MAX_DATAFLASH_BANKS];
 static AT91S_DataFlash DataFlashInst;
 
-int cs[][CFG_MAX_DATAFLASH_BANKS] = {
-	{CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},	/* Logical adress, CS */
-	{CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
-};
-
-/*define the area offsets*/
-dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
-	{0, 0x7fff, FLAG_PROTECT_SET},			/* ROM code */
-	{0x8000, 0x1ffff, FLAG_PROTECT_SET},		/* u-boot code */
-	{0x20000, 0x27fff, FLAG_PROTECT_CLEAR},		/* u-boot environment */
-	{0x28000, 0x1fffff, FLAG_PROTECT_CLEAR},	/* data area size to tune */
-};
+int (*cs)[CFG_MAX_DATAFLASH_BANKS];
+dataflash_protect_t *area_list;
 
+extern void AT91F_DataflashMapInit(void);
 extern void AT91F_SpiInit (void);
 extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc);
 extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash,
@@ -55,6 +46,7 @@ int AT91F_DataflashInit (void)
 	int dfcode;
 
 	AT91F_SpiInit ();
+	AT91F_DataflashMapInit();
 
 	for (i = 0; i < CFG_MAX_DATAFLASH_BANKS; i++) {
 		dataflash_info[i].Desc.state = IDLE;
@@ -119,11 +111,18 @@ int AT91F_DataflashInit (void)
 			dataflash_info[i].Device.area_list[j].start = area_list[j].start + dataflash_info[i].logical_address;
 			dataflash_info[i].Device.area_list[j].end = area_list[j].end + dataflash_info[i].logical_address;
 			dataflash_info[i].Device.area_list[j].protected = area_list[j].protected;
+			dataflash_info[i].Device.area_list[j].label = area_list[j].label;
 		}
 	}
 	return (1);
 }
 
+extern void AT91F_MapInit (int _cs[][CFG_MAX_DATAFLASH_BANKS], dataflash_protect_t _area_list[])
+{
+  cs = _cs;
+  area_list = _area_list;
+}
+
 
 void dataflash_print_info (void)
 {
@@ -159,11 +158,12 @@ void dataflash_print_info (void)
 				dataflash_info[i].Device.pages_size,
 				(unsigned int) dataflash_info[i].logical_address);
 			for (j=0; j< NB_DATAFLASH_AREA; j++) {
-				printf ("Area %i:\t%08lX to %08lX %s\n", j,
+				printf ("Area %i:\t%08lX to %08lX %s %s\n", j,
 					dataflash_info[i].Device.area_list[j].start,
 					dataflash_info[i].Device.area_list[j].end,
 					(dataflash_info[i].Device.area_list[j].protected ==
-					FLAG_PROTECT_SET) ? "(RO)" : "");
+					FLAG_PROTECT_SET) ? "(RO)" : "    ",
+					dataflash_info[i].Device.area_list[j].label);
 			}
 		}
 	}
diff --git a/include/dataflash.h b/include/dataflash.h
index 650454e..d7ec7eb 100644
--- a/include/dataflash.h
+++ b/include/dataflash.h
@@ -37,14 +37,12 @@
 #include <asm/arch/hardware.h>
 #include "config.h"
 
-/*number of protected area*/
-#define NB_DATAFLASH_AREA	4
-
 /*define the area structure*/
 typedef struct {
 	unsigned long start;
 	unsigned long end;
 	unsigned char protected;
+	char *label;
 } dataflash_protect_t;
 
 typedef unsigned int AT91S_DataFlashStatus;
@@ -174,5 +172,6 @@ extern int read_dataflash (unsigned long addr, unsigned long size, char *result)
 extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size);
 extern void dataflash_print_info (void);
 extern void dataflash_perror (int err);
+extern void AT91F_MapInit (int cs[][CFG_MAX_DATAFLASH_BANKS], dataflash_protect_t area_list[]); /* board initialization */
 
 #endif
diff --git a/include/configs/at91rm9200dk.h b/include/configs/at91rm9200dk.h
index 8fad55d..0daa394 100644
--- a/include/configs/at91rm9200dk.h
+++ b/include/configs/at91rm9200dk.h
@@ -157,6 +157,8 @@
 #define CFG_DATAFLASH_LOGIC_ADDR_CS0	0xC0000000	/* Logical adress for CS0 */
 #define CFG_DATAFLASH_LOGIC_ADDR_CS3	0xD0000000	/* Logical adress for CS3 */
 
+#define NB_DATAFLASH_AREA               4  /*number of protected area*/
+
 #define PHYS_FLASH_1			0x10000000
 #define PHYS_FLASH_SIZE			0x200000  /* 2 megs main flash */
 #define CFG_FLASH_BASE			PHYS_FLASH_1

diff --git a/board/at91rm9200dk/at91rm9200dk.c b/board/at91rm9200dk/at91rm9200dk.c
index 002981a..84abdbc 100644
--- a/board/at91rm9200dk/at91rm9200dk.c
+++ b/board/at91rm9200dk/at91rm9200dk.c
@@ -140,3 +140,29 @@ void nand_init (void)
 	printf ("%4lu MB\n", nand_probe(AT91_SMARTMEDIA_BASE) >> 20);
 }
 #endif
+
+
+#ifdef CONFIG_HAS_DATAFLASH
+#include <dataflash.h>
+
+void AT91F_DataflashMapInit(void)
+{
+	static int cs[][CFG_MAX_DATAFLASH_BANKS] = {
+		/* Logical adress, CS */
+		{CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},
+		{CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
+		};
+
+	static dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+		/*define the area offsets*/
+		{0, 0x7fff, FLAG_PROTECT_SET, "ROM code"},
+		{0x8000, 0x1ffff, FLAG_PROTECT_SET, "u-boot code"},
+		{0x20000, 0x27fff, FLAG_PROTECT_CLEAR, "u-boot environment"},
+		{0x28000, 0x1fffff, FLAG_PROTECT_CLEAR,
+		 "Data area size to tune"},
+		};
+
+	AT91F_MapInit (cs, area_list);
+}
+
+#endif


-- 

http://arhuaco.org
http://emQbit.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20070611/7c27b1cb/attachment.pgp 


More information about the U-Boot mailing list