/*
 * (C) Copyright 2010
 * Allied Telesis <www.alliedtelesis.com>
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 */

/* Based on include/configs/rd6281a.h */

#ifndef _CONFIG_SBX81LIFXCAT_H
#define _CONFIG_SBX81LIFXCAT_H

/*
 * Version number information
 */
#define CONFIG_IDENT_STRING	"\nSBx81LIFXCAT"

/*
 * High Level Configuration Options (easy to change)
 */
#define CONFIG_MARVELL		1
#define CONFIG_ARM926EJS	1	/* Basic Architecture */
#define CONFIG_FEROCEON_88FR131	1	/* CPU Core subversion */
#define CONFIG_KIRKWOOD		1	/* SOC Family Name */
#define CONFIG_KW88F6281	1	/* SOC Name */
#define CONFIG_NO_KWB_EXTENED_HEADER 1 /*Don't configure RAM from the kwb image header*/

#define CONFIG_MD5	/* get_random_hex on krikwood needs MD5 support */
#define CONFIG_KIRKWOOD_EGIGA_INIT	/* Enable GbePort0/1 for kernel */
#define CONFIG_KIRKWOOD_PCIE_INIT	/* Enable PCIE Port0 for kernel */
#define CONFIG_KIRKWOOD_RGMII_PAD_1V8	/* Set RGMII Pad voltage to 1.8V */

/*
 * Board level bootloader configuration
 */
#undef CONFIG_SYS_USE_NOR
#undef CONFIG_SYS_USE_NAND
#define CONFIG_SYS_USE_SPI

#if defined(CONFIG_SYS_USE_NOR) || defined(CONFIG_SYS_USE_NAND) || defined(CONFIG_SYS_USE_SPI)

#define CONFIG_SYS_BOOTROM_UBOOT_SIZE	0x000c0000 /* Limit U-Boot to last 0.75MiB of bootrom */
#define CONFIG_UBOOT_SIZE_VARIES

/* When loading U-Boot directly out of BootROM */
#undef CONFIG_SKIP_LOWLEVEL_INIT	/* U-Boot run from ROM, need to do init */
#undef CONFIG_SKIP_RELOCATE_UBOOT	/* and relocate to a proper address */

#else

/* When loading U-Boot from another bootloader */
#define CONFIG_SKIP_LOWLEVEL_INIT	/* U-Boot is loaded by a bootloader */
#define CONFIG_SKIP_RELOCATE_UBOOT	/* to a proper address, init already done */

#endif

#define CONFIG_MISC_INIT_R		/* call misc_init_r */

/*
 * CLKs configurations
 */
#define CONFIG_SYS_HZ		1000

/*
 * NS16550 Configuration
 */
#define CONFIG_SYS_NS16550
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE	(-4)
#define CONFIG_SYS_NS16550_CLK		CONFIG_SYS_TCLK
#define CONFIG_SYS_NS16550_COM1		KW_UART0_BASE

/*
 * Serial Port configuration
 * The following definitions let you select what serial you want to use
 * for your console driver.
 */

#define CONFIG_CONS_INDEX	1	/*Console on UART0 */

/*
 * For booting Linux, the board info and command line data
 * have to be in the first 8 MB of memory, since this is
 * the maximum mapped by the Linux kernel during initialization.
 */
#define CONFIG_CMDLINE_TAG	1	/* enable passing of ATAGs */
#define CONFIG_INITRD_TAG	1	/* enable INITRD tag */
#define CONFIG_SETUP_MEMORY_TAGS 1	/* enable memory tag */

#define	CONFIG_SYS_PROMPT	"=> "	/* Command Prompt */

/*
 * Ensure there is no NOR Flash support
 */
#define CONFIG_SYS_NO_FLASH

/*
 * Commands configuration
 */
#include <config_cmd_default.h>
#define CONFIG_CMD_AUTOSCRIPT
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_ENV
#define CONFIG_CMD_SF
#define CONFIG_CMD_NET
#define CONFIG_CMD_PING

/*
 * Flash configuration
 */
#define CONFIG_SYS_FLASH_SECT_SIZE	0x40000		/* 256K */
#define CONFIG_SPI_FLASH		1
#define CONFIG_SPI_FLASH_ADDR		0xe8000000	/* VA */
#define CONFIG_KIRKWOOD_SPI		1
#define CONFIG_SPI_FLASH_STMICRO	1
#define CONFIG_ENV_SPI_BUS		0
#define CONFIG_ENV_SPI_CS		0
#define CONFIG_ENV_SPI_MAX_HZ		20000000	/* 20Mhz */

#define DIAG_USER_FLASH_OFFSET		0x00100000
#define DIAG_USER_FLASH_SIZE		0x00f00000	/* 15MiB (Includes errlog) */
#define MTDPARTS_DEFAULT "mtdparts=spi0.0:768K(boot)ro,256K(boot-env),14M(user),1M(errlog)"
#define MTDPARTS_MTDOOPS "errlog"
#define CONFIG_MMC_SPI
#define CONFIG_DOS_PARTITION
#define CONFIG_MMC_MAX_FREQ		400000	/* 400Khz */
#define CONFIG_USE_MPI_BOARD_SD

/*
 *  Environment variables configurations
 */
#define CONFIG_ENV_IS_IN_SPI_FLASH	1
#define CONFIG_ENV_SECT_SIZE		0x40000		/* 256K */
#define CONFIG_ENV_SIZE			0x02000
#define CONFIG_ENV_OFFSET		0xc0000		/* env starts here - 768K */
#define CONFIG_ENV_ADDR			(CONFIG_SPI_FLASH_ADDR + CONFIG_ENV_OFFSET)

/*
 * U-Boot bootcode configuration
 */
#define CONFIG_UBOOT_ROM_BASE		CONFIG_SPI_FLASH_ADDR	/* Used only by the AW+ upgrader/installer */
#define CONFIG_UBOOT_FLASH_BASE		0
#define CONFIG_UBOOT_SIZE		0x000c0000	/* 768KiB - Used only by the AW+ upgrader/installer & diagnostics */

/* size in bytes reserved for initial data */
#define CONFIG_SYS_GBL_DATA_SIZE	128

/*
 * Other required minimal configurations
 */
#define CONFIG_CONSOLE_INFO_QUIET	/* some code reduction */
#define CONFIG_ARCH_CPU_INIT	/* call arch_cpu_init() */
#define CONFIG_ARCH_MISC_INIT	/* call arch_misc_init() */
#define CONFIG_DISPLAY_CPUINFO	/* Display cpu info */
#define CONFIG_NR_DRAM_BANKS	4
#define CONFIG_STACKSIZE	0x00100000	/* regular stack- 1M */
#define CONFIG_SYS_MEMTEST_START 0x00400000	/* 4M */
#define CONFIG_SYS_MEMTEST_END	0x007fffff	/*(_8M -1) */
#define CONFIG_SYS_RESET_ADDRESS 0xffff0000	/* Rst Vector Adr */

/*
 * Ethernet Driver configuration
 */
#ifdef CONFIG_CMD_NET
#define CONFIG_NETCONSOLE	/* include NetConsole support */
#define CONFIG_NET_MULTI	/* specify more that one ports available */
#define CONFIG_MII		/* expose smi ove miiphy interface */
#define CONFIG_KIRKWOOD_EGIGA	/* Enable kirkwood Gbe Controller Driver */
#define CONFIG_KIRKWOOD_EGIGA_PORTS	{1,0}	/* enable a single port */
#define CONFIG_DIS_AUTO_NEG_SPEED_GMII /*Disable Auto speed negociation */
#define CONFIG_PHY_SPEED	_100BASET	/*Force PHYspeed to 100MBPs */
#define CONFIG_PHY_BASE_ADR	0x01
#define CONFIG_ENV_OVERWRITE	/* ethaddr can be reprogrammed */
#define CONFIG_RESET_PHY_R	/* use reset_phy() to init switch */
#define CONFIG_MV88E60XX_SWITCH	/* Enable MV88E60XX switch driver */
#define CONFIG_MV88E60XX_MULTICHIP_ADRMODE
#endif /* CONFIG_CMD_NET */

/*
 * I2C related stuff
 */
#define CONFIG_HARD_I2C			/* I2C with hardware support */
#undef CONFIG_SOFT_I2C			/* I2C bit-banged       */
#define CONFIG_CMD_I2C

#if defined(CONFIG_HARD_I2C)
#define CONFIG_I2C_KIRKWOOD
#define CONFIG_I2C_KW_REG_BASE		KW_TWSI_BASE
#define CONFIG_SYS_I2C_SLAVE		0x0
#define CONFIG_SYS_I2C_SPEED		100000
#endif

#define CONFIG_MPI_GPIO			0x74
#define CONFIG_PCA953X			/* PCA953x GPIO driver */
#define CONFIG_SYS_I2C_PCA953X_WIDTH	{{0x76, 16}, {CONFIG_MPI_GPIO, 16}}
#define CONFIG_CMD_PCA953X
#define CONFIG_CMD_PCA953X_INFO


/*********************************************************************
 * ATL specific extensions
 *********************************************************************/

#define CONFIG_THIS_DEVICE		3
#define CONFIG_RELEASE_SPECIAL		1
#define CONFIG_COMPATIBLE_DEVICES	\
{					\
	{ 317, "AT-SBx81GP24" },	\
	{ 351, "AT-SBx81GT24" },	\
	{ 0, NULL }			\
}

#define CONFIG_BOOTMENU
#define CONFIG_DIAGNOSTICS
#define CONFIG_DIAG_SPI_FLASH
#define CONFIG_DIAG_RAM_START 0
#define CONFIG_DIAG_RAM_SKIP_SIZE 0x00800000 /* skip first 8MB for code */
#define CONFIG_DIAG_IDPROM
#define CONFIG_IDPROM_LOCAL_ADDR	0x52
#define CONFIG_IDPROM_BACKPLANE_ADDR	0x50

#define CONFIG_DIAGMEM_BASE		0x01000000

/* Use BOOTP to TFTP the running release off the controller card, if the boot
 * fails reset the board
 */
#define CONFIG_BOOTCMD_ENV_SETTING	"bootp; sntp; awbootm $fileaddr; reset"

#include <configs/atl-std-opts.h>
#undef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 115200
/* TODO: enable these in future images */
#undef CONFIG_CMD_PCI

/* Time settings */
#define CONFIG_BOOTP_NTPSERVER
#define CONFIG_CMD_SNTP

/* This board does not have a DS1302 RTC */
#undef CONFIG_RTC_DS1302_ATL

#endif /* _CONFIG_SBX81LIFXCAT_H */
