cmd: cpuinfo: Add support for printing cpuinfo
authorLokesh Vutla <lokeshvutla@ti.com>
Fri, 23 Aug 2019 09:44:12 +0000 (15:14 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Mon, 26 Aug 2019 03:55:11 +0000 (09:25 +0530)
Add support for --cpuinfo argument that prints the host processor
info and the running frequency.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
common/cmd_dump.c
common/help.c
common/k3conf.c
include/k3conf.h

index 4e662aedd0f43d0450cf0e548fa9a0f6fb59ba33..518a7186b51d5f18b8cbebf3f8413aeb409ed9d8 100644 (file)
 #include <autoadjust_table.h>
 #include <k3conf.h>
 
+int dump_cpu_info(void)
+{
+       struct ti_sci_processors_info *p = soc_info.sci_info.processors_info;
+       char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+       uint32_t row = 0, found = 0;
+       uint64_t freq;
+
+       autoadjust_table_init(table);
+       strncpy(table[row][0], "Processor Name", TABLE_MAX_ELT_LEN);
+       strncpy(table[row][1], "Processor State", TABLE_MAX_ELT_LEN);
+       strncpy(table[row][2], "Processor Frequency", TABLE_MAX_ELT_LEN);
+
+       for (row = 0; row < soc_info.sci_info.num_processors; row++) {
+               if (strncmp(p[row].name, "A", 1))
+                       continue;
+               strncpy(table[found + 1][0], p[row].name, TABLE_MAX_ELT_LEN);
+               /* ToDo: Should we get the state from proc ops */
+               snprintf(table[found + 1][1], TABLE_MAX_ELT_LEN, "%s",
+                        ti_sci_cmd_get_device_status(p[row].dev_id));
+               ti_sci_cmd_get_clk_freq(p[row].dev_id, p[row].clk_id, &freq);
+               snprintf(table[found + 1][2], TABLE_MAX_ELT_LEN, "%lu", freq);
+               found++;
+       }
+
+       return autoadjust_table_print(table, found + 1, 3);
+}
+
 int dump_clocks_info(int argc, char *argv[])
 {
        struct ti_sci_clocks_info *c = soc_info.sci_info.clocks_info;
index 9224f982fe90e7f29408b2aa2bfe90cc36665f30..e1bbfed5280bcefef49ae870de7d786fd840f77e 100644 (file)
@@ -49,7 +49,7 @@ void help(help_category cat)
                printf("\tk3conf - TI K3 Configuration Diagnostic Tool\n");
 
                printf("\nSYNOPSIS\n");
-               printf("\tk3conf [--version] [--help] <command> [<args>]\n");
+               printf("\tk3conf [--version] [--help] [--cpuinfo] <command> [<args>]\n");
                if (cat == HELP_USAGE)
                        printf("\n\tSee 'k3conf --help' for more information.\n\n");
        }
@@ -73,6 +73,9 @@ void help(help_category cat)
 
                printf("\n\t--version\n");
                printf("\t    Print k3conf version.\n");
+
+               printf("\n\t--cpuinfo\n");
+               printf("\t    Print the host processor information.\n");
        }
 
        if (cat != HELP_USAGE)
index 0ab0e72d222e906fd3d7ca36a7fd95064ec8079e..af57dfb7a84480d3ad076f410f530fda2c359cd7 100644 (file)
@@ -106,6 +106,10 @@ int main(int argc, char *argv[])
        } else if (!strcmp(argv[0], "--version")) {
                k3conf_print_version(stdout);
                goto main_exit;
+       } else if (!strcmp(argv[0], "--cpuinfo")) {
+               k3conf_print_version(stdout);
+               dump_cpu_info();
+               goto main_exit;
        } else if (!strcmp(argv[0], "show")) {
                argc--;
                argv++;
index 66cf44fd30d5d35648976323c12c5b411922b16f..03c66cfbdb6ab867686e6c392ec66ca869d4bfa6 100644 (file)
@@ -47,4 +47,5 @@ int process_show_command(int argc, char *argv[]);
 int process_dump_command(int argc, char *argv[]);
 int dump_clocks_info(int argc, char *argv[]);
 int dump_devices_info(int argc, char *argv[]);
+int dump_cpu_info(void);
 #endif