afm: powermode/selinux/silent command [1/1]
PD#SWPL-194190
Problem:
add afm factory command in uboot
Solution:
1.powermode cmd
2.selinux cmd
3.silent cmd
Verify:
T6D
Change-Id: I425a5a2179f52ecc6efdf6bb713988cc89c40f21
Signed-off-by: min.ye <min.ye@amlogic.com>
diff --git a/common/cmd_afm.c b/common/cmd_afm.c
index 1c21243..99856eb3 100644
--- a/common/cmd_afm.c
+++ b/common/cmd_afm.c
@@ -7,7 +7,29 @@
static int do_afm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
const char *str_cmd, *str_value = NULL;
-
+ if (argc == 2 && !strcmp(argv[1], "print"))
+ {
+ char *mac = env_get("mac");
+ char *silent = env_get("silent");
+ char *powermode = env_get("powermode");
+ char *otg_device = env_get("otg_device");
+ char *selinux = env_get("EnableSelinux");
+ printf("\n"
+ "model_name : \n"
+ "serialno : \n"
+ "mac : %s\n"
+ "console : \n"
+ "silent : %s\n"
+ "powermode : %s\n"
+ "otg_device : %s\n"
+ "selinux : %s\n"
+ , mac != NULL? mac : ""
+ , silent != NULL? (!strcmp(silent, "0")? "on" : "off") : "on"
+ , powermode != NULL? powermode : ""
+ , otg_device != NULL? otg_device : ""
+ , selinux != NULL? selinux : "");
+ return 0;
+ }
if (argc != 3)
return CMD_RET_USAGE;
str_cmd = argv[1];
@@ -38,6 +60,38 @@
run_command(result, 0);
run_command("keyman read mac $loadaddr str; printenv mac", 0);
return 0;
+ } else if (!strcmp(str_cmd, "silent")) {
+ if (!strcmp(str_value, "on")) {
+ run_command("setenv silent 0", 0);
+ } else if (!strcmp(str_value, "off")) {
+ run_command("setenv silent 1", 0);
+ } else {
+ printf("invalid value\n");
+ return CMD_RET_USAGE;
+ }
+ run_command("saveenv", 0);
+ } else if (!strcmp(str_cmd, "powermode")) {
+ if (!strcmp(str_value, "on")) {
+ run_command("setenv powermode on", 0);
+ } else if (!strcmp(str_value, "standby")) {
+ run_command("setenv powermode standby", 0);
+ } else {
+ printf("invalid value\n");
+ return CMD_RET_USAGE;
+ }
+ run_command("saveenv", 0);
+ } else if (!strcmp(str_cmd, "selinux")) {
+ if (!strcmp(str_value, "enforcing")) {
+ run_command("setenv EnableSelinux enforcing", 0);
+ } else if (!strcmp(str_value, "permissive")) {
+ run_command("setenv EnableSelinux permissive", 0);
+ } else if (!strcmp(str_value, "disabled")) {
+ run_command("setenv EnableSelinux disabled", 0);
+ } else {
+ printf("invalid value\n");
+ return CMD_RET_USAGE;
+ }
+ run_command("saveenv", 0);
}
return 0;
}
@@ -49,9 +103,9 @@
"afm serialno <serial no> - modify serial no\n"
"afm mac <mac address> - modify mac address\n"
"afm console <on|off> - modify console state\n"
- "afm model_name <ModelName> - modify screen parameters\n"
"afm silent <on|off> - modify the print state of uboot bl33 serial port\n"
"afm powermode <on|standby> - modify power on mode\n"
"afm otg_device <1|0> - modify the USB host/device state\n"
"afm selinux <0|1|2(permissive|enforcing|disabled)> - modify the selinux mode\n"
+ "afm print - Print the values of all parameters\n"
);