Skip to content
Snippets Groups Projects
board.c 25.3 KiB
Newer Older
Wolfgang Denk's avatar
Wolfgang Denk committed
/*
 * (C) Copyright 2000-2010
Wolfgang Denk's avatar
Wolfgang Denk committed
 * 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
 */

#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <malloc.h>
Wolfgang Denk's avatar
Wolfgang Denk committed
#ifdef CONFIG_8xx
#include <mpc8xx.h>
#endif
#ifdef CONFIG_5xx
#include <mpc5xx.h>
#endif
#ifdef CONFIG_MPC5xxx
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <ide.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <scsi.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <kgdb.h>
#endif
#ifdef CONFIG_STATUS_LED
#include <status_led.h>
#endif
#include <net.h>
Andy Fleming's avatar
Andy Fleming committed
#ifdef CONFIG_GENERIC_MMC
#include <mmc.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <serial.h>
#ifdef CONFIG_SYS_ALLOC_DPRAM
#if !defined(CONFIG_CPM2)
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <commproc.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <version.h>
#if defined(CONFIG_BAB7xx)
#include <w83c553f.h>
#endif
#include <dtt.h>
#if defined(CONFIG_POST)
#include <post.h>
#endif
#if defined(CONFIG_LOGBUFFER)
#include <logbuff.h>
#endif
#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
#include <asm/cache.h>
#endif
#ifdef CONFIG_PS2KBD
#include <keyboard.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed

#ifdef CONFIG_ADDR_MAP
#include <asm/mmu.h>
#endif

#ifdef CONFIG_MP
#include <asm/mp.h>
#endif

#ifdef CONFIG_BITBANGMII
#include <miiphy.h>
#endif

#ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
extern int update_flash_size (int flash_size);
#endif

extern void sc3_read_eeprom(void);
#endif

Wolfgang Denk's avatar
Wolfgang Denk committed
void doc_init (void);
#endif
#if defined(CONFIG_HARD_I2C) || \
    defined(CONFIG_SOFT_I2C)
#include <i2c.h>
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed

static char *failed = "*** failed ***\n";

#if defined(CONFIG_OXC) || defined(CONFIG_RMU)
Wolfgang Denk's avatar
Wolfgang Denk committed
extern flash_info_t flash_info[];
Wolfgang Denk's avatar
Wolfgang Denk committed
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed

#if defined(CONFIG_START_IDE)
extern int board_start_ide(void);
#endif
Wolfgang Denk's avatar
Wolfgang Denk committed
#include <environment.h>
Wolfgang Denk's avatar
Wolfgang Denk committed

#if !defined(CONFIG_SYS_MEM_TOP_HIDE)
#define CONFIG_SYS_MEM_TOP_HIDE	0
extern ulong __init_end;
extern ulong _end;
ulong monitor_flash_len;

Wolfgang Denk's avatar
Wolfgang Denk committed
#include <bedbug/type.h>
#endif

Wolfgang Denk's avatar
Wolfgang Denk committed
/************************************************************************
 * Utilities								*
 ************************************************************************
 */

/*
 * All attempts to come up with a "common" initialization sequence
 * that works for all boards and architectures failed: some of the
 * requirements are just _too_ different. To get rid of the resulting
 * mess of board dependend #ifdef'ed code we now make the whole
 * initialization sequence configurable to the user.
 *
 * The requirements for any new initalization function is simple: it
 * receives a pointer to the "global data" structure as it's only
 * argument, and returns an integer return code, where 0 means
 * "continue" and != 0 means "fatal error, hang the system".
 */
typedef int (init_fnc_t) (void);

/************************************************************************
 * Init Utilities							*
 ************************************************************************
 * Some of this code should be moved into the core functions,
 * but let's get it working (again) first...
 */

static int init_baudrate (void)
{
Wolfgang Denk's avatar
Wolfgang Denk committed
	char tmp[64];	/* long enough for environment variables */
	int i = getenv_f("baudrate", tmp, sizeof (tmp));
Wolfgang Denk's avatar
Wolfgang Denk committed

	gd->baudrate = (i > 0)
			? (int) simple_strtoul (tmp, NULL, 10)
			: CONFIG_BAUDRATE;
	return (0);
}

/***********************************************************************/

void __board_add_ram_info(int use_default)
{
	/* please define platform specific board_add_ram_info() */
}
void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info")));

Wolfgang Denk's avatar
Wolfgang Denk committed
static int init_func_ram (void)
{
#ifdef	CONFIG_BOARD_TYPES
	int board_type = gd->board_type;
#else
	int board_type = 0;	/* use dummy arg */
#endif
	puts ("DRAM:  ");

	if ((gd->ram_size = initdram (board_type)) > 0) {
		print_size (gd->ram_size, "");
		board_add_ram_info(0);
		putc('\n');
Wolfgang Denk's avatar
Wolfgang Denk committed
		return (0);
	}
	puts (failed);
	return (1);
}

/***********************************************************************/

#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
Loading
Loading full blame...