Skip to content

Commit 2910137

Browse files
Josh-Tsaiamstan
authored andcommitted
fwk: dogwood: Set the S0ix enter/exit flags correctly
Sometimes, the system will enter and resume S0ix several times within a tick time (200ms). EC should set the flags in the correct state. E.g., If the EC chipset state is in S0ix and the system resumes S0ix and then enters again, the final memmap (EC_CUSTOMIZED_MEMMAP_POWER_STATE) is EC_PS_ENTER_S0ix. In this case, EC should not set the enter_ms_flag. BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86eu5ttc4 TEST=let system enter S0ix state, use the ec console command "memmap set 0x101 0x40", and the press power button to resume the system. Check the power LED is on and EC power state is S0. Signed-off-by: Josh Tsai <Josh_Tsai@compal.com>
1 parent 2d45c86 commit 2910137

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ void clear_power_flags(void)
264264
* host resumes from S0ix, masks from backup variables are copied over to
265265
* lpc_host_event_mask for SCI.
266266
*/
267-
static int enter_ms_flag;
268-
static int resume_ms_flag;
269-
static int system_in_s0ix;
267+
static bool enter_ms_flag, resume_ms_flag, system_in_s0ix;
270268

271269
static int check_s0ix_statsus(void)
272270
{
@@ -279,14 +277,18 @@ static int check_s0ix_statsus(void)
279277

280278

281279
/**
282-
* Sometimes PCH will set the enter and resume flag continuously
283-
* so clear the EMI when we read the flag.
280+
* Sometimes, the system will enter and resume S0ix several times within a
281+
* tick time (200ms).EC should set the flags in the correct state.
282+
*
283+
* E.g., If the EC chipset state is in S0ix and the system resumes S0ix and
284+
* then enters again, the final memmap (EC_CUSTOMIZED_MEMMAP_POWER_STATE)
285+
* is EC_PS_ENTER_S0ix. In this case, EC should not set the enter_ms_flag.
284286
*/
285-
if (power_status & EC_PS_ENTER_S0ix)
286-
enter_ms_flag++;
287+
if ((power_status & EC_PS_ENTER_S0ix) && !system_in_s0ix)
288+
enter_ms_flag = true;
287289

288-
if (power_status & EC_PS_RESUME_S0ix)
289-
resume_ms_flag++;
290+
if ((power_status & EC_PS_RESUME_S0ix) && system_in_s0ix)
291+
resume_ms_flag = true;
290292

291293
clear_flag = power_status & (EC_PS_ENTER_S0ix | EC_PS_RESUME_S0ix);
292294

@@ -298,14 +300,14 @@ static int check_s0ix_statsus(void)
298300
if (enter_ms_flag)
299301
return CS_ENTER_S0ix;
300302
}
301-
return 0;
303+
return CS_NONE;
302304
}
303305

304306
static void power_clear_s0ix_flag(void)
305307
{
306-
resume_ms_flag = 0;
307-
enter_ms_flag = 0;
308-
system_in_s0ix = 0;
308+
resume_ms_flag = false;
309+
enter_ms_flag = false;
310+
system_in_s0ix = false;
309311
}
310312

311313
void s0ix_status_handle(void)
@@ -321,11 +323,6 @@ void s0ix_status_handle(void)
321323
}
322324
DECLARE_HOOK(HOOK_TICK, s0ix_status_handle, HOOK_PRIO_DEFAULT);
323325

324-
int check_s0ix_status(void)
325-
{
326-
return system_in_s0ix;
327-
}
328-
329326
#endif
330327

331328
void chipset_reset(enum chipset_shutdown_reason reason)
@@ -827,8 +824,8 @@ enum power_state power_handle_state(enum power_state state)
827824
return POWER_S0ix;
828825

829826
case POWER_S0ixS0:
830-
resume_ms_flag = 0;
831-
system_in_s0ix = 0;
827+
resume_ms_flag = false;
828+
system_in_s0ix = false;
832829

833830
lpc_s0ix_resume_restore_masks();
834831
hook_notify(HOOK_CHIPSET_RESUME);
@@ -837,8 +834,9 @@ enum power_state power_handle_state(enum power_state state)
837834
break;
838835

839836
case POWER_S0S0ix:
840-
enter_ms_flag = 0;
841-
system_in_s0ix = 1;
837+
enter_ms_flag = false;
838+
system_in_s0ix = true;
839+
842840
lpc_s0ix_suspend_clear_masks();
843841
hook_notify(HOOK_CHIPSET_SUSPEND);
844842
return POWER_S0ix;

0 commit comments

Comments
 (0)