This patch updates uboot-xburst from 2009.11 to 2012.10-rc2 - Ingenic SoC support...
[openwrt/staging/dedeckeh.git] / package / boot / uboot-xburst / patches / 0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch
1 From c52b6168979d03fc31205444c3278c537787472a Mon Sep 17 00:00:00 2001
2 From: Xiangfu <xiangfu@openmobilefree.net>
3 Date: Wed, 10 Oct 2012 18:39:55 +0800
4 Subject: [PATCH 4/6] add more boot options(F1/F2/F3/F4/M/S)
5
6 ---
7 arch/mips/include/asm/global_data.h | 3 +++
8 arch/mips/lib/bootm.c | 17 ++++++++++++++++-
9 board/qi/qi_lb60/qi_lb60.c | 26 +++++++++++++++++++++++---
10 common/main.c | 21 +++++++++++++++++++--
11 include/configs/qi_lb60.h | 32 ++++++++++++++++++++++++++++++++
12 5 files changed, 93 insertions(+), 6 deletions(-)
13
14 diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
15 index 6e2cdc7..cd03d7e 100644
16 --- a/arch/mips/include/asm/global_data.h
17 +++ b/arch/mips/include/asm/global_data.h
18 @@ -59,6 +59,9 @@ typedef struct global_data {
19 unsigned long env_valid; /* Checksum of Environment valid? */
20 void **jt; /* jump table */
21 char env_buf[32]; /* buffer for getenv() before reloc. */
22 +#if defined(CONFIG_NANONOTE)
23 + unsigned long boot_option;
24 +#endif
25 } gd_t;
26
27 #include <asm-generic/global_data_flags.h>
28 diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
29 index 608c1a7..e00416b 100644
30 --- a/arch/mips/lib/bootm.c
31 +++ b/arch/mips/lib/bootm.c
32 @@ -47,10 +47,25 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
33 bootm_headers_t *images)
34 {
35 void (*theKernel) (int, char **, char **, int *);
36 - char *commandline = getenv("bootargs");
37 + char *commandline;
38 char env_buf[12];
39 char *cp;
40
41 +#if defined(CONFIG_NANONOTE)
42 + if (gd->boot_option & BOOT_FROM_MEMCARD)
43 + commandline = getenv ("bootargsfromsd");
44 + else if (gd->boot_option & BOOT_WITH_F1)
45 + commandline = getenv ("bootargsf1");
46 + else if (gd->boot_option & BOOT_WITH_F2)
47 + commandline = getenv ("bootargsf2");
48 + else if (gd->boot_option & BOOT_WITH_F3)
49 + commandline = getenv ("bootargsf3");
50 + else if (gd->boot_option & BOOT_WITH_F4)
51 + commandline = getenv ("bootargsf4");
52 + else
53 +#endif
54 + commandline = getenv ("bootargs");
55 +
56 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
57 return 1;
58
59 diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
60 index a2ba648..d622219 100644
61 --- a/board/qi/qi_lb60/qi_lb60.c
62 +++ b/board/qi/qi_lb60/qi_lb60.c
63 @@ -15,7 +15,7 @@ DECLARE_GLOBAL_DATA_PTR;
64
65 static void gpio_init(void)
66 {
67 - unsigned int i;
68 + unsigned int i, j;
69
70 /* Initialize NAND Flash Pins */
71 __gpio_as_nand();
72 @@ -42,14 +42,34 @@ static void gpio_init(void)
73
74 if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
75 printf("[S] pressed, enable UART0\n");
76 + gd->boot_option |= BOOT_WITH_ENABLE_UART;
77 __gpio_as_uart0();
78 } else {
79 __gpio_as_input(GPIO_KEYIN_8);
80 __gpio_enable_pull(GPIO_KEYIN_8);
81 }
82
83 - /* enable the TP4, TP5 as UART0 */
84 - __gpio_jtag_to_uart0();
85 + if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
86 + printf("[M] pressed, boot from memory card\n");
87 + gd->boot_option |= BOOT_FROM_MEMCARD;
88 + __gpio_jtag_to_uart0();
89 + }
90 +
91 + for (j = 0; j < 4; j++) {
92 + for (i = 0; i < 4; i++)
93 + __gpio_set_pin(GPIO_KEYOUT_BASE + i);
94 +
95 + __gpio_clear_pin(GPIO_KEYOUT_BASE + j);
96 +
97 + if (__gpio_get_pin(GPIO_KEYIN_BASE) == 0) {
98 + printf("[F%d] pressed", (j + 1));
99 + gd->boot_option |= (1 << (j + 2));
100 + /* BOOT_WITH_F1 (1 << 2) */
101 + /* BOOT_WITH_F2 (1 << 3) */
102 + /* BOOT_WITH_F3 (1 << 4) */
103 + /* BOOT_WITH_F4 (1 << 5) */
104 + }
105 + }
106
107 __gpio_as_output(GPIO_AUDIO_POP);
108 __gpio_set_pin(GPIO_AUDIO_POP);
109 diff --git a/common/main.c b/common/main.c
110 index 9507cec..dbfb7ca 100644
111 --- a/common/main.c
112 +++ b/common/main.c
113 @@ -355,7 +355,11 @@ void main_loop (void)
114 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
115 s = getenv ("bootdelay");
116 bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
117 -
118 +#if defined(CONFIG_NANONOTE)
119 + DECLARE_GLOBAL_DATA_PTR;
120 + if (gd->boot_option & BOOT_WITH_ENABLE_UART)
121 + bootdelay = 3;
122 +# endif
123 debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
124
125 #if defined(CONFIG_MENU_SHOW)
126 @@ -379,7 +383,20 @@ void main_loop (void)
127 }
128 else
129 #endif /* CONFIG_BOOTCOUNT_LIMIT */
130 - s = getenv ("bootcmd");
131 +#if defined(CONFIG_NANONOTE)
132 + if (gd->boot_option & BOOT_FROM_MEMCARD)
133 + s = getenv ("bootcmdfromsd");
134 + else if (gd->boot_option & BOOT_WITH_F1)
135 + s = getenv ("bootcmdf1");
136 + else if (gd->boot_option & BOOT_WITH_F2)
137 + s = getenv ("bootcmdf2");
138 + else if (gd->boot_option & BOOT_WITH_F3)
139 + s = getenv ("bootcmdf3");
140 + else if (gd->boot_option & BOOT_WITH_F4)
141 + s = getenv ("bootcmdf4");
142 + else
143 +#endif
144 + s = getenv ("bootcmd");
145
146 debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
147
148 diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
149 index 7b33be0..52b370c 100644
150 --- a/include/configs/qi_lb60.h
151 +++ b/include/configs/qi_lb60.h
152 @@ -31,6 +31,7 @@
153 /*
154 * Miscellaneous configurable options
155 */
156 +#define CONFIG_NANONOTE
157 #define CONFIG_JZ4740_MMC
158 #define CONFIG_MMC 1
159 #define CONFIG_FAT 1
160 @@ -39,6 +40,37 @@
161 #define CONFIG_CMD_FAT
162 #define CONFIG_CMD_EXT2
163
164 +#define CONFIG_CMD_UBIFS
165 +#define CONFIG_CMD_UBI
166 +#define CONFIG_MTD_PARTITIONS
167 +#define CONFIG_MTD_DEVICE
168 +#define CONFIG_CMD_MTDPARTS
169 +#define CONFIG_CMD_UBI
170 +#define CONFIG_CMD_UBIFS
171 +#define CONFIG_LZO
172 +#define CONFIG_RBTREE
173 +
174 +#define MTDIDS_DEFAULT "nand0=jz4740-nand"
175 +#define MTDPARTS_DEFAULT "mtdparts=jz4740-nand:4M@0(uboot)ro,4M@4M(kernel)ro,512M@8M(rootfs)ro,-(data)ro"
176 +
177 +#define BOOT_FROM_MEMCARD 1
178 +#define BOOT_WITH_ENABLE_UART (1 << 1) /* Vaule for global_data.h gd->boot_option */
179 +#define BOOT_WITH_F1 (1 << 2)
180 +#define BOOT_WITH_F2 (1 << 3)
181 +#define BOOT_WITH_F3 (1 << 4)
182 +#define BOOT_WITH_F4 (1 << 5)
183 +
184 +#define CONFIG_EXTRA_ENV_SETTINGS \
185 + "bootcmdfromsd=mmc init; ext2load mmc 0 0x80600000 /boot/uImage; bootm;\0" \
186 + "bootargsfromsd=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
187 + "bootcmdf1=mmc init; ext2load mmc 0:1 0x80600000 /boot/uImage; bootm;\0" \
188 + "bootargsf1=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait\0" \
189 + "bootcmdf2=mmc init; ext2load mmc 0:2 0x80600000 /boot/uImage; bootm;\0" \
190 + "bootargsf2=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p2 rw rootwait\0" \
191 + "bootcmdf3=mmc init; ext2load mmc 0:3 0x80600000 /boot/uImage; bootm;\0" \
192 + "bootargsf3=mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p3 rw rootwait\0" \
193 + "bootcmdf4=mtdparts default;ubi part rootfs;ubifsmount rootfs;ubifsload 0x80600000 /boot/uImage; bootm;\0" \
194 + "bootargsf4=mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
195
196 #define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
197 #define CONFIG_SYS_INIT_SP_OFFSET 0x400000
198 --
199 1.7.9.5
200