]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_iotrace.c
spi: omap3_spi: add am43xx support to omap3_spi
[karo-tx-uboot.git] / common / cmd_iotrace.c
1 /*
2  * Copyright (c) 2014 Google, Inc
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <command.h>
9 #include <iotrace.h>
10
11 static void do_print_stats(void)
12 {
13         ulong start, size, offset, count;
14
15         printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis");
16         iotrace_get_buffer(&start, &size, &offset, &count);
17         printf("Start:  %08lx\n", start);
18         printf("Size:   %08lx\n", size);
19         printf("Offset: %08lx\n", offset);
20         printf("Output: %08lx\n", start + offset);
21         printf("Count:  %08lx\n", count);
22         printf("CRC32:  %08lx\n", (ulong)iotrace_get_checksum());
23 }
24
25 static int do_set_buffer(int argc, char * const argv[])
26 {
27         ulong addr = 0, size = 0;
28
29         if (argc == 2) {
30                 addr = simple_strtoul(*argv++, NULL, 16);
31                 size = simple_strtoul(*argv++, NULL, 16);
32         } else if (argc != 0) {
33                 return CMD_RET_USAGE;
34         }
35
36         iotrace_set_buffer(addr, size);
37
38         return 0;
39 }
40
41 int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
42 {
43         const char *cmd = argc < 2 ? NULL : argv[1];
44
45         if (!cmd)
46                 return cmd_usage(cmdtp);
47         switch (*cmd) {
48         case 'b':
49                 return do_set_buffer(argc - 2, argv + 2);
50         case 'p':
51                 iotrace_set_enabled(0);
52                 break;
53         case 'r':
54                 iotrace_set_enabled(1);
55                 break;
56         case 's':
57                 do_print_stats();
58                 break;
59         default:
60                 return CMD_RET_USAGE;
61         }
62
63         return 0;
64 }
65
66 U_BOOT_CMD(
67         iotrace,        4,      1,      do_iotrace,
68         "iotrace utility commands",
69         "stats                        - display iotrace stats\n"
70         "iotrace buffer <address> <size>      - set iotrace buffer\n"
71         "iotrace pause                        - pause tracing\n"
72         "iotrace resume                       - resume tracing"
73 );