Skip to content

Commit bdc3c69

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) (cherry picked from commit 2cb64403c5dcdf8c32a20afceecb7d9d74514f99)
1 parent 03829d6 commit bdc3c69

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

zephyr/program/framework/include/board_host_command.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,14 @@ enum battery_extender_cmd {
458458
BATT_EXTENDER_READ_CMD,
459459
};
460460

461+
/*****************************************************************************/
462+
/*
463+
* This command uses to control the Power on AC attach enable/disable
464+
*/
465+
#define EC_CMD_POWER_ON_AC_ATTACH 0x3E2A
466+
467+
struct ec_params_power_on_ac_attach {
468+
uint8_t enable;
469+
} __ec_align1;
470+
461471
#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
@@ -68,14 +68,11 @@ int bios_function_status(uint16_t type, uint16_t addr, uint8_t flag)
6868
*/
6969
int ac_boot_status(void)
7070
{
71-
return bios_function_status(TYPE_MEMMAP, EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC,
72-
EC_AC_ATTACH_BOOT);
71+
return bios_function_status(TYPE_FLASH, FLASH_FLAGS_ACPOWERON, 0);
7372
}
7473

7574
void bios_function_detect(void)
7675
{
77-
flash_storage_update(FLASH_FLAGS_ACPOWERON, ac_boot_status());
78-
7976
flash_storage_update(FLASH_FLAGS_STANDALONE, get_standalone_mode() ? 1 : 0);
8077
#ifdef CONFIG_BOARD_LOTUS
8178
flash_storage_update(FLASH_FLAGS_INPUT_MODULE_POWER, get_detect_mode());
@@ -234,10 +231,6 @@ void chassis_interrupt_handler(enum gpio_signal signal)
234231

235232
static void bios_function_init(void)
236233
{
237-
/* restore the bios setup menu setting */
238-
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_BIOS_SETUP_FUNC) =
239-
flash_storage_get(FLASH_FLAGS_ACPOWERON);
240-
241234
if (flash_storage_get(FLASH_FLAGS_STANDALONE))
242235
set_standalone_mode(1);
243236
#ifdef CONFIG_BOARD_LOTUS

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 privacy_switches_check(struct host_cmd_handler_args *args)
460460
}
461461
DECLARE_HOST_COMMAND(EC_CMD_PRIVACY_SWITCHES_CHECK_MODE, privacy_switches_check, 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
/*******************************************************************************/
464483
/* EC console command for Project */
465484
/*******************************************************************************/

0 commit comments

Comments
 (0)