Skip to content

Commit

Permalink
minerva-ag: Modify voltage_peak commands
Browse files Browse the repository at this point in the history
Summary:
- Modify voltage_peak commands with parameter hint
- Delete plat_voltage_peak_shell.h file

Test Plan:
- Build code: PASS
  • Loading branch information
LisaChang-Quanta committed Jan 20, 2025
1 parent 6b4ad19 commit e12b30f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 51 deletions.
78 changes: 52 additions & 26 deletions meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@
#include <logging/log.h>

Check failure on line 21 in meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Include file: <logging/log.h> not found. Please note: Cppcheck does not need standard library headers to get proper results. Raw Output: meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c:21:0:Include file: <logging/log.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include "plat_hook.h"

Check failure on line 22 in meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Include file: "plat_hook.h" not found. Raw Output: meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c:22:0:Include file: "plat_hook.h" not found.
#include "plat_class.h"

Check failure on line 23 in meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Include file: "plat_class.h" not found. Raw Output: meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.c:23:0:Include file: "plat_class.h" not found.
#include "plat_voltage_peak_shell.h"

LOG_MODULE_REGISTER(plat_voltage_peak_shell);

void cmd_get_voltage_peak(const struct shell *shell, size_t argc, char **argv)
static int cmd_get_voltage_peak(const struct shell *shell, size_t argc, char **argv)
{
if (argc != 2) {
shell_warn(shell, "Help: get <voltage-rail>|all");
return;
return -1;
}

char rail_string[40] = { 0 };
int peak_value;
snprintf(rail_string, sizeof(rail_string), "%s", argv[1]);

if (strcmp(rail_string, "all") == 0) {
if (!strcmp(argv[1], "all")) {
for (int i = 0; i < VR_RAIL_E_MAX; i++) {
if ((get_board_type() == MINERVA_AEGIS_BD) && (i == 0))
continue;
Expand Down Expand Up @@ -74,14 +71,24 @@ void cmd_get_voltage_peak(const struct shell *shell, size_t argc, char **argv)
}
}
} else {
if (vr_rail_voltage_peak_get(rail_string, &peak_value) == false) {
shell_error(shell, "Invalid rail name to get peak value: %s", rail_string);
return;
enum VR_RAIL_E rail;
if (vr_rail_enum_get(argv[1], &rail) == false) {
shell_error(shell, "Invalid rail name: %s", argv[1]);
return -1;
}

if ((get_board_type() == MINERVA_AEGIS_BD) && (rail == 0)) {
shell_print(shell, "There is no osfp p3v3 on AEGIS BD");
return 0;
}

if (vr_rail_voltage_peak_get(argv[1], &peak_value) == false) {
shell_error(shell, "Invalid rail name to get peak value: %s", argv[1]);
return -1;
}

if (peak_value == 0xffffffff) {
shell_print(shell, "%-40s peak value: This is default peak value",
rail_string);
shell_print(shell, "%-40s peak value: This is default peak value", argv[1]);
} else {
float sensor_reading = 0, decimal = 0;
int16_t integer = 0;
Expand All @@ -96,24 +103,21 @@ void cmd_get_voltage_peak(const struct shell *shell, size_t argc, char **argv)
sensor_reading = (float)integer - decimal;
}

shell_print(shell, "%-40s peak value: %10.3f", rail_string, sensor_reading);
shell_print(shell, "%-40s peak value: %10.3f", argv[1], sensor_reading);
}
}

return;
return 0;
}

void cmd_clear_voltage_peak(const struct shell *shell, size_t argc, char **argv)
static int cmd_clear_voltage_peak(const struct shell *shell, size_t argc, char **argv)
{
if (argc != 2) {
shell_warn(shell, "Help: clear <voltage-rail>|all");
return;
return -1;
}

char rail_string[40] = { 0 };
snprintf(rail_string, sizeof(rail_string), "%s", argv[1]);

if (strcmp(rail_string, "all") == 0) {
if (strcmp(argv[1], "all") == 0) {
bool result = true;
for (int i = 0; i < VR_RAIL_E_MAX; i++) {
if ((get_board_type() == MINERVA_AEGIS_BD) && (i == 0))
Expand All @@ -136,26 +140,48 @@ void cmd_clear_voltage_peak(const struct shell *shell, size_t argc, char **argv)
enum VR_RAIL_E rail;
bool result = true;

if (vr_rail_enum_get(rail_string, &rail) == false) {
shell_error(shell, "Invalid rail name: %s", rail_string);
return;
if (vr_rail_enum_get(argv[1], &rail) == false) {
shell_error(shell, "Invalid rail name: %s", argv[1]);
return -1;
}

result = vr_rail_voltage_peak_clear((uint8_t)rail);
if (result != true) {
shell_print(shell, "%-40s voltage peak clear failed");
return -1;
}

shell_print(shell, "voltage_peak clear %s done!", rail_string);
shell_print(shell, "voltage_peak clear %s done!", argv[1]);
}

return;
return 0;
}

static void voltage_rname_get(size_t idx, struct shell_static_entry *entry)
{
if ((get_board_type() == MINERVA_AEGIS_BD))
idx++;

uint8_t *name = NULL;
vr_rail_name_get((uint8_t)idx, &name);

if (idx == VR_RAIL_E_MAX)
name = (uint8_t *)"all";

entry->syntax = (name) ? (const char *)name : NULL;
entry->handler = NULL;
entry->help = NULL;
entry->subcmd = NULL;
}

SHELL_DYNAMIC_CMD_CREATE(voltage_rname, voltage_rname_get);

/* Sub-command Level 1 of command voltage-peak */
SHELL_STATIC_SUBCMD_SET_CREATE(sub_voltage_peak_cmds,
SHELL_CMD(get, NULL, "get_voltage_peak", cmd_get_voltage_peak),
SHELL_CMD(clear, NULL, "clear_voltage_peak", cmd_clear_voltage_peak),
SHELL_CMD(get, &voltage_rname, "get_voltage_peak",
cmd_get_voltage_peak),
SHELL_CMD(clear, &voltage_rname, "clear_voltage_peak",
cmd_clear_voltage_peak),
SHELL_SUBCMD_SET_END);

/* Root of command voltage-peak */
Expand Down
25 changes: 0 additions & 25 deletions meta-facebook/minerva-ag/src/shell/plat_voltage_peak_shell.h

This file was deleted.

0 comments on commit e12b30f

Please sign in to comment.