]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Added FLAGADM Configuration
authorwdenk <wdenk>
Tue, 29 May 2001 23:50:24 +0000 (23:50 +0000)
committerwdenk <wdenk>
Tue, 29 May 2001 23:50:24 +0000 (23:50 +0000)
(Patch by Kári Davíðsson: 8 May 2001)

CHANGELOG
CREDITS
MAKEALL
Makefile
board/flagadm/Makefile [new file with mode: 0644]
board/flagadm/config.mk [new file with mode: 0644]
board/flagadm/flagadm.c [new file with mode: 0644]
board/flagadm/flash.c [new file with mode: 0644]
board/flagadm/ppcboot.lds [new file with mode: 0644]
board/flagadm/ppcboot.lds.debug [new file with mode: 0644]
include/flash.h

index 749cf6289c385c4e37f126eb3e4562526ca9ddde..1879297406090216c20a78c0482e972e97dce57a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,9 @@ To do:
 Modifications for 0.9.3:
 ======================================================================
 
+* Added FLAGADM Configuration
+  (Patch by Kári Davíðsson: 8 May 2001)
+
 * Added ERIC Configuration
   (Patch by Swen Anderson: 10 May 2001)
 
diff --git a/CREDITS b/CREDITS
index 9a207a8ccb808c7d86727bdded450f25fcdfba07..bc9e0e83c018b19fbd0cf3875256477d2b37fc48 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -42,6 +42,10 @@ N: Magnus Damm
 E: eramdam@kieray1.p.y.ki.era.ericsson.se
 D: 8xxrom
 
+N: Kári Davíðsson
+E: kd@flaga.is
+D: FLAGA DM Support
+
 N: Wolfgang Denk
 E: wd@denx.de
 D: PPCBOOT initial version, continuing maintenance
diff --git a/MAKEALL b/MAKEALL
index b0bc899d646445b644ff1b40070a48845a7cbb2f..ef98a3d7b23335ff5aa013fa2df482f7d875f753 100755 (executable)
--- a/MAKEALL
+++ b/MAKEALL
@@ -25,7 +25,7 @@ LIST="$LIST   \
        GENIETV                                 \
        MBX MBX860T                             \
        RPXlite                                 \
-       GTH                                     \
+       GTH FLAGADM                             \
 "
 
 #########################################################################
index 44d6edf4c1ffbcc90ce90efec2a8f3dd4dc6f769..d8bcc95295efea565d6fd469cbd5d4f97ac1b0a4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -282,6 +282,14 @@ RPXlite_config:            unconfig
        echo "CPU   = mpc8xx"   >>config.mk ;   \
        echo "#include <config_$(@:_config=).h>" >config.h
 
+FLAGADM_config:        unconfig
+       @echo "Configuring for $(@:_config=) Board..." ; \
+       cd include ;                            \
+       echo "ARCH  = ppc"      > config.mk ;   \
+       echo "BOARD = flagadm"  >>config.mk ;   \
+       echo "CPU   = mpc8xx"   >>config.mk ;   \
+       echo "#include <config_$(@:_config=).h>" >config.h
+
 #########################################################################
 ## PPC4xx Systems
 #########################################################################
diff --git a/board/flagadm/Makefile b/board/flagadm/Makefile
new file mode 100644 (file)
index 0000000..c137d4b
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# (C) Copyright 2001
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    = lib$(BOARD).a
+
+OBJS   = $(BOARD).o flash.o
+
+$(LIB):        .depend $(OBJS)
+       $(AR) crv $@ $^
+
+#########################################################################
+
+.depend:       Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
+               $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+       
+sinclude .depend
+
+#########################################################################
diff --git a/board/flagadm/config.mk b/board/flagadm/config.mk
new file mode 100644 (file)
index 0000000..9c72c79
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# (C) Copyright 2001
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#
+# TQM8xxL boards
+#
+
+TEXT_BASE = 0x40000000
diff --git a/board/flagadm/flagadm.c b/board/flagadm/flagadm.c
new file mode 100644 (file)
index 0000000..75a454a
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include "mpc8xx.h"
+
+/* ------------------------------------------------------------------------- */
+
+static long int dram_size (long int, long int *, long int);
+
+/* ------------------------------------------------------------------------- */
+
+#define        _NOT_USED_      0xFFFFFFFF
+
+const uint sdram_table[] =
+{
+       /* Single read cycle */
+0x1F07D004, 0xEEAEE004, 0x11ADD004, 0xEFBBA000,
+0x1FF75447,
+0x1FF77C34, /*Load mode register*/
+0xEFEABC34, 0x1FB57C35, 
+       /* Burst read */
+0x1F07D004, 0xEEAEE004, 0x00ADC004, 0x00AFC000, 
+0x00AFC000, 0x01AFC000, 0x0FBB8000, 0x1FF75447,
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+       /* Single write cycle */
+0x1F27D004, 0xEEAEA000, 0x01B90004, 0x1FF75447,
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+       /* Burst Write cycle */
+0x1F07D004, 0xEEAEA000, 0x00AD4000, 0x00AFC000,
+0x00AFC000, 0x01BB8004, 0x1FF75447, _NOT_USED_, 
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+       /* reFresh cycle */
+0x1FF5DC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
+0xFFFFFC84, 0xFFFFFC07, _NOT_USED_, _NOT_USED_, 
+_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, 
+       /* Exception */
+0x7FFFFC07, _NOT_USED_, _NOT_USED_, _NOT_USED_
+};
+
+/* ------------------------------------------------------------------------- */
+
+
+int checkboard (void)
+{
+       puts("FlagaDM V3.0");
+       return 3; //Version 3
+}
+
+/* ------------------------------------------------------------------------- */
+
+long int initdram (int board_type)
+{
+       volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
+       volatile memctl8xx_t *memctl = &immap->im_memctl;
+       long int size_b0;
+
+    memctl->memc_or2 = CFG_OR2_PRELIM;
+    memctl->memc_br2 = CFG_BR2_PRELIM;
+
+       udelay(1000);
+       upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
+
+       memctl->memc_mptpr = MPTPR_PTP_DIV16;
+
+       memctl->memc_mamr = CFG_MAMR_48_SDR_8; 
+       memctl->memc_mcr = 0x80004130;  // a refresh cycle
+       udelay(100);
+       
+       //Mode register programming
+       memctl->memc_mamr = CFG_MAMR_48_SDR_4;
+
+       memctl->memc_mar = 0x00000088; 
+       memctl->memc_mcr = 0x80004105;
+
+    memctl->memc_mamr |= MAMR_PTAE;    /* enable refresh */
+       
+       udelay(100);
+
+//     size_b0 = dram_size (CFG_MAMR_48_SDR_4, (ulong *)SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
+       size_b0 = 16*1024*1024;
+
+       /*
+        * No bank 1
+        *
+        * invalidate bank
+        */
+       memctl->memc_br3 = 0;
+
+       return (size_b0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Check memory range for valid RAM. A simple memory test determines
+ * the actually available RAM size between addresses `base' and
+ * `base + maxsize'. Some (not all) hardware errors are detected:
+ * - short between address lines
+ * - short between data lines
+ */
+
+static long int dram_size (long int mamr_value, long int *base, long int maxsize)
+{
+    volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
+    volatile memctl8xx_t *memctl = &immap->im_memctl;
+    volatile long int   *addr;
+    long int             cnt, val;
+
+    memctl->memc_mamr = mamr_value;
+
+    for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
+       addr = base + cnt;      /* pointer arith! */
+
+       *addr = ~cnt;
+    }
+
+    /* write 0 to base address */
+    addr = base;
+    *addr = 0;
+
+    /* check at base address */
+    if ((val = *addr) != 0) {
+       return (0);
+    }
+
+    for (cnt = 1; ; cnt <<= 1) {
+       addr = base + cnt;      /* pointer arith! */
+
+       val = *addr;
+
+       if (val != (~cnt)) {
+           return (cnt * sizeof(long));
+       }
+    }
+    /* NOTREACHED */
+}
diff --git a/board/flagadm/flash.c b/board/flagadm/flash.c
new file mode 100644 (file)
index 0000000..3e09b5c
--- /dev/null
@@ -0,0 +1,571 @@
+/*
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <mpc8xx.h>
+
+typedef volatile unsigned char vu_char;
+
+flash_info_t   flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips        */
+
+#if defined(CFG_ENV_IS_IN_FLASH)
+# ifndef  CFG_ENV_ADDR
+#  define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
+# endif
+# ifndef  CFG_ENV_SIZE
+#  define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
+# endif
+# ifndef  CFG_ENV_SECT_SIZE
+#  define CFG_ENV_SECT_SIZE  CFG_ENV_SIZE
+# endif
+#endif
+
+/*-----------------------------------------------------------------------
+ * Functions
+ */
+static ulong flash_get_size (vu_long *addr, flash_info_t *info);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets (ulong base, flash_info_t *info);
+static void sector_protect(flash_info_t *info, int on, int s_start, int s_end);
+
+/*-----------------------------------------------------------------------
+ */
+
+unsigned long flash_init (void)
+{
+       volatile immap_t        *immap  = (immap_t *)CFG_IMMR;
+       volatile memctl8xx_t    *memctl = &immap->im_memctl;
+//     volatile ip860_bcsr_t   *bcsr   = (ip860_bcsr_t *)BCSR_BASE;
+       unsigned long size;
+       int i;
+
+       /* Init: enable write,
+        * or we cannot even write flash commands
+        */
+//     bcsr->bd_ctrl |= BD_CTRL_FLWE;
+
+       for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+               flash_info[i].flash_id = FLASH_UNKNOWN;
+       }
+
+       /* Static FLASH Bank configuration here - FIXME XXX */
+
+//     size = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
+
+//     if (flash_info[0].flash_id == FLASH_UNKNOWN) {
+//             printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
+//                     size, size<<20);
+//     }
+
+       /* Remap FLASH according to real size */
+//     memctl->memc_or0 = CFG_OR_TIMING_FLASH | (-size & 0xFFFF8000);
+//     memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) |
+//                             (memctl->memc_br0 & ~(BR_BA_MSK));
+       memctl->memc_or0 = CFG_OR0_PRELIM;
+       memctl->memc_br0 = CFG_BR0_PRELIM;
+
+       /* Re-do sizing to get full correct info */
+       size = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
+
+       flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
+
+       flash_info[0].size = size;
+
+       sector_protect(&flash_info[0], 0, 0,CFG_MAX_FLASH_SECT);
+       *(vu_short*)CFG_FLASH_BASE = 0xFF; //Reset flash
+
+#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
+       /* monitor protection ON by default */
+       flash_protect(FLAG_PROTECT_SET,
+                     CFG_MONITOR_BASE,
+                     CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
+                     &flash_info[0]);
+#endif
+
+#ifdef CFG_ENV_IS_IN_FLASH
+       /* ENV protection ON by default */
+       flash_protect(FLAG_PROTECT_SET,
+                     CFG_ENV_ADDR,
+                     CFG_ENV_ADDR+CFG_ENV_SECT_SIZE-1,
+                     &flash_info[0]);
+#endif
+       return (size);
+}
+
+/*-----------------------------------------------------------------------
+ */
+static void flash_get_offsets (ulong base, flash_info_t *info)
+{
+       int i;
+
+       for (i = 0; i < 8; i++) {
+               info->start[i] = base;
+               base += 0x00002000;
+       }
+       /* set up sector start address table */
+       for (; i < info->sector_count; i++) {
+               info->start[i] = base;
+               base += 0x00010000;
+       }
+}
+
+/*-----------------------------------------------------------------------
+ */
+void flash_print_info  (flash_info_t *info)
+{
+       int i;
+
+       if (info->flash_id == FLASH_UNKNOWN) {
+               printf ("missing or unknown FLASH type\n");
+               return;
+       }
+
+       switch (info->flash_id & FLASH_VENDMASK) {
+       case FLASH_MAN_INTEL:   printf ("Intel ");              break;
+       default:                printf ("Unknown Vendor ");     break;
+       }
+
+       switch (info->flash_id & FLASH_TYPEMASK) {
+       case FLASH_28F320C3:    printf ("28F320RC3(4 MB)\n");
+                               break;
+       default:                printf ("Unknown Chip Type\n");
+                               break;
+       }
+
+       printf ("  Size: %ld MB in %d Sectors\n",
+               info->size >> 20, info->sector_count);
+
+       printf ("  Sector Start Addresses:");
+       for (i=0; i<info->sector_count; ++i) {
+               if ((i % 5) == 0)
+                       printf ("\n   ");
+               printf (" %08lX%s",
+                       info->start[i],
+                       info->protect[i] ? " (RO)" : "     "
+               );
+       }
+       printf ("\n");
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+
+/*-----------------------------------------------------------------------
+ */
+
+/*
+ * The following code cannot be run from FLASH!
+ */
+
+static ulong flash_get_size (vu_long *addr, flash_info_t *info)
+{
+       short i;
+       ulong value;
+       ulong base = (ulong)addr;
+
+       /* Write "Intelligent Identifier" command: read Manufacturer ID */
+       *addr = 0x90909090;
+
+       value = addr[0];
+       switch (value & 0x00FF0000)
+       {
+       case (MT_MANUFACT & 0x00FF0000):        /* MT or => Intel */
+       case (INTEL_ALT_MANU & 0x00FF0000):
+               info->flash_id = FLASH_MAN_INTEL;
+               break;
+       default:
+               info->flash_id = FLASH_UNKNOWN;
+               info->sector_count = 0;
+               info->size = 0;
+               return (0);                     /* no or unknown flash  */
+       }
+
+//     value = addr[1];                        /* device ID            */
+
+       switch (value & 0x0000FFFF) {
+       case (INTEL_ID_28F320C3 & 0x0000FFFF):
+               info->flash_id += FLASH_28F320C3;
+               info->sector_count = 71;
+               info->size = 0x00400000;
+               break;                          /* => 4 MB              */
+
+       default:
+               info->flash_id = FLASH_UNKNOWN;
+               return (0);                     /* => no or unknown flash */
+
+       }
+
+       /* set up sector start address table */
+       /*Should be done through the region codes.*/
+
+       for(i = 0; i < 8; i++) {
+               //first 8 sectors are 8KB
+               info->start[i] = base + (i * 0x00002000);
+               info->protect[i] = 0;
+       }
+
+       for (; i < info->sector_count; i++) {
+               //Next 63 sectors
+               info->start[i] = base + (i * 0x00010000);
+               /* don't know how to check sector protection */
+               info->protect[i] = 0;
+       }
+
+       /*
+        * Prevent writes to uninitialized FLASH.
+        */
+       if (info->flash_id != FLASH_UNKNOWN) {
+               addr = (vu_long *)info->start[0];
+
+               *addr = 0xFFFFFFFF;     /* reset bank to read array mode */
+       }
+
+       return (info->size);
+}
+
+/*-----------------------------------------------------------------------*/
+#define INTEL_FLASH_STATUS_BLS 0x02
+#define INTEL_FLASH_STATUS_PSS 0x04
+#define INTEL_FLASH_STATUS_VPPS        0x08
+#define INTEL_FLASH_STATUS_PS  0x10
+#define INTEL_FLASH_STATUS_ES  0x20
+#define INTEL_FLASH_STATUS_ESS 0x40
+#define INTEL_FLASH_STATUS_WSMS        0x80
+
+int    flash_decode_status_bits(char status)
+{
+       int err = 0;
+       
+       if(!(status & INTEL_FLASH_STATUS_WSMS)) {
+               printf("Busy\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_ESS) {
+               printf("Erase suspended\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_ES) {
+               printf("Error in block erase\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_PS) {
+               printf("Error in programming\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_VPPS) {
+               printf("Vpp low, operation aborted\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_PSS) {
+               printf("Program is suspended\n");
+               err = -1;
+       }
+
+       if(status & INTEL_FLASH_STATUS_BLS) {
+               printf("Attempting to program/erase a locked sector\n");
+               err = -1;
+       }
+
+       if((status & INTEL_FLASH_STATUS_PS) &&
+          (status & INTEL_FLASH_STATUS_ES) &&
+          (status & INTEL_FLASH_STATUS_ESS)) {
+               printf("A command sequence error\n");
+               return -1;
+       }
+
+       return err;
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+void   flash_erase (flash_info_t *info, int s_first, int s_last)
+{
+       vu_short *addr;
+       int flag, prot, 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;
+       }
+
+       if ((info->flash_id & FLASH_VENDMASK) != FLASH_MAN_INTEL) {
+               printf ("Can't erase unknown flash type %08lx - aborted\n",
+                       info->flash_id);
+               return;
+       }
+
+       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");
+       }
+
+       start = get_timer (0);
+
+       /* Start erase on unprotected sectors */
+       for (sect = s_first; sect<=s_last; sect++) {
+               char tmp;
+
+               if (info->protect[sect] == 0) { /* not protected */
+                       addr = (vu_short *)(info->start[sect]);
+
+                       /* Disable interrupts which might cause a timeout here */
+                       flag = disable_interrupts();
+
+                       /* Single Block Erase Command */
+                       *addr = 0x20;
+                       /* Confirm */
+                       *addr = 0xD0;
+                       /* Resume Command, as per errata update */
+                       *addr = 0xD0;
+
+                       /* re-enable interrupts if necessary */
+                       if (flag)
+                               enable_interrupts();
+
+                       tmp = (short)*addr & 0x00FF;
+                       while (!(tmp & INTEL_FLASH_STATUS_WSMS)) {
+                               if ((now=get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+                                       printf ("Timeout\n");
+                                       *addr = 0xFFFF; /* reset bank */
+                                       return;
+                               }
+                               /* show that we're waiting */
+                               if ((now - last) > 1000) {      /* every second */
+                                       putc ('.');
+                                       last = now;
+                               }
+                               udelay(80);
+                               tmp = (short)*addr & 0x00FF;
+                               if(flash_decode_status_bits(tmp|INTEL_FLASH_STATUS_WSMS)==-1
+                                               && (tmp & INTEL_FLASH_STATUS_WSMS)) {
+                                       printf("Error erasing\n");
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /* reset to read mode */
+       *addr = 0xFFFF; /* reset bank */
+
+       printf (" done\n");
+}
+
+void   sector_protect (flash_info_t *info, int on, int s_first, int s_last)
+{
+       vu_short *addr;
+       int flag, sect;
+       char cmd;
+
+       if ((s_first < 0) || (s_first > s_last)) {
+               return;
+       }
+
+       if ((info->flash_id & FLASH_VENDMASK) != FLASH_MAN_INTEL) {
+               printf ("Can't erase unknown flash type %08lx - aborted\n",
+                       info->flash_id);
+               return;
+       }
+
+       if(on == 0) {
+               //Unlock the sector
+               cmd = 0xD0;
+       }
+       else {
+               //Lock the sector
+               cmd = 0x01;
+       }
+       
+       for (sect = s_first; sect<=s_last; sect++) {
+               addr = (vu_short *)(info->start[sect]);
+
+               /* Disable interrupts which might cause a timeout here */
+               flag = disable_interrupts();
+
+               /* Unlock block*/
+               *addr = 0x60;
+               /* Confirm */
+               *addr = cmd;
+
+               /* re-enable interrupts if necessary */
+               if (flag)
+                       enable_interrupts();
+       }
+
+       /* reset to read mode */
+       *addr = 0xFF;   /* reset bank */
+}
+
+/*-----------------------------------------------------------------------
+ * 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 & ~3);       /* get lower word aligned address */
+
+       /*
+        * handle unaligned start bytes
+        */
+       if ((l = addr - wp) != 0) {
+               data = 0;
+               for (i=0, cp=wp; i<l; ++i, ++cp) {
+                       data = (data << 8) | (*(uchar *)cp);
+               }
+               for (; i<4 && cnt>0; ++i) {
+                       data = (data << 8) | *src++;
+                       --cnt;
+                       ++cp;
+               }
+               for (; cnt==0 && i<4; ++i, ++cp) {
+                       data = (data << 8) | (*(uchar *)cp);
+               }
+
+               if ((rc = write_word(info, wp, data)) != 0) {
+                       return (rc);
+               }
+               wp += 4;
+       }
+
+       /*
+        * handle word aligned part
+        */
+       while (cnt >= 4) {
+               data = 0;
+               for (i=0; i<4; ++i) {
+                       data = (data << 8) | *src++;
+               }
+               if ((rc = write_word(info, wp, data)) != 0) {
+                       return (rc);
+               }
+               wp  += 4;
+               cnt -= 4;
+       }
+
+       if (cnt == 0) {
+               return (0);
+       }
+
+       /*
+        * handle unaligned tail bytes
+        */
+       data = 0;
+       for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+               data = (data << 8) | *src++;
+               --cnt;
+       }
+       for (; i<4; ++i, ++cp) {
+               data = (data << 8) | (*(uchar *)cp);
+       }
+
+       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 da)
+{
+       vu_short *addr = (vu_short *)dest;
+       ulong start;
+       char csr;
+       int flag;
+       ushort * d = (ushort*)&da;
+       int i;
+
+       /* Check if Flash is (sufficiently) erased */
+       if (((*addr & d[0]) != d[0]) || ((*(addr+1) & d[1]) != d[1])) {
+               return (2);
+       }
+       /* Disable interrupts which might cause a timeout here */
+       flag = disable_interrupts();
+
+       for(i = 0; i < 2; i++)
+       {
+               /* Write Command */
+               *addr = 0x10;
+
+               /* Write Data */
+               *addr = d[i];
+
+               /* re-enable interrupts if necessary */
+               if (flag)
+                       enable_interrupts();
+
+               /* data polling for D7 */
+               start = get_timer (0);
+               flag  = 0;
+               while (((csr = *addr) & INTEL_FLASH_STATUS_WSMS)!=INTEL_FLASH_STATUS_WSMS) {
+                       if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+                               flag = 1;
+                               break;
+                       }
+               }
+               if (csr & INTEL_FLASH_STATUS_PSS) {
+                       printf ("CSR indicates write error (%0x) at %08lx\n",
+                                       csr, (ulong)addr);
+                       flag = 1;
+               }
+
+               /* Clear Status Registers Command */
+               *addr = 0x50;
+               /* Reset to read array mode */
+               *addr = 0xFF;
+               addr++;
+       }
+
+       return (flag);
+}
+
+/*-----------------------------------------------------------------------
+ */
diff --git a/board/flagadm/ppcboot.lds b/board/flagadm/ppcboot.lds
new file mode 100644 (file)
index 0000000..8e390cc
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = + SIZEOF_HEADERS;
+  .interp : { *(.interp) }
+  .hash          : { *(.hash)          }
+  .dynsym        : { *(.dynsym)                }
+  .dynstr        : { *(.dynstr)                }
+  .rel.text      : { *(.rel.text)              }
+  .rela.text     : { *(.rela.text)     }
+  .rel.data      : { *(.rel.data)              }
+  .rela.data     : { *(.rela.data)     }
+  .rel.rodata    : { *(.rel.rodata)    }
+  .rela.rodata   : { *(.rela.rodata)   }
+  .rel.got       : { *(.rel.got)               }
+  .rela.got      : { *(.rela.got)              }
+  .rel.ctors     : { *(.rel.ctors)     }
+  .rela.ctors    : { *(.rela.ctors)    }
+  .rel.dtors     : { *(.rel.dtors)     }
+  .rela.dtors    : { *(.rela.dtors)    }
+  .rel.bss       : { *(.rel.bss)               }
+  .rela.bss      : { *(.rela.bss)              }
+  .rel.plt       : { *(.rel.plt)               }
+  .rela.plt      : { *(.rela.plt)              }
+  .init          : { *(.init)  }
+  .plt : { *(.plt) }
+  .text      :
+  {
+    /* WARNING - the following is hand-optimized to fit within */
+    /* the sector layout of our flash chips!   XXX FIXME XXX   */
+
+    cpu/mpc8xx/start.o (.text)
+    common/dlmalloc.o  (.text)
+    ppc/ppcstring.o    (.text)
+    ppc/vsprintf.o     (.text)
+    ppc/crc32.o                (.text)
+    ppc/zlib.o         (.text)
+
+    . = env_offset;
+    common/environment.o(.text)
+
+    *(.text)
+    *(.fixup)
+    *(.got1)
+  }
+  _etext = .;
+  PROVIDE (etext = .);
+  .rodata    :
+  {
+    *(.rodata)
+    *(.rodata1)
+  }
+  .fini      : { *(.fini)    } =0
+  .ctors     : { *(.ctors)   }
+  .dtors     : { *(.dtors)   }
+
+  /* Read-write section, merged into data segment: */
+  . = (. + 0x00FF) & 0xFFFFFF00;
+  _erotext = .;
+  PROVIDE (erotext = .);
+  .reloc   :
+  {
+    *(.got) 
+    _GOT2_TABLE_ = .;
+    *(.got2)
+    _FIXUP_TABLE_ = .;
+    *(.fixup)
+  }
+  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+  .data    :
+  {
+    *(.data)
+    *(.data1)
+    *(.sdata)
+    *(.sdata2)
+    *(.dynamic)
+    CONSTRUCTORS
+  }
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  . = ALIGN(256);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(256);
+  __init_end = .;
+
+  __bss_start = .;
+  .bss       :
+  {
+   *(.sbss) *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = . ;
+  PROVIDE (end = .);
+}
+
diff --git a/board/flagadm/ppcboot.lds.debug b/board/flagadm/ppcboot.lds.debug
new file mode 100644 (file)
index 0000000..ab39976
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = + SIZEOF_HEADERS;
+  .interp : { *(.interp) }
+  .hash          : { *(.hash)          }
+  .dynsym        : { *(.dynsym)                }
+  .dynstr        : { *(.dynstr)                }
+  .rel.text      : { *(.rel.text)              }
+  .rela.text     : { *(.rela.text)     }
+  .rel.data      : { *(.rel.data)              }
+  .rela.data     : { *(.rela.data)     }
+  .rel.rodata    : { *(.rel.rodata)    }
+  .rela.rodata   : { *(.rela.rodata)   }
+  .rel.got       : { *(.rel.got)               }
+  .rela.got      : { *(.rela.got)              }
+  .rel.ctors     : { *(.rel.ctors)     }
+  .rela.ctors    : { *(.rela.ctors)    }
+  .rel.dtors     : { *(.rel.dtors)     }
+  .rela.dtors    : { *(.rela.dtors)    }
+  .rel.bss       : { *(.rel.bss)               }
+  .rela.bss      : { *(.rela.bss)              }
+  .rel.plt       : { *(.rel.plt)               }
+  .rela.plt      : { *(.rela.plt)              }
+  .init          : { *(.init)  }
+  .plt : { *(.plt) }
+  .text      :
+  {
+    /* WARNING - the following is hand-optimized to fit within */
+    /* the sector layout of our flash chips!   XXX FIXME XXX   */
+
+    cpu/mpc8xx/start.o (.text)
+    common/dlmalloc.o  (.text)
+    ppc/vsprintf.o     (.text)
+    ppc/crc32.o                (.text)
+
+    . = env_offset;
+    common/environment.o(.text)
+
+    *(.text)
+    *(.fixup)
+    *(.got1)
+  }
+  _etext = .;
+  PROVIDE (etext = .);
+  .rodata    :
+  {
+    *(.rodata)
+    *(.rodata1)
+  }
+  .fini      : { *(.fini)    } =0
+  .ctors     : { *(.ctors)   }
+  .dtors     : { *(.dtors)   }
+
+  /* Read-write section, merged into data segment: */
+  . = (. + 0x0FFF) & 0xFFFFF000;
+  _erotext = .;
+  PROVIDE (erotext = .);
+  .reloc   :
+  {
+    *(.got) 
+    _GOT2_TABLE_ = .;
+    *(.got2)
+    _FIXUP_TABLE_ = .;
+    *(.fixup)
+  }
+  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+  .data    :
+  {
+    *(.data)
+    *(.data1)
+    *(.sdata)
+    *(.sdata2)
+    *(.dynamic)
+    CONSTRUCTORS
+  }
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  . = ALIGN(4096);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(4096);
+  __init_end = .;
+
+  __bss_start = .;
+  .bss       :
+  {
+   *(.sbss) *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = . ;
+  PROVIDE (end = .);
+}
+
index 9dec3d51f6b2eb65ec314d4edd98cbd7563f8c5b..98a5d225c8e7773072e43cda8aeaea5f7ebc6c9e 100644 (file)
@@ -129,6 +129,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
 #define INTEL_ID_28F320B3B  0x88978897 /*  32M = 2M x 16 bottom boot sector    */
 #define INTEL_ID_28F640B3T  0x88988898 /*  64M = 4M x 16 top boot sector       */
 #define INTEL_ID_28F640B3B  0x88998899 /*  64M = 4M x 16 bottom boot sector    */
+#define INTEL_ID_28F320C3              0x88C588C5      /*      4MB , 8 8KB + 63 64KB bbt*/
 
 #define INTEL_ID_28F320JA3  0x00160016 /*  32M = 128K x  32                    */
 #define INTEL_ID_28F640JA3  0x00170017 /*  64M = 128K x  64                    */
@@ -196,6 +197,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
 #define FLASH_28F320J5 0x0085          /* Intel 28F320J5  (  4M = 128K x 32 )  */
 #define FLASH_28F160S3 0x0086          /* Intel 28F160S3  ( 16M = 512K x 32 )  */
 #define FLASH_28F320S3 0x0088          /* Intel 28F320S3  ( 32M = 512K x 64 )  */
+#define FLASH_28F320C3 0x0089          /* Intel 28F320C3  ( 32M = 64Kx8 + 512x64)*/
 
 #define FLASH_UNKNOWN  0xFFFF          /* unknown flash type                   */