From ec08ceb0d0ed2e6c2deb5c6d81ebf0087e6fc5f8 Mon Sep 17 00:00:00 2001
From: Aneesh V <aneesh@ti.com>
Date: Thu, 17 Feb 2011 18:23:31 +0530
Subject: [PATCH 10/22] omap4: add spl support for OMAP4 SDP

Adapted from: nand_spl/board/samsung/smdk6400/Makefile

- Add the SPL makefile for OMAP4430 SDP
- Add the necessary CONFIG flags in the board config file

Signed-off-by: Aneesh V <aneesh@ti.com>
---
 board/ti/sdp4430/config.mk      |    3 +-
 include/configs/omap4_sdp4430.h |   19 ++++++
 spl/board/ti/sdp4430/Makefile   |  120 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+), 1 deletions(-)
 create mode 100644 spl/board/ti/sdp4430/Makefile

diff --git a/board/ti/sdp4430/config.mk b/board/ti/sdp4430/config.mk
index 33901a7..c62965d 100644
--- a/board/ti/sdp4430/config.mk
+++ b/board/ti/sdp4430/config.mk
@@ -28,4 +28,5 @@
 # Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
 # (mem base + reserved)
 
-CONFIG_SYS_TEXT_BASE = 0x80e80000
+# 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
+CONFIG_SYS_TEXT_BASE = 0x80100000
diff --git a/include/configs/omap4_sdp4430.h b/include/configs/omap4_sdp4430.h
index 9a8bb73..5b20841 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -122,7 +122,9 @@
 
 /* USB device configuration */
 #define CONFIG_USB_DEVICE		1
+#ifndef CONFIG_PRELOADER
 #define CONFIG_USB_TTY			1
+#endif
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV	1
 
 /* Flash */
@@ -240,4 +242,21 @@
 					 CONFIG_SYS_INIT_RAM_SIZE - \
 					 GENERATED_GBL_DATA_SIZE)
 
+/* Defines for Clock init */
+#define CONFIG_SYS_OMAP4_ABE_SYSCK
+
+/* Defines for SDRAM init */
+#define CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION	1
+#define CONFIG_SYS_EMIF_UPDATE_TIMINGS		1
+#define CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS	1
+
+/* Defines for SPL */
+#define CONFIG_SPL
+#define CONFIG_SYS_SPL_TEXT_BASE	0x40304360
+#define CONFIG_SYS_SPL_MAX_SIZE		0x7800	/* 30 K */
+#define CONFIG_SYS_SPL_STACK		LOW_LEVEL_SRAM_STACK
+
+#define CONFIG_SYS_SPL_BSS_START_ADDR	0x80000000
+#define CONFIG_SYS_SPL_BSS_MAX_SIZE	0x80000		/* 512 KB */
+
 #endif /* __CONFIG_H */
diff --git a/spl/board/ti/sdp4430/Makefile b/spl/board/ti/sdp4430/Makefile
new file mode 100644
index 0000000..dd56a40
--- /dev/null
+++ b/spl/board/ti/sdp4430/Makefile
@@ -0,0 +1,120 @@
+#
+# (C) Copyright 2006-2007
+# Stefan Roese, DENX Software Engineering, sr@denx.de.
+#
+# (C) Copyright 2008
+# Guennadi Liakhovetki, DENX Software Engineering, <lg@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
+#
+splobj	:= $(OBJTREE)/spl/
+include $(TOPDIR)/config.mk
+SOBJS =
+COBJS =
+
+# armv7
+$(obj)start.S:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/start.S $@
+
+$(obj)syslib.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/syslib.c $@
+
+SOBJS	+= start.o
+COBJS	+= syslib.o
+
+# omap-common
+$(obj)timer.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/omap-common/timer.c $@
+
+$(obj)reset.S:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/omap-common/reset.S $@
+
+$(obj)spl-omap.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/spl/board/ti/spl-omap.c $@
+
+SOBJS	+= reset.o
+COBJS	+= timer.o spl-omap.o
+
+$(OBJTREE)/MLO:	$(splobj)u-boot-spl.bin
+	$(OBJTREE)/tools/mkimage -T omapimage \
+		-a $(CONFIG_SYS_SPL_TEXT_BASE) -d $< $@
+
+LDSCRIPT_SOURCE = $(TOPDIR)/spl/board/ti/spl-omap.lds
+
+# omap4
+$(obj)lowlevel_init.S:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/omap4/lowlevel_init.S $@
+
+$(obj)omap4_mux_data.h:
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/omap4/omap4_mux_data.h $@
+
+$(obj)board.c:$(obj)omap4_mux_data.h
+	@rm -f $@
+	@ln -s $(TOPDIR)/arch/arm/cpu/armv7/omap4/board.c $@
+
+SOBJS	+= lowlevel_init.o
+COBJS	+= board.o
+
+# rules
+LDPPFLAGS += -include $(TOPDIR)/include/config.h
+LDSCRIPT = $(splobj)u-boot-spl-generated.lds
+$(LDSCRIPT): $(LDSCRIPT_SOURCE)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+LDFLAGS	= -Bstatic -T $(LDSCRIPT) \
+	$(PLATFORM_LDFLAGS) --gc-sections
+AFLAGS	+= -DCONFIG_PRELOADER -Os -ffixed-r8
+CFLAGS	+= -DCONFIG_PRELOADER -Os -ffixed-r8 -ffunction-sections \
+	-fdata-sections -march=armv7-a -mthumb
+PLATFORM_LIBGCC = -L $(shell dirname `$(CC) $(CFLAGS) \
+		-print-libgcc-file-name`) -lgcc
+
+$(obj)%.o:	$(obj)%.S
+	$(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)%.o:	$(obj)%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+__OBJS	:= $(SOBJS) $(COBJS)
+LNDIR	:= $(OBJTREE)/spl/board/$(BOARDDIR)
+
+$(splobj)u-boot-spl.bin:	$(splobj)u-boot-spl
+	$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(splobj)u-boot-spl:	$(OBJS) $(LDSCRIPT)
+	cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \
+		$(PLATFORM_LIBGCC) \
+		-Map $(splobj)u-boot-spl.map \
+		-o $(splobj)u-boot-spl
+
+ALL	= $(OBJTREE)/MLO
+all:	$(obj).depend $(ALL)
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
-- 
1.7.2.3

