[U-Boot] [RFC 5/5] MX31: Add NAND SPL boot support to i.MX31 PDK board.

Magnus Lilja lilja.magnus at gmail.com
Fri Apr 3 23:28:04 CEST 2009


---
 MAKEALL                                     |    3 +-
 Makefile                                    |    7 ++
 board/freescale/mx31pdk/config.mk           |    4 +
 board/freescale/mx31pdk/lowlevel_init.S     |   93 +++++++++++++++++++++++++++
 board/freescale/mx31pdk/u-boot-nand.lds     |   33 ++++++++++
 include/configs/mx31pdk.h                   |   19 +++++-
 nand_spl/board/freescale/mx31pdk/.gitignore |    8 ++
 nand_spl/board/freescale/mx31pdk/Makefile   |   66 +++++++++++++++++++
 nand_spl/board/freescale/mx31pdk/config.mk  |    5 ++
 nand_spl/board/freescale/mx31pdk/u-boot.lds |   36 ++++++++++
 10 files changed, 270 insertions(+), 4 deletions(-)
 create mode 100644 board/freescale/mx31pdk/u-boot-nand.lds
 create mode 100644 nand_spl/board/freescale/mx31pdk/.gitignore
 create mode 100644 nand_spl/board/freescale/mx31pdk/Makefile
 create mode 100644 nand_spl/board/freescale/mx31pdk/config.mk
 create mode 100644 nand_spl/board/freescale/mx31pdk/u-boot.lds

diff --git a/MAKEALL b/MAKEALL
index b581608..2f55060 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -549,7 +549,8 @@ LIST_ARM11="			\
 	imx31_phycore_eet	\
  	imx31_phycore_nand	\
 	mx31ads			\
- 	mx31pdk			\
+	mx31pdk			\
+	mx31pdk_nand		\
 	qong			\
 	smdk6400		\
 "
diff --git a/Makefile b/Makefile
index 40f3465..9706cb2 100644
--- a/Makefile
+++ b/Makefile
@@ -3084,6 +3084,13 @@ mx31ads_config		: unconfig
 mx31pdk_config		: unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm1136 mx31pdk freescale mx31
 
+mx31pdk_nand_config	: unconfig
+	@mkdir -p $(obj)include $(obj)board/mx31pdk
+	@mkdir -p $(obj)nand_spl/board/mx31pdk
+	@echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h
+	@$(MKCONFIG) -n $@ -a mx31pdk arm arm1136 mx31pdk freescale mx31
+	@echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk
+
 omap2420h4_config	: unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm1136 omap2420h4 NULL omap24xx
 
diff --git a/board/freescale/mx31pdk/config.mk b/board/freescale/mx31pdk/config.mk
index d34dc02..dcaa09f 100644
--- a/board/freescale/mx31pdk/config.mk
+++ b/board/freescale/mx31pdk/config.mk
@@ -1 +1,5 @@
+ifdef CONFIG_NAND_SPL
+TEXT_BASE = 0x87ec0000
+else
 TEXT_BASE = 0x87f00000
+endif
diff --git a/board/freescale/mx31pdk/lowlevel_init.S b/board/freescale/mx31pdk/lowlevel_init.S
index ec5eedb..602eb53 100644
--- a/board/freescale/mx31pdk/lowlevel_init.S
+++ b/board/freescale/mx31pdk/lowlevel_init.S
@@ -26,5 +26,98 @@
 
 .globl lowlevel_init
 
+#ifdef CONFIG_NAND_SPL
+#include <asm/arch/mx31-regs.h>
+
+.macro REG reg, val
+	ldr	r2, =\reg
+	ldr	r3, =\val
+	str	r3, [r2]
+.endm
+
+.macro REG8 reg, val
+	ldr	r2, =\reg
+	ldr	r3, =\val
+	strb	r3, [r2]
+.endm
+
+.macro DELAY loops
+	ldr	r2, =\loops
+1:
+	subs	r2, r2, #1
+	nop
+	bcs	1b
+.endm
+
+.globl lowlevel_init
+lowlevel_init:
+	/* Also setup the Peripheral Port Remap register inside the core */
+	ldr	r0, =ARM_PPMRR      /* start from AIPS 2GB region */
+	mcr	p15, 0, r0, c15, c2, 4
+
+	REG	IPU_CONF, IPU_CONF_DI_EN
+	REG	CCM_CCMR, 0x074B0BF5
+
+	DELAY	0x40000
+
+	REG	CCM_CCMR, 0x074B0BF5 | CCMR_MPE
+	REG	CCM_CCMR, (0x074B0BF5 | CCMR_MPE) & ~CCMR_MDS
+
+	/* Set up clock to 532MHz */
+	REG	CCM_PDR0, 0xFF871D58
+	REG	CCM_MPCTL, 0x0033280C
+
+	REG	CCM_SPCTL, PLL_PD(1) | PLL_MFD(4) | PLL_MFI(12) | PLL_MFN(1)
+
+	/* Set up CPLD on CS5 */
+	REG	CSCR_U(5), 0x0000D843
+	REG	CSCR_L(5), 0x22252521
+	REG	CSCR_A(5), 0x22220A00
+
+	/* Set up MX31 DDR Memory Controller */
+	REG	0x43FAC26C, 0 /* SDCLK */
+	REG	0x43FAC270, 0 /* CAS */
+	REG	0x43FAC274, 0 /* RAS */
+	REG	0x43FAC27C, 0x1000 /* CS2       CSD0) */
+	REG	0x43FAC284, 0 /* DQM3 */
+	REG	0x43FAC288, 0 /* DQM2, DQM1, DQM0, SD31-SD0, A25-A0, MA10       0x288..0x2DC) */
+	REG	0x43FAC28C, 0
+	REG	0x43FAC290, 0
+	REG	0x43FAC294, 0
+	REG	0x43FAC298, 0
+	REG	0x43FAC29C, 0
+	REG	0x43FAC2A0, 0
+	REG	0x43FAC2A4, 0
+	REG	0x43FAC2A8, 0
+	REG	0x43FAC2AC, 0
+	REG	0x43FAC2B0, 0
+	REG	0x43FAC2B4, 0
+	REG	0x43FAC2B8, 0
+	REG	0x43FAC2BC, 0
+	REG	0x43FAC2C0, 0
+	REG	0x43FAC2C4, 0
+	REG	0x43FAC2C8, 0
+	REG	0x43FAC2CC, 0
+	REG	0x43FAC2D0, 0
+	REG	0x43FAC2D4, 0
+	REG	0x43FAC2D8, 0
+	REG	0x43FAC2DC, 0
+	REG	0xB8001010, 0x00000004
+	REG	0xB8001004, 0x006ac73a
+	REG	0xB8001000, 0x92100000
+	REG	0x80000f00, 0x12344321
+	REG	0xB8001000, 0xa2100000
+	REG	0x80000000, 0x12344321
+	REG	0x80000000, 0x12344321
+	REG	0xB8001000, 0xb2100000
+	REG8	0x80000033, 0xda
+	REG8	0x81000000, 0xff
+	REG	0xB8001000, 0x82226080
+	REG	0x80000000, 0xDEADBEEF
+	REG	0xB8001010, 0x0000000c
+
+	mov	pc, lr
+#else
 lowlevel_init:
 	mov	pc, lr
+#endif
diff --git a/board/freescale/mx31pdk/u-boot-nand.lds b/board/freescale/mx31pdk/u-boot-nand.lds
new file mode 100644
index 0000000..b604480
--- /dev/null
+++ b/board/freescale/mx31pdk/u-boot-nand.lds
@@ -0,0 +1,33 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	. = ALIGN(4);
+	.text	   :
+	{
+	  cpu/arm1136/start.o	(.text)
+	  *(.text)
+	}
+
+	. = ALIGN(4);
+	.rodata : { *(.rodata) }
+
+	. = ALIGN(4);
+	.data : { *(.data) }
+
+	. = ALIGN(4);
+	.got : { *(.got) }
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss : { *(.bss) }
+	_end = .;
+}
diff --git a/include/configs/mx31pdk.h b/include/configs/mx31pdk.h
index deda70d..29b1574 100644
--- a/include/configs/mx31pdk.h
+++ b/include/configs/mx31pdk.h
@@ -45,10 +45,10 @@
 #define CONFIG_SETUP_MEMORY_TAGS	1
 #define CONFIG_INITRD_TAG		1
 
-/* No support for NAND boot for i.MX31 PDK yet, so we rely on some other
- * program to initialize the SDRAM.
- */
+#if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
 #define CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SKIP_RELOCATE_UBOOT
+#endif
 
 /*
  * Size of malloc() pool
@@ -158,5 +158,18 @@
 
 #define CONFIG_ENV_SIZE		(128 * 1024)
 
+#define CFG_NAND_U_BOOT_OFFS	0x800
+#define CFG_NAND_U_BOOT_SIZE	0x30000
+#define CFG_NAND_U_BOOT_DST	0x87f00000 /* Load U-Boot to this address */
+#define CFG_NAND_U_BOOT_START	CFG_NAND_U_BOOT_DST
+#define CFG_NAND_SPL_DST	(CFG_NAND_U_BOOT_DST-0x40000)
+
+#define CFG_NAND_PAGE_SIZE	0x800
+#define CFG_NAND_BLOCK_SIZE	(128 * 1024)
+#define CFG_NAND_PAGE_COUNT	64
+/* for NAND_SPL */
+#define CFG_NAND_CHIP_SIZE	(256 * 1024 * 1024)
+#define CFG_NAND_PAGES_PER_BLOCK CFG_NAND_PAGE_COUNT
+
 #endif /* __CONFIG_H */
 
diff --git a/nand_spl/board/freescale/mx31pdk/.gitignore b/nand_spl/board/freescale/mx31pdk/.gitignore
new file mode 100644
index 0000000..f3c743e
--- /dev/null
+++ b/nand_spl/board/freescale/mx31pdk/.gitignore
@@ -0,0 +1,8 @@
+#
+# Linked files.
+#
+
+/lowlevel_init.S
+/nand_boot_mx31.c
+/start.S
+
diff --git a/nand_spl/board/freescale/mx31pdk/Makefile b/nand_spl/board/freescale/mx31pdk/Makefile
new file mode 100644
index 0000000..f3ef669
--- /dev/null
+++ b/nand_spl/board/freescale/mx31pdk/Makefile
@@ -0,0 +1,66 @@
+CONFIG_NAND_SPL	= y
+
+include $(TOPDIR)/config.mk
+include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
+
+LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
+LDFLAGS	= -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
+AFLAGS	+= -DCONFIG_NAND_SPL
+CFLAGS	+= -DCONFIG_NAND_SPL
+
+SOBJS	= start.o lowlevel_init.o 
+COBJS	= nand_boot_mx31.o 
+
+SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+__OBJS	:= $(SOBJS) $(COBJS)
+LNDIR	:= $(OBJTREE)/nand_spl/board/$(BOARDDIR)
+
+nandobj	:= $(OBJTREE)/nand_spl/
+
+ALL	= $(nandobj)u-boot-spl $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-aligned.bin
+
+all:	$(obj).depend $(ALL)
+
+$(nandobj)u-boot-spl-aligned.bin: $(nandobj)u-boot-spl
+	$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@
+
+$(nandobj)u-boot-spl.bin:	$(nandobj)u-boot-spl
+	$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(nandobj)u-boot-spl:	$(OBJS)
+	cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \
+		-Map $(nandobj)u-boot-spl.map \
+		-o $(nandobj)u-boot-spl
+
+# create symbolic links for common files
+
+# from cpu directory
+$(obj)start.S:
+	@rm -f $@
+	@ln -s $(TOPDIR)/cpu/arm1136/start.S $@
+
+# from board directory
+$(obj)lowlevel_init.S:
+	@rm -f $@
+	@ln -s $(TOPDIR)/board/freescale/mx31pdk/lowlevel_init.S $@
+
+# from nand_spl directory
+$(obj)nand_boot_mx31.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/nand_spl/nand_boot_mx31.c $@
+
+#########################################################################
+
+$(obj)%.o:	$(obj)%.S
+	$(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)%.o:	$(obj)%.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/nand_spl/board/freescale/mx31pdk/config.mk b/nand_spl/board/freescale/mx31pdk/config.mk
new file mode 100644
index 0000000..119934b
--- /dev/null
+++ b/nand_spl/board/freescale/mx31pdk/config.mk
@@ -0,0 +1,5 @@
+PAD_TO	:= $(shell expr $$[$(TEXT_BASE) + 2048])
+
+ifeq ($(debug),1)
+PLATFORM_CPPFLAGS += -DDEBUG
+endif
diff --git a/nand_spl/board/freescale/mx31pdk/u-boot.lds b/nand_spl/board/freescale/mx31pdk/u-boot.lds
new file mode 100644
index 0000000..2780e11
--- /dev/null
+++ b/nand_spl/board/freescale/mx31pdk/u-boot.lds
@@ -0,0 +1,36 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	. = ALIGN(4);
+	.text	   :
+	{
+	  start.o	(.text)
+	  lowlevel_init.o	(.text)
+	  nand_boot_mx31.o	(.text)
+	  *(.text)
+	  . = 2K;
+	}
+
+	. = ALIGN(4);
+	.rodata : { *(.rodata) }
+
+	. = ALIGN(4);
+	.data : { *(.data) }
+
+	. = ALIGN(4);
+	.got : { *(.got) }
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss : { *(.bss) }
+	_end = .;
+}
-- 
1.5.6



More information about the U-Boot mailing list