Commit a60d1e5b authored by Graeme Russ's avatar Graeme Russ Committed by Albert ARIBAUD
Browse files

Timer: Fix misuse of ARM *timer_masked() functions outside arch/arm


Signed-off-by: default avatarGraeme Russ <graeme.russ@gmail.com>
parent 4e0499eb
......@@ -162,6 +162,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
int rc = ERR_OK;
unsigned long base;
unsigned long addr;
ulong start;
if ((info->flash_id & FLASH_VENDMASK) !=
(FUJ_MANUFACT & FLASH_VENDMASK)) {
......@@ -192,7 +193,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
/* Start erase on unprotected sectors */
for (sect = s_first; sect <= s_last && !ctrlc (); sect++) {
/* ARM simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
......@@ -232,6 +233,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
{
int flag;
unsigned long base;
ulong start;
/* Check if Flash is (sufficiently) erased
*/
......@@ -250,7 +252,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
flag = disable_interrupts ();
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
base = dest & 0xF0000000;
FL_WORD (base + (0x555 << 1)) = 0xAA;
......
......@@ -285,6 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
int iflag, cflag, prot, sect;
int rc = ERR_OK;
int chip1;
ulong start;
/* first look for protection bits */
......@@ -325,7 +326,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
volatile u16 *addr = (volatile u16 *) (info->start[sect]);
......@@ -345,7 +346,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
result = *addr;
/* check timeout */
if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
chip1 = TMO;
break;
......@@ -400,6 +401,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data)
int rc = ERR_OK;
int cflag, iflag;
int chip1;
ulong start;
/*
* Check if Flash is (sufficiently) erased
......@@ -425,7 +427,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait until flash is ready */
chip1 = 0;
......@@ -433,7 +435,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data)
result = *addr;
/* check timeout */
if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
chip1 = ERR | TMO;
break;
}
......
......@@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info)
int flash_erase (flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect;
ulong type, start, last;
ulong type, start;
int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) {
......@@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf ("\n");
}
start = get_timer (0);
last = start;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts ();
......@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */
*addr = (FPW) 0x00200020; /* erase setup */
*addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
*addr = (FPW) 0x00B000B0; /* suspend erase */
*addr = (FPW) 0x00FF00FF; /* reset to read mode */
......@@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
FPWV *addr = (FPWV *) dest;
ulong status;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
......@@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait while polling the status register */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (1);
}
......
......@@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
int flag, prot, sect;
ulong type;
int rcode = 0;
ulong start;
if ((s_first < 0) || (s_first > s_last)) {
if (info->flash_id == FLASH_UNKNOWN) {
......@@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]);
*addr = 0x50; /* clear status register */
......@@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
*addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) {
if (get_timer_masked () >
if (get_timer(start) >
CONFIG_SYS_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
*addr = 0xB0; /* suspend erase */
......@@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data)
volatile unsigned char *addr = (volatile unsigned char *) dest;
ulong status;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
......@@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait while polling the status register */
while (((status = *addr) & 0x80) != 0x80) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*addr = 0xFF; /* restore read mode */
return (1);
}
......
......@@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
int flag, prot, sect;
ulong type;
int rcode = 0;
ulong start;
if ((s_first < 0) || (s_first > s_last)) {
if (info->flash_id == FLASH_UNKNOWN) {
......@@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]);
*addr = 0x50; /* clear status register */
......@@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
*addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) {
if (get_timer_masked () >
if (get_timer(start) >
CONFIG_SYS_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
*addr = 0xB0; /* suspend erase */
......@@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data)
volatile unsigned char *addr = (volatile unsigned char *) dest;
ulong status;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
......@@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait while polling the status register */
while (((status = *addr) & 0x80) != 0x80) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*addr = 0xFF; /* restore read mode */
return (1);
}
......
......@@ -264,7 +264,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
{
vu_short *addr = (vu_short *)(info->start[0]);
int flag, prot, sect, ssect, l_sect;
ulong now, last;
ulong now, last, start;
debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
......@@ -335,11 +335,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
if (l_sect < 0)
goto DONE;
reset_timer_masked ();
start = get_timer(0);
last = 0;
addr = (vu_short *)(info->start[l_sect]);
while ((addr[0] & 0x0080) != 0x0080) {
if ((now = get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) {
if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
return 1;
}
......@@ -434,6 +434,7 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data)
{
int flag;
vu_short *base; /* first address in flash bank */
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*dest & data) != data) {
......@@ -455,11 +456,11 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data)
if (flag)
enable_interrupts();
reset_timer_masked ();
start = get_timer(0);
/* data polling for D7 */
while ((*dest & 0x0080) != (data & 0x0080)) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*dest = 0x00F0; /* reset bank */
return (1);
}
......
......@@ -136,6 +136,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
int rc = ERR_OK;
ulong start;
if (info->flash_id == FLASH_UNKNOWN)
return ERR_UNKNOWN_FLASH_TYPE;
......@@ -173,7 +174,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
vu_short *addr = (vu_short *) (info->start[sect]);
......@@ -182,7 +183,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
*addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) {
if (get_timer_masked () >
if (get_timer(start) >
CONFIG_SYS_FLASH_ERASE_TOUT) {
*addr = 0xB0; /* suspend erase */
*addr = 0xFF; /* reset to read mode */
......@@ -221,6 +222,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
vu_short *addr = (vu_short *) dest, val;
int rc = ERR_OK;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased
*/
......@@ -246,11 +248,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait while polling the status register */
while (((val = *addr) & 0x80) != 0x80) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
/* suspend program command */
*addr = 0xB0;
......
......@@ -141,6 +141,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect;
int rc = ERR_OK;
ulong start;
if (info->flash_id == FLASH_UNKNOWN)
return ERR_UNKNOWN_FLASH_TYPE;
......@@ -175,7 +176,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
u32 * volatile addr = (u32 * volatile)(info->start[sect]);
......@@ -189,7 +190,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
*addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
*addr = 0x00B000B0; /* suspend erase*/
*addr = 0x00FF00FF; /* read mode */
rc = ERR_TIMOUT;
......@@ -221,6 +222,7 @@ static int write_long (flash_info_t *info, ulong dest, ulong data)
u32 * volatile addr = (u32 * volatile)dest, val;
int rc = ERR_OK;
int flag;
ulong start;
/* read array command - just for the case... */
*addr = 0x00FF00FF;
......@@ -247,11 +249,11 @@ static int write_long (flash_info_t *info, ulong dest, ulong data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
/* wait while polling the status register */
while(((val = *addr) & 0x00800080) != 0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
/* suspend program command */
*addr = 0x00B000B0;
......
......@@ -212,7 +212,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info)
int flash_erase (flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect;
ulong type, start, last;
ulong type, start;
int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) {
......@@ -245,9 +245,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf ("\n");
}
start = get_timer (0);
last = start;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
......@@ -260,14 +257,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
*addr = (FPW)0x00500050; /* clear status register */
*addr = (FPW)0x00200020; /* erase setup */
*addr = (FPW)0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
*addr = (FPW)0x00B000B0; /* suspend erase */
*addr = (FPW)0x00FF00FF; /* reset to read mode */
......@@ -385,6 +382,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
FPWV *addr = (FPWV *)dest;
ulong status;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
......@@ -398,11 +396,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
/* wait while polling the status register */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (start = get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*addr = (FPW)0x00FF00FF; /* restore read mode */
return (1);
}
......
......@@ -119,6 +119,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
int rc = ERR_OK;
ulong start;
if (info->flash_id == FLASH_UNKNOWN)
return ERR_UNKNOWN_FLASH_TYPE;
......@@ -156,7 +157,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
vu_short *addr = (vu_short *) (info->start[sect]);
......@@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
*addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) {
if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
*addr = 0xB0; /* suspend erase */
*addr = 0xFF; /* reset to read mode */
rc = ERR_TIMOUT;
......@@ -203,6 +204,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
vu_short *addr = (vu_short *) dest, val;
int rc = ERR_OK;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased
*/
......@@ -228,11 +230,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* wait while polling the status register */
while (((val = *addr) & 0x80) != 0x80) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
/* suspend program command */
*addr = 0xB0;
......
......@@ -225,7 +225,7 @@ int
flash_erase(flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
ulong type, start, last;
ulong type, start;
int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) {
......@@ -258,9 +258,6 @@ flash_erase(flash_info_t * info, int s_first, int s_last)
printf("\n");
}
start = get_timer(0);
last = start;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
......@@ -273,7 +270,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last)
printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */
*addr = (FPW) 0x00200020; /* erase setup */
......@@ -282,7 +279,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last)
while (((status =
*addr) & (FPW) 0x00800080) !=
(FPW) 0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
printf("Timeout\n");
*addr = (FPW) 0x00B000B0; /* suspend erase */
*addr = (FPW) 0x00FF00FF; /* reset to read mode */
......@@ -401,6 +398,7 @@ write_data(flash_info_t * info, ulong dest, FPW data)
FPWV *addr = (FPWV *) dest;
ulong status;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
......@@ -414,11 +412,11 @@ write_data(flash_info_t * info, ulong dest, FPW data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
/* wait while polling the status register */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (1);
}
......
......@@ -128,6 +128,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
int rc = ERR_OK;
ulong start;
if (info->flash_id == FLASH_UNKNOWN)
return ERR_UNKNOWN_FLASH_TYPE;
......@@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
vu_long *addr = (vu_long *) (info->start[sect]);
......@@ -174,7 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
*addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) {
if (get_timer_masked () >
if (get_timer(start) >
CONFIG_SYS_FLASH_ERASE_TOUT) {
*addr = 0x00B000B0; /* suspend erase */
*addr = 0x00FF00FF; /* reset to read mode */
......@@ -211,6 +212,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data)
ulong barf;
int rc = ERR_OK;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased
*/
......@@ -236,14 +238,14 @@ static int write_word (flash_info_t * info, ulong dest, ulong data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
start = get_timer(0);
/* read status register command */
*addr = 0x00700070;
/* wait while polling the status register */
while ((*addr & 0x00800080) != 0x00800080) {
if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
/* suspend program command */
*addr = 0x00B000B0;
......
......@@ -182,6 +182,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect;
int rc = ERR_OK;
ulong start;
if (info->flash_id == FLASH_UNKNOWN)
return ERR_UNKNOWN_FLASH_TYPE;
......@@ -218,7 +219,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
PRINTK("\n");
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
u16 * volatile addr = (u16 * volatile)(info->start[sect]);
......@@ -235,7 +236,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
while ((*addr & 0x0080) != 0x0080) {
PRINTK(".");
if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
*addr = 0x00B0; /* suspend erase*/
*addr = 0x00FF; /* read mode */
rc = ERR_TIMOUT;
......@@ -279,6 +280,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
volatile u16 *addr = (u16 *)dest, val;
int rc = ERR_OK;
int flag;
ulong start;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) return ERR_NOT_ERASED;
......@@ -302,11 +304,11 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked();
start = get_timer(0);
/* wait while polling the status register */
while(((val = *addr) & 0x80) != 0x80) {
if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;