Skip to content

Commit a373792

Browse files
authored
Merge pull request #454 from FrameworkComputer/hx30.fix_ac_power_on
hx30: modify power on by AC
2 parents 1047dc8 + 278572c commit a373792

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
{
2+
"files.associations": {
3+
"*.inc": "c",
4+
"battery_smart.h": "c"
5+
}
26
}

board/hx30/board.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,23 @@ void board_reset_pd_mcu(void)
369369

370370
}
371371

372+
/**
373+
* Check the plug-in AC then power on system setting.
374+
*/
375+
bool ac_poweron_check(void)
376+
{
377+
uint8_t memcap;
378+
379+
system_get_bbram(SYSTEM_BBRAM_IDX_AC_BOOT, &memcap);
380+
381+
return memcap ? true : false;
382+
}
383+
384+
int poweron_reason_acin(void)
385+
{
386+
return extpower_is_present() && ac_poweron_check();
387+
}
388+
372389
static int power_button_pressed_on_boot;
373390
int poweron_reason_powerbtn(void)
374391
{

board/hx30/board.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ void thm_ft5399m_set_timeout_en(void);
772772
void update_me_change(int change);
773773

774774
int poweron_reason_powerbtn(void);
775+
int poweron_reason_acin(void);
775776

776777
#ifdef CONFIG_EMI_REGION1
777778
void power_state_clear(int state);

board/hx30/power_button_x86.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,6 @@ int power_button_batt_cutoff(void)
261261
return power_button_battery_cutoff;
262262
}
263263

264-
/**
265-
* Check the plug-in AC then power on system setting.
266-
*/
267-
bool ac_poweron_check(void)
268-
{
269-
uint8_t memcap;
270-
271-
system_get_bbram(SYSTEM_BBRAM_IDX_AC_BOOT, &memcap);
272-
273-
return memcap ? true : false;
274-
}
275-
276264
/**
277265
* Power button state machine.
278266
*
@@ -396,9 +384,8 @@ static void state_machine(uint64_t tnow)
396384
tnext_state = tnow + PWRBTN_DELAY_INITIAL;
397385
initial_delay--;
398386
} else {
399-
if ((poweron_reason_powerbtn() || (system_get_reset_flags() &
400-
EC_RESET_FLAG_HARD) == EC_RESET_FLAG_HARD) ||
401-
(extpower_is_present() && ac_poweron_check())) {
387+
if (poweron_reason_powerbtn() || poweron_reason_acin() ||
388+
((system_get_reset_flags() & EC_RESET_FLAG_HARD) == EC_RESET_FLAG_HARD)) {
402389

403390
reset_diagnostics();
404391

@@ -429,8 +416,8 @@ static void state_machine(uint64_t tnow)
429416
* button until it's released, so that holding down the
430417
* recovery combination doesn't cause the chipset to shut back
431418
* down. */
432-
if (poweron_reason_powerbtn() || (system_get_reset_flags() &
433-
EC_RESET_FLAG_HARD) == EC_RESET_FLAG_HARD)
419+
if (poweron_reason_powerbtn() || poweron_reason_acin() ||
420+
((system_get_reset_flags() & EC_RESET_FLAG_HARD) == EC_RESET_FLAG_HARD))
434421
set_pwrbtn_to_pch(1, 1);
435422

436423
if (power_button_is_pressed())

0 commit comments

Comments
 (0)