summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b8208f7)
raw | patch | inline | side by side (parent: b8208f7)
author | Lokesh Vutla <lokeshvutla@ti.com> | |
Fri, 23 Aug 2019 06:23:26 +0000 (11:53 +0530) | ||
committer | Lokesh Vutla <lokeshvutla@ti.com> | |
Mon, 26 Aug 2019 03:55:11 +0000 (09:25 +0530) |
Add support for dump command that supports the following args:
- k3conf dump device- Prints device status of all the TISCI devices
- k3conf dump device <dev_id>: Prints the corresponding device id status
- k3conf dump clock: Prints clock status all the available TISCI clocks
- k3conf dump clock <dev_id>: Prints the available clock status for
corresponding device id
- k3conf dump processor: Prints status of all the available TISCI processors
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
- k3conf dump device- Prints device status of all the TISCI devices
- k3conf dump device <dev_id>: Prints the corresponding device id status
- k3conf dump clock: Prints clock status all the available TISCI clocks
- k3conf dump clock <dev_id>: Prints the available clock status for
corresponding device id
- k3conf dump processor: Prints status of all the available TISCI processors
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Makefile | patch | blob | history | |
common/cmd_dump.c | [new file with mode: 0644] | patch | blob |
common/help.c | patch | blob | history | |
common/k3conf.c | patch | blob | history | |
include/help.h | patch | blob | history | |
include/k3conf.h | patch | blob | history |
diff --git a/Makefile b/Makefile
index a5cd1bdaf1b4b0b1665f13de9e4196e57bd81d61..8ba687589289f3152bf9234df3b522f26aa2786d 100644 (file)
--- a/Makefile
+++ b/Makefile
common/tisci/tisci_device.c \
common/tisci/tisci_clock.c \
common/autoadjust_table.c \
- common/cmd_show.c
+ common/cmd_show.c \
+ common/cmd_dump.c
AM65XSOURCES =\
soc/am65x/am65x_host_info.c \
diff --git a/common/cmd_dump.c b/common/cmd_dump.c
--- /dev/null
+++ b/common/cmd_dump.c
@@ -0,0 +1,256 @@
+/*
+ * K3CONF Command Dump
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Lokesh Vutla <lokeshvutla@ti.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <tisci.h>
+#include <socinfo.h>
+#include <help.h>
+#include <autoadjust_table.h>
+#include <k3conf.h>
+
+int dump_clocks_info(int argc, char *argv[])
+{
+ struct ti_sci_clocks_info *c = soc_info.sci_info.clocks_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0, dev_id;
+ int found = 0, ret;
+ uint64_t freq;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Clock ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Clock Name", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Status", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], "Clock Frequency", TABLE_MAX_ELT_LEN);
+
+ if (argc)
+ goto print_single_device;
+
+ for (row = 0; row < soc_info.sci_info.num_clocks; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].dev_id);
+ snprintf(table[row + 1][1], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].clk_id);
+ strncpy(table[row + 1][2], c[row].clk_name, TABLE_MAX_ELT_LEN);
+ snprintf(table[row + 1][3], TABLE_MAX_ELT_LEN, "%s",
+ ti_sci_cmd_get_clk_state(c[row].dev_id, c[row].clk_id));
+ ti_sci_cmd_get_clk_freq(c[row].dev_id, c[row].clk_id, &freq);
+ snprintf(table[row + 1][4], TABLE_MAX_ELT_LEN, "%lu", freq);
+ }
+
+ return autoadjust_table_print(table, row + 1, 5);
+
+print_single_device:
+ ret = sscanf(argv[0], "%u", &dev_id);
+ if (ret != 1)
+ return -1;
+
+ for (row = 0; row < soc_info.sci_info.num_clocks; row++) {
+ if (dev_id == c[row].dev_id) {
+ snprintf(table[found + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].dev_id);
+ snprintf(table[found + 1][1], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].clk_id);
+ strncpy(table[found + 1][2], c[row].clk_name,
+ TABLE_MAX_ELT_LEN);
+ strncpy(table[found + 1][3],
+ ti_sci_cmd_get_clk_state(dev_id, c[row].clk_id),
+ TABLE_MAX_ELT_LEN);
+ ti_sci_cmd_get_clk_freq(c[row].dev_id, c[row].clk_id,
+ &freq);
+ snprintf(table[found + 1][4], TABLE_MAX_ELT_LEN, "%lu",
+ freq);
+ found++;
+ }
+ }
+
+ if (!found)
+ return -1;
+
+ return autoadjust_table_print(table, found + 1, 5);
+}
+
+int dump_devices_info(int argc, char *argv[])
+{
+ struct ti_sci_devices_info *p = soc_info.sci_info.devices_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0, dev_id;
+ int found = 0, ret;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Device Name", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Device Status", TABLE_MAX_ELT_LEN);
+
+ if (argc)
+ goto print_single_device;
+
+ for (row = 0; row < soc_info.sci_info.num_devices; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ strncpy(table[row + 1][1], p[row].name, TABLE_MAX_ELT_LEN);
+ snprintf(table[row + 1][2], TABLE_MAX_ELT_LEN, "%s",
+ ti_sci_cmd_get_device_status(p[row].dev_id));
+ }
+
+ return autoadjust_table_print(table, row + 1, 3);
+
+print_single_device:
+ ret = sscanf(argv[0], "%u", &dev_id);
+ if (ret != 1)
+ return -1;
+
+ for (row = 0; row < soc_info.sci_info.num_devices; row++) {
+ if (dev_id == p[row].dev_id) {
+ snprintf(table[1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ strncpy(table[1][1], p[row].name,
+ TABLE_MAX_ELT_LEN);
+ snprintf(table[1][2], TABLE_MAX_ELT_LEN, "%s",
+ ti_sci_cmd_get_device_status(p[row].dev_id));
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return -1;
+
+ return autoadjust_table_print(table, 2, 3);
+}
+
+static int dump_processors_info(int argc, char *argv[])
+{
+ 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, proc_id;
+ int found = 0, ret;
+ uint64_t freq;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Processor ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Processor Name", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Processor State", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], "Processor Frequency", TABLE_MAX_ELT_LEN);
+
+ if (argc)
+ goto print_single_processor;
+
+ for (row = 0; row < soc_info.sci_info.num_processors; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ snprintf(table[row + 1][1], TABLE_MAX_ELT_LEN, "%7d",
+ p[row].processor_id);
+ strncpy(table[row + 1][2], p[row].name, TABLE_MAX_ELT_LEN);
+ /* ToDo: Should we get the state from proc ops */
+ snprintf(table[row + 1][3], 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[row + 1][4], TABLE_MAX_ELT_LEN, "%lu", freq);
+ }
+
+ return autoadjust_table_print(table, row + 1, 5);
+
+print_single_processor:
+ ret = sscanf(argv[0], "%u", &proc_id);
+ if (ret != 1)
+ return -1;
+
+ for (row = 0; row < soc_info.sci_info.num_processors; row++) {
+ if (proc_id != p[row].processor_id)
+ continue;
+ snprintf(table[found + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ snprintf(table[found + 1][1], TABLE_MAX_ELT_LEN, "%7d",
+ p[row].processor_id);
+ strncpy(table[found + 1][2], p[row].name, TABLE_MAX_ELT_LEN);
+ /* ToDo: Should we get the state from proc ops */
+ snprintf(table[found + 1][3], 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][4], TABLE_MAX_ELT_LEN, "%lu", freq);
+ found++;
+ break;
+ }
+ if (!found)
+ return -1;
+
+ return autoadjust_table_print(table, found + 1, 5);
+}
+
+int process_dump_command(int argc, char *argv[])
+{
+ int ret;
+
+ if (argc < 1) {
+ help(HELP_DUMP);
+ return -1;
+ }
+
+ if (!strncmp(argv[0], "device", 6)) {
+ argc--;
+ argv++;
+ ret = dump_devices_info(argc, argv);
+ if (ret) {
+ fprintf(stderr, "Invalid device arguments\n");
+ help(HELP_DUMP_DEVICE);
+ }
+ } else if (!strncmp(argv[0], "clock", 5)) {
+ argc--;
+ argv++;
+ ret = dump_clocks_info(argc, argv);
+ if (ret) {
+ fprintf(stderr, "Invalid clock arguments\n");
+ help(HELP_DUMP_CLOCK);
+ }
+ } else if(!strncmp(argv[0], "processor", 9)) {
+ argc--;
+ argv++;
+ ret = dump_processors_info(argc, argv);
+ if (ret)
+ help(HELP_DUMP_PROCESSOR);
+ } else if (!strcmp(argv[0], "--help")) {
+ help(HELP_DUMP);
+ return 0;
+ } else {
+ fprintf(stderr, "Invalid argument %s\n", argv[1]);
+ help(HELP_DUMP);
+ return -1;
+ }
+ return ret;
+}
diff --git a/common/help.c b/common/help.c
index 8132015dc307d45cd9dafe759117259160b066f7..9224f982fe90e7f29408b2aa2bfe90cc36665f30 100644 (file)
--- a/common/help.c
+++ b/common/help.c
printf("\n\tk3conf show processor\n");
printf("\t Prints all the available TISCI processors\n");
}
+ if ((cat == HELP_ALL) || (cat == HELP_DUMP) ||
+ (cat == HELP_DUMP_DEVICE)) {
+ printf("\n\tk3conf dump device\n");
+ printf("\t Prints device status of all the TISCI devices\n");
+ printf("\n\tk3conf dump device <dev_id>\n");
+ printf("\t Prints the corresponding device id status\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_DUMP) ||
+ (cat == HELP_DUMP_CLOCK)) {
+ printf("\n\tk3conf dump clock\n");
+ printf("\t Prints clock status all the available TISCI clocks\n");
+ printf("\n\tk3conf dump clock <dev_id>\n");
+ printf("\t Prints the available clock status for corresponding device id\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_DUMP) ||
+ (cat == HELP_DUMP_PROCESSOR)) {
+ printf("\n\tk3conf dump processor\n");
+ printf("\t Prints status of all the available TISCI processors\n");
+ printf("\n\tk3conf dump processor <proc_id>\n");
+ printf("\t Prints status of the given TISCI processors\n");
+ }
}
diff --git a/common/k3conf.c b/common/k3conf.c
index f6fcfc6083634ac1f57ff839c61e90898a942c55..0ab0e72d222e906fd3d7ca36a7fd95064ec8079e 100644 (file)
--- a/common/k3conf.c
+++ b/common/k3conf.c
argv++;
k3conf_print_version(stdout);
return process_show_command(argc, argv);
+ } else if (!strcmp(argv[0], "dump")) {
+ argc--;
+ argv++;
+ k3conf_print_version(stdout);
+ return process_dump_command(argc, argv);
} else {
fprintf(stderr, "Invalid argument %s", argv[0]);
help(HELP_USAGE);
diff --git a/include/help.h b/include/help.h
index c46444f310b49dd429e4366a9049914954844104..9af9541422fc0ca1ca1071b2f33769b03b40148d 100644 (file)
--- a/include/help.h
+++ b/include/help.h
HELP_SHOW_DEVICE,
HELP_SHOW_CLOCK,
HELP_SHOW_PROCESSOR,
+ HELP_DUMP,
+ HELP_DUMP_DEVICE,
+ HELP_DUMP_CLOCK,
+ HELP_DUMP_PROCESSOR,
HELP_ALL,
HELP_CATEGORY_MAX,
} help_category;
diff --git a/include/k3conf.h b/include/k3conf.h
index 394bfaa6d58cbd05c79be3ae450204ed495c12a5..66cf44fd30d5d35648976323c12c5b411922b16f 100644 (file)
--- a/include/k3conf.h
+++ b/include/k3conf.h
#define __K3CONF_H
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[]);
#endif