]> git.sur5r.net Git - u-boot/blobdiff - board/trab/cmd_trab.c
[new uImage] Add gen_get_image() routine
[u-boot] / board / trab / cmd_trab.c
index 794c5271869e14fa3fb2e58c185ab5516b097f67..daa6aeefc73f5a6b0bc8d3b974ea8fca07416e49 100644 (file)
 #include <common.h>
 #include <command.h>
 #include <s3c2400.h>
+#include <rtc.h>
 
 /*
  * TRAB board specific commands. Especially commands for burn-in and function
  * test.
  */
-#if (CONFIG_COMMANDS & CFG_CMD_BSP)
+#if defined(CONFIG_CMD_BSP)
 
 /* limits for valid range of VCC5V in mV  */
 #define VCC5V_MIN       4500
@@ -117,6 +118,7 @@ int i2c_write_multiple (uchar chip, uint addr, int alen,
                        uchar *buffer, int len);
 int i2c_read_multiple (uchar chip, uint addr, int alen,
                        uchar *buffer, int len);
+int do_temp_log (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 /* helper functions */
 static void adc_init (void);
@@ -145,11 +147,11 @@ u8 status;
 u16 pass_cycles;
 u16 first_error_cycle;
 u8 first_error_num;
-unsigned char first_error_name[16];
+char first_error_name[16];
 u16 act_cycle;
 
 typedef struct test_function_s {
-       unsigned char *name;
+       char *name;
        int (*pf)(void);
 } test_function_t;
 
@@ -173,6 +175,7 @@ int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        led_init ();
        global_vars_init ();
        test_function_table_init ();
+       spi_init ();
 
        if (global_vars_write_to_eeprom () != 0) {
                printf ("%s: error writing global_vars to eeprom\n",
@@ -334,7 +337,6 @@ int do_contact_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        }
 
        spi_init ();
-       tsc2000_reg_init ();
 
        contact_temp = tsc2000_contact_temp();
        printf ("%d degree C * 100\n", contact_temp) ;
@@ -374,7 +376,7 @@ int do_burn_in_status (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                return (1);
        }
        if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
-                              1, first_error_name,
+                              1, (unsigned char*)first_error_name,
                               sizeof (first_error_name))) {
                return (1);
        }
@@ -535,7 +537,7 @@ static int test_eeprom (void)
 
        /* write test string 1, read back and verify */
        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                               EEPROM_TEST_STRING_1,
+                               (unsigned char*)EEPROM_TEST_STRING_1,
                                sizeof (EEPROM_TEST_STRING_1))) {
                return (1);
        }
@@ -545,7 +547,7 @@ static int test_eeprom (void)
                return (1);
        }
 
-       if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
+       if (strcmp ((char *)temp, EEPROM_TEST_STRING_1) != 0) {
                result = 1;
                printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
        }
@@ -553,7 +555,7 @@ static int test_eeprom (void)
        /* write test string 2, read back and verify */
        if (result == 0) {
                if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
-                                       EEPROM_TEST_STRING_2,
+                                       (unsigned char*)EEPROM_TEST_STRING_2,
                                        sizeof (EEPROM_TEST_STRING_2))) {
                        return (1);
                }
@@ -563,7 +565,7 @@ static int test_eeprom (void)
                        return (1);
                }
 
-               if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
+               if (strcmp ((char *)temp, EEPROM_TEST_STRING_2) != 0) {
                        result = 1;
                        printf ("%s: error; read str = \"%s\"\n",
                                __FUNCTION__, temp);
@@ -577,7 +579,6 @@ static int test_contact_temp (void)
 {
        int contact_temp;
 
-       spi_init ();
        contact_temp = tsc2000_contact_temp ();
 
        if ((contact_temp < MIN_CONTACT_TEMP)
@@ -728,6 +729,7 @@ static void led_blink (void)
 
        /* blink LED. This function does not return! */
        while (1) {
+               reset_timer_masked ();
                led_set (1);
                udelay (1000000 / LED_BLINK_FREQ / 2);
                led_set (0);
@@ -775,7 +777,7 @@ static int global_vars_write_to_eeprom (void)
                return (1);
        }
        if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
-                               1, first_error_name,
+                               1, (unsigned char*) first_error_name,
                                sizeof(first_error_name))) {
                return (1);
        }
@@ -840,4 +842,55 @@ static int dummy(void)
        return (0);
 }
 
-#endif /* CFG_CMD_BSP */
+int do_temp_log (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+       int contact_temp;
+       int delay = 0;
+#if defined(CONFIG_CMD_DATE)
+       struct rtc_time tm;
+#endif
+
+       if (argc > 2) {
+               printf ("Usage:\n%s\n", cmdtp->usage);
+               return 1;
+       }
+
+       if (argc > 1) {
+               delay = simple_strtoul(argv[1], NULL, 10);
+       }
+
+       spi_init ();
+       while (1) {
+
+#if defined(CONFIG_CMD_DATE)
+               rtc_get (&tm);
+               printf ("%4d-%02d-%02d %2d:%02d:%02d - ",
+                       tm.tm_year, tm.tm_mon, tm.tm_mday,
+                       tm.tm_hour, tm.tm_min, tm.tm_sec);
+#endif
+
+               contact_temp = tsc2000_contact_temp();
+               printf ("%d\n", contact_temp) ;
+
+               if (delay != 0)
+                       /*
+                        * reset timer to avoid timestamp overflow problem
+                        * after about 68 minutes of udelay() time.
+                        */
+                       reset_timer_masked ();
+                       sdelay (delay);
+       }
+
+       return 0;
+}
+
+U_BOOT_CMD(
+       tlog,   2,      1,      do_temp_log,
+       "tlog    - log contact temperature [1/100 C] to console (endlessly)\n",
+       "delay\n"
+       "    - contact temperature [1/100 C] is printed endlessly to console\n"
+       "      <delay> specifies the seconds to wait between two measurements\n"
+       "      For each measurment a timestamp is printeted\n"
+);
+
+#endif