]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib_ppc/board.c
Do not init SATA when disabled on 8536DS.
[karo-tx-uboot.git] / lib_ppc / board.c
index ee0213e1acac8748330015fac23f659d6191e9b4..564faf2c651b1a93ad41a99746572f63e9c90456 100644 (file)
@@ -38,6 +38,9 @@
 #if defined(CONFIG_CMD_IDE)
 #include <ide.h>
 #endif
+#if defined(CONFIG_CMD_SATA)
+#include <sata.h>
+#endif
 #if defined(CONFIG_CMD_SCSI)
 #include <scsi.h>
 #endif
@@ -87,12 +90,8 @@ void doc_init (void);
     defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
 #endif
-#if defined(CONFIG_HARD_SPI)
 #include <spi.h>
-#endif
-#if defined(CONFIG_CMD_NAND)
-void nand_init (void);
-#endif
+#include <nand.h>
 
 static char *failed = "*** failed ***\n";
 
@@ -107,16 +106,20 @@ extern int board_start_ide(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CFG_ENV_IS_EMBEDDED)
+#if defined(CONFIG_ENV_IS_EMBEDDED)
 #define TOTAL_MALLOC_LEN       CFG_MALLOC_LEN
-#elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
-       (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
-      defined(CFG_ENV_IS_IN_NVRAM)
-#define        TOTAL_MALLOC_LEN        (CFG_MALLOC_LEN + CFG_ENV_SIZE)
+#elif ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CFG_MONITOR_BASE) || \
+       (CONFIG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
+      defined(CONFIG_ENV_IS_IN_NVRAM)
+#define        TOTAL_MALLOC_LEN        (CFG_MALLOC_LEN + CONFIG_ENV_SIZE)
 #else
 #define        TOTAL_MALLOC_LEN        CFG_MALLOC_LEN
 #endif
 
+#if !defined(CFG_MEM_TOP_HIDE)
+#define CFG_MEM_TOP_HIDE       0
+#endif
+
 extern ulong __init_end;
 extern ulong _end;
 ulong monitor_flash_len;
@@ -165,19 +168,6 @@ void *sbrk (ptrdiff_t increment)
        return ((void *) old);
 }
 
-char *strmhz (char *buf, long hz)
-{
-       long l, n;
-       long m;
-
-       n = hz / 1000000L;
-       l = sprintf (buf, "%ld", n);
-       m = (hz % 1000000L) / 1000L;
-       if (m != 0)
-               sprintf (buf + l, ".%03ld", m);
-       return (buf);
-}
-
 /*
  * All attempts to come up with a "common" initialization sequence
  * that works for all boards and architectures failed: some of the
@@ -391,6 +381,13 @@ ulong get_effective_memsize(void)
  ************************************************************************
  */
 
+#ifdef CONFIG_LOGBUFFER
+unsigned long logbuffer_base(void)
+{
+       return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
+}
+#endif
+
 void board_init_f (ulong bootflag)
 {
        bd_t *bd;
@@ -409,7 +406,8 @@ void board_init_f (ulong bootflag)
        /* compiler optimization barrier needed for GCC >= 3.4 */
        __asm__ __volatile__("": : :"memory");
 
-#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
+#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \
+    !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx)
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
 #endif
@@ -425,6 +423,7 @@ void board_init_f (ulong bootflag)
         * relocate the code and continue running from DRAM.
         *
         * Reserve memory at end of RAM for (top down in that order):
+        *  - area that won't get touched by U-Boot and Linux (optional)
         *  - kernel log buffer
         *  - protected RAM
         *  - LCD framebuffer
@@ -433,6 +432,18 @@ void board_init_f (ulong bootflag)
         */
        len = (ulong)&_end - CFG_MONITOR_BASE;
 
+       /*
+        * Subtract specified amount of memory to hide so that it won't
+        * get "touched" at all by U-Boot. By fixing up gd->ram_size
+        * the Linux kernel should now get passed the now "corrected"
+        * memory size and won't touch it either. This should work
+        * for arch/ppc and arch/powerpc. Only Linux board ports in
+        * arch/powerpc with bootwrapper support, that recalculate the
+        * memory size from the SDRAM controller setup will have to
+        * get fixed.
+        */
+       gd->ram_size -= CFG_MEM_TOP_HIDE;
+
        addr = CFG_SDRAM_BASE + get_effective_memsize();
 
 #ifdef CONFIG_LOGBUFFER
@@ -500,11 +511,11 @@ void board_init_f (ulong bootflag)
        addr_sp -= sizeof (bd_t);
        bd = (bd_t *) addr_sp;
        gd->bd = bd;
-       debug ("Reserving %d Bytes for Board Info at: %08lx\n",
+       debug ("Reserving %zu Bytes for Board Info at: %08lx\n",
                        sizeof (bd_t), addr_sp);
        addr_sp -= sizeof (gd_t);
        id = (gd_t *) addr_sp;
-       debug ("Reserving %d Bytes for Global Data at: %08lx\n",
+       debug ("Reserving %zu Bytes for Global Data at: %08lx\n",
                        sizeof (gd_t), addr_sp);
 
        /*
@@ -601,7 +612,7 @@ void board_init_f (ulong bootflag)
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
        bd->bi_pci_busfreq = get_PCI_freq ();
        bd->bi_opbfreq = get_OPB_freq ();
-#elif defined(CONFIG_XILINX_ML300)
+#elif defined(CONFIG_XILINX_405)
        bd->bi_pci_busfreq = get_PCI_freq ();
 #endif
 #endif
@@ -624,6 +635,16 @@ void board_init_f (ulong bootflag)
        /* NOTREACHED - relocate_code() does not return */
 }
 
+int __is_sata_supported()
+{
+       /* For some boards, when sata disabled by the switch, and the
+        * driver still access the sata registers, the cpu will hangup.
+        * please define platform specific is_sata_supported() if your
+        * board have such issue.*/
+       return 1;
+}
+int is_sata_supported() __attribute__((weak, alias("__is_sata_supported")));
+
 /************************************************************************
  *
  * This is the next part if the initialization sequence: we are now
@@ -640,7 +661,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        bd_t *bd;
        int i;
        extern void malloc_bin_reloc (void);
-#ifndef CFG_ENV_IS_NOWHERE
+#ifndef CONFIG_ENV_IS_NOWHERE
        extern char * env_name_spec;
 #endif
 
@@ -702,7 +723,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #endif
        }
        /* there are some other pointer constants we must deal with */
-#ifndef CFG_ENV_IS_NOWHERE
+#ifndef CONFIG_ENV_IS_NOWHERE
        env_name_spec += gd->reloc_off;
 #endif
 
@@ -762,7 +783,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
                 */
                s = getenv ("flashchecksum");
                if (s && (*s == 'y')) {
-                       printf ("  CRC: %08lX",
+                       printf ("  CRC: %08X",
                                crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size)
                        );
                }
@@ -811,7 +832,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        malloc_bin_reloc ();
 
 #ifdef CONFIG_SPI
-# if !defined(CFG_ENV_IS_IN_EEPROM)
+# if !defined(CONFIG_ENV_IS_IN_EEPROM)
        spi_init_f ();
 # endif
        spi_init_r ();
@@ -862,7 +883,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
        sc3_read_eeprom();
 #endif
 
-#ifdef CFG_ID_EEPROM
+#if defined (CONFIG_ID_EEPROM) || defined (CFG_I2C_MAC_OFFSET)
        mac_read_from_eeprom();
 #endif
 
@@ -1093,6 +1114,13 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #endif
 #endif
 
+#if defined(CONFIG_CMD_SATA)
+       if (is_sata_supported()) {
+               puts("SATA:  ");
+               sata_initialize();
+       }
+#endif
+
 #ifdef CONFIG_LAST_STAGE_INIT
        WATCHDOG_RESET ();
        /*