mtd: nand: spi: Support GigaDevice GD5F1GQ5UExxG
[pandora-u-boot.git] / cmd / load.c
index 36db571..5bbc39b 100644 (file)
@@ -20,6 +20,8 @@
 #include <serial.h>
 #include <xyzModem.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
+#include <linux/delay.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -41,8 +43,8 @@ static int do_echo = 1;
 /* -------------------------------------------------------------------- */
 
 #if defined(CONFIG_CMD_LOADS)
-static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
-                         char * const argv[])
+static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
+                         char *const argv[])
 {
        long offset = 0;
        ulong addr;
@@ -80,7 +82,7 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == '\r')
+                       if (getchar() == '\r')
                                break;
                }
        }
@@ -101,7 +103,7 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
         */
        for (i=0; i<100; ++i) {
                if (tstc()) {
-                       (void) getc();
+                       getchar();
                }
                udelay(1000);
        }
@@ -123,7 +125,7 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == 0x1B) /* ESC */
+                       if (getchar() == 0x1B) /* ESC */
                                break;
                }
        }
@@ -211,7 +213,7 @@ static int read_record(char *buf, ulong len)
        --len;  /* always leave room for terminating '\0' byte */
 
        for (p=buf; p < buf+len; ++p) {
-               c = getc();             /* read character               */
+               c = getchar();          /* read character               */
                if (do_echo)
                        putc(c);        /* ... and echo it              */
 
@@ -227,12 +229,11 @@ static int read_record(char *buf, ulong len)
                        *p = c;
                }
 
-           /* Check for the console hangup (if any different from serial) */
-           if (gd->jt->getc != getc) {
-               if (ctrlc()) {
-                   return (-1);
+               /* Check for the console hangup (if any different from serial) */
+               if (gd->jt->getc != getchar) {
+                       if (ctrlc())
+                               return (-1);
                }
-           }
        }
 
        /* line too long - truncate */
@@ -242,7 +243,8 @@ static int read_record(char *buf, ulong len)
 
 #if defined(CONFIG_CMD_SAVES)
 
-int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_save_serial(struct cmd_tbl *cmdtp, int flag, int argc,
+                  char *const argv[])
 {
        ulong offset = 0;
        ulong size   = 0;
@@ -274,7 +276,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == '\r')
+                       if (getchar() == '\r')
                                break;
                }
        }
@@ -286,7 +288,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        printf("## Ready for S-Record upload, press ENTER to proceed ...\n");
        for (;;) {
-               if (getc() == '\r')
+               if (getchar() == '\r')
                        break;
        }
        if (save_serial(offset, size)) {
@@ -303,7 +305,7 @@ int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == 0x1B) /* ESC */
+                       if (getchar() == 0x1B) /* ESC */
                                break;
                }
        }
@@ -419,8 +421,8 @@ static int  his_pad_count;  /* number of pad chars he needs */
 static char his_pad_char;   /* pad chars he needs */
 static char his_quote;      /* quote chars he'll use */
 
-static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
-                             char * const argv[])
+static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
+                             char *const argv[])
 {
        ulong offset = 0;
        ulong addr;
@@ -457,7 +459,7 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == '\r')
+                       if (getchar() == '\r')
                                break;
                }
        }
@@ -503,7 +505,7 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
                serial_setbrg();
                udelay(50000);
                for (;;) {
-                       if (getc() == 0x1B) /* ESC */
+                       if (getchar() == 0x1B) /* ESC */
                                break;
                }
        }
@@ -526,7 +528,7 @@ static ulong load_serial_bin(ulong offset)
         */
        for (i=0; i<100; ++i) {
                if (tstc()) {
-                       (void) getc();
+                       getchar();
                }
                udelay(1000);
        }
@@ -829,7 +831,7 @@ static int k_recv(void)
                /* get a packet */
                /* wait for the starting character or ^C */
                for (;;) {
-                       switch (getc ()) {
+                       switch (getchar()) {
                        case START_CHAR:        /* start packet */
                                goto START;
                        case ETX_CHAR:          /* ^C waiting for packet */
@@ -841,13 +843,13 @@ static int k_recv(void)
 START:
                /* get length of packet */
                sum = 0;
-               new_char = getc();
+               new_char = getchar();
                if ((new_char & 0xE0) == 0)
                        goto packet_error;
                sum += new_char & 0xff;
                length = untochar(new_char);
                /* get sequence number */
-               new_char = getc();
+               new_char = getchar();
                if ((new_char & 0xE0) == 0)
                        goto packet_error;
                sum += new_char & 0xff;
@@ -874,7 +876,7 @@ START:
                /* END NEW CODE */
 
                /* get packet type */
-               new_char = getc();
+               new_char = getchar();
                if ((new_char & 0xE0) == 0)
                        goto packet_error;
                sum += new_char & 0xff;
@@ -884,19 +886,19 @@ START:
                if (length == -2) {
                        /* (length byte was 0, decremented twice) */
                        /* get the two length bytes */
-                       new_char = getc();
+                       new_char = getchar();
                        if ((new_char & 0xE0) == 0)
                                goto packet_error;
                        sum += new_char & 0xff;
                        len_hi = untochar(new_char);
-                       new_char = getc();
+                       new_char = getchar();
                        if ((new_char & 0xE0) == 0)
                                goto packet_error;
                        sum += new_char & 0xff;
                        len_lo = untochar(new_char);
                        length = len_hi * 95 + len_lo;
                        /* check header checksum */
-                       new_char = getc();
+                       new_char = getchar();
                        if ((new_char & 0xE0) == 0)
                                goto packet_error;
                        if (new_char != tochar((sum + ((sum >> 6) & 0x03)) & 0x3f))
@@ -906,7 +908,7 @@ START:
                }
                /* bring in rest of packet */
                while (length > 1) {
-                       new_char = getc();
+                       new_char = getchar();
                        if ((new_char & 0xE0) == 0)
                                goto packet_error;
                        sum += new_char & 0xff;
@@ -923,13 +925,13 @@ START:
                        }
                }
                /* get and validate checksum character */
-               new_char = getc();
+               new_char = getchar();
                if ((new_char & 0xE0) == 0)
                        goto packet_error;
                if (new_char != tochar((sum + ((sum >> 6) & 0x03)) & 0x3f))
                        goto packet_error;
                /* get END_CHAR */
-               new_char = getc();
+               new_char = getchar();
                if (new_char != END_CHAR) {
                  packet_error:
                        /* restore state machines */
@@ -953,7 +955,7 @@ START:
 
 static int getcxmodem(void) {
        if (tstc())
-               return (getc());
+               return (getchar());
        return -1;
 }
 static ulong load_serial_ymodem(ulong offset, int mode)
@@ -1064,25 +1066,25 @@ U_BOOT_CMD(
 U_BOOT_CMD(
        loadb, 3, 0,    do_load_serial_bin,
        "load binary file over serial line (kermit mode)",
-       "[ off ] [ baud ]\n"
+       "[ addr [ baud ] ]\n"
        "    - load binary file over serial line"
-       " with offset 'off' and baudrate 'baud'"
+       " at address 'addr' with baudrate 'baud'"
 );
 
 U_BOOT_CMD(
        loadx, 3, 0,    do_load_serial_bin,
        "load binary file over serial line (xmodem mode)",
-       "[ off ] [ baud ]\n"
+       "[ addr [ baud ] ]\n"
        "    - load binary file over serial line"
-       " with offset 'off' and baudrate 'baud'"
+       " at address 'addr' with baudrate 'baud'"
 );
 
 U_BOOT_CMD(
        loady, 3, 0,    do_load_serial_bin,
        "load binary file over serial line (ymodem mode)",
-       "[ off ] [ baud ]\n"
+       "[ addr [ baud ] ]\n"
        "    - load binary file over serial line"
-       " with offset 'off' and baudrate 'baud'"
+       " at address 'addr' with baudrate 'baud'"
 );
 
 #endif /* CONFIG_CMD_LOADB */