This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Intel StrataFlash fix for MIPS


HI,

when using the Intel StrataFlash driver on my MIPS platform, I
encountered the following problem:

In flash_query(), which is executing from RAM, the flash chip is
returned to array mode by writing the control code FLASH_Reset
(0xff) immediatly before return. The actual write operation can
be (and in my case, was) delayed until after the return, because
the processor's bus interface schedules opcode fetches and load/
store operations independently. The effect is that instructions
ar fetched from flash, while the flash is still in query mode.

Since the processor guarantees execution of load/store operations
in program order, a dummy read fixes this. It took me a while to
notice that neither HAL_REORDER_BARRIER() nor HAL_IO_BARRIER()
(the latter does not even exist for MIPS) address this particular
problem. AFAICT there is nothing in ecos that does, or am I missing
something here?

The attached patch, besides fixing the probler dscribed above, also
cleans up a minor issue that caused the FLASH_Reset code not to be
written to flash offset 0. This did not cause any harm, but is
somewhat unclean and confusing.

tk

diff -rpu packages-orig/devs/flash/intel/strata/current/ChangeLog packages/devs/flash/intel/strata/current/ChangeLog
--- packages-orig/devs/flash/intel/strata/current/ChangeLog	2004-09-13 15:18:11.000000000 +0200
+++ packages/devs/flash/intel/strata/current/ChangeLog	2005-01-14 13:58:08.329248848 +0100
@@ -1,3 +1,9 @@
+2005-01-14  Thomas Koeller  <thomas.koeller@baslerweb.com>
+
+	* src/flash_query.c (flash_query):
+	Fix switching the flash back to array mode, which was broken on
+	MIPS platforms. Always write control codes to offset 0.
+
 2004-09-02  Mark Salter  <msalter@redhat.com>
 
 	* src/flash_query.c (CYGHWR_FLASH_READ_QUERY): Add platform hook
diff -rpu packages-orig/devs/flash/intel/strata/current/src/flash_query.c packages/devs/flash/intel/strata/current/src/flash_query.c
--- packages-orig/devs/flash/intel/strata/current/src/flash_query.c	2004-09-13 15:18:11.000000000 +0200
+++ packages/devs/flash/intel/strata/current/src/flash_query.c	2005-01-14 13:35:29.617804384 +0100
@@ -68,7 +68,7 @@ flash_query(unsigned char *data)  __attr
 int
 flash_query(unsigned char *data)
 {
-    volatile flash_t *ROM;
+    volatile flash_t *ROM, *p, dummy;
     int i, cnt;
 
     // Get base address and map addresses to virtual addresses
@@ -85,19 +85,25 @@ flash_query(unsigned char *data)
 #endif // Not CYGOPT_FLASH_IS_BOOTBLOCK
 
     for (cnt = CNT;  cnt > 0;  cnt--) ;
-    for ( /* i */;  i > 0;  i--, ++ROM) {
+    p = ROM;
+    while ( i-- ) {
         // It is very deliberate that data is chars NOT flash_t:
         // The info comes out in bytes regardless of device.
-        *data++ = (unsigned char) CYGHWR_FLASH_READ_QUERY(ROM);
+        *data++ = (unsigned char) CYGHWR_FLASH_READ_QUERY(p++);
 #ifndef CYGOPT_FLASH_IS_BOOTBLOCK
 # if  8 == CYGNUM_FLASH_WIDTH
 	// strata flash with 'byte-enable' contains the configuration data
 	// at even addresses
-	++ROM;
+	++p;
 # endif
 #endif
     }
+    
+    // Reset the flash to array mode. The dummy read is required on MIPS
+    // platforms (don't know about others) to force the write out. Should
+    // there be direct HAL support for this kind of operation?
     ROM[0] = FLASH_Reset;
+    dummy = ROM[0];
 
     return 0;
 }

-- 
--------------------------------------------------

Thomas Koeller, Software Development

Basler Vision Technologies
An der Strusbek 60-62
22926 Ahrensburg
Germany

Tel +49 (4102) 463-390
Fax +49 (4102) 463-46390

mailto:thomas.koeller@baslerweb.com
http://www.baslerweb.com

==============================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]