ram: stm32mp1: add parameter addr in test FrequencySelectivePattern
[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, 4 * 1024, 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         error = (u32)addressbus((u32 *)addr, bufsize);
456         if (error) {
457                 sprintf(string, "0x%x: error for address 0x%x",
458                         addr, error);
459                 return TEST_FAILED;
460         }
461         sprintf(string, "address 0x%x, size 0x%x",
462                 addr, bufsize);
463         return TEST_PASSED;
464 }
465
466 static enum test_result test_memdevice(struct stm32mp1_ddrctl *ctl,
467                                        struct stm32mp1_ddrphy *phy,
468                                        char *string, int argc, char *argv[])
469 {
470         u32 addr;
471         size_t bufsize;
472         u32 error;
473
474         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
475                 return TEST_ERROR;
476         if (get_addr(string, argc, argv, 1, &addr))
477                 return TEST_ERROR;
478         error = (u32)memdevice((u32 *)addr, (unsigned long)bufsize);
479         if (error) {
480                 sprintf(string, "0x%x: error for address 0x%x",
481                         addr, error);
482                 return TEST_FAILED;
483         }
484         sprintf(string, "address 0x%x, size 0x%x",
485                 addr, bufsize);
486         return TEST_PASSED;
487 }
488
489 /**********************************************************************
490  *
491  * Function:    sso
492  *
493  * Description: Test the Simultaneous Switching Output.
494  *              Verifies succes sive reads and writes to the same memory word,
495  *              holding one bit constant while toggling all other data bits
496  *              simultaneously
497  *              => stress the data bus over an address range
498  *
499  *              The CPU writes to each address in the given range.
500  *              For each bit, first the CPU holds the bit at 1 while
501  *              toggling the other bits, and then the CPU holds the bit at 0
502  *              while toggling the other bits.
503  *              After each write, the CPU reads the address that was written
504  *              to verify that it contains the correct data
505  *
506  **********************************************************************/
507 static enum test_result test_sso(struct stm32mp1_ddrctl *ctl,
508                                  struct stm32mp1_ddrphy *phy,
509                                  char *string, int argc, char *argv[])
510 {
511         int i, j;
512         u32 addr, bufsize, remaining, offset;
513         u32 error = 0;
514         u32 data;
515
516         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
517                 return TEST_ERROR;
518         if (get_addr(string, argc, argv, 1, &addr))
519                 return TEST_ERROR;
520
521         printf("running sso at 0x%x length 0x%x", addr, bufsize);
522         offset = addr;
523         remaining = bufsize;
524         while (remaining) {
525                 for (i = 0; i < 32; i++) {
526                         /* write pattern. */
527                         for (j = 0; j < 6; j++) {
528                                 switch (j) {
529                                 case 0:
530                                 case 2:
531                                         data = 1 << i;
532                                         break;
533                                 case 3:
534                                 case 5:
535                                         data = ~(1 << i);
536                                         break;
537                                 case 1:
538                                         data = ~0x0;
539                                         break;
540                                 case 4:
541                                         data = 0x0;
542                                         break;
543                                 }
544
545                                 writel(data, offset);
546                                 error = check_addr(offset, data);
547                                 if (error)
548                                         goto end;
549                         }
550                 }
551                 offset += 4;
552                 remaining -= 4;
553                 if (progress(offset << 7))
554                         goto end;
555         }
556         puts("\n");
557
558 end:
559         if (error) {
560                 sprintf(string, "error for pattern 0x%x @0x%x",
561                         data, offset);
562                 return TEST_FAILED;
563         }
564         sprintf(string, "no error for sso at 0x%x length 0x%x", addr, bufsize);
565         return TEST_PASSED;
566 }
567
568 /**********************************************************************
569  *
570  * Function:    Random
571  *
572  * Description: Verifies r/w with pseudo-ramdom value on one region
573  *              + write the region (individual access)
574  *              + memcopy to the 2nd region (try to use burst)
575  *              + verify the 2 regions
576  *
577  **********************************************************************/
578 static enum test_result test_random(struct stm32mp1_ddrctl *ctl,
579                                     struct stm32mp1_ddrphy *phy,
580                                     char *string, int argc, char *argv[])
581 {
582         u32 addr, offset, value = 0;
583         size_t bufsize;
584         u32 loop = 0, nb_loop;
585         u32 error = 0;
586         unsigned int seed;
587
588         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 8))
589                 return TEST_ERROR;
590         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
591                 return TEST_ERROR;
592         if (get_addr(string, argc, argv, 2, &addr))
593                 return TEST_ERROR;
594
595         bufsize /= 2;
596         printf("running %d loops copy from 0x%x to 0x%x (buffer size=0x%x)\n",
597                nb_loop, addr, addr + bufsize, bufsize);
598         while (!error) {
599                 seed = rand();
600                 for (offset = 0; offset < bufsize; offset += 4)
601                         writel(rand(), addr + offset);
602
603                 memcpy((void *)addr + bufsize, (void *)addr, bufsize);
604
605                 srand(seed);
606                 for (offset = 0; offset < 2 * bufsize; offset += 4) {
607                         if (offset == bufsize)
608                                 srand(seed);
609                         value = rand();
610                         error = check_addr(addr + offset, value);
611                         if (error)
612                                 break;
613                         if (progress(offset))
614                                 return TEST_FAILED;
615                 }
616                 if (test_loop_end(&loop, nb_loop, 100))
617                         break;
618         }
619         putc('\n');
620
621         if (error) {
622                 sprintf(string,
623                         "loop %d: error for address 0x%x: 0x%x expected 0x%x",
624                         loop, offset, readl(offset), value);
625                 return TEST_FAILED;
626         }
627         sprintf(string, "no error for %d loops, size 0x%x",
628                 loop, bufsize);
629         return TEST_PASSED;
630 }
631
632 /**********************************************************************
633  *
634  * Function:    noise
635  *
636  * Description: Verifies r/w while forcing switching of all data bus lines.
637  *              optimised 4 iteration write/read/write/read cycles...
638  *              for pattern and inversed pattern
639  *
640  **********************************************************************/
641 void do_noise(u32 addr, u32 pattern, u32 *result)
642 {
643         __asm__("push {R0-R11}");
644         __asm__("mov r0, %0" : : "r" (addr));
645         __asm__("mov r1, %0" : : "r" (pattern));
646         __asm__("mov r11, %0" : : "r" (result));
647
648         __asm__("mvn r2, r1");
649
650         __asm__("str r1, [r0]");
651         __asm__("ldr r3, [r0]");
652         __asm__("str r2, [r0]");
653         __asm__("ldr r4, [r0]");
654
655         __asm__("str r1, [r0]");
656         __asm__("ldr r5, [r0]");
657         __asm__("str r2, [r0]");
658         __asm__("ldr r6, [r0]");
659
660         __asm__("str r1, [r0]");
661         __asm__("ldr r7, [r0]");
662         __asm__("str r2, [r0]");
663         __asm__("ldr r8, [r0]");
664
665         __asm__("str r1, [r0]");
666         __asm__("ldr r9, [r0]");
667         __asm__("str r2, [r0]");
668         __asm__("ldr r10, [r0]");
669
670         __asm__("stmia R11!, {R3-R10}");
671
672         __asm__("pop {R0-R11}");
673 }
674
675 static enum test_result test_noise(struct stm32mp1_ddrctl *ctl,
676                                    struct stm32mp1_ddrphy *phy,
677                                    char *string, int argc, char *argv[])
678 {
679         u32 addr, pattern;
680         u32 result[8];
681         int i;
682         enum test_result res = TEST_PASSED;
683
684         if (get_pattern(string, argc, argv, 0, &pattern, 0xFFFFFFFF))
685                 return TEST_ERROR;
686         if (get_addr(string, argc, argv, 1, &addr))
687                 return TEST_ERROR;
688
689         printf("running noise for 0x%x at 0x%x\n", pattern, addr);
690
691         do_noise(addr, pattern, result);
692
693         for (i = 0; i < 0x8;) {
694                 if (check_addr((u32)&result[i++], pattern))
695                         res = TEST_FAILED;
696                 if (check_addr((u32)&result[i++], ~pattern))
697                         res = TEST_FAILED;
698         }
699
700         return res;
701 }
702
703 /**********************************************************************
704  *
705  * Function:    noise_burst
706  *
707  * Description: Verifies r/w while forcing switching of all data bus lines.
708  *              optimised write loop witrh store multiple to use burst
709  *              for pattern and inversed pattern
710  *
711  **********************************************************************/
712 void do_noise_burst(u32 addr, u32 pattern, size_t bufsize)
713 {
714         __asm__("push {R0-R9}");
715         __asm__("mov r0, %0" : : "r" (addr));
716         __asm__("mov r1, %0" : : "r" (pattern));
717         __asm__("mov r9, %0" : : "r" (bufsize));
718
719         __asm__("mvn r2, r1");
720         __asm__("mov r3, r1");
721         __asm__("mov r4, r2");
722         __asm__("mov r5, r1");
723         __asm__("mov r6, r2");
724         __asm__("mov r7, r1");
725         __asm__("mov r8, r2");
726
727         __asm__("loop1:");
728         __asm__("stmia R0!, {R1-R8}");
729         __asm__("stmia R0!, {R1-R8}");
730         __asm__("stmia R0!, {R1-R8}");
731         __asm__("stmia R0!, {R1-R8}");
732         __asm__("subs r9, r9, #128");
733         __asm__("bge loop1");
734         __asm__("pop {R0-R9}");
735 }
736
737 /* chunk size enough to allow interruption with Ctrl-C*/
738 #define CHUNK_SIZE      0x8000000
739 static enum test_result test_noise_burst(struct stm32mp1_ddrctl *ctl,
740                                          struct stm32mp1_ddrphy *phy,
741                                          char *string, int argc, char *argv[])
742 {
743         u32 addr, offset, pattern;
744         size_t bufsize, remaining, size;
745         int i;
746         enum test_result res = TEST_PASSED;
747
748         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 128))
749                 return TEST_ERROR;
750         if (get_pattern(string, argc, argv, 1, &pattern, 0xFFFFFFFF))
751                 return TEST_ERROR;
752         if (get_addr(string, argc, argv, 2, &addr))
753                 return TEST_ERROR;
754
755         printf("running noise burst for 0x%x at 0x%x + 0x%x",
756                pattern, addr, bufsize);
757
758         offset = addr;
759         remaining = bufsize;
760         size = CHUNK_SIZE;
761         while (remaining) {
762                 if (remaining < size)
763                         size = remaining;
764                 do_noise_burst(offset, pattern, size);
765                 remaining -= size;
766                 offset += size;
767                 if (progress(offset)) {
768                         res = TEST_FAILED;
769                         goto end;
770                 }
771         }
772         puts("\ncheck buffer");
773         for (i = 0; i < bufsize;) {
774                 if (check_addr(addr + i, pattern))
775                         res = TEST_FAILED;
776                 i += 4;
777                 if (check_addr(addr + i, ~pattern))
778                         res = TEST_FAILED;
779                 i += 4;
780                 if (progress(i)) {
781                         res = TEST_FAILED;
782                         goto end;
783                 }
784         }
785 end:
786         puts("\n");
787         return res;
788 }
789
790 /**********************************************************************
791  *
792  * Function:    pattern test
793  *
794  * Description: optimized loop for read/write pattern (array of 8 u32)
795  *
796  **********************************************************************/
797 #define PATTERN_SIZE    8
798 static enum test_result test_loop(const u32 *pattern, u32 *address,
799                                   const u32 bufsize)
800 {
801         int i;
802         int j;
803         enum test_result res = TEST_PASSED;
804         u32 offset, testsize, remaining;
805
806         offset = (u32)address;
807         remaining = bufsize;
808         while (remaining) {
809                 testsize = bufsize > 0x1000000 ? 0x1000000 : bufsize;
810
811                 __asm__("push {R0-R10}");
812                 __asm__("mov r0, %0" : : "r" (pattern));
813                 __asm__("mov r1, %0" : : "r" (offset));
814                 __asm__("mov r2, %0" : : "r" (testsize));
815                 __asm__("ldmia r0!, {R3-R10}");
816
817                 __asm__("loop2:");
818                 __asm__("stmia r1!, {R3-R10}");
819                 __asm__("stmia r1!, {R3-R10}");
820                 __asm__("stmia r1!, {R3-R10}");
821                 __asm__("stmia r1!, {R3-R10}");
822                 __asm__("subs r2, r2, #128");
823                 __asm__("bge loop2");
824                 __asm__("pop {R0-R10}");
825
826                 offset += testsize;
827                 remaining -= testsize;
828                 if (progress((u32)offset)) {
829                         res = TEST_FAILED;
830                         goto end;
831                 }
832         }
833
834         puts("\ncheck buffer");
835         for (i = 0; i < bufsize; i += PATTERN_SIZE * 4) {
836                 for (j = 0; j < PATTERN_SIZE; j++, address++)
837                         if (check_addr((u32)address, pattern[j])) {
838                                 res = TEST_FAILED;
839                                 goto end;
840                         }
841                 if (progress(i)) {
842                         res = TEST_FAILED;
843                         goto end;
844                 }
845         }
846
847 end:
848         puts("\n");
849         return res;
850 }
851
852 const u32 pattern_div1_x16[PATTERN_SIZE] = {
853         0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF,
854         0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF
855 };
856
857 const u32 pattern_div2_x16[PATTERN_SIZE] = {
858         0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
859         0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000
860 };
861
862 const u32 pattern_div4_x16[PATTERN_SIZE] = {
863         0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
864         0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000
865 };
866
867 const u32 pattern_div4_x32[PATTERN_SIZE] = {
868         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
869         0x00000000, 0x00000000, 0x00000000, 0x00000000
870 };
871
872 const u32 pattern_mostly_zero_x16[PATTERN_SIZE] = {
873         0x00000000, 0x00000000, 0x00000000, 0x0000FFFF,
874         0x00000000, 0x00000000, 0x00000000, 0x00000000
875 };
876
877 const u32 pattern_mostly_zero_x32[PATTERN_SIZE] = {
878         0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF,
879         0x00000000, 0x00000000, 0x00000000, 0x00000000
880 };
881
882 const u32 pattern_mostly_one_x16[PATTERN_SIZE] = {
883         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF,
884         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
885 };
886
887 const u32 pattern_mostly_one_x32[PATTERN_SIZE] = {
888         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
889         0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
890 };
891
892 #define NB_PATTERN      5
893 static enum test_result test_freq_pattern(struct stm32mp1_ddrctl *ctl,
894                                           struct stm32mp1_ddrphy *phy,
895                                           char *string, int argc, char *argv[])
896 {
897         const u32 * const patterns_x16[NB_PATTERN] = {
898                 pattern_div1_x16,
899                 pattern_div2_x16,
900                 pattern_div4_x16,
901                 pattern_mostly_zero_x16,
902                 pattern_mostly_one_x16,
903         };
904         const u32 * const patterns_x32[NB_PATTERN] = {
905                 pattern_div2_x16,
906                 pattern_div4_x16,
907                 pattern_div4_x32,
908                 pattern_mostly_zero_x32,
909                 pattern_mostly_one_x32
910         };
911         const char *patterns_comments[NB_PATTERN] = {
912                 "switching at frequency F/1",
913                 "switching at frequency F/2",
914                 "switching at frequency F/4",
915                 "mostly zero",
916                 "mostly one"
917         };
918
919         enum test_result res = TEST_PASSED, pattern_res;
920         int i, bus_width;
921         const u32 **patterns;
922         u32 bufsize, addr;
923
924         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 128))
925                 return TEST_ERROR;
926         if (get_addr(string, argc, argv, 1, &addr))
927                 return TEST_ERROR;
928
929         switch (readl(&ctl->mstr) & DDRCTRL_MSTR_DATA_BUS_WIDTH_MASK) {
930         case DDRCTRL_MSTR_DATA_BUS_WIDTH_HALF:
931         case DDRCTRL_MSTR_DATA_BUS_WIDTH_QUARTER:
932                 bus_width = 16;
933                 break;
934         default:
935                 bus_width = 32;
936                 break;
937         }
938
939         printf("running test pattern at 0x%08x length 0x%x width = %d\n",
940                addr, bufsize, bus_width);
941
942         patterns =
943                 (const u32 **)(bus_width == 16 ? patterns_x16 : patterns_x32);
944
945         for (i = 0; i < NB_PATTERN; i++) {
946                 printf("test data pattern %s:", patterns_comments[i]);
947                 pattern_res = test_loop(patterns[i], (u32 *)addr, bufsize);
948                 if (pattern_res != TEST_PASSED) {
949                         printf("Failed\n");
950                         return pattern_res;
951                 }
952                 printf("Passed\n");
953         }
954
955         return res;
956 }
957
958 /**********************************************************************
959  *
960  * Function:    pattern test with size
961  *
962  * Description: loop for write pattern
963  *
964  **********************************************************************/
965
966 static enum test_result test_loop_size(const u32 *pattern, u32 size,
967                                        u32 *address,
968                                        const u32 bufsize)
969 {
970         int i, j;
971         enum test_result res = TEST_PASSED;
972         u32 *p = address;
973
974         for (i = 0; i < bufsize; i += size * 4) {
975                 for (j = 0; j < size ; j++, p++)
976                         *p = pattern[j];
977                 if (progress(i)) {
978                         res = TEST_FAILED;
979                         goto end;
980                 }
981         }
982
983         puts("\ncheck buffer");
984         p = address;
985         for (i = 0; i < bufsize; i += size * 4) {
986                 for (j = 0; j < size; j++, p++)
987                         if (check_addr((u32)p, pattern[j])) {
988                                 res = TEST_FAILED;
989                                 goto end;
990                         }
991                 if (progress(i)) {
992                         res = TEST_FAILED;
993                         goto end;
994                 }
995         }
996
997 end:
998         puts("\n");
999         return res;
1000 }
1001
1002 static enum test_result test_checkboard(struct stm32mp1_ddrctl *ctl,
1003                                         struct stm32mp1_ddrphy *phy,
1004                                         char *string, int argc, char *argv[])
1005 {
1006         enum test_result res = TEST_PASSED;
1007         u32 bufsize, nb_loop, loop = 0, addr;
1008         int i;
1009
1010         u32 checkboard[2] = {0x55555555, 0xAAAAAAAA};
1011
1012         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 8))
1013                 return TEST_ERROR;
1014         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1015                 return TEST_ERROR;
1016         if (get_addr(string, argc, argv, 2, &addr))
1017                 return TEST_ERROR;
1018
1019         printf("running %d loops at 0x%08x length 0x%x\n",
1020                nb_loop, addr, bufsize);
1021         while (1) {
1022                 for (i = 0; i < 2; i++) {
1023                         res = test_loop_size(checkboard, 2, (u32 *)addr,
1024                                              bufsize);
1025                         if (res)
1026                                 return res;
1027                         checkboard[0] = ~checkboard[0];
1028                         checkboard[1] = ~checkboard[1];
1029                 }
1030                 if (test_loop_end(&loop, nb_loop, 1))
1031                         break;
1032         }
1033         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1034                 loop, addr, bufsize);
1035
1036         return res;
1037 }
1038
1039 static enum test_result test_blockseq(struct stm32mp1_ddrctl *ctl,
1040                                       struct stm32mp1_ddrphy *phy,
1041                                       char *string, int argc, char *argv[])
1042 {
1043         enum test_result res = TEST_PASSED;
1044         u32 bufsize, nb_loop, loop = 0, addr, value;
1045         int i;
1046
1047         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1048                 return TEST_ERROR;
1049         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1050                 return TEST_ERROR;
1051         if (get_addr(string, argc, argv, 2, &addr))
1052                 return TEST_ERROR;
1053
1054         printf("running %d loops at 0x%08x length 0x%x\n",
1055                nb_loop, addr, bufsize);
1056         while (1) {
1057                 for (i = 0; i < 256; i++) {
1058                         value = i | i << 8 | i << 16 | i << 24;
1059                         printf("pattern = %08x", value);
1060                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1061                         if (res != TEST_PASSED)
1062                                 return res;
1063                 }
1064                 if (test_loop_end(&loop, nb_loop, 1))
1065                         break;
1066         }
1067         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1068                 loop, addr, bufsize);
1069
1070         return res;
1071 }
1072
1073 static enum test_result test_walkbit0(struct stm32mp1_ddrctl *ctl,
1074                                       struct stm32mp1_ddrphy *phy,
1075                                       char *string, int argc, char *argv[])
1076 {
1077         enum test_result res = TEST_PASSED;
1078         u32 bufsize, nb_loop, loop = 0, addr, value;
1079         int i;
1080
1081         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1082                 return TEST_ERROR;
1083         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1084                 return TEST_ERROR;
1085         if (get_addr(string, argc, argv, 2, &addr))
1086                 return TEST_ERROR;
1087
1088         printf("running %d loops at 0x%08x length 0x%x\n",
1089                nb_loop, addr, bufsize);
1090         while (1) {
1091                 for (i = 0; i < 64; i++) {
1092                         if (i < 32)
1093                                 value = 1 << i;
1094                         else
1095                                 value = 1 << (63 - i);
1096
1097                         printf("pattern = %08x", value);
1098                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1099                         if (res != TEST_PASSED)
1100                                 return res;
1101                 }
1102                 if (test_loop_end(&loop, nb_loop, 1))
1103                         break;
1104         }
1105         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1106                 loop, addr, bufsize);
1107
1108         return res;
1109 }
1110
1111 static enum test_result test_walkbit1(struct stm32mp1_ddrctl *ctl,
1112                                       struct stm32mp1_ddrphy *phy,
1113                                       char *string, int argc, char *argv[])
1114 {
1115         enum test_result res = TEST_PASSED;
1116         u32 bufsize, nb_loop, loop = 0, addr, value;
1117         int i;
1118
1119         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 4))
1120                 return TEST_ERROR;
1121         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1122                 return TEST_ERROR;
1123         if (get_addr(string, argc, argv, 2, &addr))
1124                 return TEST_ERROR;
1125
1126         printf("running %d loops at 0x%08x length 0x%x\n",
1127                nb_loop, addr, bufsize);
1128         while (1) {
1129                 for (i = 0; i < 64; i++) {
1130                         if (i < 32)
1131                                 value = ~(1 << i);
1132                         else
1133                                 value = ~(1 << (63 - i));
1134
1135                         printf("pattern = %08x", value);
1136                         res = test_loop_size(&value, 1, (u32 *)addr, bufsize);
1137                         if (res != TEST_PASSED)
1138                                 return res;
1139                 }
1140                 if (test_loop_end(&loop, nb_loop, 1))
1141                         break;
1142         }
1143         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1144                 loop, addr, bufsize);
1145
1146         return res;
1147 }
1148
1149 /*
1150  * try to catch bad bits which are dependent on the current values of
1151  * surrounding bits in either the same word32
1152  */
1153 static enum test_result test_bitspread(struct stm32mp1_ddrctl *ctl,
1154                                        struct stm32mp1_ddrphy *phy,
1155                                        char *string, int argc, char *argv[])
1156 {
1157         enum test_result res = TEST_PASSED;
1158         u32 bufsize, nb_loop, loop = 0, addr, bitspread[4];
1159         int i, j;
1160
1161         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 32))
1162                 return TEST_ERROR;
1163         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1164                 return TEST_ERROR;
1165         if (get_addr(string, argc, argv, 2, &addr))
1166                 return TEST_ERROR;
1167
1168         printf("running %d loops at 0x%08x length 0x%x\n",
1169                nb_loop, addr, bufsize);
1170         while (1) {
1171                 for (i = 1; i < 32; i++) {
1172                         for (j = 0; j < i; j++) {
1173                                 if (i < 32)
1174                                         bitspread[0] = (1 << i) | (1 << j);
1175                                 else
1176                                         bitspread[0] = (1 << (63 - i)) |
1177                                                        (1 << (63 - j));
1178                                 bitspread[1] = bitspread[0];
1179                                 bitspread[2] = ~bitspread[0];
1180                                 bitspread[3] = ~bitspread[0];
1181                                 printf("pattern = %08x", bitspread[0]);
1182
1183                                 res = test_loop_size(bitspread, 4, (u32 *)addr,
1184                                                      bufsize);
1185                                 if (res != TEST_PASSED)
1186                                         return res;
1187                         }
1188                 }
1189                 if (test_loop_end(&loop, nb_loop, 1))
1190                         break;
1191         }
1192         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1193                 loop, addr, bufsize);
1194
1195         return res;
1196 }
1197
1198 static enum test_result test_bitflip(struct stm32mp1_ddrctl *ctl,
1199                                      struct stm32mp1_ddrphy *phy,
1200                                      char *string, int argc, char *argv[])
1201 {
1202         enum test_result res = TEST_PASSED;
1203         u32 bufsize, nb_loop, loop = 0, addr;
1204         int i;
1205
1206         u32 bitflip[4];
1207
1208         if (get_bufsize(string, argc, argv, 0, &bufsize, 4 * 1024, 32))
1209                 return TEST_ERROR;
1210         if (get_nb_loop(string, argc, argv, 1, &nb_loop, 1))
1211                 return TEST_ERROR;
1212         if (get_addr(string, argc, argv, 2, &addr))
1213                 return TEST_ERROR;
1214
1215         printf("running %d loops at 0x%08x length 0x%x\n",
1216                nb_loop, addr, bufsize);
1217         while (1) {
1218                 for (i = 0; i < 32; i++) {
1219                         bitflip[0] = 1 << i;
1220                         bitflip[1] = bitflip[0];
1221                         bitflip[2] = ~bitflip[0];
1222                         bitflip[3] = bitflip[2];
1223                         printf("pattern = %08x", bitflip[0]);
1224
1225                         res = test_loop_size(bitflip, 4, (u32 *)addr, bufsize);
1226                         if (res != TEST_PASSED)
1227                                 return res;
1228                 }
1229                 if (test_loop_end(&loop, nb_loop, 1))
1230                         break;
1231         }
1232         sprintf(string, "no error for %d loops at 0x%08x length 0x%x",
1233                 loop, addr, bufsize);
1234
1235         return res;
1236 }
1237
1238 /**********************************************************************
1239  *
1240  * Function: infinite read access to DDR
1241  *
1242  * Description: continuous read the same pattern at the same address
1243  *
1244  **********************************************************************/
1245 static enum test_result test_read(struct stm32mp1_ddrctl *ctl,
1246                                   struct stm32mp1_ddrphy *phy,
1247                                   char *string, int argc, char *argv[])
1248 {
1249         u32 *addr;
1250         u32 data;
1251         u32 loop = 0;
1252         int i, size = 1024 * 1024;
1253         bool random = false;
1254
1255         if (get_addr(string, argc, argv, 0, (u32 *)&addr))
1256                 return TEST_ERROR;
1257
1258         if (get_pattern(string, argc, argv, 1, &data, 0xA5A5AA55))
1259                 return TEST_ERROR;
1260
1261         if ((u32)addr == ADDR_INVALID) {
1262                 printf("running random\n");
1263                 random = true;
1264         } else {
1265                 printf("running at 0x%08x with pattern=0x%08x\n",
1266                        (u32)addr, data);
1267                 writel(data, addr);
1268         }
1269
1270         while (1) {
1271                 for (i = 0; i < size; i++) {
1272                         if (random)
1273                                 addr = (u32 *)(STM32_DDR_BASE +
1274                                        (rand() & (STM32_DDR_SIZE - 1) & ~0x3));
1275                         data = readl(addr);
1276                 }
1277                 if (test_loop_end(&loop, 0, 1))
1278                         break;
1279         }
1280         if (random)
1281                 sprintf(string, "%d loops random", loop);
1282         else
1283                 sprintf(string, "%d loops at 0x%x: %x", loop, (u32)addr, data);
1284
1285         return TEST_PASSED;
1286 }
1287
1288 /**********************************************************************
1289  *
1290  * Function: infinite write access to DDR
1291  *
1292  * Description: continuous write the same pattern at the same address
1293  *
1294  **********************************************************************/
1295 static enum test_result test_write(struct stm32mp1_ddrctl *ctl,
1296                                    struct stm32mp1_ddrphy *phy,
1297                                    char *string, int argc, char *argv[])
1298 {
1299         u32 *addr;
1300         u32 data;
1301         u32 loop = 0;
1302         int i, size = 1024 * 1024;
1303         bool random = false;
1304
1305         if (get_addr(string, argc, argv, 0, (u32 *)&addr))
1306                 return TEST_ERROR;
1307
1308         if (get_pattern(string, argc, argv, 1, &data, 0xA5A5AA55))
1309                 return TEST_ERROR;
1310
1311         if ((u32)addr == ADDR_INVALID) {
1312                 printf("running random\n");
1313                 random = true;
1314         } else {
1315                 printf("running at 0x%08x with pattern 0x%08x\n",
1316                        (u32)addr, data);
1317         }
1318
1319         while (1) {
1320                 for (i = 0; i < size; i++) {
1321                         if (random) {
1322                                 addr = (u32 *)(STM32_DDR_BASE +
1323                                        (rand() & (STM32_DDR_SIZE - 1) & ~0x3));
1324                                 data = rand();
1325                         }
1326                         writel(data, addr);
1327                 }
1328                 if (test_loop_end(&loop, 0, 1))
1329                         break;
1330         }
1331         if (random)
1332                 sprintf(string, "%d loops random", loop);
1333         else
1334                 sprintf(string, "%d loops at 0x%x: %x", loop, (u32)addr, data);
1335
1336         return TEST_PASSED;
1337 }
1338
1339 #define NB_TEST_INFINITE 2
1340 static enum test_result test_all(struct stm32mp1_ddrctl *ctl,
1341                                  struct stm32mp1_ddrphy *phy,
1342                                  char *string, int argc, char *argv[])
1343 {
1344         enum test_result res = TEST_PASSED, result;
1345         int i, nb_error = 0;
1346         u32 loop = 0, nb_loop;
1347
1348         if (get_nb_loop(string, argc, argv, 0, &nb_loop, 1))
1349                 return TEST_ERROR;
1350
1351         while (!nb_error) {
1352                 /* execute all the test except the lasts which are infinite */
1353                 for (i = 1; i < test_nb - NB_TEST_INFINITE; i++) {
1354                         printf("execute %d:%s\n", (int)i, test[i].name);
1355                         result = test[i].fct(ctl, phy, string, 0, NULL);
1356                         printf("result %d:%s = ", (int)i, test[i].name);
1357                         if (result != TEST_PASSED) {
1358                                 nb_error++;
1359                                 res = TEST_FAILED;
1360                                 puts("Failed");
1361                         } else {
1362                                 puts("Passed");
1363                         }
1364                         puts("\n\n");
1365                 }
1366                 printf("loop %d: %d/%d test failed\n\n\n",
1367                        loop + 1, nb_error, test_nb - NB_TEST_INFINITE);
1368                 if (test_loop_end(&loop, nb_loop, 1))
1369                         break;
1370         }
1371         if (res != TEST_PASSED) {
1372                 sprintf(string, "loop %d: %d/%d test failed", loop, nb_error,
1373                         test_nb - NB_TEST_INFINITE);
1374         } else {
1375                 sprintf(string, "loop %d: %d tests passed", loop,
1376                         test_nb - NB_TEST_INFINITE);
1377         }
1378         return res;
1379 }
1380
1381 /****************************************************************
1382  * TEST Description
1383  ****************************************************************/
1384
1385 const struct test_desc test[] = {
1386         {test_all, "All", "[loop]", "Execute all tests", 1 },
1387         {test_databus, "Simple DataBus", "[addr]",
1388          "Verifies each data line by walking 1 on fixed address",
1389          1
1390          },
1391         {databuswalk0, "DataBusWalking0", "[loop] [addr]",
1392          "Verifies each data bus signal can be driven low (32 word burst)",
1393          2
1394         },
1395         {databuswalk1, "DataBusWalking1", "[loop] [addr]",
1396          "Verifies each data bus signal can be driven high (32 word burst)",
1397          2
1398         },
1399         {test_addressbus, "AddressBus", "[size] [addr]",
1400          "Verifies each relevant bits of the address and checking for aliasing",
1401          2
1402          },
1403         {test_memdevice, "MemDevice", "[size] [addr]",
1404          "Test the integrity of a physical memory (test every storage bit in the region)",
1405          2
1406          },
1407         {test_sso, "SimultaneousSwitchingOutput", "[size] [addr] ",
1408          "Stress the data bus over an address range",
1409          2
1410         },
1411         {test_noise, "Noise", "[pattern] [addr]",
1412          "Verifies r/w while forcing switching of all data bus lines.",
1413          3
1414         },
1415         {test_noise_burst, "NoiseBurst", "[size] [pattern] [addr]",
1416          "burst transfers while forcing switching of the data bus lines",
1417          3
1418         },
1419         {test_random, "Random", "[size] [loop] [addr]",
1420          "Verifies r/w and memcopy(burst for pseudo random value.",
1421          3
1422         },
1423         {test_freq_pattern, "FrequencySelectivePattern", "[size] [addr]",
1424          "write & test patterns: Mostly Zero, Mostly One and F/n",
1425          2
1426         },
1427         {test_blockseq, "BlockSequential", "[size] [loop] [addr]",
1428          "test incremental pattern",
1429          3
1430         },
1431         {test_checkboard, "Checkerboard", "[size] [loop] [addr]",
1432          "test checker pattern",
1433          3
1434         },
1435         {test_bitspread, "BitSpread", "[size] [loop] [addr]",
1436          "test Bit Spread pattern",
1437          3
1438         },
1439         {test_bitflip, "BitFlip", "[size] [loop] [addr]",
1440          "test Bit Flip pattern",
1441          3
1442         },
1443         {test_walkbit0, "WalkingOnes", "[size] [loop] [addr]",
1444          "test Walking Ones pattern",
1445          3
1446         },
1447         {test_walkbit1, "WalkingZeroes", "[size] [loop] [addr]",
1448          "test Walking Zeroes pattern",
1449          3
1450         },
1451         /* need to the the 2 last one (infinite) : skipped for test all */
1452         {test_read, "infinite read", "[addr] [pattern]",
1453          "basic test : infinite read access (random: addr=0xFFFFFFFF)", 2},
1454         {test_write, "infinite write", "[addr] [pattern]",
1455          "basic test : infinite write access (random: addr=0xFFFFFFFF)", 2},
1456 };
1457
1458 const int test_nb = ARRAY_SIZE(test);