ColdFire: Add Freescale MCF54418TWR ColdFire development board support

Add Freescale MCF54418TWR ColdFire development board support.

Signed-off-by: TsiChung Liew <tsicliew@gmail.com>
Signed-off-by: Jason Jin <Jason.jin@freescale.com>
Signed-off-by: Alison Wang <b18965@freescale.com>
diff --git a/board/freescale/m54418twr/Makefile b/board/freescale/m54418twr/Makefile
new file mode 100644
index 0000000..1e53f48
--- /dev/null
+++ b/board/freescale/m54418twr/Makefile
@@ -0,0 +1,43 @@
+# Copyright 2010-2012 Freescale Semiconductor, Inc.
+# TsiChung Liew (Tsi-Chung.Liew@freescale.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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	= $(BOARD).o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/freescale/m54418twr/config.mk b/board/freescale/m54418twr/config.mk
new file mode 100644
index 0000000..a592335
--- /dev/null
+++ b/board/freescale/m54418twr/config.mk
@@ -0,0 +1,25 @@
+# Copyright 2010-2012 Freescale Semiconductor, Inc.
+# TsiChung Liew (Tsi-Chung.Liew@freescale.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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
+
+PLATFORM_CPPFLAGS += -DTEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
diff --git a/board/freescale/m54418twr/m54418twr.c b/board/freescale/m54418twr/m54418twr.c
new file mode 100644
index 0000000..6e57bef
--- /dev/null
+++ b/board/freescale/m54418twr/m54418twr.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2010-2012 Freescale Semiconductor, Inc.
+ * TsiChung Liew (Tsi-Chung.Liew@freescale.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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <spi.h>
+#include <asm/io.h>
+#include <asm/immap.h>
+#include <mmc.h>
+#include <fsl_esdhc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int checkboard(void)
+{
+	/*
+	 * need to to:
+	 * Check serial flash size. if 2mb evb, else 8mb demo
+	 */
+	puts("Board: ");
+	puts("Freescale MCF54418 Tower System\n");
+	return 0;
+};
+
+phys_size_t initdram(int board_type)
+{
+	u32 dramsize;
+
+#if defined(CONFIG_SERIAL_BOOT)
+	/*
+	 * Serial Boot: The dram is already initialized in start.S
+	 * only require to return DRAM size
+	 */
+	dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
+#else
+	sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
+	ccm_t *ccm = (ccm_t *)MMAP_CCM;
+	gpio_t *gpio = (gpio_t *) MMAP_GPIO;
+	pm_t *pm = (pm_t *) MMAP_PM;
+	u32 i;
+
+	dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
+
+	for (i = 0x13; i < 0x20; i++) {
+		if (dramsize == (1 << i))
+			break;
+	}
+
+	out_8(&pm->pmcr0, 0x2E);
+	out_8(&gpio->mscr_sdram, 1);
+
+	clrbits_be16(&ccm->misccr2, CCM_MISCCR2_FBHALF);
+	setbits_be16(&ccm->misccr2, CCM_MISCCR2_DDR2CLK);
+
+	out_be32(&sdram->rcrcr, 0x40000000);
+	out_be32(&sdram->padcr, 0x01030203);
+
+	out_be32(&sdram->cr00, 0x01010101);
+	out_be32(&sdram->cr01, 0x00000101);
+	out_be32(&sdram->cr02, 0x01010100);
+	out_be32(&sdram->cr03, 0x01010000);
+	out_be32(&sdram->cr04, 0x00010101);
+	out_be32(&sdram->cr06, 0x00010100);
+	out_be32(&sdram->cr07, 0x00000001);
+	out_be32(&sdram->cr08, 0x01000001);
+	out_be32(&sdram->cr09, 0x00000100);
+	out_be32(&sdram->cr10, 0x00010001);
+	out_be32(&sdram->cr11, 0x00000200);
+	out_be32(&sdram->cr12, 0x01000002);
+	out_be32(&sdram->cr13, 0x00000000);
+	out_be32(&sdram->cr14, 0x00000100);
+	out_be32(&sdram->cr15, 0x02000100);
+	out_be32(&sdram->cr16, 0x02000407);
+	out_be32(&sdram->cr17, 0x02030007);
+	out_be32(&sdram->cr18, 0x02000100);
+	out_be32(&sdram->cr19, 0x0A030203);
+	out_be32(&sdram->cr20, 0x00020708);
+	out_be32(&sdram->cr21, 0x00050008);
+	out_be32(&sdram->cr22, 0x04030002);
+	out_be32(&sdram->cr23, 0x00000004);
+	out_be32(&sdram->cr24, 0x020A0000);
+	out_be32(&sdram->cr25, 0x0C00000E);
+	out_be32(&sdram->cr26, 0x00002004);
+	out_be32(&sdram->cr28, 0x00100010);
+	out_be32(&sdram->cr29, 0x00100010);
+	out_be32(&sdram->cr31, 0x07990000);
+	out_be32(&sdram->cr40, 0x00000000);
+	out_be32(&sdram->cr41, 0x00C80064);
+	out_be32(&sdram->cr42, 0x44520002);
+	out_be32(&sdram->cr43, 0x00C80023);
+	out_be32(&sdram->cr45, 0x0000C350);
+	out_be32(&sdram->cr56, 0x04000000);
+	out_be32(&sdram->cr57, 0x03000304);
+	out_be32(&sdram->cr58, 0x40040000);
+	out_be32(&sdram->cr59, 0xC0004004);
+	out_be32(&sdram->cr60, 0x0642C000);
+	out_be32(&sdram->cr61, 0x00000642);
+	asm("tpf");
+
+	out_be32(&sdram->cr09, 0x01000100);
+
+	udelay(100);
+#endif
+	return dramsize;
+};
+
+int testdram(void)
+{
+	return 0;
+}
diff --git a/board/freescale/m54418twr/u-boot.lds b/board/freescale/m54418twr/u-boot.lds
new file mode 100644
index 0000000..f341449
--- /dev/null
+++ b/board/freescale/m54418twr/u-boot.lds
@@ -0,0 +1,97 @@
+/*
+ * (C) Copyright 2000
+ * 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
+ */
+
+OUTPUT_ARCH(m68k)
+
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  .text      :
+  {
+    arch/m68k/cpu/mcf5445x/start.o		(.text*)
+
+    *(.text*)
+  }
+  _etext = .;
+  PROVIDE (etext = .);
+  .rodata    :
+  {
+    *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+  }
+
+  /* Read-write section, merged into data segment: */
+  . = (. + 0x00FF) & 0xFFFFFF00;
+  _erotext = .;
+  PROVIDE (erotext = .);
+
+  .reloc   :
+  {
+    __got_start = .;
+    KEEP(*(.got))
+    __got_end = .;
+    _GOT2_TABLE_ = .;
+    KEEP(*(.got2))
+    _FIXUP_TABLE_ = .;
+    KEEP(*(.fixup))
+  }
+  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+  .data    :
+  {
+    *(.data*)
+    *(.sdata*)
+  }
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  . = .;
+  __u_boot_cmd_start = .;
+  .u_boot_cmd : { *(.u_boot_cmd) }
+  __u_boot_cmd_end = .;
+
+  . = .;
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  . = ALIGN(256);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(256);
+  __init_end = .;
+
+  __bss_start = .;
+  .bss  (NOLOAD)     :
+  {
+   _sbss = .;
+   *(.bss*)
+   *(.sbss*)
+   *(COMMON)
+   . = ALIGN(4);
+   _ebss = .;
+  }
+  __bss_end__ = . ;
+  PROVIDE (end = .);
+}