summaryrefslogtreecommitdiff
path: root/packages/u-boot/u-boot-mkimage-openmoko-native/boot-from-ram-and-nand.patch
blob: fa0de39ab716f6b86cebf02664b4eda9f27f8bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Auto-detect whether we're booting from RAM or NAND, and act accordingly. This
allows us to use the same u-boot binary for all boot modes.

include/configs/neo1973.h: introduced new config option
  CONFIG_LL_INIT_NAND_ONLY to perform low-level initialization only when
  booting from NAND
include/configs/neo1973.h: got rid of BUILD_FOR_RAM
cpu/arm920t/start.S: detect if we need to boot from NAND at run time (i.e., if
  we're running at address 0)

- Werner Almesberger <werner@openmoko.org>

Index: u-boot/cpu/arm920t/start.S
===================================================================
--- u-boot.orig/cpu/arm920t/start.S
+++ u-boot/cpu/arm920t/start.S
@@ -157,18 +157,26 @@
 	str	r1, [r0]
 #endif	/* CONFIG_S3C2400 || CONFIG_S3C2410 */
 
-	/*
-	 * we do sys-critical inits only at reboot,
-	 * not when booting from ram!
-	 */
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
+#ifndef CONFIG_LL_INIT_NAND_ONLY
 	bl	cpu_init_crit
 #endif
+#endif
 
 #ifndef CONFIG_SKIP_RELOCATE_UBOOT
-#ifndef CONFIG_S3C2410_NAND_BOOT
-relocate:				/* relocate U-Boot to RAM	    */
 	adr	r0, _start		/* r0 <- current position of code   */
+
+#ifdef CONFIG_S3C2410_NAND_BOOT
+					/* are we running from NAND ?	    */
+#define	BWSCON	0x48000000
+	ldr	r1, =BWSCON		/* Z = CPU booted from NAND	    */
+	ldr	r1, [r1]
+	tst	r1, #6			/* BWSCON[2:1] = OM[1:0]	    */
+	teqeq	r0, #0			/* Z &= running at address 0	    */
+	beq	nand_load
+#endif /* CONFIG_S3C2410_NAND_BOOT */
+
+relocate:				/* relocate U-Boot to RAM	    */
 	ldr	r1, _TEXT_BASE		/* test if we run from flash or RAM */
 	cmp     r0, r1                  /* don't reloc during debug         */
 	beq     done_relocate
@@ -188,10 +196,13 @@
 	ldr	pc, _done_relocate	/* jump to relocated code */
 _done_relocate:
 	.word	done_relocate
-done_relocate:
-#else /* NAND_BOOT */
-relocate:
-copy_myself:
+
+#ifdef CONFIG_S3C2410_NAND_BOOT
+nand_load:
+#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && defined(CONFIG_LL_INIT_NAND_ONLY)
+	bl	cpu_init_crit
+#endif
+
 	/* mov	r10, lr */
 
 	@ reset NAND
@@ -275,7 +286,8 @@
 #endif
 1:	b	1b
 done_nand_read:
-#endif /* NAND_BOOT */
+#endif /* CONFIG_S3C2410_NAND_BOOT */
+done_relocate:
 #endif /* CONFIG_SKIP_RELOCATE_UBOOT */
 
 	/* Set up the stack						    */
Index: u-boot/include/configs/neo1973_gta01.h
===================================================================
--- u-boot.orig/include/configs/neo1973_gta01.h
+++ u-boot/include/configs/neo1973_gta01.h
@@ -26,14 +26,10 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#if defined(BUILD_FOR_RAM)
-/* If we want to start u-boot from inside RAM */
-#define CONFIG_SKIP_LOWLEVEL_INIT	1
-#else
-/* we want to start u-boot directly from within NAND flash */
+/* we want to be able to start u-boot directly from within NAND flash */
+#define CONFIG_LL_INIT_NAND_ONLY
 #define CONFIG_S3C2410_NAND_BOOT	1
 #define CONFIG_S3C2410_NAND_SKIP_BAD	1
-#endif
 
 #define CFG_UBOOT_SIZE		0x40000 /* size of u-boot, for NAND loading */