1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-25 17:21:53 +02:00
openwrt-xburst/target/linux/xburst/image/u-boot/patches/0003-other-function-for-ben.patch

233 lines
6.2 KiB
Diff

diff --git a/board/qi_lb60/qi_lb60.c b/board/qi_lb60/qi_lb60.c
index d13f2ab..93c2571 100644
--- a/board/qi_lb60/qi_lb60.c
+++ b/board/qi_lb60/qi_lb60.c
@@ -12,6 +12,8 @@
#include <asm/mipsregs.h>
#include <asm/jz4740.h>
+DECLARE_GLOBAL_DATA_PTR;
+
static void gpio_init(void)
{
/*
@@ -25,11 +27,6 @@ static void gpio_init(void)
__gpio_as_sdram_32bit();
/*
- * Initialize UART0 pins
- */
- __gpio_as_uart0();
-
- /*
* Initialize LCD pins
*/
__gpio_as_lcd_18bit();
@@ -43,17 +40,31 @@ static void gpio_init(void)
* Initialize Other pins
*/
unsigned int i;
+ for (i = 0; i < 7; i++){
+ __gpio_as_input(GPIO_KEYIN_BASE + i);
+ __gpio_enable_pull(GPIO_KEYIN_BASE + i);
+ }
+
for (i = 0; i < 8; i++) {
__gpio_as_output(GPIO_KEYOUT_BASE + i);
- __gpio_set_pin(GPIO_KEYOUT_BASE + i);
+ __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
}
- for (i = 0; i < 7; i++){
- __gpio_as_input(GPIO_KEYIN_BASE + i);
- __gpio_enable_pull(GPIO_KEYIN_BASE + i);
+ /*
+ * Initialize UART0 pins, in Ben NanoNote uart0 and keyin8 use the
+ * same gpio, init the gpio as uart0 cause a keyboard bug. so for
+ * end user we disable the uart0
+ */
+ if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
+ /* if pressed [S] */
+ printf("[S] pressed, enable UART0\n");
+ gd->boot_option = 5;
+ __gpio_as_uart0();
+ } else {
+ printf("[S] not pressed, disable UART0\n");
+ __gpio_as_input(GPIO_KEYIN_8);
+ __gpio_enable_pull(GPIO_KEYIN_8);
}
- /* __gpio_as_input( GPIO_KEYIN_8 ); */
- /* __gpio_enable_pull( GPIO_KEYIN_8 ); */
__gpio_as_output(GPIO_AUDIO_POP);
__gpio_set_pin(GPIO_AUDIO_POP);
@@ -73,6 +84,11 @@ static void gpio_init(void)
__gpio_as_input(GPIO_USB_DETECT);
__gpio_enable_pull(GPIO_USB_DETECT);
+
+ if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
+ printf("[M] pressed, boot from sd card\n");
+ gd->boot_option = 1;
+ }
}
static void cpm_init(void)
@@ -96,7 +112,6 @@ void board_early_init(void)
int checkboard (void)
{
- DECLARE_GLOBAL_DATA_PTR;
printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %d MHz)\n",
gd->cpu_clk/1000000);
diff --git a/common/env_common.c b/common/env_common.c
index be64d13..54bf0ea 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -134,7 +134,7 @@ uchar default_environment[] = {
"pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0"
#endif
#ifdef CONFIG_EXTRA_ENV_SETTINGS
- CONFIG_EXTRA_ENV_SETTINGS
+ "bootargsfromsd=" CONFIG_BOOTARGSFROMSD "\0"
#endif
"\0"
};
diff --git a/common/main.c b/common/main.c
index 026edd1..1703d4f 100644
--- a/common/main.c
+++ b/common/main.c
@@ -372,7 +372,9 @@ void main_loop (void)
#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
s = getenv ("bootdelay");
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
-
+ DECLARE_GLOBAL_DATA_PTR;
+ if (gd->boot_option == 5)
+ bootdelay = gd->boot_option;
debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);
# ifdef CONFIG_BOOT_RETRY_TIME
diff --git a/include/asm-mips/global_data.h b/include/asm-mips/global_data.h
index db88704..23f597e 100644
--- a/include/asm-mips/global_data.h
+++ b/include/asm-mips/global_data.h
@@ -47,6 +47,8 @@ typedef struct global_data {
unsigned long mem_clk; /* Memory bus clock */
unsigned long dev_clk; /* Device clock */
unsigned long fb_base; /* base address of framebuffer */
+ unsigned long boot_option; /* 1: boot from sd
+ * 5: boot delay for 5 secs*/
#endif
unsigned long baudrate;
unsigned long have_console; /* serial_init() was called */
diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
index 02af607..c3bf9c7 100644
--- a/include/configs/qi_lb60.h
+++ b/include/configs/qi_lb60.h
@@ -45,6 +45,8 @@
#define CONFIG_BOOTDELAY 0
#define CONFIG_BOOTFILE "uImage" /* file to load */
#define CONFIG_BOOTARGS "mem=32M console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
+#define CONFIG_EXTRA_ENV_SETTINGS 1
+#define CONFIG_BOOTARGSFROMSD "mem=32M console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait"
#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x200000;bootm"
/*
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index 54af24c..34150e9 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -46,7 +46,9 @@ static void linux_env_set (char * env_name, char * env_val);
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
void (*theKernel) (int, char **, char **, int *);
- char *commandline = getenv ("bootargs");
+ char *commandline = gd->boot_option == 1 ?
+ getenv ("bootargsfromsd") :
+ getenv ("bootargs");
char env_buf[12];
char *cp;
diff --git a/nand_spl/nand_boot_jz4740.c b/nand_spl/nand_boot_jz4740.c
index 924a47a..146de19 100644
--- a/nand_spl/nand_boot_jz4740.c
+++ b/nand_spl/nand_boot_jz4740.c
@@ -24,10 +24,8 @@
#include <asm/io.h>
#include <asm/jz4740.h>
-#define KEY_1_OUT (32 * 3 + 21)
-#define KEY_1_IN (32 * 3 + 19)
-#define KEY_2_OUT (32 * 3 + 25)
-#define KEY_2_IN (32 * 3 + 26)
+#define KEY_U_OUT (32 * 2 + 16)
+#define KEY_U_IN (32 * 3 + 19)
/*
* NAND flash definitions
@@ -350,40 +348,25 @@ static void gpio_init(void)
static int is_usb_boot()
{
- int key2,keyh;
-
- key2 = 0;
- keyh = 0;
+ int keyU = 0;
- __gpio_as_output(KEY_1_OUT);
- __gpio_as_output(KEY_2_OUT);
- __gpio_as_input(KEY_1_IN);
- __gpio_as_input(KEY_2_IN);
- __gpio_disable_pull(KEY_1_IN);
- __gpio_disable_pull(KEY_2_IN);
+ __gpio_as_input(KEY_U_IN);
+ __gpio_enable_pull(KEY_U_IN);
- __gpio_clear_pin(KEY_1_OUT);
- __gpio_clear_pin(KEY_2_OUT);
-
- key2 = __gpio_get_pin(KEY_2_IN);
- keyh = __gpio_get_pin(KEY_1_IN);
+ __gpio_as_output(KEY_U_OUT);
+ __gpio_clear_pin(KEY_U_OUT);
- if(key2)
- serial_puts("key2");
- else
- serial_puts("key2--");
+ keyU = __gpio_get_pin(KEY_U_IN);
- if(keyh)
- serial_puts("keyh");
+ if (keyU)
+ serial_puts("[U] not pressed\n");
else
- serial_puts("keyh--");
+ serial_puts("[U] pressed\n");
-
- if( ( key2 == 0 ) && ( keyh == 0 ) )
+ if (keyU == 0)
return 1;
else
return 0;
-
}
void nand_boot(void)
@@ -402,9 +385,8 @@ void nand_boot(void)
pll_init();
sdram_init();
- int ret = 0;
- ret = is_usb_boot();
- if(ret) {
+ if(is_usb_boot()) {
+ serial_puts("enter USB BOOT mode\n");
usb_boot();
}