Skip to content

Commit 5892d68

Browse files
LeoCX-Tsaiamstan
authored andcommitted
fwk: dogwood: move force_enable_psu cmd to common function
move force_enable_psu relate function to common BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86ev2xjqm TEST=boot to system check cmd 3E28 still work. Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent fed8eaf commit 5892d68

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

zephyr/program/framework/dogwood/src/power_sequence.c

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "board_adc.h"
77
#include "board_host_command.h"
8+
#include "board_function.h"
89
#include "chipset.h"
910
#include "config.h"
1011
#include "console.h"
@@ -63,7 +64,6 @@ static int timeout_5vsb = TIMEOUT_5VSB_MIN;
6364
static bool power_s5_up; /* Chipset is sequencing up or down */
6465
static int force_shutdown_flags;
6566
static int d3cold_is_entry; /* check the d3cold status */
66-
static int force_enable_psu = 0;
6767

6868
static void system_check_ssd_status(void);
6969

@@ -430,7 +430,7 @@ void power_5vsb_enter(void)
430430
return;
431431
}
432432

433-
if (force_enable_psu) {
433+
if (get_force_enable_psu()) {
434434
CPRINTS("...but we want to force power supply on");
435435
return;
436436
}
@@ -1030,37 +1030,3 @@ __override bool cypd_allow_increase_rdo_profile(void)
10301030
return false;
10311031
}
10321032

1033-
static int cmd_psu_s3_keep(int argc, const char **argv)
1034-
{
1035-
char *e;
1036-
1037-
if (argc > 2)
1038-
return EC_ERROR_PARAM_COUNT;
1039-
1040-
if (argc == 2) {
1041-
force_enable_psu = strtoi(argv[1], &e, 10);
1042-
if (*e)
1043-
return EC_ERROR_PARAM1;
1044-
};
1045-
1046-
CPRINTS("PSU is forced on in S3: %d", force_enable_psu);
1047-
1048-
return EC_SUCCESS;
1049-
}
1050-
DECLARE_CONSOLE_COMMAND(psu_s3_keep, cmd_psu_s3_keep,
1051-
"[1/0]",
1052-
"Keep the PSU on when the system is in S3.");
1053-
1054-
static enum ec_status hc_psu_control(struct host_cmd_handler_args *args)
1055-
{
1056-
const struct ec_params_psu_control *p = args->params;
1057-
struct ec_response_psu_control *r = args->response;
1058-
1059-
force_enable_psu = p->force_enable_in_standby > 0 ? true : false;
1060-
1061-
r->force_enable_in_standby = force_enable_psu;
1062-
args->response_size = sizeof(*r);
1063-
1064-
return EC_SUCCESS;
1065-
}
1066-
DECLARE_HOST_COMMAND(EC_CMD_PSU_CONTROL, hc_psu_control, EC_VER_MASK(0));

zephyr/program/framework/include/board_function.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ __override_proto void project_chassis_function(enum gpio_signal signal);
2323

2424
uint32_t get_system_percentage(void);
2525

26+
int get_force_enable_psu(void);
27+
2628
#endif /* __CROS_EC_BOARD_FUNCTION_H */

zephyr/program/framework/src/board_function.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define CPRINTS(format, args...) cprints(CC_HOSTCMD, format, ##args)
3333
#define CPRINTF(format, args...) cprintf(CC_HOSTCMD, format, ##args)
3434

35+
static int force_enable_psu;
36+
3537
int bios_function_status(uint16_t type, uint16_t addr, uint8_t flag)
3638
{
3739
uint8_t status;
@@ -145,3 +147,43 @@ __override int board_temp_smi_evet(void)
145147

146148
return false;
147149
}
150+
151+
int get_force_enable_psu(void)
152+
{
153+
return force_enable_psu;
154+
}
155+
156+
static enum ec_status hc_psu_control(struct host_cmd_handler_args *args)
157+
{
158+
const struct ec_params_psu_control *p = args->params;
159+
struct ec_response_psu_control *r = args->response;
160+
161+
force_enable_psu = p->force_enable_in_standby > 0 ? true : false;
162+
163+
r->force_enable_in_standby = force_enable_psu;
164+
args->response_size = sizeof(*r);
165+
166+
return EC_SUCCESS;
167+
}
168+
DECLARE_HOST_COMMAND(EC_CMD_PSU_CONTROL, hc_psu_control, EC_VER_MASK(0));
169+
170+
static int cmd_psu_s3_keep(int argc, const char **argv)
171+
{
172+
char *e;
173+
174+
if (argc > 2)
175+
return EC_ERROR_PARAM_COUNT;
176+
177+
if (argc == 2) {
178+
force_enable_psu = strtoi(argv[1], &e, 10);
179+
if (*e)
180+
return EC_ERROR_PARAM1;
181+
};
182+
183+
CPRINTS("PSU is forced on in S3: %d", force_enable_psu);
184+
185+
return EC_SUCCESS;
186+
}
187+
DECLARE_CONSOLE_COMMAND(psu_s3_keep, cmd_psu_s3_keep,
188+
"[1/0]",
189+
"Keep the PSU on when the system is in S3.");

0 commit comments

Comments
 (0)