/* Board initialization shamelessly stolen from Ashling PathFinder
   configuration */

#include <config.h>
#include <version.h>
#include <asm/regdef.h>
#include <asm/mipsregs.h>

	.text
	.set noreorder
	.set mips32

	.globl	lowlevel_init
	.ent lowlevel_init

lowlevel_init:

#ifdef GENERATED_CONFIG
#ifndef STR
#define __STR(x) #x
#define STR(x) __STR(x)
#endif

#include STR(GENERATED_CONFIG.S)

#else

	lui a0, 0xb7e0

#define WRITEREG(value, offset)  li t0, value;  sw t0, offset(a0)

	WRITEREG(0xffffbfff, 0x8004)

/* Skip RAM initialization of already running from RAM, or board may hang */
#if CFG_MONITOR_BASE >= 0xb8000000

#if defined(CONFIG_STB221) || defined(CONFIG_STB220) || defined(CONFIG_STB225)
	WRITEREG(0x1ad1, 0x3004)
#elif defined(CONFIG_STB220t3)
	WRITEREG(0x17, 0x9244)
	WRITEREG(0x1ad2, 0x3004)
#else
#error Board-specific initialization missing for this configuration!
#endif

	WRITEREG(0x5a0, 0x3008)
	WRITEREG(0x0, 0x3038)
	WRITEREG(0x7, 0x300c)
	WRITEREG(0x2, 0x3010)
	WRITEREG(0x4, 0x3014)
	WRITEREG(0x2, 0x3018)
	WRITEREG(0xd, 0x301c)
	WRITEREG(0x1, 0x3020)
	WRITEREG(0x3, 0x3024)
	WRITEREG(0x2, 0x3028)
	WRITEREG(0x3, 0x3ff4)

#endif

#endif
	jr ra
	nop

	.end lowlevel_init
