Skip to content

Commit ad0db6a

Browse files
Josh-Tsaiamstan
authored andcommitted
fwk: dogwood: blink 12V LED for 30 seconds if not detect 12V
The 12V LED should blink for 30 seconds, or until the user pushes the power button again to attempt to transition to S0. BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86ettgaw5 TEST=Disconnect JPSU1 and then press the power button check that LED2 is blinking for 30 seconds. TEST=Continue from the previous step. Connect the JPSU1 and then press the power button to power on the system, the LED2 will stop blink and keep on, TEST=Enter 5VSB and check the LED2 is off. Signed-off-by: Josh Tsai <Josh_Tsai@compal.com>
1 parent 21c442c commit ad0db6a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
*/
4545
#define TIMEOUT_VS_POWER_TURN_OFF (20 * MSEC)
4646

47+
#define POWER_12V_LED_BLINKING_PERIOD (500 * MSEC)
48+
#define POWER_12V_LED_BLINKING_SECOND(x) ((x * SECOND) / POWER_12V_LED_BLINKING_PERIOD)
49+
4750
/*
4851
* Time to wait until turning off the power supply in low power
4952
* usage (like suspend).
@@ -371,7 +374,14 @@ void power_led2_blinking(void)
371374

372375
/* blink LED2 with 2 Hz */
373376
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led2_drv), !!(tick++ % 2));
374-
hook_call_deferred(&power_led2_blinking_data, 500 * MSEC);
377+
378+
if (tick < POWER_12V_LED_BLINKING_SECOND(30))
379+
hook_call_deferred(&power_led2_blinking_data, POWER_12V_LED_BLINKING_PERIOD);
380+
else {
381+
/* Stop blinking the LED2 */
382+
tick = 0;
383+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led2_drv), 0);
384+
}
375385
}
376386

377387
static void power_check_12vb_apu(void)
@@ -390,15 +400,12 @@ static void power_check_12vb_apu(void)
390400
* 12VB_APU is present or not to control the debug led2.
391401
*/
392402
if (voltage < 5000) {
393-
if (!psu_is_supposed_to_be_on) {
394-
/* Stop blinking the LED2 (G3) */
395-
hook_call_deferred(&power_led2_blinking_data, -1);
396-
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led2_drv), 0);
397-
} else {
398-
/* Start blinking the LED2 (S0 but 12V is not detected) */
399-
power_led2_blinking();
400-
set_diagnostic(DIAGNOSTICS_12V_OK, 1);
401-
}
403+
/* Start blinking the LED2 30 seconds */
404+
power_led2_blinking();
405+
set_diagnostic(DIAGNOSTICS_12V_OK, 1);
406+
} else {
407+
/* Stop blinking if the 12V is detected */
408+
hook_call_deferred(&power_led2_blinking_data, -1);
402409
}
403410
}
404411

0 commit comments

Comments
 (0)