0004-add-more-boot-options-F1-F2-F3-F4-M-S.patch 6.8 KB

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