Consolidate strmhz() implementation
[platform/kernel/u-boot.git] / lib_m68k / board.c
index 778ec78..e59c6b0 100644 (file)
@@ -30,9 +30,7 @@
 #include <malloc.h>
 #include <devices.h>
 
-#ifdef CONFIG_M5272
-#include <asm/immap_5272.h>
-#endif
+#include <asm/immap.h>
 
 #if defined(CONFIG_CMD_IDE)
 #include <ide.h>
@@ -47,6 +45,7 @@
 #include <status_led.h>
 #endif
 #include <net.h>
+#include <serial.h>
 #if defined(CONFIG_CMD_BEDBUG)
 #include <cmd_bedbug.h>
 #endif
 #include <i2c.h>
 #endif
 
+#ifdef CONFIG_CMD_SPI
+#include <spi.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static char *failed = "*** failed ***\n";
@@ -137,23 +140,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
@@ -169,7 +155,7 @@ char *strmhz(char *buf, long hz)
 typedef int (init_fnc_t) (void);
 
 /************************************************************************
- * Init Utilities                                                      *
+ * Init Utilities
  ************************************************************************
  * Some of this code should be moved into the core functions,
  * but let's get it working (again) first...
@@ -177,7 +163,7 @@ typedef int (init_fnc_t) (void);
 
 static int init_baudrate (void)
 {
-       uchar tmp[64];  /* long enough for environment variables */
+       char tmp[64];   /* long enough for environment variables */
        int i = getenv_r ("baudrate", tmp, sizeof (tmp));
 
        gd->baudrate = (i > 0)
@@ -213,6 +199,16 @@ static int init_func_i2c (void)
 }
 #endif
 
+#if defined(CONFIG_HARD_SPI)
+static int init_func_spi (void)
+{
+       puts ("SPI:   ");
+       spi_init ();
+       puts ("ready\n");
+       return (0);
+}
+#endif
+
 /***********************************************************************/
 
 /************************************************************************
@@ -232,6 +228,9 @@ init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
        init_func_i2c,
 #endif
+#if defined(CONFIG_HARD_SPI)
+       init_func_spi,
+#endif
        init_func_ram,
 #if defined(CFG_DRAM_TEST)
        testdram,
@@ -268,7 +267,7 @@ board_init_f (ulong bootflag)
 #ifdef CONFIG_PRAM
        int i;
        ulong reg;
-       uchar tmp[64];          /* long enough for environment variables */
+       char tmp[64];           /* long enough for environment variables */
 #endif
 
        /* Pointer is writable since we allocated a register for it */
@@ -315,6 +314,16 @@ board_init_f (ulong bootflag)
        debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
 #endif /* CONFIG_PRAM */
 
+       /* round down to next 4 kB limit */
+       addr &= ~(4096 - 1);
+       debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
+
+#ifdef CONFIG_LCD
+       /* reserve memory for LCD display (always full pages) */
+       addr = lcd_setmem (addr);
+       gd->fb_base = addr;
+#endif /* CONFIG_LCD */
+
        /*
         * reserve memory for U-Boot code, data & bss
         * round down to next 4 kB limit
@@ -338,14 +347,14 @@ 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);
 
-       /* Reserve memory for boot params. */
+       /* Reserve memory for boot params. */
        addr_sp -= CFG_BOOTPARAMS_LEN;
        bd->bi_boot_params = addr_sp;
        debug ("Reserving %dk for boot parameters at: %08lx\n",
@@ -383,6 +392,14 @@ board_init_f (ulong bootflag)
        WATCHDOG_RESET ();
        bd->bi_intfreq = gd->cpu_clk;   /* Internal Freq, in Hz */
        bd->bi_busfreq = gd->bus_clk;   /* Bus Freq,      in Hz */
+#ifdef CONFIG_PCI
+       bd->bi_pcifreq = gd->pci_clk;           /* PCI Freq in Hz */
+#endif
+#ifdef CONFIG_EXTRA_CLOCK
+       bd->bi_inpfreq = gd->inp_clk;           /* input Freq in Hz */
+       bd->bi_vcofreq = gd->vco_clk;           /* vco Freq in Hz */
+       bd->bi_flbfreq = gd->flb_clk;           /* flexbus Freq in Hz */
+#endif
        bd->bi_baudrate = gd->baudrate; /* Console Baudrate     */
 
 #ifdef CFG_EXTBDINFO
@@ -735,7 +752,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
         */
        {
                ulong pram;
-               uchar memsz[32];
+               char memsz[32];
 #ifdef CONFIG_PRAM
                char *s;