]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/m68k/lib/board.c
Merge branch 'master' of git://git.denx.de/u-boot-i2c
[karo-tx-uboot.git] / arch / m68k / lib / board.c
index eba2435a59786615c21635b4c0732d22cd2ea599..e75b6a98dd5cb615d8d592504574b275ed2899a2 100644 (file)
@@ -5,23 +5,7 @@
  * (C) Copyright 2000-2002
  * 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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -29,6 +13,7 @@
 #include <command.h>
 #include <malloc.h>
 #include <stdio_dev.h>
+#include <linux/compiler.h>
 
 #include <asm/immap.h>
 
@@ -55,7 +40,7 @@
 #include <version.h>
 
 #if defined(CONFIG_HARD_I2C) || \
-    defined(CONFIG_SOFT_I2C)
+       defined(CONFIG_SYS_I2C)
 #include <i2c.h>
 #endif
 
@@ -76,11 +61,10 @@ static char *failed = "*** failed ***\n";
 #include <environment.h>
 
 extern ulong __init_end;
-extern ulong _end;
-
-extern void timer_init(void);
+extern ulong __bss_end;
 
 #if defined(CONFIG_WATCHDOG)
+# undef INIT_FUNC_WATCHDOG_INIT
 # define INIT_FUNC_WATCHDOG_INIT       watchdog_init,
 # define WATCHDOG_DISABLE              watchdog_disable
 
@@ -121,13 +105,8 @@ typedef int (init_fnc_t) (void);
 
 static int init_baudrate (void)
 {
-       char tmp[64];   /* long enough for environment variables */
-       int i = getenv_f("baudrate", tmp, sizeof (tmp));
-
-       gd->baudrate = (i > 0)
-                       ? (int) simple_strtoul (tmp, NULL, 10)
-                       : CONFIG_BAUDRATE;
-       return (0);
+       gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
+       return 0;
 }
 
 /***********************************************************************/
@@ -147,11 +126,15 @@ static int init_func_ram (void)
 
 /***********************************************************************/
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) ||        defined(CONFIG_SYS_I2C)
 static int init_func_i2c (void)
 {
        puts ("I2C:   ");
+#ifdef CONFIG_SYS_I2C
+       i2c_init_all();
+#else
        i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
        puts ("ready\n");
        return (0);
 }
@@ -183,7 +166,7 @@ init_fnc_t *init_sequence[] = {
        display_options,
        checkcpu,
        checkboard,
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
        init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
@@ -223,9 +206,7 @@ board_init_f (ulong bootflag)
        gd_t *id;
        init_fnc_t **init_fnc_ptr;
 #ifdef CONFIG_PRAM
-       int i;
        ulong reg;
-       char tmp[64];           /* long enough for environment variables */
 #endif
 
        /* Pointer is writable since we allocated a register for it */
@@ -252,7 +233,7 @@ board_init_f (ulong bootflag)
         *      - monitor code
         *      - board info struct
         */
-       len = (ulong)&_end - CONFIG_SYS_MONITOR_BASE;
+       len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
 
        addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
 
@@ -266,8 +247,7 @@ board_init_f (ulong bootflag)
        /*
         * reserve protected RAM
         */
-       i = getenv_f("pram", tmp, sizeof (tmp));
-       reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
+       reg = getenv_ulong("pram", 10, CONFIG_PRAM);
        addr -= (reg << 10);            /* size is in kB */
        debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
 #endif /* CONFIG_PRAM */
@@ -277,9 +257,13 @@ board_init_f (ulong bootflag)
        debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
 
 #ifdef CONFIG_LCD
+#ifdef CONFIG_FB_ADDR
+       gd->fb_base = CONFIG_FB_ADDR;
+#else
        /* reserve memory for LCD display (always full pages) */
        addr = lcd_setmem (addr);
        gd->fb_base = addr;
+#endif /* CONFIG_FB_ADDR */
 #endif /* CONFIG_LCD */
 
        /*
@@ -341,7 +325,7 @@ board_init_f (ulong bootflag)
        bd->bi_memsize   = gd->ram_size;        /* size  of  DRAM memory in bytes */
 #ifdef CONFIG_SYS_INIT_RAM_ADDR
        bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR;    /* start of  SRAM memory        */
-       bd->bi_sramsize  = CONFIG_SYS_INIT_RAM_END;     /* size  of  SRAM memory        */
+       bd->bi_sramsize  = CONFIG_SYS_INIT_RAM_SIZE;    /* size  of  SRAM memory        */
 #endif
        bd->bi_mbar_base = CONFIG_SYS_MBAR;             /* base of internal registers */
 
@@ -354,9 +338,9 @@ board_init_f (ulong bootflag)
        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 */
+       bd->bi_inpfreq = gd->arch.inp_clk;              /* input Freq in Hz */
+       bd->bi_vcofreq = gd->arch.vco_clk;              /* vco Freq in Hz */
+       bd->bi_flbfreq = gd->arch.flb_clk;              /* flexbus Freq in Hz */
 #endif
        bd->bi_baudrate = gd->baudrate; /* Console Baudrate     */
 
@@ -393,10 +377,8 @@ board_init_f (ulong bootflag)
  */
 void board_init_r (gd_t *id, ulong dest_addr)
 {
-       cmd_tbl_t *cmdtp;
-       char *s;
+       char *s __maybe_unused;
        bd_t *bd;
-       extern void malloc_bin_reloc (void);
 
 #ifndef CONFIG_ENV_IS_NOWHERE
        extern char * env_name_spec;
@@ -409,25 +391,23 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
 
-#ifdef CONFIG_SERIAL_MULTI
-       serial_initialize();
-#endif
-
-       debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
-
        WATCHDOG_RESET ();
 
        gd->reloc_off =  dest_addr - CONFIG_SYS_MONITOR_BASE;
 
+       serial_initialize();
+
+       debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
+
        monitor_flash_len = (ulong)&__init_end - dest_addr;
 
-#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
        /*
         * We have to relocate the command table manually
         */
-       fixup_cmdtable(&__u_boot_cmd_start,
-               (ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
-#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
+       fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+                       ll_entry_count(cmd_tbl_t, cmd));
+#endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */
 
        /* there are some other pointer constants we must deal with */
 #ifndef CONFIG_ENV_IS_NOWHERE
@@ -458,10 +438,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
        /* The Malloc area is immediately below the monitor copy in DRAM */
        mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
                        TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN);
-       malloc_bin_reloc ();
 
 #if !defined(CONFIG_SYS_NO_FLASH)
-       puts ("FLASH: ");
+       puts ("Flash: ");
 
        if ((flash_size = flash_init ()) > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
@@ -471,8 +450,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
                 *
                 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
                 */
-               s = getenv ("flashchecksum");
-               if (s && (*s == 'y')) {
+               if (getenv_yesno("flashchecksum") == 1) {
                        printf ("  CRC: %08X",
                                        crc32 (0,
                                                   (const unsigned char *) CONFIG_SYS_FLASH_BASE,
@@ -511,18 +489,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
        spi_init_r ();
 #endif
 
+#if defined(CONFIG_SYS_I2C)
+       /* Adjust I2C subsystem pointers after relocation */
+       i2c_reloc_fixup();
+#endif
+
        /* relocate environment function pointers etc. */
        env_relocate ();
 
-       /*
-        * Fill in missing fields of bd_info.
-        * We do this here, where we have "normal" access to the
-        * environment; we used to do this still running from ROM,
-        * where had to use getenv_f(), which can be pretty slow when
-        * the environment is in EEPROM.
-        */
-       bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-
        WATCHDOG_RESET ();
 
 #if defined(CONFIG_PCI)
@@ -571,19 +545,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        udelay (20);
 
-       set_timer (0);
-
        /* Insert function pointers now that we have relocated the code */
 
        /* Initialize from environment */
-       if ((s = getenv ("loadaddr")) != NULL) {
-               load_addr = simple_strtoul (s, NULL, 16);
-       }
-#if defined(CONFIG_CMD_NET)
-       if ((s = getenv ("bootfile")) != NULL) {
-               copy_filename (BootFile, s, sizeof (BootFile));
-       }
-#endif
+       load_addr = getenv_ulong("loadaddr", 16, load_addr);
 
        WATCHDOG_RESET ();
 
@@ -607,11 +572,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
 #if defined(FEC_ENET)
        eth_init(bd);
 #endif
-#if defined(CONFIG_NET_MULTI)
        puts ("Net:   ");
        eth_initialize (bd);
 #endif
-#endif
 
 #ifdef CONFIG_POST
        post_run (NULL, POST_RAM | post_bootmode_get(0));
@@ -651,18 +614,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
         * taking into account the protected RAM at top of memory
         */
        {
-               ulong pram;
+               ulong pram = 0;
                char memsz[32];
-#ifdef CONFIG_PRAM
-               char *s;
 
-               if ((s = getenv ("pram")) != NULL) {
-                       pram = simple_strtoul (s, NULL, 10);
-               } else {
-                       pram = CONFIG_PRAM;
-               }
-#else
-               pram=0;
+#ifdef CONFIG_PRAM
+               pram = getenv_ulong("pram", 10, CONFIG_PRAM);
 #endif
 #ifdef CONFIG_LOGBUFFER
                /* Also take the logbuffer into account (pram is in kB) */
@@ -700,10 +656,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
        /* NOTREACHED - no way out of command loop except booting */
 }
-
-
-void hang(void)
-{
-       puts ("### ERROR ### Please RESET the board ###\n");
-       for (;;);
-}