Skip to content

Commit 7147d1f

Browse files
JohnWC-Yehquinchou77
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 da46d46 commit 7147d1f

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

zephyr/program/framework/include/board_host_command.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,14 @@ enum battery_extender_cmd {
574574
BATT_EXTENDER_READ_CMD,
575575
};
576576

577+
/*****************************************************************************/
578+
/*
579+
* This command uses to control the Power on AC attach enable/disable
580+
*/
581+
#define EC_CMD_POWER_ON_AC_ATTACH 0x3E2A
582+
583+
struct ec_params_power_on_ac_attach {
584+
uint8_t enable;
585+
} __ec_align1;
586+
577587
#endif /* __BOARD_HOST_COMMAND_H */

zephyr/program/framework/src/board_function.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ int bios_function_status(uint16_t type, uint16_t addr, uint8_t flag)
7070
*/
7171
int ac_boot_status(void)
7272
{
73-
return bios_function_status(TYPE_MEMMAP, EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC,
74-
EC_AC_ATTACH_BOOT);
73+
return bios_function_status(TYPE_FLASH, FLASH_FLAGS_ACPOWERON, 0);
7574
}
7675

7776
void bios_function_detect(void)
7877
{
79-
flash_storage_update(FLASH_FLAGS_ACPOWERON, ac_boot_status());
8078

8179
flash_storage_update(FLASH_FLAGS_STANDALONE, get_standalone_mode() ? 1 : 0);
8280
#ifdef CONFIG_BOARD_LOTUS
@@ -244,9 +242,6 @@ void chassis_interrupt_handler(enum gpio_signal signal)
244242

245243
static void bios_function_init(void)
246244
{
247-
/* restore the bios setup menu setting */
248-
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC) =
249-
flash_storage_get(FLASH_FLAGS_ACPOWERON);
250245

251246
if (flash_storage_get(FLASH_FLAGS_STANDALONE))
252247
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
@@ -506,6 +506,25 @@ static enum ec_status cmd_get_ap_throttle_status(struct host_cmd_handler_args *a
506506
}
507507
DECLARE_HOST_COMMAND(EC_CMD_GET_AP_THROTTLE_STATUS, cmd_get_ap_throttle_status, EC_VER_MASK(0));
508508

509+
static enum ec_status power_on_ac_attach_control(struct host_cmd_handler_args *args)
510+
{
511+
const struct ec_params_power_on_ac_attach *p = args->params;
512+
int enable = p->enable;
513+
int status;
514+
515+
status = flash_storage_get(FLASH_FLAGS_ACPOWERON);
516+
517+
/* Update the flash if status changes */
518+
if (enable != status) {
519+
/* Store the status in EC ROM and restore when EC power on */
520+
flash_storage_update(FLASH_FLAGS_ACPOWERON, enable);
521+
flash_storage_commit();
522+
}
523+
524+
return EC_SUCCESS;
525+
}
526+
DECLARE_HOST_COMMAND(EC_CMD_POWER_ON_AC_ATTACH, power_on_ac_attach_control, EC_VER_MASK(0));
527+
509528
static enum ec_status cmd_get_pd_port_state(struct host_cmd_handler_args *args)
510529
{
511530
const struct ec_params_get_pd_port_state *p = args->params;

0 commit comments

Comments
 (0)