summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2010-08-25 22:29:55 +0000
committerTill Straumann <strauman@slac.stanford.edu>2010-08-25 22:29:55 +0000
commit66eaf3d9cec2390d0c6036b90e9ea680ebafb30c (patch)
treec77b0a64acec668f4681e2c7ca82ea5740bf03b0
parent2010-06-21 Peter Dufault <dufault@hda.com> (diff)
downloadrtems-66eaf3d9cec2390d0c6036b90e9ea680ebafb30c.tar.bz2
2010-08-25 Till Straumann <strauman@slac.stanford.edu>
PR 1689/bsps * shared/flash/intelFlash.c: Scale erase timeout by actual system clock rate rather than assuming a fixed value.
-rw-r--r--c/src/lib/libbsp/powerpc/ChangeLog6
-rw-r--r--c/src/lib/libbsp/powerpc/shared/flash/intelFlash.c21
2 files changed, 21 insertions, 6 deletions
diff --git a/c/src/lib/libbsp/powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/ChangeLog
index 8d847545ae..f0ef3a4fa1 100644
--- a/c/src/lib/libbsp/powerpc/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-25 Till Straumann <strauman@slac.stanford.edu>
+
+ PR 1689/bsps
+ * shared/flash/intelFlash.c: Scale erase timeout by actual
+ system clock rate rather than assuming a fixed value.
+
2010-02-01 Till Straumann <strauman@slac.stanford.edu>
PR 1492/bsps
diff --git a/c/src/lib/libbsp/powerpc/shared/flash/intelFlash.c b/c/src/lib/libbsp/powerpc/shared/flash/intelFlash.c
index c0685b32f0..3238cb7e97 100644
--- a/c/src/lib/libbsp/powerpc/shared/flash/intelFlash.c
+++ b/c/src/lib/libbsp/powerpc/shared/flash/intelFlash.c
@@ -56,16 +56,20 @@
*/
#ifdef TESTING
-#define TIMEOUT_US 100000
-#define rtems_task_wake_after(args...) do {} while (0)
+#define TIMEOUT_US 100000
+#define rtems_task_wake_after(t) sleep(t)
+#define CLOCKRATE_GET(p) (*(p)=1)
#else
#include <rtems.h>
-#define TIMEOUT_US 1000
+#define TIMEOUT_US 1000
+#define CLOCKRATE_GET(p) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, p )
#endif
+#define ERASE_TIMEOUT_S 2
+
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
@@ -321,14 +325,19 @@ uint32_t sta;
STATIC int
flash_erase_block_intel(struct bankdesc *b, uint32_t addr)
{
-uint32_t sta;
-int i;
+uint32_t sta;
+int i;
+rtems_interval p;
+
if ( (sta = flash_check_ready_intel(b, addr)) )
return sta;
(void)BSP_flashReadRaw(F_CMD_WR_ERA, addr);
(void)BSP_flashReadRaw(F_CMD_WR_CMD, addr);
- i = 50;
+
+ CLOCKRATE_GET( &p );
+ i = p * ERASE_TIMEOUT_S;
+
while ( STA_RDYRDY != (STA_RDYRDY & (sta = BSP_flashReadRaw(F_CMD_RD_STA, addr))) && --i > 0 ) {
rtems_task_wake_after(1);
}