]> git.sur5r.net Git - u-boot/blobdiff - board/sixnet/sixnet.c
Merge with /home/wd/git/u-boot/master
[u-boot] / board / sixnet / sixnet.c
index c65e8097bbcfa2f571c4459fc3a2967050a98917..c31ea539e2b0886861c24c50a7ffd4158c60c570 100644 (file)
 
 #include <common.h>
 #include <config.h>
+#include <jffs2/jffs2.h>
 #include <mpc8xx.h>
 #include <net.h>       /* for eth_init() */
 #include <rtc.h>
 #include "sixnet.h"
+#ifdef CONFIG_SHOW_BOOT_PROGRESS
+# include <status_led.h>
+#endif
+
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+#include <linux/mtd/nand.h>
+extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
+#endif
 
 #define ORMASK(size) ((-size) & OR_AM_MSK)
 
@@ -35,6 +44,22 @@ static long ram_size(ulong *, long);
 
 /* ------------------------------------------------------------------------- */
 
+#ifdef CONFIG_SHOW_BOOT_PROGRESS
+void show_boot_progress (int status)
+{
+#if defined(CONFIG_STATUS_LED)
+# if defined(STATUS_LED_BOOT)
+       if (status == 15) {
+               /* ready to transfer to kernel, make sure LED is proper state */
+               status_led_set(STATUS_LED_BOOT, CONFIG_BOOT_LED_STATE);
+       }
+# endif /* STATUS_LED_BOOT */
+#endif /* CONFIG_STATUS_LED */
+}
+#endif
+
+/* ------------------------------------------------------------------------- */
+
 /*
  * Check Board Identity:
  * returns 0 if recognized, -1 if unknown
@@ -150,7 +175,7 @@ int board_postclk_init (void)
 
        /* write program data to FPGA at the programming address
         * so extra /CS1 strobes at end of configuration don't actually
-         * write to any registers.
+        * write to any registers.
         */
        fpga = 0xff;            /* first write is ignored       */
        fpga = 0xff;            /* fill byte                    */
@@ -235,6 +260,9 @@ int misc_init_r (void)
 
        volatile immap_t     *immap = (immap_t *)CFG_IMMR;
        volatile memctl8xx_t *memctl = &immap->im_memctl;
+       char* s;
+       char* e;
+       int reg;
        bd_t *bd = gd->bd;
 
        memctl->memc_or2 = NVRAM_OR_PRELIM;
@@ -283,21 +311,31 @@ int misc_init_r (void)
            immap->im_sit.sit_rtc = tim;
        }
 
-#if 0
-       /* The code below is no longer valid since the prototype of
-        * eth_init() and eth_halt() have been changed to support
-        * multi-ethernet feature in U-Boot; the eth_initialize()
-        * routine should be called before any access to the ethernet
-        * callbacks.
+       /* set up ethernet address for SCC ethernet. If eth1addr
+        * is present it gets a unique address, otherwise it
+        * shares the FEC address.
         */
+       s = getenv("eth1addr");
+       if (s == NULL)
+               s = getenv("ethaddr");
+       for (reg=0; reg<6; ++reg) {
+               bd->bi_enet1addr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
+               if (s)
+                       s = (*e) ? e+1 : e;
+       }
 
-       /* FIXME - for now init ethernet to force PHY special mode */
-       eth_init(bd);
-       eth_halt();
-#endif
        return (0);
 }
 
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+void nand_init(void)
+{
+       unsigned long totlen = nand_probe(CFG_DFLASH_BASE);
+
+       printf ("%4lu MB\n", totlen >> 20);
+}
+#endif
+
 /* ------------------------------------------------------------------------- */
 
 /*
@@ -307,7 +345,7 @@ int misc_init_r (void)
  *
  * The memory size MUST be a power of 2 for this to work.
  *
- * The only memory modified is 4 bytes at offset 0. This is important
+ * The only memory modified is 8 bytes at offset 0. This is important
  * since for the SRAM this location is reserved for autosizing, so if
  * it is modified and the board is reset before ram_size() completes
  * no damage is  done. Normally even the memory at 0 is preserved. The
@@ -319,28 +357,27 @@ static long ram_size(ulong *base, long maxsize)
 {
     volatile long      *test_addr;
     volatile long      *base_addr = base;
-    volatile long      *flash = (volatile long*)CFG_FLASH_BASE;
     ulong              ofs;            /* byte offset from base_addr */
     ulong              save;           /* to make test non-destructive */
-    ulong              junk;
+    ulong              save2;          /* to make test non-destructive */
     long               ramsize = -1;   /* size not determined yet */
 
     save = *base_addr;         /* save value at 0 so can restore */
+    save2 = *(base_addr+1);    /* save value at 4 so can restore */
 
     /* is any SRAM present? */
     *base_addr = 0x5555aaaa;
 
-    /* use flash read to modify data bus, since with no SRAM present
-     * the data bus may retain the value if our code is running
-     * completely in the cache.
+    /* It is important to drive the data bus with different data so
+     * it doesn't remember the value and look like RAM that isn't there.
      */
-    junk = *flash;
+    *(base_addr + 1) = 0xaaaa5555;     /* use write to modify data bus */
 
     if (*base_addr != 0x5555aaaa)
        ramsize = 0;            /* no RAM present, or defective */
     else {
        *base_addr = 0xaaaa5555;
-       junk = *flash;          /* use flash read to modify data bus */
+       *(base_addr + 1) = 0x5555aaaa;  /* use write to modify data bus */
        if (*base_addr != 0xaaaa5555)
            ramsize = 0;        /* no RAM present, or defective */
     }
@@ -355,6 +392,7 @@ static long ram_size(ulong *base, long maxsize)
     }
 
     *base_addr = save;         /* restore value at 0 */
+    *(base_addr+1) = save2;    /* restore value at 4 */
     return (ramsize);
 }
 
@@ -383,7 +421,7 @@ const uint sdram_table[] =
        _not_used_, _not_used_, _not_used_, _not_used_,
 
        /* single write. (offset 18 in upm RAM) */
-        /* FADS had 0x1f27fc04, ...
+       /* FADS had 0x1f27fc04, ...
         * but most other boards have 0x1f07fc04, which
         * sets GPL0 from A11MPC to 0 1/4 clock earlier,
         * like the single read.
@@ -426,18 +464,21 @@ const uint sdram_table[] =
                          MCR_MLCF(2) | MCR_MAD(0x30))  /* twice at 0x30  */
 
 /* MAMR values work in either mamr or mbmr */
-/* 8 column SDRAM */
-#define SDRAM_MAMR_8COL  /* refresh at 50MHz */                                  \
+#define SDRAM_MAMR_BASE  /* refresh at 50MHz */                                  \
                         ((195 << MAMR_PTA_SHIFT) | MAMR_PTAE             \
-                        | MAMR_AMA_TYPE_0      /* Address MUX 0 */       \
                         | MAMR_DSA_1_CYCL      /* 1 cycle disable */     \
-                        | MAMR_G0CLA_A11       /* GPL0 A11[MPC] */       \
                         | MAMR_RLFA_1X         /* Read loop 1 time */    \
                         | MAMR_WLFA_1X         /* Write loop 1 time */   \
                         | MAMR_TLFA_4X)        /* Timer loop 4 times */
+/* 8 column SDRAM */
+#define SDRAM_MAMR_8COL        (SDRAM_MAMR_BASE                                  \
+                        | MAMR_AMA_TYPE_0      /* Address MUX 0 */       \
+                        | MAMR_G0CLA_A11)      /* GPL0 A11[MPC] */
 
 /* 9 column SDRAM */
-#define SDRAM_MAMR_9COL ((SDRAM_MAMR_8COL & (~MAMR_G0CLA_A11)) | MAMR_G0CLA_A10)
+#define SDRAM_MAMR_9COL        (SDRAM_MAMR_BASE                                  \
+                        | MAMR_AMA_TYPE_1      /* Address MUX 1 */       \
+                        | MAMR_G0CLA_A10)      /* GPL0 A10[MPC] */
 
 /* base address 0, 32-bit port, SDRAM UPM, valid */
 #define SDRAM_BR_VALUE   (BR_PS_32 | BR_MS_UPMA | BR_V)
@@ -476,7 +517,7 @@ long int initdram(int board_type)
         * This may be too fast, but works for any memory.
         * It is adjusted to 4096 cycles in 64 milliseconds if
         * possible once we know what memory we have.
-         *
+        *
         * We have to be careful changing UPM registers after we
         * ask it to run these commands.
         *
@@ -490,7 +531,7 @@ long int initdram(int board_type)
         *    SCCR[DFBRG] 0
         *    PTP divide by 8
         *    1 chip select
-         */
+        */
        memctl->memc_mptpr = MPTPR_PTP_DIV8;    /* 0x0800 */
        memctl->memc_mamr = SDRAM_MAMR_8COL & (~MAMR_PTAE); /* no refresh yet */
 
@@ -560,4 +601,3 @@ long int initdram(int board_type)
 
        return (size_sdram);
 }
-