/*
 * (C) Copyright 2008-2011
 * Graeme Russ, <graeme.russ@gmail.com>
 *
 * (C) Copyright 2002
 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
 *
 * (C) Copyright 2002
 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
 *
 * (C) Copyright 2002
 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 * Marius Groeger <mgroeger@sysgo.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 <stdio_dev.h>
#include <asm/u-boot-x86.h>
#include <asm/relocate.h>

#include <asm/init_helpers.h>
#include <asm/init_wrappers.h>

/*
 * Breath some life into the board...
 *
 * Getting the board up and running is a three-stage process:
 *  1) Execute from Flash, SDRAM Uninitialised
 *     At this point, there is a limited amount of non-SDRAM memory
 *     (typically the CPU cache, but can also be SRAM or even a buffer of
 *     of some peripheral). This limited memory is used to hold:
 *      - The initial copy of the Global Data Structure
 *      - A temporary stack
 *      - A temporary x86 Global Descriptor Table
 *      - The pre-console buffer (if enabled)
 *
 *     The following is performed during this phase of execution:
 *      - Core low-level CPU initialisation
 *      - Console initialisation
 *      - SDRAM initialisation
 *
 *  2) Execute from Flash, SDRAM Initialised
 *     At this point we copy Global Data from the initial non-SDRAM
 *     memory and set up the permanent stack in SDRAM. The CPU cache is no
 *     longer being used as temporary memory, so we can now fully enable
 *     it.
 *
 *     The following is performed during this phase of execution:
 *      - Create final stack in SDRAM
 *      - Copy Global Data from temporary memory to SDRAM
 *      - Enabling of CPU cache(s),
 *      - Copying of U-Boot code and data from Flash to RAM
 *      - Clearing of the BSS
 *      - ELF relocation adjustments
 *
 *  3) Execute from SDRAM
 *     The following is performed during this phase of execution:
 *      - All remaining initialisation
 */

/*
 * The requirements for any new initalization function is simple: it is
 * a function with no parameters which returns an integer return code,
 * where 0 means "continue" and != 0 means "fatal error, hang the system"
 */
typedef int (init_fnc_t) (void);

/*
 * init_sequence_f is the list of init functions which are run when U-Boot
 * is executing from Flash with a limited 'C' environment. The following
 * limitations must be considered when implementing an '_f' function:
 *  - 'static' variables are read-only
 *  - Global Data (gd->xxx) is read/write
 *  - Stack space is limited
 *
 * The '_f' sequence must, as a minimum, initialise SDRAM. It _should_
 * also initialise the console (to provide early debug output)
 */
init_fnc_t *init_sequence_f[] = {
	cpu_init_f,
	board_early_init_f,
	env_init,
	init_baudrate_f,
	serial_init,
	console_init_f,
	dram_init_f,
	calculate_relocation_address,

	NULL,
};

/*
 * init_sequence_f_r is the list of init functions which are run when
 * U-Boot is executing from Flash with a semi-limited 'C' environment.
 * The following limitations must be considered when implementing an
 * '_f_r' function:
 *  - 'static' variables are read-only
 *  - Global Data (gd->xxx) is read/write
 *
 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
 * supported).  It _should_, if possible, copy global data to RAM and
 * initialise the CPU caches (to speed up the relocation process)
 */
init_fnc_t *init_sequence_f_r[] = {
	copy_gd_to_ram_f_r,
	init_cache_f_r,
	copy_uboot_to_ram,
	clear_bss,
	do_elf_reloc_fixups,

	NULL,
};

/*
 * init_sequence_r is the list of init functions which are run when U-Boot
 * is executing from RAM with a full 'C' environment. There are no longer
 * any limitations which must be considered when implementing an '_r'
 * function, (i.e.'static' variables are read/write)
 *
 * If not already done, the '_r' sequence must copy global data to RAM and
 * (should) initialise the CPU caches.
 */
init_fnc_t *init_sequence_r[] = {
	set_reloc_flag_r,
	init_bd_struct_r,
	mem_malloc_init_r,
	cpu_init_r,
	board_early_init_r,
	dram_init,
	interrupt_init,
	timer_init,
	display_banner,
	display_dram_config,
#ifdef CONFIG_SERIAL_MULTI
	serial_initialize_r,
#endif
#ifndef CONFIG_SYS_NO_FLASH
	flash_init_r,
#endif
	env_relocate_r,
#ifdef CONFIG_PCI
	pci_init_r,
#endif
	stdio_init,
	jumptable_init_r,
	console_init_r,
#ifdef CONFIG_MISC_INIT_R
	misc_init_r,
#endif
#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
	pci_init_r,
#endif
#if defined(CONFIG_CMD_KGDB)
	kgdb_init_r,
#endif
	enable_interrupts_r,
#ifdef CONFIG_STATUS_LED
	status_led_set_r,
#endif
	set_load_addr_r,
#if defined(CONFIG_CMD_NET)
	set_bootfile_r,
#endif
#if defined(CONFIG_CMD_IDE)
	ide_init_r,
#endif
#if defined(CONFIG_CMD_SCSI)
	scsi_init_r,
#endif
#if defined(CONFIG_CMD_DOC)
	doc_init_r,
#endif
#ifdef CONFIG_BITBANGMII
	bb_miiphy_init_r,
#endif
#if defined(CONFIG_CMD_NET)
	eth_initialize_r,
#ifdef CONFIG_RESET_PHY_R
	reset_phy_r,
#endif
#endif
#ifdef CONFIG_LAST_STAGE_INIT
	last_stage_init,
#endif
	NULL,
};

static void do_init_loop(init_fnc_t **init_fnc_ptr)
{
	for (; *init_fnc_ptr; ++init_fnc_ptr) {
		WATCHDOG_RESET();
		if ((*init_fnc_ptr)() != 0)
			hang();
	}
}

void board_init_f(ulong boot_flags)
{
	gd->flags = boot_flags;

	do_init_loop(init_sequence_f);

	/*
	 * SDRAM and console are now initialised. The final stack can now
	 * be setup in SDRAM. Code execution will continue in Flash, but
	 * with the stack in SDRAM and Global Data in temporary memory
	 * (CPU cache)
	 */
	board_init_f_r_trampoline(gd->start_addr_sp);

	/* NOTREACHED - board_init_f_r_trampoline() does not return */
	while (1)
		;
}

void board_init_f_r(void)
{
	do_init_loop(init_sequence_f_r);

	/*
	 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
	 * Transfer execution from Flash to RAM by calculating the address
	 * of the in-RAM copy of board_init_r() and calling it
	 */
	(board_init_r + gd->reloc_off)(gd, gd->relocaddr);

	/* NOTREACHED - board_init_r() does not return */
	while (1)
		;
}

void board_init_r(gd_t *id, ulong dest_addr)
{
	do_init_loop(init_sequence_r);

	/* main_loop() can return to retry autoboot, if so just run it again. */
	for (;;)
		main_loop();

	/* NOTREACHED - no way out of command loop except booting */
}

void hang(void)
{
	puts("### ERROR ### Please RESET the board ###\n");
	for (;;)
		;
}
