]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ram: stm32mp1: add size and addr parameter to test all
authorPatrick Delaunay <patrick.delaunay@st.com>
Thu, 2 Jul 2020 17:56:37 +0000 (19:56 +0200)
committerPatrick Delaunay <patrick.delaunay@st.com>
Tue, 7 Jul 2020 14:01:23 +0000 (16:01 +0200)
Add size and addr parameter to test "All" to override the default
value (4kB and STM32_DDR_BASE) used in tests with these optional
parameters: [size] or [addr].

When other optional parameters are present before [addr],
they are replaced by default value:
- [loop] = "1"
- [pattern] = "-" (new: force default pattern)

Example to use:

DDR>test 0 1 0x20000

DDR>test 0 1 0x1000000 0xD0000000

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
drivers/ram/stm32mp1/stm32mp1_tests.c

index a2a69da9a37d801785942cf3013200d1b6b02998..952006aa1493daf1292ea44710fd2f395a78f07c 100644 (file)
@@ -14,6 +14,8 @@
 
 #define ADDR_INVALID   0xFFFFFFFF
 
+#define PATTERN_DEFAULT        "-"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static int get_bufsize(char *string, int argc, char *argv[], int arg_nb,
@@ -103,6 +105,10 @@ static int get_pattern(char *string, int argc, char *argv[], int arg_nb,
        unsigned long value;
 
        if (argc > arg_nb) {
+               if (!strcmp(argv[arg_nb], PATTERN_DEFAULT)) {
+                       *pattern = default_pattern;
+                       return 0;
+               }
                if (strict_strtoul(argv[arg_nb], 16, &value) < 0) {
                        sprintf(string, "invalid %d parameter %s",
                                arg_nb, argv[arg_nb]);
@@ -1343,17 +1349,52 @@ static enum test_result test_all(struct stm32mp1_ddrctl *ctl,
                                 char *string, int argc, char *argv[])
 {
        enum test_result res = TEST_PASSED, result;
-       int i, nb_error = 0;
+       int i, j, nb_error = 0, len;
        u32 loop = 0, nb_loop;
+       int argc_test;
+       char *argv_test[4];
+       char loop_string[] = "1";
+       char pattern_string[] = PATTERN_DEFAULT;
+       u32 *addr;
 
        if (get_nb_loop(string, argc, argv, 0, &nb_loop, 1))
                return TEST_ERROR;
 
+       if (get_addr(string, argc, argv, 2, (u32 *)&addr))
+               return TEST_ERROR;
+
        while (!nb_error) {
                /* execute all the test except the lasts which are infinite */
                for (i = 1; i < test_nb - NB_TEST_INFINITE; i++) {
+                       argc_test = 0;
+                       j = 0;
+                       len = strlen(test[i].usage);
+                       if (argc > 1 && j < len &&
+                           !strncmp("[size]", &test[i].usage[j], 6)) {
+                               argv_test[argc_test++] = argv[1];
+                               j += 7;
+                       }
+                       if (argc > 2) {
+                               if (j < len &&
+                                   !strncmp("[loop]", &test[i].usage[j], 6)) {
+                                       argv_test[argc_test++] = loop_string;
+                                       j += 7;
+                               }
+                               if (j < len &&
+                                   !strncmp("[pattern]", &test[i].usage[j],
+                                            9)) {
+                                       argv_test[argc_test++] = pattern_string;
+                                       j += 10;
+                               }
+                               if (j < len &&
+                                   !strncmp("[addr]", &test[i].usage[j], 6)) {
+                                       argv_test[argc_test++] = argv[2];
+                                       j += 7;
+                               }
+                       }
                        printf("execute %d:%s\n", (int)i, test[i].name);
-                       result = test[i].fct(ctl, phy, string, 0, NULL);
+                       result = test[i].fct(ctl, phy, string,
+                                            argc_test, argv_test);
                        printf("result %d:%s = ", (int)i, test[i].name);
                        if (result != TEST_PASSED) {
                                nb_error++;
@@ -1384,7 +1425,7 @@ static enum test_result test_all(struct stm32mp1_ddrctl *ctl,
  ****************************************************************/
 
 const struct test_desc test[] = {
-       {test_all, "All", "[loop]", "Execute all tests", 1 },
+       {test_all, "All", "[loop] [size] [addr]", "Execute all tests", 3 },
        {test_databus, "Simple DataBus", "[addr]",
         "Verifies each data line by walking 1 on fixed address",
         1