Skip to content

Commit 6f1d9c0

Browse files
JohnWC-Yehamstan
authored andcommitted
fwk: fix power on AC attach requiring OS boot to take effect
Previously, you needed to boot an OS first for the settings to kick in. So if you remove SSDs, the setting will not kick in. Add a host command EC_CMD_POWER_ON_AC_ATTACH(0x3E2A) only for power on AC attach, use for BIOS to notify EC to save it. BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86evbbru9 TEST=1.unplug all SSDs and other storage 2. enable "power on ac attach" f10, save, reboot 3. unplug AC power and wait a few seconds 4. plug AC power can power on Signed-off-by: johnwc_yeh <JohnWC_Yeh@compal.com> (cherry picked from commit 1402170)
1 parent c8091da commit 6f1d9c0

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

zephyr/program/framework/include/board_host_command.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,4 +619,14 @@ struct ec_response_wake_on_lan_control {
619619
uint8_t enable;
620620
} __ec_align1;
621621

622+
/*****************************************************************************/
623+
/*
624+
* This command uses to control the Power on AC attach enable/disable
625+
*/
626+
#define EC_CMD_POWER_ON_AC_ATTACH 0x3E2A
627+
628+
struct ec_params_power_on_ac_attach {
629+
uint8_t enable;
630+
} __ec_align1;
631+
622632
#endif /* __BOARD_HOST_COMMAND_H */

zephyr/program/framework/src/board_function.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,11 @@ int bios_function_status(uint16_t type, uint16_t addr, uint8_t flag)
5555
*/
5656
int ac_boot_status(void)
5757
{
58-
return bios_function_status(TYPE_MEMMAP, EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC,
59-
EC_AC_ATTACH_BOOT);
58+
return bios_function_status(TYPE_FLASH, FLASH_FLAGS_ACPOWERON, 0);
6059
}
6160

6261
void bios_function_detect(void)
6362
{
64-
flash_storage_update(FLASH_FLAGS_ACPOWERON, ac_boot_status());
65-
6663
#ifndef CONFIG_PLATFORM_EC_FRAMEWORK_MINI_PC
6764
flash_storage_update(FLASH_FLAGS_STANDALONE, get_standalone_mode() ? 1 : 0);
6865
#endif
@@ -117,10 +114,6 @@ void board_power_button_interrupt(enum gpio_signal signal)
117114

118115
static void bios_function_init(void)
119116
{
120-
/* restore the bios setup menu setting */
121-
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC) =
122-
flash_storage_get(FLASH_FLAGS_ACPOWERON);
123-
124117
#ifndef CONFIG_PLATFORM_EC_FRAMEWORK_MINI_PC
125118
if (flash_storage_get(FLASH_FLAGS_STANDALONE))
126119
set_standalone_mode(1);

zephyr/program/framework/src/board_host_command.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,25 @@ static enum ec_status cmd_get_ap_throttle_status(struct host_cmd_handler_args *a
460460
}
461461
DECLARE_HOST_COMMAND(EC_CMD_GET_AP_THROTTLE_STATUS, cmd_get_ap_throttle_status, EC_VER_MASK(0));
462462

463+
static enum ec_status power_on_ac_attach_control(struct host_cmd_handler_args *args)
464+
{
465+
const struct ec_params_power_on_ac_attach *p = args->params;
466+
int enable = p->enable;
467+
int status;
468+
469+
status = flash_storage_get(FLASH_FLAGS_ACPOWERON);
470+
471+
/* Update the flash if status changes */
472+
if (enable != status) {
473+
/* Store the status in EC ROM and restore when EC power on */
474+
flash_storage_update(FLASH_FLAGS_ACPOWERON, enable);
475+
flash_storage_commit();
476+
}
477+
478+
return EC_SUCCESS;
479+
}
480+
DECLARE_HOST_COMMAND(EC_CMD_POWER_ON_AC_ATTACH, power_on_ac_attach_control, EC_VER_MASK(0));
481+
463482
static enum ec_status cmd_get_pd_port_state(struct host_cmd_handler_args *args)
464483
{
465484
const struct ec_params_get_pd_port_state *p = args->params;

0 commit comments

Comments
 (0)