X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=lib_m68k%2Fboard.c;h=3d885306e216178b0e2252e0900e82aefc522204;hb=6385b28116f775da4771b768ba9bf93c3aaaf26e;hp=1b515a4c59950833b8b8dadbd7c8d57435adf364;hpb=98c80b462f9532f3ff6a62dd9629023b48627a6d;p=u-boot diff --git a/lib_m68k/board.c b/lib_m68k/board.c index 1b515a4c59..3d885306e2 100644 --- a/lib_m68k/board.c +++ b/lib_m68k/board.c @@ -28,29 +28,28 @@ #include #include #include -#include +#include -#ifdef CONFIG_M5272 -#include -#endif +#include -#if (CONFIG_COMMANDS & CFG_CMD_IDE) +#if defined(CONFIG_CMD_IDE) #include #endif -#if (CONFIG_COMMANDS & CFG_CMD_SCSI) +#if defined(CONFIG_CMD_SCSI) #include #endif -#if (CONFIG_COMMANDS & CFG_CMD_KGDB) +#if defined(CONFIG_CMD_KGDB) #include #endif #ifdef CONFIG_STATUS_LED #include #endif #include -#if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) +#include +#if defined(CONFIG_CMD_BEDBUG) #include #endif -#ifdef CFG_ALLOC_DPRAM +#ifdef CONFIG_SYS_ALLOC_DPRAM #include #endif #include @@ -60,6 +59,12 @@ #include #endif +#ifdef CONFIG_CMD_SPI +#include +#endif + +#include + DECLARE_GLOBAL_DATA_PTR; static char *failed = "*** failed ***\n"; @@ -70,12 +75,12 @@ extern flash_info_t flash_info[]; #include -#if ( ((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) +#if ( ((CONFIG_ENV_ADDR+CONFIG_ENV_SIZE) < CONFIG_SYS_MONITOR_BASE) || \ + (CONFIG_ENV_ADDR >= (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) ) || \ + defined(CONFIG_ENV_IS_IN_NVRAM) +#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE) #else -#define TOTAL_MALLOC_LEN CFG_MALLOC_LEN +#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN #endif extern ulong __init_end; @@ -96,64 +101,11 @@ extern int watchdog_disable(void); ulong monitor_flash_len; -/* - * Begin and End of memory area for malloc(), and current "brk" - */ -static ulong mem_malloc_start = 0; -static ulong mem_malloc_end = 0; -static ulong mem_malloc_brk = 0; - /************************************************************************ * Utilities * ************************************************************************ */ -/* - * The Malloc area is immediately below the monitor copy in DRAM - */ -static void mem_malloc_init (void) -{ - ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; - - mem_malloc_end = dest_addr; - mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; - mem_malloc_brk = mem_malloc_start; - - memset ((void *) mem_malloc_start, - 0, - mem_malloc_end - mem_malloc_start); -} - -void *sbrk (ptrdiff_t increment) -{ - ulong old = mem_malloc_brk; - ulong new = old + increment; - - if ((new < mem_malloc_start) || - (new > mem_malloc_end) ) { - return (NULL); - } - mem_malloc_brk = new; - 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 +121,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 +129,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) @@ -207,7 +159,17 @@ static int init_func_ram (void) static int init_func_i2c (void) { puts ("I2C: "); - i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); + i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); + puts ("ready\n"); + return (0); +} +#endif + +#if defined(CONFIG_HARD_SPI) +static int init_func_spi (void) +{ + puts ("SPI: "); + spi_init (); puts ("ready\n"); return (0); } @@ -221,7 +183,7 @@ static int init_func_i2c (void) */ init_fnc_t *init_sequence[] = { - get_clocks, + get_clocks, env_init, init_baudrate, serial_init, @@ -231,11 +193,14 @@ init_fnc_t *init_sequence[] = { checkboard, #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) +#if defined(CONFIG_SYS_DRAM_TEST) testdram, -#endif /* CFG_DRAM_TEST */ +#endif /* CONFIG_SYS_DRAM_TEST */ INIT_FUNC_WATCHDOG_INIT NULL, /* Terminate this list */ }; @@ -268,11 +233,11 @@ 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 */ - gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); + gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); @@ -295,9 +260,9 @@ board_init_f (ulong bootflag) * - monitor code * - board info struct */ - len = (ulong)&_end - CFG_MONITOR_BASE; + len = (ulong)&_end - CONFIG_SYS_MONITOR_BASE; - addr = CFG_SDRAM_BASE + gd->ram_size; + addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; #ifdef CONFIG_LOGBUFFER /* reserve kernel log buffer */ @@ -315,6 +280,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,18 +313,18 @@ 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. */ - addr_sp -= CFG_BOOTPARAMS_LEN; + /* Reserve memory for boot params. */ + addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN; bd->bi_boot_params = addr_sp; debug ("Reserving %dk for boot parameters at: %08lx\n", - CFG_BOOTPARAMS_LEN >> 10, addr_sp); + CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp); /* * Finally, we set up a new (bigger) stack. @@ -370,22 +345,30 @@ board_init_f (ulong bootflag) /* * Save local variables to board info struct */ - bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ + bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */ bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ -#ifdef CFG_INIT_RAM_ADDR - bd->bi_sramstart = CFG_INIT_RAM_ADDR; /* start of SRAM memory */ - bd->bi_sramsize = CFG_INIT_RAM_END; /* size of SRAM memory */ +#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 */ #endif - bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */ + bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */ bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ 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 +#ifdef CONFIG_SYS_EXTBDINFO strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); #endif @@ -401,7 +384,7 @@ board_init_f (ulong bootflag) memcpy (id, (void *)gd, sizeof (gd_t)); - debug ("Start relocate of code from %08x to %08lx\n", CFG_MONITOR_BASE, addr); + debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr); relocate_code (addr_sp, id, addr); /* NOTREACHED - jump_to_ram() does not return */ @@ -419,15 +402,14 @@ board_init_f (ulong bootflag) void board_init_r (gd_t *id, ulong dest_addr) { cmd_tbl_t *cmdtp; - char *s, *e; + char *s; 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 -#ifndef CFG_NO_FLASH +#ifndef CONFIG_SYS_NO_FLASH ulong flash_size; #endif gd = id; /* initialize RAM version of global data */ @@ -443,7 +425,7 @@ void board_init_r (gd_t *id, ulong dest_addr) WATCHDOG_RESET (); - gd->reloc_off = dest_addr - CFG_MONITOR_BASE; + gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; monitor_flash_len = (ulong)&__init_end - dest_addr; @@ -467,7 +449,7 @@ void board_init_r (gd_t *id, ulong dest_addr) addr = (ulong)(cmdtp->usage) + gd->reloc_off; cmdtp->usage = (char *)addr; } -#ifdef CFG_LONGHELP +#ifdef CONFIG_SYS_LONGHELP if (cmdtp->help) { addr = (ulong)(cmdtp->help) + gd->reloc_off; cmdtp->help = (char *)addr; @@ -475,7 +457,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 @@ -498,13 +480,18 @@ void board_init_r (gd_t *id, ulong dest_addr) /* * Setup trap handlers */ - trap_init (CFG_SDRAM_BASE); + trap_init (CONFIG_SYS_SDRAM_BASE); + + /* 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(CFG_NO_FLASH) +#if !defined(CONFIG_SYS_NO_FLASH) puts ("FLASH: "); if ((flash_size = flash_init ()) > 0) { -# ifdef CFG_FLASH_CHECKSUM +# ifdef CONFIG_SYS_FLASH_CHECKSUM print_size (flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' @@ -513,29 +500,29 @@ 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, + (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size) ); } putc ('\n'); -# else /* !CFG_FLASH_CHECKSUM */ +# else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size (flash_size, "\n"); -# endif /* CFG_FLASH_CHECKSUM */ +# endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts (failed); hang (); } - bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ + bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ bd->bi_flashoffset = 0; -#else /* CFG_NO_FLASH */ +#else /* CONFIG_SYS_NO_FLASH */ bd->bi_flashsize = 0; bd->bi_flashstart = 0; bd->bi_flashoffset = 0; -#endif /* !CFG_NO_FLASH */ +#endif /* !CONFIG_SYS_NO_FLASH */ WATCHDOG_RESET (); @@ -544,12 +531,8 @@ void board_init_r (gd_t *id, ulong dest_addr) WATCHDOG_RESET (); - /* initialize malloc() area */ - mem_malloc_init (); - 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 (); @@ -565,44 +548,6 @@ void board_init_r (gd_t *id, ulong dest_addr) * where had to use getenv_r(), which can be pretty slow when * the environment is in EEPROM. */ - s = getenv ("ethaddr"); - for (i = 0; i < 6; ++i) { - bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; - if (s) - s = (*e) ? e + 1 : e; - } -#ifdef CONFIG_HAS_ETH1 - /* handle the 2nd ethernet address */ - - s = getenv ("eth1addr"); - for (i = 0; i < 6; ++i) { - bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; - if (s) - s = (*e) ? e + 1 : e; - } -#endif -#ifdef CONFIG_HAS_ETH2 - /* handle the 3rd ethernet address */ - - s = getenv ("eth2addr"); - for (i = 0; i < 6; ++i) { - bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; - if (s) - s = (*e) ? e + 1 : e; - } -#endif - -#ifdef CONFIG_HAS_ETH3 - /* handle 4th ethernet address */ - s = getenv("eth3addr"); - for (i = 0; i < 6; ++i) { - bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0; - if (s) - s = (*e) ? e + 1 : e; - } -#endif - - /* IP Address */ bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); WATCHDOG_RESET (); @@ -615,8 +560,8 @@ void board_init_r (gd_t *id, ulong dest_addr) #endif /** leave this here (after malloc(), environment and PCI are working) **/ - /* Initialize devices */ - devices_init (); + /* Initialize stdio devices */ + stdio_init (); /* Initialize the jump table for applications */ jumptable_init (); @@ -629,7 +574,7 @@ void board_init_r (gd_t *id, ulong dest_addr) misc_init_r (); #endif -#if (CONFIG_COMMANDS & CFG_CMD_KGDB) +#if defined(CONFIG_CMD_KGDB) WATCHDOG_RESET (); puts ("KGDB: "); kgdb_init (); @@ -665,27 +610,27 @@ void board_init_r (gd_t *id, ulong dest_addr) if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); } -#if (CONFIG_COMMANDS & CFG_CMD_NET) +#if defined(CONFIG_CMD_NET) if ((s = getenv ("bootfile")) != NULL) { copy_filename (BootFile, s, sizeof (BootFile)); } -#endif /* CFG_CMD_NET */ +#endif WATCHDOG_RESET (); -#if (CONFIG_COMMANDS & CFG_CMD_DOC) +#if defined(CONFIG_CMD_DOC) WATCHDOG_RESET (); puts ("DOC: "); doc_init (); #endif -#if (CONFIG_COMMANDS & CFG_CMD_NAND) +#if defined(CONFIG_CMD_NAND) WATCHDOG_RESET (); puts ("NAND: "); nand_init(); /* go init the NAND */ #endif -#if (CONFIG_COMMANDS & CFG_CMD_NET) +#if defined(CONFIG_CMD_NET) WATCHDOG_RESET(); #if defined(FEC_ENET) eth_init(bd); @@ -700,17 +645,18 @@ void board_init_r (gd_t *id, ulong dest_addr) post_run (NULL, POST_RAM | post_bootmode_get(0)); #endif -#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE) +#if defined(CONFIG_CMD_PCMCIA) \ + && !defined(CONFIG_CMD_IDE) WATCHDOG_RESET (); puts ("PCMCIA:"); pcmcia_init (); #endif -#if (CONFIG_COMMANDS & CFG_CMD_IDE) +#if defined(CONFIG_CMD_IDE) WATCHDOG_RESET (); puts ("IDE: "); ide_init (); -#endif /* CFG_CMD_IDE */ +#endif #ifdef CONFIG_LAST_STAGE_INIT WATCHDOG_RESET (); @@ -722,7 +668,7 @@ void board_init_r (gd_t *id, ulong dest_addr) last_stage_init (); #endif -#if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) +#if defined(CONFIG_CMD_BEDBUG) WATCHDOG_RESET (); bedbug_init (); #endif @@ -734,7 +680,7 @@ void board_init_r (gd_t *id, ulong dest_addr) */ { ulong pram; - uchar memsz[32]; + char memsz[32]; #ifdef CONFIG_PRAM char *s;