ram: stm32mp1: use the DDR size by default in the test addressBus
[platform/kernel/u-boot.git] / drivers / ram / stm32mp1 / stm32mp1_tests.c
1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
4  */
5 #include <common.h>
6 #include <console.h>
7 #include <init.h>
8 #include <log.h>
9 #include <rand.h>
10 #include <watchdog.h>
11 #include <asm/io.h>
12 #include <linux/log2.h>
13 #include "stm32mp1_tests.h"
14
15 #define ADDR_INVALID    0xFFFFFFFF
16
17 DECLARE_GLOBAL_DATA_PTR;
18
19 static int get_bufsize(char *string, int argc, char *argv[], int arg_nb,
20                        size_t *bufsize, size_t default_size, size_t min_size)
21 {
22         unsigned long value;
23
24         if (argc > arg_nb) {
25                 if (strict_strtoul(argv[arg_nb], 0, &value) < 0) {
26                         sprintf(string, "invalid %d parameter %s",
27                                 arg_nb, argv[arg_nb]);
28                         return -1;
29                 }
30                 if (value > STM32_DDR_SIZE || value < min_size) {
31                         sprintf(string, "invalid size %s (min=%d)",
32                                 argv[arg_nb], min_size);
33                         return -1;
34                 }
35                 if (value & (min_size - 1)) {
36                         sprintf(string, "unaligned size %s (min=%d)",
37                                 argv[arg_nb], min_size);
38                         return -1;
39                 }
40                 *bufsize = value;
41         } else {
42                 if (default_size != STM32_DDR_SIZE)
43                         *bufsize = default_size;
44                 else
45                         *bufsize = get_ram_size((long *)STM32_DDR_BASE,
46                                                 STM32_DDR_SIZE);
47         }
48         return 0;
49 }
50
51 static int get_nb_loop(char *string, int argc, char *argv[], int arg_nb,
52                        u32 *nb_loop, u32 default_nb_loop)
53 {
54         unsigned long value;
55
56         if (argc > arg_nb) {
57                 if (strict_strtoul(argv[arg_nb], 0, &value) < 0) {
58                         sprintf(string, "invalid %d parameter %s",
59                                 arg_nb, argv[arg_nb]);
60                         return -1;
61                 }
62                 if (value == 0)
63                         printf("WARNING: infinite loop requested\n");
64                 *nb_loop = value;
65         } else {
66                 *nb_loop = default_nb_loop;
67         }
68
69         return 0;
70 }
71
72 static int get_addr(char *string, int argc, char *argv[], int arg_nb,
73                     u32 *addr)
74 {
75         unsigned long value;
76
77         if (argc > arg_nb) {
78                 if (strict_strtoul(argv[arg_nb], 16, &value) < 0) {
79                         sprintf(string, "invalid %d parameter %s",
80                                 arg_nb, argv[arg_nb]);
81                         return -1;
82                 }
83                 if (value < STM32_DDR_BASE) {
84                         sprintf(string, "too low address %s", argv[arg_nb]);
85                         return -1;
86                 }
87                 if (value & 0x3 && value != ADDR_INVALID) {
88                         sprintf(string, "unaligned address %s",
89                                 argv[arg_nb]);
90                         return -1;
91                 }
92                 *addr = value;
93         } else {
94                 *addr = STM32_DDR_BASE;
95         }
96
97         return 0;
98 }
99
100 static int get_pattern(char *string, int argc, char *argv[], int arg_nb,
101                        u32 *pattern, u32 default_pattern)
102 {
103         unsigned long value;
104
105         if (argc > arg_nb) {
106                 if (strict_strtoul(argv[arg_nb], 16, &value) < 0) {
107                         sprintf(string, "invalid %d parameter %s",
108                                 arg_nb, argv[arg_nb]);
109                         return -1;
110                 }
111                 *pattern = value;
112         } else {
113                 *pattern = default_pattern;
114         }
115
116         return 0;
117 }
118
119 static u32 check_addr(u32 addr, u32 value)
120 {
121         u32 data = readl(addr);
122
123         if (value !=  data) {
124                 printf("0x%08x: 0x%08x <=> 0x%08x", addr, data, value);
125                 data = readl(addr);
126                 printf("(2nd read: 0x%08x)", data);
127                 if (value == data)
128                         printf("- read error");
129                 else
130                         printf("- write error");
131                 printf("\n");
132                 return -1;
133         }
134         return 0;
135 }
136
137 static int progress(u32 offset)
138 {
139         if (!(offset & 0xFFFFFF)) {
140                 putc('.');
141                 if (ctrlc()) {
142                         printf("\ntest interrupted!\n");
143                         return 1;
144                 }
145         }
146         return 0;
147 }
148
149 static int test_loop_end(u32 *loop, u32 nb_loop, u32 progress)
150 {
151         (*loop)++;
152         if (nb_loop && *loop >= nb_loop)
153                 return 1;
154         if ((*loop) % progress)
155                 return 0;
156         /* allow to interrupt the test only for progress step */
157         if (ctrlc()) {
158                 printf("test interrupted!\n");
159                 return 1;
160         }
161         printf("loop #%d\n", *loop);
162         WATCHDOG_RESET();
163
164         return 0;
165 }
166
167 /**********************************************************************
168  *
169  * Function:    memTestDataBus()
170  *
171  * Description: Test the data bus wiring in a memory region by
172  *              performing a walking 1's test at a fixed address
173  *              within that region.  The address is selected
174  *              by the caller.
175  *
176  * Notes:
177  *
178  * Returns:     0 if the test succeeds.
179  *              A non-zero result is the first pattern that failed.
180  *
181  **********************************************************************/
182 static u32 databus(u32 *address)
183 {
184         u32 pattern;
185         u32 read_value;
186
187         /* Perform a walking 1's test at the given address. */
188         for (pattern = 1; pattern != 0; pattern <<= 1) {
189                 /* Write the test pattern. */
190                 writel(pattern, address);
191
192                 /* Read it back (immediately is okay for this test). */
193                 read_value = readl(address);
194                 debug("%x: %x <=> %x\n",
195                       (u32)address, read_value, pattern);
196
197                 if (read_value != pattern)
198                         return pattern;
199         }
200
201         return 0;
202 }
203
204 /**********************************************************************
205  *
206  * Function:    memTestAddressBus()
207  *
208  * Description: Test the address bus wiring in a memory region by
209  *              performing a walking 1's test on the relevant bits
210  *              of the address and checking for aliasing. This test
211  *              will find single-bit address failures such as stuck
212  *              -high, stuck-low, and shorted pins.  The base address
213  *              and size of the region are selected by the caller.
214  *
215  * Notes:       For best results, the selected base address should
216  *              have enough LSB 0's to guarantee single address bit
217  *              changes.  For example, to test a 64-Kbyte region,
218  *              select a base address on a 64-Kbyte boundary.  Also,
219  *              select the region size as a power-of-two--if at all
220  *              possible.
221  *
222  * Returns:     NULL if the test succeeds.
223  *              A non-zero result is the first address at which an
224  *              aliasing problem was uncovered.  By examining the
225  *              contents of memory, it may be possible to gather
226  *              additional information about the problem.
227  *
228  **********************************************************************/
229 static u32 *addressbus(u32 *address, u32 nb_bytes)
230 {
231         u32 mask = (nb_bytes / sizeof(u32) - 1);
232         u32 offset;
233         u32 test_offset;
234         u32 read_value;
235
236         u32 pattern     = 0xAAAAAAAA;
237         u32 antipattern = 0x55555555;
238
239         /* Write the default pattern at each of the power-of-two offsets. */
240         for (offset = 1; (offset & mask) != 0; offset <<= 1)
241                 writel(pattern, &address[offset]);
242
243         /* Check for address bits stuck high. */
244         test_offset = 0;
245         writel(antipattern, &address[test_offset]);
246
247         for (offset = 1; (offset & mask) != 0; offset <<= 1) {
248                 read_value = readl(&address[offset]);
249                 debug("%x: %x <=> %x\n",
250                       (u32)&address[offset], read_value, pattern);
251                 if (read_value != pattern)
252                         return &address[offset];
253         }
254
255         writel(pattern, &address[test_offset]);
256
257         /* Check for address bits stuck low or shorted. */
258         for (test_offset = 1; (test_offset & mask) != 0; test_offset <<= 1) {
259                 writel(antipattern, &address[test_offset]);
260                 if (readl(&address[0]) != pattern)
261                         return &address[test_offset];
262
263                 for (offset = 1; (offset & mask) != 0; offset <<= 1) {
264                         if (readl(&address[offset]) != pattern &&
265                             offset != test_offset)
266                                 return &address[test_offset];
267                 }
268                 writel(pattern, &address[test_offset]);
269         }
270
271         return NULL;
272 }
273
274 /**********************************************************************
275  *
276  * Function:    memTestDevice()
277  *
278  * Description: Test the integrity of a physical memory device by
279  *              performing an increment/decrement test over the
280  *              entire region.  In the process every storage bit
281  *              in the device is tested as a zero and a one.  The
282  *              base address and the size of the region are
283  *              selected by the caller.
284  *
285  * Notes:
286  *
287  * Returns:     NULL if the test succeeds.
288  *
289  *              A non-zero result is the first address at which an
290  *              incorrect value was read back.  By examining the
291  *              contents of memory, it may be possible to gather
292  *              additional information about the problem.
293  *
294  **********************************************************************/
295 static u32 *memdevice(u32 *address, u32 nb_bytes)
296 {
297         u32 offset;
298         u32 nb_words = nb_bytes / sizeof(u32);
299
300         u32 pattern;
301         u32 antipattern;
302
303         puts("Fill with pattern");
304         /* Fill memory with a known pattern. */
305         for (pattern = 1, offset = 0; offset < nb_words; pattern++, offset++) {
306                 writel(pattern, &address[offset]);
307                 if (progress(offset))
308                         return NULL;
309         }
310
311         puts("\nCheck and invert pattern");
312         /* Check each location and invert it for the second pass. */
313         for (pattern = 1, offset = 0; offset < nb_words; pattern++, offset++) {
314                 if (readl(&address[offset]) != pattern)
315                         return &address[offset];
316
317                 antipattern = ~pattern;
318                 writel(antipattern, &address[offset]);
319                 if (progress(offset))
320                         return NULL;
321         }
322
323         puts("\nCheck inverted pattern");
324         /* Check each location for the inverted pattern and zero it. */
325         for (pattern = 1, offset = 0; offset < nb_words; pattern++, offset++) {
326                 antipattern = ~pattern;
327                 if (readl(&address[offset]) != antipattern)
328                         return &address[offset];
329                 if (progress(offset))
330                         return NULL;
331         }
332         printf("\n");
333
334         return NULL;
335 }
336
337 static enum test_result databuswalk0(struct stm32mp1_ddrctl *ctl,
338                                      struct stm32mp1_ddrphy *phy,
339                                      char *string, int argc, char *argv[])
340 {
341         int i;
342         u32 loop = 0, nb_loop;
343         u32 addr;
344         u32 error = 0;
345         u32 data;
346
347         if (get_nb_loop(string, argc, argv, 0, &nb_loop, 100))
348                 return TEST_ERROR;
349         if (get_addr(string, argc, argv, 1, &addr))
350                 return TEST_ERROR;
351
352         printf("running %d loops at 0x%x\n", nb_loop, addr);
353         while (!error) {
354                 for (i = 0; i < 32; i++)
355                         writel(~(1 << i), addr + 4 * i);
356                 for (i = 0; i < 32; i++) {
357                         data = readl(addr + 4 * i);
358                         if (~(1 << i) !=  data) {
359                                 error |= 1 << i;
360                                 debug("%x: error %x expected %x => error:%x\n",
361                                       addr + 4 * i, data, ~(1 << i), error);
362                         }
363                 }
364                 if (test_loop_end(&loop, nb_loop, 1000))
365                         break;
366                 for (i = 0; i < 32; i++)
367                         writel(0, addr + 4 * i);
368         }
369         if (error) {
370                 sprintf(string, "loop %d: error for bits 0x%x",
371                         loop, error);
372                 return TEST_FAILED;
373         }
374         sprintf(string, "no error for %d loops", loop);
375         return TEST_PASSED;
376 }
377
378 static enum test_result databuswalk1(struct stm32mp1_ddrctl *ctl,
379                                      struct stm32mp1_ddrphy *phy,
380                                      char *string, int argc, char *argv[])
381 {
382         int i;
383         u32 loop = 0, nb_loop;
384         u32 addr;
385         u32 error = 0;
386         u32 data;
387
388         if (get_nb_loop(string, argc, argv, 0, &nb_loop, 100))
389                 return TEST_ERROR;
390         if (get_addr(string, argc, argv, 1, &addr))
391                 return TEST_ERROR;
392         printf("running %d loops at 0x%x\n", nb_loop, addr);
393         while (!error) {
394                 for (i = 0; i < 32; i++)
395                         writel(1 << i, addr + 4 * i);
396                 for (i = 0; i < 32; i++) {
397                         data = readl(addr + 4 * i);
398                         if ((1 << i) !=  data) {
399                                 error |= 1 << i;
400                                 debug("%x: error %x expected %x => error:%x\n",
401                                       addr + 4 * i, data, (1 << i), error);
402                         }
403                 }
404                 if (test_loop_end(&loop, nb_loop, 1000))
405                         break;
406                 for (i = 0; i < 32; i++)
407                         writel(0, addr + 4 * i);
408         }
409         if (error) {
410                 sprintf(string, "loop %d: error for bits 0x%x",
411                         loop, error);
412                 return TEST_FAILED;
413         }
414         sprintf(string, "no error for %d loops", loop);
415         return TEST_PASSED;
416 }
417
418 static enum test_result test_databus(struct stm32mp1_ddrctl *ctl,
419                                      struct stm32mp1_ddrphy *phy,
420                                      char *string, int argc, char *argv[])
421 {
422         u32 addr;
423         u32 error;
424
425         if (get_addr(string, argc, argv, 0, &addr))
426                 return TEST_ERROR;
427         error = databus((u32 *)addr);
428         if (error) {
429                 sprintf(string, "0x%x: error for bits 0x%x",
430                         addr, error);
431                 return TEST_FAILED;
432         }
433         sprintf(string, "address 0x%x", addr);
434         return TEST_PASSED;
435 }
436
437 static enum test_result test_addressbus(struct stm32mp1_ddrctl *ctl,
438                                         struct stm32mp1_ddrphy *phy,
439                                         char *string, int argc, char *argv[])
440 {
441         u32 addr;
442         u32 bufsize;
443         u32 error;
444
445         if (get_bufsize(string, argc, argv, 0, &bufsize, STM32_DDR_SIZE, 4))
446                 return TEST_ERROR;
447         if (!is_power_of_2(bufsize)) {
448                 sprintf(string, "size 0x%x is not a power of 2",
449                         (u32)bufsize);
450                 return TEST_ERROR;
451         }
452         if (get_addr(string, argc, argv, 1, &addr))
453                 return TEST_ERROR;
454
455         printf("running at 0x%08x length 0x%x\n", addr, bufsize);
456         error = (u32)addressbus((u32 *)addr, bufsize);
457         if (error) {
458                 sprintf(string, "0x%x: error for address 0x%x",
459                         addr, error);
460                 return TEST_FAILED;
461         }
462         sprintf(string, "address 0x%x, size 0x%x",
463                 addr, bufsize);
464         return TEST_PASSED;
465 }
466
467 static enum test_result test_memdevice(struct stm32mp1_ddrctl *ctl,
468                                        struct stm32mp1_ddrphy *phy,
469                                        char *string, int argc, char *argv[])
470 {
471         u32 addr;
472         size_t bufsize;
473         u32 error;
474
475         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
476                 return TEST_ERROR;
477         if (get_addr(string, argc, argv, 1, &addr))
478                 return TEST_ERROR;
479         error = (u32)memdevice((u32 *)addr, (unsigned long)bufsize);
480         if (error) {
481                 sprintf(string, "0x%x: error for address 0x%x",
482                         addr, error);
483                 return TEST_FAILED;
484         }
485         sprintf(string, "address 0x%x, size 0x%x",
486                 addr, bufsize);
487         return TEST_PASSED;
488 }
489
490 /**********************************************************************
491  *
492  * Function:    sso
493  *
494  * Description: Test the Simultaneous Switching Output.
495  *              Verifies succes sive reads and writes to the same memory word,
496  *              holding one bit constant while toggling all other data bits
497  *              simultaneously
498  *              => stress the data bus over an address range
499  *
500  *              The CPU writes to each address in the given range.
501  *              For each bit, first the CPU holds the bit at 1 while
502  *              toggling the other bits, and then the CPU holds the bit at 0
503  *              while toggling the other bits.
504  *              After each write, the CPU reads the address that was written
505  *              to verify that it contains the correct data
506  *
507  **********************************************************************/
508 static enum test_result test_sso(struct stm32mp1_ddrctl *ctl,
509                                  struct stm32mp1_ddrphy *phy,
510                                  char *string, int argc, char *argv[])
511 {
512         int i, j;
513         u32 addr, bufsize, remaining, offset;
514         u32 error = 0;
515         u32 data;
516
517         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
518                 return TEST_ERROR;
519         if (get_addr(string, argc, argv, 1, &addr))
520                 return TEST_ERROR;
521
522         printf("running sso at 0x%x length 0x%x", addr, bufsize);
523         offset = addr;
524         remaining = bufsize;
525         while (remaining) {
526                 for (i = 0; i < 32; i++) {
527                         /* write pattern. */
528                         for (j = 0; j < 6; j++) {
529                                 switch (j) {
530                                 case 0:
531                                 case 2:
532                                         data = 1 << i;
533                                         break;
534                                 case 3:
535                                 case 5:
536                                         data = ~(1 << i);
537                                         break;
538                                 case 1:
539                                         data = ~0x0;
540                                         break;
541                                 case 4:
542                                         data = 0x0;
543                                         break;
544                                 }
545
546                                 writel(data, offset);
547                                 error = check_addr(offset, data);
548                                 if (error)
549                                         goto end;
550                         }
551                 }
552                 offset += 4;
553                 remaining -= 4;
554                 if (progress(offset << 7))
555                         goto end;
556         }
557         puts("\n");
558
559 end:
560         if (error) {
561                 sprintf(string, "error for pattern 0x%x @0x%x",
562                         data, offset);
563                 return TEST_FAILED;
564         }
565         sprintf(string, "no error for sso at 0x%x length 0x%x", addr, bufsize);
566         return TEST_PASSED;
567 }
568
569 /**********************************************************************
570  *
571  * Function:    Random
572  *
573  * Description: Verifies r/w with pseudo-ramdom value on one region
574  *              + write the region (individual access)
575  *              + memcopy to the 2nd region (try to use burst)
576  *              + verify the 2 regions
577  *
578  **********************************************************************/
579 static enum test_result test_random(struct stm32mp1_ddrctl *ctl,
580                                     struct stm32mp1_ddrphy *phy,
581                                     char *string, int argc, char *argv[])
582 {
583         u32 addr, offset, value = 0;
584         size_t bufsize;
585         u32 loop = 0, nb_loop;
586         u32 error = 0;
587         unsigned int seed;
588
589         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 8))
590                 return TEST_ERROR;
591         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
592                 return TEST_ERROR;
593         if (get_addr(string, argc, argv, 2, &addr))
594                 return TEST_ERROR;
595
596         bufsize /= 2;
597         printf("running %d loops copy from 0x%x to 0x%x (buffer size=0x%x)\n",
598                nb_loop, addr, addr + bufsize, bufsize);
599         while (!error) {
600                 seed = rand();
601                 for (offset = 0; offset < bufsize; offset += 4)
602                         writel(rand(), addr + offset);
603
604                 memcpy((void *)addr + bufsize, (void *)addr, bufsize);
605
606                 srand(seed);
607                 for (offset = 0; offset < 2 * bufsize; offset += 4) {
608                         if (offset == bufsize)
609                                 srand(seed);
610                         value = rand();
611                         error = check_addr(addr + offset, value);
612                         if (error)
613                                 break;
614                         if (progress(offset))
615                                 return TEST_FAILED;
616                 }
617                 if (test_loop_end(&loop, nb_loop, 100))
618                         break;
619         }
620         putc('\n');
621
622         if (error) {
623                 sprintf(string,
624                         "loop %d: error for address 0x%x: 0x%x expected 0x%x",
625                         loop, offset, readl(offset), value);
626                 return TEST_FAILED;
627         }
628         sprintf(string, "no error for %d loops, size 0x%x",
629                 loop, bufsize);
630         return TEST_PASSED;
631 }
632
633 /**********************************************************************
634  *
635  * Function:    noise
636  *
637  * Description: Verifies r/w while forcing switching of all data bus lines.
638  *              optimised 4 iteration write/read/write/read cycles...
639  *              for pattern and inversed pattern
640  *
641  **********************************************************************/
642 void do_noise(u32 addr, u32 pattern, u32 *result)
643 {
644         __asm__("push {R0-R11}");
645         __asm__("mov r0, %0" : : "r" (addr));
646         __asm__("mov r1, %0" : : "r" (pattern));
647         __asm__("mov r11, %0" : : "r" (result));
648
649         __asm__("mvn r2, r1");
650
651         __asm__("str r1, [r0]");
652         __asm__("ldr r3, [r0]");
653         __asm__("str r2, [r0]");
654         __asm__("ldr r4, [r0]");
655
656         __asm__("str r1, [r0]");
657         __asm__("ldr r5, [r0]");
658         __asm__("str r2, [r0]");
659         __asm__("ldr r6, [r0]");
660
661         __asm__("str r1, [r0]");
662         __asm__("ldr r7, [r0]");
663         __asm__("str r2, [r0]");
664         __asm__("ldr r8, [r0]");
665
666         __asm__("str r1, [r0]");
667         __asm__("ldr r9, [r0]");
668         __asm__("str r2, [r0]");
669         __asm__("ldr r10, [r0]");
670
671         __asm__("stmia R11!, {R3-R10}");
672
673         __asm__("pop {R0-R11}");
674 }
675
676 static enum test_result test_noise(struct stm32mp1_ddrctl *ctl,
677                                    struct stm32mp1_ddrphy *phy,
678                                    char *string, int argc, char *argv[])
679 {
680         u32 addr, pattern;
681         u32 result[8];
682         int i;
683         enum test_result res = TEST_PASSED;
684
685         if (get_pattern(string, argc, argv, 0, &pattern, 0xFFFFFFFF))
686                 return TEST_ERROR;
687         if (get_addr(string, argc, argv, 1, &addr))
688                 return TEST_ERROR;
689
690         printf("running noise for 0x%x at 0x%x\n", pattern, addr);
691
692         do_noise(addr, pattern, result);
693
694         for (i = 0; i < 0x8;) {
695                 if (check_addr((u32)&result[i++], pattern))
696                         res = TEST_FAILED;
697                 if (check_addr((u32)&result[i++], ~pattern))
698                         res = TEST_FAILED;
699         }
700
701         return res;
702 }
703
704 /**********************************************************************
705  *
706  * Function:    noise_burst
707  *
708  * Description: Verifies r/w while forcing switching of all data bus lines.
709  *              optimised write loop witrh store multiple to use burst
710  *              for pattern and inversed pattern
711  *
712  **********************************************************************/
713 void do_noise_burst(u32 addr, u32 pattern, size_t bufsize)
714 {
715         __asm__("push {R0-R9}");
716         __asm__("mov r0, %0" : : "r" (addr));
717         __asm__("mov r1, %0" : : "r" (pattern));
718         __asm__("mov r9, %0" : : "r" (bufsize));
719
720         __asm__("mvn r2, r1");
721         __asm__("mov r3, r1");
722         __asm__("mov r4, r2");
723         __asm__("mov r5, r1");
724         __asm__("mov r6, r2");
725         __asm__("mov r7, r1");
726         __asm__("mov r8, r2");
727
728         __asm__("loop1:");
729         __asm__("stmia R0!, {R1-R8}");
730         __asm__("stmia R0!, {R1-R8}");
731         __asm__("stmia R0!, {R1-R8}");
732         __asm__("stmia R0!, {R1-R8}");
733         __asm__("subs r9, r9, #128");
734         __asm__("bge loop1");
735         __asm__("pop {R0-R9}");
736 }
737
738 /* chunk size enough to allow interruption with Ctrl-C*/
739 #define CHUNK_SIZE      0x8000000
740 static enum test_result test_noise_burst(struct stm32mp1_ddrctl *ctl,
741                                          struct stm32mp1_ddrphy *phy,
742                                          char *string, int argc, char *argv[])
743 {
744         u32 addr, offset, pattern;
745         size_t bufsize, remaining, size;
746         int i;
747         enum test_result res = TEST_PASSED;
748
749         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 128))
750                 return TEST_ERROR;
751         if (get_pattern(string, argc, argv, 1, &pattern, 0xFFFFFFFF))
752                 return TEST_ERROR;
753         if (get_addr(string, argc, argv, 2, &addr))
754                 return TEST_ERROR;
755
756         printf("running noise burst for 0x%x at 0x%x + 0x%x",
757                pattern, addr, bufsize);
758
759         offset = addr;
760         remaining = bufsize;
761         size = CHUNK_SIZE;
762         while (remaining) {
763                 if (remaining < size)
764                         size = remaining;
765                 do_noise_burst(offset, pattern, size);
766                 remaining -= size;
767                 offset += size;
768                 if (progress(offset)) {
769                         res = TEST_FAILED;
770                         goto end;
771                 }
772         }
773         puts("\ncheck buffer");
774         for (i = 0; i < bufsize;) {
775                 if (check_addr(addr + i, pattern))
776                         res = TEST_FAILED;
777                 i += 4;
778                 if (check_addr(addr + i, ~pattern))
779                         res = TEST_FAILED;
780                 i += 4;
781                 if (progress(i)) {
782                         res = TEST_FAILED;
783                         goto end;
784                 }
785         }
786 end:
787         puts("\n");
788         return res;
789 }
790
791 /**********************************************************************
792  *
793  * Function:    pattern test
794  *
795  * Description: optimized loop for read/write pattern (array of 8 u32)
796  *
797  **********************************************************************/
798 #define PATTERN_SIZE    8
799 static enum test_result test_loop(const u32 *pattern, u32 *address,
800                                   const u32 bufsize)
801 {
802         int i;
803         int j;
804         enum test_result res = TEST_PASSED;
805         u32 offset, testsize, remaining;
806
807         offset = (u32)address;
808         remaining = bufsize;
809         while (remaining) {
810                 testsize = bufsize > 0x1000000 ? 0x1000000 : bufsize;
811
812                 __asm__("push {R0-R10}");
813                 __asm__("mov r0, %0" : : "r" (pattern));
814                 __asm__("mov r1, %0" : : "r" (offset));
815                 __asm__("mov r2, %0" : : "r" (testsize));
816                 __asm__("ldmia r0!, {R3-R10}");
817
818                 __asm__("loop2:");
819                 __asm__("stmia r1!, {R3-R10}");
820                 __asm__("stmia r1!, {R3-R10}");
821                 __asm__("stmia r1!, {R3-R10}");
822                 __asm__("stmia r1!, {R3-R10}");
823                 __asm__("subs r2, r2, #128");
824                 __asm__("bge loop2");
825                 __asm__("pop {R0-R10}");
826
827                 offset += testsize;
828                 remaining -= testsize;
829                 if (progress((u32)offset)) {
830                         res = TEST_FAILED;
831                         goto end;
832                 }
833         }
834
835         puts("\ncheck buffer");
836         for (i = 0; i < bufsize; i += PATTERN_SIZE * 4) {
837                 for (j = 0; j < PATTERN_SIZE; j++, address++)
838                         if (check_addr((u32)address, pattern[j])) {
839                                 res = TEST_FAILED;
840                                 goto end;
841                         }
842                 if (progress(i)) {
843                         res = TEST_FAILED;
844                         goto end;
845                 }
846         }
847
848 end:
849         puts("\n");
850         return res;
851 }
852
853 const u32 pattern_div1_x16[PATTERN_SIZE] = {
854         0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF,
855         0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF
856 };
857
858 const u32 pattern_div2_x16[PATTERN_SIZE] = {
859         0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
860         0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000
861 };
862
863 const u32 pattern_div4_x16[PATTERN_SIZE] = {
864         0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
865         0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000
866 };
867
868 const u32 pattern_div4_x32[PATTERN_SIZE] = {
869         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
870         0x00000000, 0x00000000, 0x00000000, 0x00000000
871 };
872
873 const u32 pattern_mostly_zero_x16[PATTERN_SIZE] = {
874         0x00000000, 0x00000000, 0x00000000, 0x0000FFFF,
875         0x00000000, 0x00000000, 0x00000000, 0x00000000
876 };
877
878 const u32 pattern_mostly_zero_x32[PATTERN_SIZE] = {
879         0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF,
880         0x00000000, 0x00000000, 0x00000000, 0x00000000
881 };
882
883 const u32 pattern_mostly_one_x16[PATTERN_SIZE] = {
884         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF,
885         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
886 };
887
888 const u32 pattern_mostly_one_x32[PATTERN_SIZE] = {
889         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
890         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
891 };
892
893 #define NB_PATTERN      5
894 static enum test_result test_freq_pattern(struct stm32mp1_ddrctl *ctl,
895                                           struct stm32mp1_ddrphy *phy,
896                                           char *string, int argc, char *argv[])
897 {
898         const u32 * const patterns_x16[NB_PATTERN] = {
899                 pattern_div1_x16,
900                 pattern_div2_x16,
901                 pattern_div4_x16,
902                 pattern_mostly_zero_x16,
903                 pattern_mostly_one_x16,
904         };
905         const u32 * const patterns_x32[NB_PATTERN] = {
906                 pattern_div2_x16,
907                 pattern_div4_x16,
908                 pattern_div4_x32,
909                 pattern_mostly_zero_x32,
910                 pattern_mostly_one_x32
911         };
912         const char *patterns_comments[NB_PATTERN] = {
913                 "switching at frequency F/1",
914                 "switching at frequency F/2",
915                 "switching at frequency F/4",
916                 "mostly zero",
917                 "mostly one"
918         };
919
920         enum test_result res = TEST_PASSED, pattern_res;
921         int i, bus_width;
922         const u32 **patterns;
923         u32 bufsize, addr;
924
925         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 128))
926                 return TEST_ERROR;
927         if (get_addr(string, argc, argv, 1, &addr))
928                 return TEST_ERROR;
929
930         switch (readl(&ctl->mstr) & DDRCTRL_MSTR_DATA_BUS_WIDTH_MASK) {
931         case DDRCTRL_MSTR_DATA_BUS_WIDTH_HALF:
932         case DDRCTRL_MSTR_DATA_BUS_WIDTH_QUARTER:
933                 bus_width = 16;
934                 break;
935         default:
936                 bus_width = 32;
937                 break;
938         }
939
940         printf("running test pattern at 0x%08x length 0x%x width = %d\n",
941                addr, bufsize, bus_width);
942
943         patterns =
944                 (const u32 **)(bus_width == 16 ? patterns_x16 : patterns_x32);
945
946         for (i = 0; i < NB_PATTERN; i++) {
947                 printf("test data pattern %s:", patterns_comments[i]);
948                 pattern_res = test_loop(patterns[i], (u32 *)addr, bufsize);
949                 if (pattern_res != TEST_PASSED) {
950                         printf("Failed\n");
951                         return pattern_res;
952                 }
953                 printf("Passed\n");
954         }
955
956         return res;
957 }
958
959 /**********************************************************************
960  *
961  * Function:    pattern test with size
962  *
963  * Description: loop for write pattern
964  *
965  **********************************************************************/
966
967 static enum test_result test_loop_size(const u32 *pattern, u32 size,
968                                        u32 *address,
969                                        const u32 bufsize)
970 {
971         int i, j;
972         enum test_result res = TEST_PASSED;
973         u32 *p = address;
974
975         for (i = 0; i < bufsize; i += size * 4) {
976                 for (j = 0; j < size ; j++, p++)
977                         *p = pattern[j];
978                 if (progress(i)) {
979                         res = TEST_FAILED;
980                         goto end;
981                 }
982         }
983
984         puts("\ncheck buffer");
985         p = address;
986         for (i = 0; i < bufsize; i += size * 4) {
987                 for (j = 0; j < size; j++, p++)
988                         if (check_addr((u32)p, pattern[j])) {
989                                 res = TEST_FAILED;
990                                 goto end;
991                         }
992                 if (progress(i)) {
993                         res = TEST_FAILED;
994                         goto end;
995                 }
996         }
997
998 end:
999         puts("\n");
1000         return res;
1001 }
1002
1003 static enum test_result test_checkboard(struct stm32mp1_ddrctl *ctl,
1004                                         struct stm32mp1_ddrphy *phy,
1005                                         char *string, int argc, char *argv[])
1006 {
1007         enum test_result res = TEST_PASSED;
1008         u32 bufsize, nb_loop, loop = 0, addr;
1009         int i;
1010
1011         u32 checkboard[2] = {0x55555555, 0xAAAAAAAA};
1012
1013         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 8))
1014                 return TEST_ERROR;
1015         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1016                 return TEST_ERROR;
1017         if (get_addr(string, argc, argv, 2, &addr))
1018                 return TEST_ERROR;
1019
1020         printf("running %d loops at 0x%08x length 0x%x\n",
1021                nb_loop, addr, bufsize);
1022         while (1) {
1023                 for (i = 0; i < 2; i++) {
1024                         res = test_loop_size(checkboard, 2, (u32 *)addr,
1025                                              bufsize);
1026                         if (res)
1027                                 return res;
1028                         checkboard[0] = ~checkboard[0];
1029                         checkboard[1] = ~checkboard[1];
1030                 }
1031                 if (test_loop_end(&loop, nb_loop, 1))
1032                         break;
1033         }
1034         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1035                 loop, addr, bufsize);
1036
1037         return res;
1038 }
1039
1040 static enum test_result test_blockseq(struct stm32mp1_ddrctl *ctl,
1041                                       struct stm32mp1_ddrphy *phy,
1042                                       char *string, int argc, char *argv[])
1043 {
1044         enum test_result res = TEST_PASSED;
1045         u32 bufsize, nb_loop, loop = 0, addr, value;
1046         int i;
1047
1048         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1049                 return TEST_ERROR;
1050         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1051                 return TEST_ERROR;
1052         if (get_addr(string, argc, argv, 2, &addr))
1053                 return TEST_ERROR;
1054
1055         printf("running %d loops at 0x%08x length 0x%x\n",
1056                nb_loop, addr, bufsize);
1057         while (1) {
1058                 for (i = 0; i < 256; i++) {
1059                         value = i | i << 8 | i << 16 | i << 24;
1060                         printf("pattern = %08x", value);
1061                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1062                         if (res != TEST_PASSED)
1063                                 return res;
1064                 }
1065                 if (test_loop_end(&loop, nb_loop, 1))
1066                         break;
1067         }
1068         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1069                 loop, addr, bufsize);
1070
1071         return res;
1072 }
1073
1074 static enum test_result test_walkbit0(struct stm32mp1_ddrctl *ctl,
1075                                       struct stm32mp1_ddrphy *phy,
1076                                       char *string, int argc, char *argv[])
1077 {
1078         enum test_result res = TEST_PASSED;
1079         u32 bufsize, nb_loop, loop = 0, addr, value;
1080         int i;
1081
1082         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1083                 return TEST_ERROR;
1084         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1085                 return TEST_ERROR;
1086         if (get_addr(string, argc, argv, 2, &addr))
1087                 return TEST_ERROR;
1088
1089         printf("running %d loops at 0x%08x length 0x%x\n",
1090                nb_loop, addr, bufsize);
1091         while (1) {
1092                 for (i = 0; i < 64; i++) {
1093                         if (i < 32)
1094                                 value = 1 << i;
1095                         else
1096                                 value = 1 << (63 - i);
1097
1098                         printf("pattern = %08x", value);
1099                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1100                         if (res != TEST_PASSED)
1101                                 return res;
1102                 }
1103                 if (test_loop_end(&loop, nb_loop, 1))
1104                         break;
1105         }
1106         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1107                 loop, addr, bufsize);
1108
1109         return res;
1110 }
1111
1112 static enum test_result test_walkbit1(struct stm32mp1_ddrctl *ctl,
1113                                       struct stm32mp1_ddrphy *phy,
1114                                       char *string, int argc, char *argv[])
1115 {
1116         enum test_result res = TEST_PASSED;
1117         u32 bufsize, nb_loop, loop = 0, addr, value;
1118         int i;
1119
1120         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1121                 return TEST_ERROR;
1122         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1123                 return TEST_ERROR;
1124         if (get_addr(string, argc, argv, 2, &addr))
1125                 return TEST_ERROR;
1126
1127         printf("running %d loops at 0x%08x length 0x%x\n",
1128                nb_loop, addr, bufsize);
1129         while (1) {
1130                 for (i = 0; i < 64; i++) {
1131                         if (i < 32)
1132                                 value = ~(1 << i);
1133                         else
1134                                 value = ~(1 << (63 - i));
1135
1136                         printf("pattern = %08x", value);
1137                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1138                         if (res != TEST_PASSED)
1139                                 return res;
1140                 }
1141                 if (test_loop_end(&loop, nb_loop, 1))
1142                         break;
1143         }
1144         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1145                 loop, addr, bufsize);
1146
1147         return res;
1148 }
1149
1150 /*
1151  * try to catch bad bits which are dependent on the current values of
1152  * surrounding bits in either the same word32
1153  */
1154 static enum test_result test_bitspread(struct stm32mp1_ddrctl *ctl,
1155                                        struct stm32mp1_ddrphy *phy,
1156                                        char *string, int argc, char *argv[])
1157 {
1158         enum test_result res = TEST_PASSED;
1159         u32 bufsize, nb_loop, loop = 0, addr, bitspread[4];
1160         int i, j;
1161
1162         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 32))
1163                 return TEST_ERROR;
1164         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1165                 return TEST_ERROR;
1166         if (get_addr(string, argc, argv, 2, &addr))
1167                 return TEST_ERROR;
1168
1169         printf("running %d loops at 0x%08x length 0x%x\n",
1170                nb_loop, addr, bufsize);
1171         while (1) {
1172                 for (i = 1; i < 32; i++) {
1173                         for (j = 0; j < i; j++) {
1174                                 if (i < 32)
1175                                         bitspread[0] = (1 << i) | (1 << j);
1176                                 else
1177                                         bitspread[0] = (1 << (63 - i)) |
1178                                                        (1 << (63 - j));
1179                                 bitspread[1] = bitspread[0];
1180                                 bitspread[2] = ~bitspread[0];
1181                                 bitspread[3] = ~bitspread[0];
1182                                 printf("pattern = %08x", bitspread[0]);
1183
1184                                 res = test_loop_size(bitspread, 4, (u32 *)addr,
1185                                                      bufsize);
1186                                 if (res != TEST_PASSED)
1187                                         return res;
1188                         }
1189                 }
1190                 if (test_loop_end(&loop, nb_loop, 1))
1191                         break;
1192         }
1193         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1194                 loop, addr, bufsize);
1195
1196         return res;
1197 }
1198
1199 static enum test_result test_bitflip(struct stm32mp1_ddrctl *ctl,
1200                                      struct stm32mp1_ddrphy *phy,
1201                                      char *string, int argc, char *argv[])
1202 {
1203         enum test_result res = TEST_PASSED;
1204         u32 bufsize, nb_loop, loop = 0, addr;
1205         int i;
1206
1207         u32 bitflip[4];
1208
1209         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 32))
1210                 return TEST_ERROR;
1211         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1212                 return TEST_ERROR;
1213         if (get_addr(string, argc, argv, 2, &addr))
1214                 return TEST_ERROR;
1215
1216         printf("running %d loops at 0x%08x length 0x%x\n",
1217                nb_loop, addr, bufsize);
1218         while (1) {
1219                 for (i = 0; i < 32; i++) {
1220                         bitflip[0] = 1 << i;
1221                         bitflip[1] = bitflip[0];
1222                         bitflip[2] = ~bitflip[0];
1223                         bitflip[3] = bitflip[2];
1224                         printf("pattern = %08x", bitflip[0]);
1225
1226                         res = test_loop_size(bitflip, 4, (u32 *)addr, bufsize);
1227                         if (res != TEST_PASSED)
1228                                 return res;
1229                 }
1230                 if (test_loop_end(&loop, nb_loop, 1))
1231                         break;
1232         }
1233         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1234                 loop, addr, bufsize);
1235
1236         return res;
1237 }
1238
1239 /**********************************************************************
1240  *
1241  * Function: infinite read access to DDR
1242  *
1243  * Description: continuous read the same pattern at the same address
1244  *
1245  **********************************************************************/
1246 static enum test_result test_read(struct stm32mp1_ddrctl *ctl,
1247                                   struct stm32mp1_ddrphy *phy,
1248                                   char *string, int argc, char *argv[])
1249 {
1250         u32 *addr;
1251         u32 data;
1252         u32 loop = 0;
1253         int i, size = 1024 * 1024;
1254         bool random = false;
1255
1256         if (get_addr(string, argc, argv, 0, (u32 *)&addr))
1257                 return TEST_ERROR;
1258
1259         if (get_pattern(string, argc, argv, 1, &data, 0xA5A5AA55))
1260                 return TEST_ERROR;
1261
1262         if ((u32)addr == ADDR_INVALID) {
1263                 printf("running random\n");
1264                 random = true;
1265         } else {
1266                 printf("running at 0x%08x with pattern=0x%08x\n",
1267                        (u32)addr, data);
1268                 writel(data, addr);
1269         }
1270
1271         while (1) {
1272                 for (i = 0; i < size; i++) {
1273                         if (random)
1274                                 addr = (u32 *)(STM32_DDR_BASE +
1275                                        (rand() & (STM32_DDR_SIZE - 1) & ~0x3));
1276                         data = readl(addr);
1277                 }
1278                 if (test_loop_end(&loop, 0, 1))
1279                         break;
1280         }
1281         if (random)
1282                 sprintf(string, "%d loops random", loop);
1283         else
1284                 sprintf(string, "%d loops at 0x%x: %x", loop, (u32)addr, data);
1285
1286         return TEST_PASSED;
1287 }
1288
1289 /**********************************************************************
1290  *
1291  * Function: infinite write access to DDR
1292  *
1293  * Description: continuous write the same pattern at the same address
1294  *
1295  **********************************************************************/
1296 static enum test_result test_write(struct stm32mp1_ddrctl *ctl,
1297                                    struct stm32mp1_ddrphy *phy,
1298                                    char *string, int argc, char *argv[])
1299 {
1300         u32 *addr;
1301         u32 data;
1302         u32 loop = 0;
1303         int i, size = 1024 * 1024;
1304         bool random = false;
1305
1306         if (get_addr(string, argc, argv, 0, (u32 *)&addr))
1307                 return TEST_ERROR;
1308
1309         if (get_pattern(string, argc, argv, 1, &data, 0xA5A5AA55))
1310                 return TEST_ERROR;
1311
1312         if ((u32)addr == ADDR_INVALID) {
1313                 printf("running random\n");
1314                 random = true;
1315         } else {
1316                 printf("running at 0x%08x with pattern 0x%08x\n",
1317                        (u32)addr, data);
1318         }
1319
1320         while (1) {
1321                 for (i = 0; i < size; i++) {
1322                         if (random) {
1323                                 addr = (u32 *)(STM32_DDR_BASE +
1324                                        (rand() & (STM32_DDR_SIZE - 1) & ~0x3));
1325                                 data = rand();
1326                         }
1327                         writel(data, addr);
1328                 }
1329                 if (test_loop_end(&loop, 0, 1))
1330                         break;
1331         }
1332         if (random)
1333                 sprintf(string, "%d loops random", loop);
1334         else
1335                 sprintf(string, "%d loops at 0x%x: %x", loop, (u32)addr, data);
1336
1337         return TEST_PASSED;
1338 }
1339
1340 #define NB_TEST_INFINITE 2
1341 static enum test_result test_all(struct stm32mp1_ddrctl *ctl,
1342                                  struct stm32mp1_ddrphy *phy,
1343                                  char *string, int argc, char *argv[])
1344 {
1345         enum test_result res = TEST_PASSED, result;
1346         int i, nb_error = 0;
1347         u32 loop = 0, nb_loop;
1348
1349         if (get_nb_loop(string, argc, argv, 0, &nb_loop, 1))
1350                 return TEST_ERROR;
1351
1352         while (!nb_error) {
1353                 /* execute all the test except the lasts which are infinite */
1354                 for (i = 1; i < test_nb - NB_TEST_INFINITE; i++) {
1355                         printf("execute %d:%s\n", (int)i, test[i].name);
1356                         result = test[i].fct(ctl, phy, string, 0, NULL);
1357                         printf("result %d:%s = ", (int)i, test[i].name);
1358                         if (result != TEST_PASSED) {
1359                                 nb_error++;
1360                                 res = TEST_FAILED;
1361                                 puts("Failed");
1362                         } else {
1363                                 puts("Passed");
1364                         }
1365                         puts("\n\n");
1366                 }
1367                 printf("loop %d: %d/%d test failed\n\n\n",
1368                        loop + 1, nb_error, test_nb - NB_TEST_INFINITE);
1369                 if (test_loop_end(&loop, nb_loop, 1))
1370                         break;
1371         }
1372         if (res != TEST_PASSED) {
1373                 sprintf(string, "loop %d: %d/%d test failed", loop, nb_error,
1374                         test_nb - NB_TEST_INFINITE);
1375         } else {
1376                 sprintf(string, "loop %d: %d tests passed", loop,
1377                         test_nb - NB_TEST_INFINITE);
1378         }
1379         return res;
1380 }
1381
1382 /****************************************************************
1383  * TEST Description
1384  ****************************************************************/
1385
1386 const struct test_desc test[] = {
1387         {test_all, "All", "[loop]", "Execute all tests", 1 },
1388         {test_databus, "Simple DataBus", "[addr]",
1389          "Verifies each data line by walking 1 on fixed address",
1390          1
1391          },
1392         {databuswalk0, "DataBusWalking0", "[loop] [addr]",
1393          "Verifies each data bus signal can be driven low (32 word burst)",
1394          2
1395         },
1396         {databuswalk1, "DataBusWalking1", "[loop] [addr]",
1397          "Verifies each data bus signal can be driven high (32 word burst)",
1398          2
1399         },
1400         {test_addressbus, "AddressBus", "[size] [addr]",
1401          "Verifies each relevant bits of the address and checking for aliasing",
1402          2
1403          },
1404         {test_memdevice, "MemDevice", "[size] [addr]",
1405          "Test the integrity of a physical memory (test every storage bit in the region)",
1406          2
1407          },
1408         {test_sso, "SimultaneousSwitchingOutput", "[size] [addr] ",
1409          "Stress the data bus over an address range",
1410          2
1411         },
1412         {test_noise, "Noise", "[pattern] [addr]",
1413          "Verifies r/w while forcing switching of all data bus lines.",
1414          3
1415         },
1416         {test_noise_burst, "NoiseBurst", "[size] [pattern] [addr]",
1417          "burst transfers while forcing switching of the data bus lines",
1418          3
1419         },
1420         {test_random, "Random", "[size] [loop] [addr]",
1421          "Verifies r/w and memcopy(burst for pseudo random value.",
1422          3
1423         },
1424         {test_freq_pattern, "FrequencySelectivePattern", "[size] [addr]",
1425          "write & test patterns: Mostly Zero, Mostly One and F/n",
1426          2
1427         },
1428         {test_blockseq, "BlockSequential", "[size] [loop] [addr]",
1429          "test incremental pattern",
1430          3
1431         },
1432         {test_checkboard, "Checkerboard", "[size] [loop] [addr]",
1433          "test checker pattern",
1434          3
1435         },
1436         {test_bitspread, "BitSpread", "[size] [loop] [addr]",
1437          "test Bit Spread pattern",
1438          3
1439         },
1440         {test_bitflip, "BitFlip", "[size] [loop] [addr]",
1441          "test Bit Flip pattern",
1442          3
1443         },
1444         {test_walkbit0, "WalkingOnes", "[size] [loop] [addr]",
1445          "test Walking Ones pattern",
1446          3
1447         },
1448         {test_walkbit1, "WalkingZeroes", "[size] [loop] [addr]",
1449          "test Walking Zeroes pattern",
1450          3
1451         },
1452         /* need to the the 2 last one (infinite) : skipped for test all */
1453         {test_read, "infinite read", "[addr] [pattern]",
1454          "basic test : infinite read access (random: addr=0xFFFFFFFF)", 2},
1455         {test_write, "infinite write", "[addr] [pattern]",
1456          "basic test : infinite write access (random: addr=0xFFFFFFFF)", 2},
1457 };
1458
1459 const int test_nb = ARRAY_SIZE(test);