Skip to content

Commit 1acf61f

Browse files
LeoCX-Tsaiquinchou77
authored andcommitted
fwk: lilac: Set the S0ix enter/exit flags correctly
reference PR#1653 to add this solution to avoid MS mode abnormal 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-lilac-27116 BUG=None 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: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent 6415758 commit 1acf61f

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ void clear_power_flags(void)
159159
* host resumes from S0ix, masks from backup variables are copied over to
160160
* lpc_host_event_mask for SCI.
161161
*/
162-
static int enter_ms_flag;
163-
static int resume_ms_flag;
164-
static int system_in_s0ix;
162+
static bool enter_ms_flag, resume_ms_flag, system_in_s0ix;
165163

166164
static int check_s0ix_statsus(void)
167165
{
@@ -174,14 +172,18 @@ static int check_s0ix_statsus(void)
174172

175173

176174
/**
177-
* Sometimes PCH will set the enter and resume flag continuously
178-
* so clear the EMI when we read the flag.
175+
* Sometimes, the system will enter and resume S0ix several times within a
176+
* tick time (200ms).EC should set the flags in the correct state.
177+
*
178+
* E.g., If the EC chipset state is in S0ix and the system resumes S0ix and
179+
* then enters again, the final memmap (EC_CUSTOMIZED_MEMMAP_POWER_STATE)
180+
* is EC_PS_ENTER_S0ix. In this case, EC should not set the enter_ms_flag.
179181
*/
180-
if (power_status & EC_PS_ENTER_S0ix)
181-
enter_ms_flag++;
182+
if ((power_status & EC_PS_ENTER_S0ix) && !system_in_s0ix)
183+
enter_ms_flag = true;
182184

183-
if (power_status & EC_PS_RESUME_S0ix)
184-
resume_ms_flag++;
185+
if ((power_status & EC_PS_RESUME_S0ix) && system_in_s0ix)
186+
resume_ms_flag = true;
185187

186188
clear_flag = power_status & (EC_PS_ENTER_S0ix | EC_PS_RESUME_S0ix);
187189

@@ -193,7 +195,14 @@ static int check_s0ix_statsus(void)
193195
if (enter_ms_flag)
194196
return CS_ENTER_S0ix;
195197
}
196-
return 0;
198+
return CS_NONE;
199+
}
200+
201+
static void power_clear_s0ix_flag(void)
202+
{
203+
resume_ms_flag = false;
204+
enter_ms_flag = false;
205+
system_in_s0ix = false;
197206
}
198207

199208
void s0ix_status_handle(void)
@@ -209,11 +218,6 @@ void s0ix_status_handle(void)
209218
}
210219
DECLARE_HOOK(HOOK_TICK, s0ix_status_handle, HOOK_PRIO_DEFAULT);
211220

212-
int check_s0ix_status(void)
213-
{
214-
return system_in_s0ix;
215-
}
216-
217221
#endif
218222

219223
void chipset_reset(enum chipset_shutdown_reason reason)
@@ -395,9 +399,7 @@ enum power_state power_handle_state(enum power_state state)
395399
} else if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l)) == 0) {
396400

397401
if (system_in_s0ix) {
398-
resume_ms_flag = 0;
399-
enter_ms_flag = 0;
400-
system_in_s0ix = 0;
402+
power_clear_s0ix_flag();
401403
lpc_s0ix_resume_restore_masks();
402404
/* Call hooks now that rails are up */
403405
hook_notify(HOOK_CHIPSET_RESUME);
@@ -479,9 +481,7 @@ enum power_state power_handle_state(enum power_state state)
479481
* clear the resume ms flag
480482
*/
481483
if (resume_ms_flag > 0) {
482-
resume_ms_flag = 0;
483-
enter_ms_flag = 0;
484-
system_in_s0ix = 0;
484+
power_clear_s0ix_flag();
485485
return POWER_S0ixS0;
486486
}
487487
return POWER_S0ixS3;
@@ -508,8 +508,8 @@ enum power_state power_handle_state(enum power_state state)
508508

509509
case POWER_S0ixS0:
510510
CPRINTS("PH S0ixS0");
511-
resume_ms_flag = 0;
512-
system_in_s0ix = 0;
511+
resume_ms_flag = false;
512+
system_in_s0ix = false;
513513
lpc_s0ix_resume_restore_masks();
514514
/* Call hooks now that rails are up */
515515
hook_notify(HOOK_CHIPSET_RESUME);
@@ -526,8 +526,8 @@ enum power_state power_handle_state(enum power_state state)
526526
break;
527527

528528
case POWER_S0S0ix:
529-
enter_ms_flag = 0;
530-
system_in_s0ix = 1;
529+
enter_ms_flag = false;
530+
system_in_s0ix = true;
531531
CPRINTS("PH S0->S0ix");
532532
lpc_s0ix_suspend_clear_masks();
533533
/* Call hooks before we remove power rails */

0 commit comments

Comments
 (0)