diff options
Diffstat (limited to 'board/emk/top860')
-rw-r--r-- | board/emk/top860/Makefile | 2 | ||||
-rw-r--r-- | board/emk/top860/flash.c | 853 | ||||
-rw-r--r-- | board/emk/top860/top860.c | 232 | ||||
-rw-r--r-- | board/emk/top860/u-boot.lds | 7 | ||||
-rw-r--r-- | board/emk/top860/u-boot.lds.debug | 1 |
5 files changed, 544 insertions, 551 deletions
diff --git a/board/emk/top860/Makefile b/board/emk/top860/Makefile index ef173d0..13ce9fc 100644 --- a/board/emk/top860/Makefile +++ b/board/emk/top860/Makefile @@ -28,7 +28,7 @@ LIB = lib$(BOARD).a OBJS = $(BOARD).o flash.o $(LIB): .depend $(OBJS) - $(AR) crv $@ $^ + $(AR) crv $@ $(OBJS) ######################################################################### diff --git a/board/emk/top860/flash.c b/board/emk/top860/flash.c index a9a9771..0f827df 100644 --- a/board/emk/top860/flash.c +++ b/board/emk/top860/flash.c @@ -2,11 +2,11 @@ * (C) Copyright 2003 * EMK Elektronik GmbH <www.emk-elektronik.de> * Reinhard Meyer <r.meyer@emk-elektronik.de> - *
- * copied from the BMW Port - seems that its similiar enough
- * to be easily adaped ;) --- Well, it turned out to become a
- * merger between parts of the EMKstax Flash routines and the
- * BMW funtion frames...
+ * + * copied from the BMW Port - seems that its similiar enough + * to be easily adaped ;) --- Well, it turned out to become a + * merger between parts of the EMKstax Flash routines and the + * BMW funtion frames... * * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. @@ -34,457 +34,456 @@ #include <mpc8xx.h> #define FLASH_WORD_SIZE unsigned short -#define FLASH_WORD_WIDTH (sizeof (FLASH_WORD_SIZE))
-
+#define FLASH_WORD_WIDTH (sizeof (FLASH_WORD_SIZE)) + flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ -
+ /*----------------------------------------------------------------------- * Functions */ static int write_word (flash_info_t *info, ulong dest, ulong data); -/*****************************************************************************
- * software product ID entry/exit
- *****************************************************************************/
-static void FlashProductIdMode (
- volatile FLASH_WORD_SIZE *b,
- int on_off)
-{
- b[0x5555] = 0xaa;
- b[0x2aaa] = 0x55;
- b[0x5555] = on_off ? 0x90 : 0xf0;
-}
-
-/*****************************************************************************
- * sector erase start
- *****************************************************************************/
-static void FlashSectorErase (
- volatile FLASH_WORD_SIZE *b,
- volatile FLASH_WORD_SIZE *a)
-{
- b[0x5555] = 0xaa;
- b[0x2aaa] = 0x55;
- b[0x5555] = 0x80;
- b[0x5555] = 0xaa;
- b[0x2aaa] = 0x55;
- a[0] = 0x30;
-}
-
-/*****************************************************************************
- * program a word
- *****************************************************************************/
-static void FlashProgWord (
- volatile FLASH_WORD_SIZE *b,
- volatile FLASH_WORD_SIZE *a,
- FLASH_WORD_SIZE v)
-{
- b[0x5555] = 0xaa;
- b[0x2aaa] = 0x55;
- b[0x5555] = 0xa0;
- a[0] = v;
-}
-
-/*****************************************************************************
- * reset bank, back to read mode
- *****************************************************************************/
-static void FlashReset (volatile FLASH_WORD_SIZE *b)
-{
- b[0] = 0xf0;
-}
-
-/*****************************************************************************
- * identify FLASH chip
- * this code is a stripped version of the FlashGetType() function in EMKstax
- *****************************************************************************/
+/***************************************************************************** + * software product ID entry/exit + *****************************************************************************/ +static void FlashProductIdMode ( + volatile FLASH_WORD_SIZE *b, + int on_off) +{ + b[0x5555] = 0xaa; + b[0x2aaa] = 0x55; + b[0x5555] = on_off ? 0x90 : 0xf0; +} + +/***************************************************************************** + * sector erase start + *****************************************************************************/ +static void FlashSectorErase ( + volatile FLASH_WORD_SIZE *b, + volatile FLASH_WORD_SIZE *a) +{ + b[0x5555] = 0xaa; + b[0x2aaa] = 0x55; + b[0x5555] = 0x80; + b[0x5555] = 0xaa; + b[0x2aaa] = 0x55; + a[0] = 0x30; +} + +/***************************************************************************** + * program a word + *****************************************************************************/ +static void FlashProgWord ( + volatile FLASH_WORD_SIZE *b, + volatile FLASH_WORD_SIZE *a, + FLASH_WORD_SIZE v) +{ + b[0x5555] = 0xaa; + b[0x2aaa] = 0x55; + b[0x5555] = 0xa0; + a[0] = v; +} + +/***************************************************************************** + * reset bank, back to read mode + *****************************************************************************/ +static void FlashReset (volatile FLASH_WORD_SIZE *b) +{ + b[0] = 0xf0; +} + +/***************************************************************************** + * identify FLASH chip + * this code is a stripped version of the FlashGetType() function in EMKstax + *****************************************************************************/ unsigned long flash_init (void) -{
- volatile FLASH_WORD_SIZE * const flash = (volatile FLASH_WORD_SIZE *) CFG_FLASH_BASE;
- FLASH_WORD_SIZE manu, dev;
- flash_info_t * const pflinfo = &flash_info[0];
- int j;
-
- /* get Id Bytes */
- FlashProductIdMode (flash, 1);
- manu = flash[0];
- dev = flash[1];
- FlashProductIdMode (flash, 0);
-
- pflinfo->size = 0;
- pflinfo->sector_count = 0;
- pflinfo->flash_id = 0xffffffff;
- pflinfo->portwidth = FLASH_CFI_16BIT;
- pflinfo->chipwidth = FLASH_CFI_BY16;
-
- switch (manu&0xff)
- {
- case 0x01: /* AMD */
- pflinfo->flash_id = FLASH_MAN_AMD;
- switch (dev&0xff)
- {
- case 0x49:
- pflinfo->size = 0x00200000;
- pflinfo->sector_count = 35;
- pflinfo->flash_id |= FLASH_AM160B;
- pflinfo->start[0] = CFG_FLASH_BASE;
- pflinfo->start[1] = CFG_FLASH_BASE + 0x4000;
- pflinfo->start[2] = CFG_FLASH_BASE + 0x6000;
- pflinfo->start[3] = CFG_FLASH_BASE + 0x8000;
- for (j = 4; j < 35; j++)
- {
- pflinfo->start[j] = CFG_FLASH_BASE + 0x00010000 * (j-3);
- }
- break;
-
- case 0xf9:
- pflinfo->size = 0x00400000;
- pflinfo->sector_count = 71;
- pflinfo->flash_id |= FLASH_AM320B;
- pflinfo->start[0] = CFG_FLASH_BASE;
- pflinfo->start[1] = CFG_FLASH_BASE + 0x4000;
- pflinfo->start[2] = CFG_FLASH_BASE + 0x6000;
- pflinfo->start[3] = CFG_FLASH_BASE + 0x8000;
- for (j = 0; j < 8; j++)
- {
- pflinfo->start[j] = CFG_FLASH_BASE + 0x00002000 * (j);
- }
- for (j = 8; j < 71; j++)
- {
- pflinfo->start[j] = CFG_FLASH_BASE + 0x00010000 * (j-7);
- }
- break;
-
- default:
- printf ("unknown AMD dev=%x ", dev);
- pflinfo->flash_id |= FLASH_UNKNOWN;
- }
- break;
-
- default:
- printf ("unknown manu=%x ", manu);
- }
- return pflinfo->size;
+{ + volatile FLASH_WORD_SIZE * const flash = (volatile FLASH_WORD_SIZE *) CFG_FLASH_BASE; + FLASH_WORD_SIZE manu, dev; + flash_info_t * const pflinfo = &flash_info[0]; + int j; + + /* get Id Bytes */ + FlashProductIdMode (flash, 1); + manu = flash[0]; + dev = flash[1]; + FlashProductIdMode (flash, 0); + + pflinfo->size = 0; + pflinfo->sector_count = 0; + pflinfo->flash_id = 0xffffffff; + pflinfo->portwidth = FLASH_CFI_16BIT; + pflinfo->chipwidth = FLASH_CFI_BY16; + + switch (manu&0xff) + { + case 0x01: /* AMD */ + pflinfo->flash_id = FLASH_MAN_AMD; + switch (dev&0xff) + { + case 0x49: + pflinfo->size = 0x00200000; + pflinfo->sector_count = 35; + pflinfo->flash_id |= FLASH_AM160B; + pflinfo->start[0] = CFG_FLASH_BASE; + pflinfo->start[1] = CFG_FLASH_BASE + 0x4000; + pflinfo->start[2] = CFG_FLASH_BASE + 0x6000; + pflinfo->start[3] = CFG_FLASH_BASE + 0x8000; + for (j = 4; j < 35; j++) + { + pflinfo->start[j] = CFG_FLASH_BASE + 0x00010000 * (j-3); + } + break; + + case 0xf9: + pflinfo->size = 0x00400000; + pflinfo->sector_count = 71; + pflinfo->flash_id |= FLASH_AM320B; + pflinfo->start[0] = CFG_FLASH_BASE; + pflinfo->start[1] = CFG_FLASH_BASE + 0x4000; + pflinfo->start[2] = CFG_FLASH_BASE + 0x6000; + pflinfo->start[3] = CFG_FLASH_BASE + 0x8000; + for (j = 0; j < 8; j++) + { + pflinfo->start[j] = CFG_FLASH_BASE + 0x00002000 * (j); + } + for (j = 8; j < 71; j++) + { + pflinfo->start[j] = CFG_FLASH_BASE + 0x00010000 * (j-7); + } + break; + + default: + printf ("unknown AMD dev=%x ", dev); + pflinfo->flash_id |= FLASH_UNKNOWN; + } + break; + + default: + printf ("unknown manu=%x ", manu); + } + return pflinfo->size; } -/*****************************************************************************
- * print info about a FLASH
- *****************************************************************************/
+/***************************************************************************** + * print info about a FLASH + *****************************************************************************/ void flash_print_info (flash_info_t *info) -{
- static const char unk[] = "Unknown";
- unsigned int i;
- const char *mfct=unk,
- *type=unk;
-
- if(info->flash_id != FLASH_UNKNOWN)
- {
- switch (info->flash_id & FLASH_VENDMASK)
- {
- case FLASH_MAN_AMD:
- mfct = "AMD";
- break;
- }
-
- switch (info->flash_id & FLASH_TYPEMASK)
- {
- case FLASH_AM160B:
- type = "AM29LV160B (16 Mbit, bottom boot sect)";
- break;
- case FLASH_AM320B:
- type = "AM29LV320B (32 Mbit, bottom boot sect)";
- break;
- }
- }
-
- printf (
- "\n Brand: %s Type: %s\n"
- " Size: %lu KB in %d Sectors\n",
- mfct,
- type,
- info->size >> 10,
- info->sector_count
- );
-
- printf (" Sector Start Addresses:");
-
- for (i = 0; i < info->sector_count; i++)
- {
- unsigned long size;
- unsigned int erased;
- unsigned long *flash = (unsigned long *) info->start[i];
-
- /*
- * Check if whole sector is erased
- */
- size =
- (i != (info->sector_count - 1)) ?
- (info->start[i + 1] - info->start[i]) >> 2 :
- (info->start[0] + info->size - info->start[i]) >> 2;
-
- for (
- flash = (unsigned long *) info->start[i], erased = 1;
- (flash != (unsigned long *) info->start[i] + size) && erased;
- flash++
- )
- erased = *flash == ~0x0UL;
-
- printf (
- "%s %08lX %s %s",
- (i % 5) ? "" : "\n ",
- info->start[i],
- erased ? "E" : " ",
- info->protect[i] ? "RO" : " "
- );
- }
-
- puts ("\n");
- return;
+{ + static const char unk[] = "Unknown"; + unsigned int i; + const char *mfct=unk, + *type=unk; + + if(info->flash_id != FLASH_UNKNOWN) + { + switch (info->flash_id & FLASH_VENDMASK) + { + case FLASH_MAN_AMD: + mfct = "AMD"; + break; + } + + switch (info->flash_id & FLASH_TYPEMASK) + { + case FLASH_AM160B: + type = "AM29LV160B (16 Mbit, bottom boot sect)"; + break; + case FLASH_AM320B: + type = "AM29LV320B (32 Mbit, bottom boot sect)"; + break; + } + } + + printf ( + "\n Brand: %s Type: %s\n" + " Size: %lu KB in %d Sectors\n", + mfct, + type, + info->size >> 10, + info->sector_count + ); + + printf (" Sector Start Addresses:"); + + for (i = 0; i < info->sector_count; i++) + { + unsigned long size; + unsigned int erased; + unsigned long *flash = (unsigned long *) info->start[i]; + + /* + * Check if whole sector is erased + */ + size = + (i != (info->sector_count - 1)) ? + (info->start[i + 1] - info->start[i]) >> 2 : + (info->start[0] + info->size - info->start[i]) >> 2; + + for ( + flash = (unsigned long *) info->start[i], erased = 1; + (flash != (unsigned long *) info->start[i] + size) && erased; + flash++ + ) + erased = *flash == ~0x0UL; + + printf ( + "%s %08lX %s %s", + (i % 5) ? "" : "\n ", + info->start[i], + erased ? "E" : " ", + info->protect[i] ? "RO" : " " + ); + } + + puts ("\n"); + return; } -/*****************************************************************************
- * erase one or more sectors
- *****************************************************************************/
+/***************************************************************************** + * erase one or more sectors + *****************************************************************************/ int flash_erase (flash_info_t *info, int s_first, int s_last) -{
- volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
- int flag,
- prot,
- sect,
- l_sect;
- ulong start,
- now,
- last;
-
- if ((s_first < 0) || (s_first > s_last))
- {
- if (info->flash_id == FLASH_UNKNOWN)
- {
- printf ("- missing\n");
- }
- else
- {
- printf ("- no sectors to erase\n");
- }
- return 1;
- }
-
- if ((info->flash_id == FLASH_UNKNOWN) ||
- (info->flash_id > (FLASH_MAN_STM | FLASH_AMD_COMP)))
- {
- printf ("Can't erase unknown flash type - aborted\n");
- return 1;
- }
-
- prot = 0;
- for (sect=s_first; sect<=s_last; ++sect)
- {
- if (info->protect[sect])
- {
- prot++;
- }
- }
-
- if (prot)
- {
- printf ("- Warning: %d protected sectors will not be erased!\n",
- prot);
- }
- else
- {
- printf ("\n");
- }
-
- l_sect = -1;
-
- /* Disable interrupts which might cause a timeout here */
- flag = disable_interrupts();
-
- /* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++)
- {
- if (info->protect[sect] == 0)
- { /* not protected */
- FlashSectorErase ((FLASH_WORD_SIZE *)info->start[0], (FLASH_WORD_SIZE *)info->start[sect]);
- l_sect = sect;
- }
- }
-
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts();
-
- /* wait at least 80us - let's wait 1 ms */
- udelay (1000);
-
- /*
- * We wait for the last triggered sector
- */
- if (l_sect < 0)
- goto DONE;
-
- start = get_timer (0);
- last = start;
- addr = (FLASH_WORD_SIZE *)info->start[l_sect];
- while ((addr[0] & 0x0080) != 0x0080)
- {
- if ((now = get_timer (start)) > CFG_FLASH_ERASE_TOUT)
- {
- printf ("Timeout\n");
- return 1;
- }
- /* show that we're waiting */
- if ((now - last) > 1000)
- { /* every second */
- serial_putc ('.');
- last = now;
- }
- }
-
- DONE:
- /* reset to read mode */
- FlashReset ((FLASH_WORD_SIZE *)info->start[0]);
-
- printf (" done\n");
- return 0;
+{ + volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]); + int flag, + prot, + sect, + l_sect; + ulong start, + now, + last; + + if ((s_first < 0) || (s_first > s_last)) + { + if (info->flash_id == FLASH_UNKNOWN) + { + printf ("- missing\n"); + } + else + { + printf ("- no sectors to erase\n"); + } + return 1; + } + + if ((info->flash_id == FLASH_UNKNOWN) || + (info->flash_id > (FLASH_MAN_STM | FLASH_AMD_COMP))) + { + printf ("Can't erase unknown flash type - aborted\n"); + return 1; + } + + prot = 0; + for (sect=s_first; sect<=s_last; ++sect) + { + if (info->protect[sect]) + { + prot++; + } + } + + if (prot) + { + printf ("- Warning: %d protected sectors will not be erased!\n", + prot); + } + else + { + printf ("\n"); + } + + l_sect = -1; + + /* Disable interrupts which might cause a timeout here */ + flag = disable_interrupts(); + + /* Start erase on unprotected sectors */ + for (sect = s_first; sect<=s_last; sect++) + { + if (info->protect[sect] == 0) + { /* not protected */ + FlashSectorErase ((FLASH_WORD_SIZE *)info->start[0], (FLASH_WORD_SIZE *)info->start[sect]); + l_sect = sect; + } + } + + /* re-enable interrupts if necessary */ + if (flag) + enable_interrupts(); + + /* wait at least 80us - let's wait 1 ms */ + udelay (1000); + + /* + * We wait for the last triggered sector + */ + if (l_sect < 0) + goto DONE; + + start = get_timer (0); + last = start; + addr = (FLASH_WORD_SIZE *)info->start[l_sect]; + while ((addr[0] & 0x0080) != 0x0080) + { + if ((now = get_timer (start)) > CFG_FLASH_ERASE_TOUT) + { + printf ("Timeout\n"); + return 1; + } + /* show that we're waiting */ + if ((now - last) > 1000) + { /* every second */ + serial_putc ('.'); + last = now; + } + } + + DONE: + /* reset to read mode */ + FlashReset ((FLASH_WORD_SIZE *)info->start[0]); + + printf (" done\n"); + return 0; } -/*****************************************************************************
+/***************************************************************************** * Copy memory to flash, returns: * 0 - OK * 1 - write timeout * 2 - Flash not erased - *****************************************************************************/
+ *****************************************************************************/ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt) -{
- ulong cp,
- wp,
- data;
- int i,
- l,
- rc;
-
- wp = (addr & ~(FLASH_WORD_WIDTH-1)); /* get lower word aligned address */
-
- /*
- * handle unaligned start bytes, if there are...
- */
- if ((l = addr - wp) != 0)
- {
- data = 0;
-
- /* get the current before the new data into our data word */
- for (i=0, cp=wp; i<l; ++i, ++cp)
- {
- data = (data << 8) | (*(uchar *)cp);
- }
-
- /* now merge the to be programmed values */
- for (; i<4 && cnt>0; ++i, ++cp, --cnt)
- {
- data = (data << 8) | *src++;
- }
-
- /* get the current after the new data into our data word */
- for (; cnt==0 && i<FLASH_WORD_WIDTH; ++i, ++cp)
- {
- data = (data << 8) | (*(uchar *)cp);
- }
-
- /* now write the combined word */
- if ((rc = write_word (info, wp, data)) != 0)
- {
- return (rc);
- }
- wp += FLASH_WORD_WIDTH;
- }
-
- /*
- * handle word aligned part
- */
- while (cnt >= FLASH_WORD_WIDTH)
- {
- data = 0;
- for (i=0; i<FLASH_WORD_WIDTH; ++i)
- {
- data = (data << 8) | *src++;
- }
- if ((rc = write_word (info, wp, data)) != 0)
- {
- return (rc);
- }
- wp += FLASH_WORD_WIDTH;
- cnt -= FLASH_WORD_WIDTH;
- }
-
- if (cnt == 0)
- {
- return (0);
- }
-
- /*
- * handle unaligned tail bytes, if there are...
- */
- data = 0;
-
- /* now merge the to be programmed values */
- for (i=0, cp=wp; i<FLASH_WORD_WIDTH && cnt>0; ++i, ++cp)
- {
- data = (data << 8) | *src++;
- --cnt;
- }
-
- /* get the current after the new data into our data word */
- for (; i<FLASH_WORD_WIDTH; ++i, ++cp)
- {
- data = (data << 8) | (*(uchar *)cp);
- }
-
- /* now write the combined word */
- return (write_word (info, wp, data));
+{ + ulong cp, + wp, + data; + int i, + l, + rc; + + wp = (addr & ~(FLASH_WORD_WIDTH-1)); /* get lower word aligned address */ + + /* + * handle unaligned start bytes, if there are... + */ + if ((l = addr - wp) != 0) + { + data = 0; + + /* get the current before the new data into our data word */ + for (i=0, cp=wp; i<l; ++i, ++cp) + { + data = (data << 8) | (*(uchar *)cp); + } + + /* now merge the to be programmed values */ + for (; i<4 && cnt>0; ++i, ++cp, --cnt) + { + data = (data << 8) | *src++; + } + + /* get the current after the new data into our data word */ + for (; cnt==0 && i<FLASH_WORD_WIDTH; ++i, ++cp) + { + data = (data << 8) | (*(uchar *)cp); + } + + /* now write the combined word */ + if ((rc = write_word (info, wp, data)) != 0) + { + return (rc); + } + wp += FLASH_WORD_WIDTH; + } + + /* + * handle word aligned part + */ + while (cnt >= FLASH_WORD_WIDTH) + { + data = 0; + for (i=0; i<FLASH_WORD_WIDTH; ++i) + { + data = (data << 8) | *src++; + } + if ((rc = write_word (info, wp, data)) != 0) + { + return (rc); + } + wp += FLASH_WORD_WIDTH; + cnt -= FLASH_WORD_WIDTH; + } + + if (cnt == 0) + { + return (0); + } + + /* + * handle unaligned tail bytes, if there are... + */ + data = 0; + + /* now merge the to be programmed values */ + for (i=0, cp=wp; i<FLASH_WORD_WIDTH && cnt>0; ++i, ++cp) + { + data = (data << 8) | *src++; + --cnt; + } + + /* get the current after the new data into our data word */ + for (; i<FLASH_WORD_WIDTH; ++i, ++cp) + { + data = (data << 8) | (*(uchar *)cp); + } + + /* now write the combined word */ + return (write_word (info, wp, data)); } -/*****************************************************************************
+/***************************************************************************** * Write a word to Flash, returns: * 0 - OK * 1 - write timeout * 2 - Flash not erased - *****************************************************************************/
+ *****************************************************************************/ static int write_word (flash_info_t *info, ulong dest, ulong data) -{
- volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)info->start[0];
- volatile FLASH_WORD_SIZE *dest2 = (FLASH_WORD_SIZE *)dest;
- FLASH_WORD_SIZE data2 = data;
- ulong start;
- int flag;
-
- /* Check if Flash is (sufficiently) erased */
- if ((*dest2 & data2) != data2)
- {
- return (2);
- }
-
- /* Disable interrupts which might cause a timeout here */
- flag = disable_interrupts ();
-
- FlashProgWord (addr2, dest2, data2);
-
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts ();
-
- /* data polling for D7 */
- start = get_timer (0);
- while ((*dest2 & 0x0080) != (data2 & 0x0080))
- {
- if (get_timer (start) > CFG_FLASH_WRITE_TOUT)
- {
- return (1);
- }
- }
-
- return (0);
+{ + volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)info->start[0]; + volatile FLASH_WORD_SIZE *dest2 = (FLASH_WORD_SIZE *)dest; + FLASH_WORD_SIZE data2 = data; + ulong start; + int flag; + + /* Check if Flash is (sufficiently) erased */ + if ((*dest2 & data2) != data2) + { + return (2); + } + + /* Disable interrupts which might cause a timeout here */ + flag = disable_interrupts (); + + FlashProgWord (addr2, dest2, data2); + + /* re-enable interrupts if necessary */ + if (flag) + enable_interrupts (); + + /* data polling for D7 */ + start = get_timer (0); + while ((*dest2 & 0x0080) != (data2 & 0x0080)) + { + if (get_timer (start) > CFG_FLASH_WRITE_TOUT) + { + return (1); + } + } + + return (0); } /*----------------------------------------------------------------------- */ -
diff --git a/board/emk/top860/top860.c b/board/emk/top860/top860.c index b99bf0e..d13be98 100644 --- a/board/emk/top860/top860.c +++ b/board/emk/top860/top860.c @@ -35,47 +35,47 @@ #include <commproc.h> #include <mpc8xx.h> -/*****************************************************************************
- * UPM table for 60ns EDO RAM at 25 MHz bus/external clock
- *****************************************************************************/
+/***************************************************************************** + * UPM table for 60ns EDO RAM at 25 MHz bus/external clock + *****************************************************************************/ static const uint edo_60ns_25MHz_tbl[] = { -
-/* single read (offset 0x00 in upm ram) */
- 0x0ff3fc04,0x08f3fc04,0x00f3fc04,0x00f3fc00,
- 0x33f7fc07,0xfffffc05,0xfffffc05,0xfffffc05,
-/* burst read (offset 0x08 in upm ram) */
- 0x0ff3fc04,0x08f3fc04,0x00f3fc0c,0x0ff3fc40,
- 0x0cf3fc04,0x03f3fc48,0x0cf3fc04,0x03f3fc48,
- 0x0cf3fc04,0x03f3fc00,0x3ff7fc07,0xfffffc05,
- 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05,
-/* single write (offset 0x18 in upm ram) */
- 0x0ffffc04,0x08fffc04,0x30fffc00,0xf1fffc07,
- 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05,
-/* burst write (offset 0x20 in upm ram) */
- 0x0ffffc04,0x08fffc00,0x00fffc04,0x03fffc4c,
- 0x00fffc00,0x07fffc4c,0x00fffc00,0x0ffffc4c,
- 0x00fffc00,0x3ffffc07,0xfffffc05,0xfffffc05,
- 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05,
-/* refresh (offset 0x30 in upm ram) */
- 0xc0fffc04,0x07fffc04,0x0ffffc04,0x0ffffc04,
- 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05,
- 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05,
-/* exception (offset 0x3C in upm ram) */
- 0xfffffc07,0xfffffc03,0xfffffc05,0xfffffc05,
+ +/* single read (offset 0x00 in upm ram) */ + 0x0ff3fc04,0x08f3fc04,0x00f3fc04,0x00f3fc00, + 0x33f7fc07,0xfffffc05,0xfffffc05,0xfffffc05, +/* burst read (offset 0x08 in upm ram) */ + 0x0ff3fc04,0x08f3fc04,0x00f3fc0c,0x0ff3fc40, + 0x0cf3fc04,0x03f3fc48,0x0cf3fc04,0x03f3fc48, + 0x0cf3fc04,0x03f3fc00,0x3ff7fc07,0xfffffc05, + 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05, +/* single write (offset 0x18 in upm ram) */ + 0x0ffffc04,0x08fffc04,0x30fffc00,0xf1fffc07, + 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05, +/* burst write (offset 0x20 in upm ram) */ + 0x0ffffc04,0x08fffc00,0x00fffc04,0x03fffc4c, + 0x00fffc00,0x07fffc4c,0x00fffc00,0x0ffffc4c, + 0x00fffc00,0x3ffffc07,0xfffffc05,0xfffffc05, + 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05, +/* refresh (offset 0x30 in upm ram) */ + 0xc0fffc04,0x07fffc04,0x0ffffc04,0x0ffffc04, + 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05, + 0xfffffc05,0xfffffc05,0xfffffc05,0xfffffc05, +/* exception (offset 0x3C in upm ram) */ + 0xfffffc07,0xfffffc03,0xfffffc05,0xfffffc05, }; -/*****************************************************************************
- * Print Board Identity
- *****************************************************************************/
+/***************************************************************************** + * Print Board Identity + *****************************************************************************/ int checkboard (void) { puts ("Board:"CONFIG_IDENT_STRING"\n"); return (0); } -/*****************************************************************************
- * Initialize DRAM controller
- *****************************************************************************/
+/***************************************************************************** + * Initialize DRAM controller + *****************************************************************************/ long int initdram (int board_type) { volatile immap_t *immap = (immap_t *) CFG_IMMR; @@ -85,103 +85,93 @@ long int initdram (int board_type) * Only initialize memory controller when running from FLASH. * When running from RAM, don't touch it. */ - if ((ulong) initdram & 0xff000000)
- {
- volatile uint *addr1, *addr2;
- uint i, j;
+ if ((ulong) initdram & 0xff000000) { + volatile uint *addr1, *addr2; + uint i, j; - upmconfig (UPMA, (uint *) edo_60ns_25MHz_tbl,
- sizeof (edo_60ns_25MHz_tbl) / sizeof (uint)); + upmconfig (UPMA, (uint *) edo_60ns_25MHz_tbl, + sizeof (edo_60ns_25MHz_tbl) / sizeof (uint)); memctl->memc_mptpr = 0x0200; memctl->memc_mamr = 0x0ca20330; memctl->memc_or2 = -CFG_DRAM_MAX | OR_CSNT_SAM; memctl->memc_br2 = CFG_DRAM_BASE | BR_MS_UPMA | BR_V; - /*
- * Do 8 read accesses to DRAM
- */
- addr1 = (volatile uint*) 0;
- addr2 = (volatile uint*) 0x00400000;
- for (i=0, j=0; i<8; i++)
- j = addr1[0];
-
- /*
- * Now check whether we got 4MB or 16MB populated
- */
- addr1[0] = 0x12345678;
- addr1[1] = 0x9abcdef0;
- addr2[0] = 0xfeedc0de;
- addr2[1] = 0x47110815;
- if (addr1[0] == 0xfeedc0de && addr1[1] == 0x47110815)
- {
- /* only 4MB populated */
- memctl->memc_or2 = -(CFG_DRAM_MAX/4) | OR_CSNT_SAM;
- }
- }
-
+ /* + * Do 8 read accesses to DRAM + */ + addr1 = (volatile uint *) 0; + addr2 = (volatile uint *) 0x00400000; + for (i = 0, j = 0; i < 8; i++) + j = addr1[0]; + + /* + * Now check whether we got 4MB or 16MB populated + */ + addr1[0] = 0x12345678; + addr1[1] = 0x9abcdef0; + addr2[0] = 0xfeedc0de; + addr2[1] = 0x47110815; + if (addr1[0] == 0xfeedc0de && addr1[1] == 0x47110815) { + /* only 4MB populated */ + memctl->memc_or2 = -(CFG_DRAM_MAX / 4) | OR_CSNT_SAM; + } + } + return -(memctl->memc_or2 & 0xffff0000); } -
-/*****************************************************************************
- * otherinits after RAM is there and we are relocated to RAM
- * note: though this is an int function, nobody cares for the result!
- *****************************************************************************/
+ +/***************************************************************************** + * otherinits after RAM is there and we are relocated to RAM + * note: though this is an int function, nobody cares for the result! + *****************************************************************************/ int misc_init_r (void) -{
- /* read 'factory' part of EEPROM */
- uchar buf[81];
- uchar *p;
- uint length;
- uint addr;
- uint len;
-
- /* get length first */
- addr = CFG_FACT_OFFSET;
- if (eeprom_read (CFG_I2C_FACT_ADDR, addr, buf, 2))
- {
-bailout:
- printf ("cannot read factory configuration\n");
- printf ("be sure to set ethaddr yourself!\n");
- return 0;
+{ + /* read 'factory' part of EEPROM */ + uchar buf[81]; + uchar *p; + uint length; + uint addr; + uint len; + + /* get length first */ + addr = CFG_FACT_OFFSET; + if (eeprom_read (CFG_I2C_FACT_ADDR, addr, buf, 2)) { + bailout: + printf ("cannot read factory configuration\n"); + printf ("be sure to set ethaddr yourself!\n"); + return 0; + } + length = buf[0] + (buf[1] << 8); + addr += 2; + + /* sanity check */ + if (length < 20 || length > CFG_FACT_SIZE - 2) + goto bailout; + + /* read lines */ + while (length > 0) { + /* read one line */ + len = length > 80 ? 80 : length; + if (eeprom_read (CFG_I2C_FACT_ADDR, addr, buf, len)) + goto bailout; + /* mark end of buffer */ + buf[len] = 0; + /* search end of line */ + for (p = buf; *p && *p != 0x0a; p++); + if (!*p) + goto bailout; + *p++ = 0; + /* advance to next line start */ + length -= p - buf; + addr += p - buf; + /*printf ("%s\n", buf); */ + /* search for our specific entry */ + if (!strncmp ((char *) buf, "[RLA/lan/Ethernet] ", 19)) { + setenv ("ethaddr", buf + 19); + } else if (!strncmp ((char *) buf, "[BOARD/SERIAL] ", 15)) { + setenv ("serial#", buf + 15); + } else if (!strncmp ((char *) buf, "[BOARD/TYPE] ", 13)) { + setenv ("board_id", buf + 13); + } } - length = buf[0] + (buf[1]<<8);
- addr += 2;
-
- /* sanity check */
- if (length < 20 || length > CFG_FACT_SIZE-2)
- goto bailout;
-
- /* read lines */
- while (length > 0)
- {
- /* read one line */
- len = length > 80 ? 80 : length;
- if (eeprom_read (CFG_I2C_FACT_ADDR, addr, buf, len))
- goto bailout;
- /* mark end of buffer */
- buf[len] = 0;
- /* search end of line */
- for (p=buf; *p && *p != 0x0a; p++) ;
- if (!*p)
- goto bailout;
- *p++ = 0;
- /* advance to next line start */
- length -= p-buf;
- addr += p-buf;
- /*printf ("%s\n", buf);*/
- /* search for our specific entry */
- if (!strncmp ((char *)buf, "[RLA/lan/Ethernet] ", 19))
- {
- setenv ("ethaddr", buf+19); - }
- else if (!strncmp ((char *)buf, "[BOARD/SERIAL] ", 15))
- {
- setenv ("serial#", buf+15); - }
- else if (!strncmp ((char *)buf, "[BOARD/TYPE] ", 13))
- {
- setenv ("board_id", buf+13); - }
- }
return (0); } - diff --git a/board/emk/top860/u-boot.lds b/board/emk/top860/u-boot.lds index 6371110..f6f5485 100644 --- a/board/emk/top860/u-boot.lds +++ b/board/emk/top860/u-boot.lds @@ -98,6 +98,12 @@ SECTIONS _edata = .; PROVIDE (edata = .); + + __u_boot_cmd_start = .; + .u_boot_cmd : { *(.u_boot_cmd) } + __u_boot_cmd_end = .; + + __start___ex_table = .; __ex_table : { *(__ex_table) } __stop___ex_table = .; @@ -120,4 +126,3 @@ SECTIONS _end = . ; PROVIDE (end = .); } - diff --git a/board/emk/top860/u-boot.lds.debug b/board/emk/top860/u-boot.lds.debug index bd13b7b..8d91be5 100644 --- a/board/emk/top860/u-boot.lds.debug +++ b/board/emk/top860/u-boot.lds.debug @@ -129,4 +129,3 @@ SECTIONS _end = . ; PROVIDE (end = .); } - |