]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - post/post.c
post: new nor flash test
[karo-tx-uboot.git] / post / post.c
index c982e27fff1f54e3e8b2bb2b73b21b130b837e55..76602243e70d088ad52e9adc4366ddb8ffc39030 100644 (file)
  */
 
 #include <common.h>
-#include <console.h>
+#include <stdio_dev.h>
 #include <watchdog.h>
 #include <post.h>
 
+#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
+#include <asm/gpio.h>
+#endif
+
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
@@ -58,6 +62,39 @@ int post_init_f (void)
        return res;
 }
 
+/*
+ * Supply a default implementation for post_hotkeys_pressed() for boards
+ * without hotkey support. We always return 0 here, so that the
+ * long-running tests won't be started.
+ *
+ * Boards with hotkey support can override this weak default function
+ * by defining one in their board specific code.
+ */
+int __post_hotkeys_pressed(void)
+{
+#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
+       int ret;
+       unsigned gpio = CONFIG_SYS_POST_HOTKEYS_GPIO;
+
+       ret = gpio_request(gpio, "hotkeys");
+       if (ret) {
+               printf("POST: gpio hotkey request failed\n");
+               return 0;
+       }
+
+       gpio_direction_input(gpio);
+       ret = gpio_get_value(gpio);
+       gpio_free(gpio);
+
+       return ret;
+#endif
+
+       return 0;       /* No hotkeys supported */
+}
+int post_hotkeys_pressed(void)
+       __attribute__((weak, alias("__post_hotkeys_pressed")));
+
+
 void post_bootmode_init (void)
 {
        int bootmode = post_bootmode_get (0);
@@ -159,7 +196,7 @@ static void post_get_flags (int *test_flags)
                         POST_CRITICAL };
        char *var[] = { "post_poweron", "post_normal", "post_slowtest",
                        "post_critical" };
-       int varnum = sizeof (var) / sizeof (var[0]);
+       int varnum = ARRAY_SIZE(var);
        char list[128];                 /* long enough for POST list */
        char *name;
        char *s;
@@ -171,7 +208,7 @@ static void post_get_flags (int *test_flags)
        }
 
        for (i = 0; i < varnum; i++) {
-               if (getenv_(var[i], list, sizeof (list)) <= 0)
+               if (getenv_f(var[i], list, sizeof (list)) <= 0)
                        continue;
 
                for (j = 0; j < post_list_size; j++) {
@@ -215,6 +252,12 @@ static void post_get_flags (int *test_flags)
        }
 }
 
+void __show_post_progress (unsigned int test_num, int before, int result)
+{
+}
+void show_post_progress (unsigned int, int, int)
+                       __attribute__((weak, alias("__show_post_progress")));
+
 static int post_run_single (struct post_test *test,
                                int test_flags, int flags, unsigned int i)
 {
@@ -232,13 +275,18 @@ static int post_run_single (struct post_test *test,
                        if (test_flags & POST_PREREL)
                                post_log_mark_start ( test->testid );
                        else
-                       post_log ("POST %s ", test->cmd);
+                               post_log ("POST %s ", test->cmd);
                }
 
+               show_post_progress(i, POST_BEFORE, POST_FAILED);
+
                if (test_flags & POST_PREREL) {
-                       if ((*test->test) (flags) == 0)
+                       if ((*test->test) (flags) == 0) {
                                post_log_mark_succ ( test->testid );
+                               show_post_progress(i, POST_AFTER, POST_PASSED);
+                       }
                        else {
+                               show_post_progress(i, POST_AFTER, POST_FAILED);
                                if (test_flags & POST_CRITICAL)
                                        gd->flags |= GD_FLG_POSTFAIL;
                                if (test_flags & POST_STOP)
@@ -248,6 +296,7 @@ static int post_run_single (struct post_test *test,
                if ((*test->test) (flags) != 0) {
                        post_log ("FAILED\n");
                        show_boot_progress (-32);
+                       show_post_progress(i, POST_AFTER, POST_FAILED);
                        if (test_flags & POST_CRITICAL)
                                gd->flags |= GD_FLG_POSTFAIL;
                        if (test_flags & POST_STOP)
@@ -255,6 +304,7 @@ static int post_run_single (struct post_test *test,
                }
                else
                        post_log ("PASSED\n");
+                       show_post_progress(i, POST_AFTER, POST_PASSED);
                }
 
                if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) {
@@ -393,6 +443,7 @@ int post_log (char *format, ...)
        return 0;
 }
 
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
 void post_reloc (void)
 {
        unsigned int i;
@@ -437,6 +488,7 @@ void post_reloc (void)
                }
        }
 }
+#endif
 
 
 /*