Skip to content

Commit 7268dba

Browse files
committed
Lotus: follow the ERS x5 to implement the LED behavior
Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent 4fab1ea commit 7268dba

File tree

1 file changed

+63
-8
lines changed
  • zephyr/program/lotus/src

1 file changed

+63
-8
lines changed

zephyr/program/lotus/src/led.c

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "charge_state.h"
1616
#include "chipset.h"
1717
#include "ec_commands.h"
18+
#include "extpower.h"
1819
#include "hooks.h"
1920
#include "host_command.h"
2021
#include "led.h"
@@ -27,6 +28,11 @@
2728
#include "diagnostics.h"
2829
#include "lid_switch.h"
2930

31+
#ifdef CONFIG_BOARD_LOTUS
32+
#include "gpu.h"
33+
#include "input_module.h"
34+
#endif
35+
3036

3137
#include <zephyr/devicetree.h>
3238
#include <zephyr/drivers/gpio.h>
@@ -430,19 +436,25 @@ static void board_led_set_power(void)
430436
led_set_color(LED_OFF, EC_LED_ID_POWER_LED);
431437
}
432438

433-
static void chassis_open_blink_leds(void)
439+
static void multifunction_leds_control(int *colors, int num_color, int period)
434440
{
435441
static uint32_t ticks;
442+
static int idx;
436443

437444
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_right_side), 1);
438445
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_left_side), 1);
439446

440447
ticks++;
441448

442-
if ((ticks / 3) % 2)
443-
led_set_color(LED_RED, EC_LED_ID_BATTERY_LED);
444-
else
445-
led_set_color(LED_OFF, EC_LED_ID_BATTERY_LED);
449+
if ((ticks * 200) >= period) {
450+
ticks = 0;
451+
idx++;
452+
453+
if (idx >= num_color)
454+
idx = 0;
455+
}
456+
457+
led_set_color(colors[idx], EC_LED_ID_BATTERY_LED);
446458
}
447459

448460
/* =============================== */
@@ -476,19 +488,62 @@ static void board_led_set_color(void)
476488
/* Called by hook task every HOOK_TICK_INTERVAL_MS */
477489
static void led_tick(void)
478490
{
491+
int colors[3] = {LED_OFF, LED_OFF, LED_OFF};
492+
479493
if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
480494
board_led_set_power();
481495

482-
/* we have an error, override LED control*/
496+
/* Debug Active */
483497
if (diagnostics_tick())
484498
return;
485499

486-
/* chassis open */
500+
/* Battery disconnect active signal */
501+
if (battery_is_cut_off()) {
502+
colors[0] = LED_RED;
503+
colors[1] = LED_BLUE;
504+
colors[2] = LED_OFF;
505+
multifunction_leds_control(colors, 2, 1000);
506+
return;
507+
}
508+
509+
/* C cover detect switch open */
487510
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_chassis_open_l)) == 0 &&
488511
!get_standalone_mode()) {
489-
chassis_open_blink_leds();
512+
colors[0] = LED_RED;
513+
colors[1] = LED_OFF;
514+
colors[2] = LED_OFF;
515+
multifunction_leds_control(colors, 2, 1000);
516+
return;
517+
}
518+
519+
#ifdef CONFIG_BOARD_LOTUS
520+
/* GPU bay cover detect switch open */
521+
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_f_beam_open_l)) == 0) {
522+
colors[0] = LED_RED;
523+
colors[1] = LED_AMBER;
524+
colors[2] = LED_OFF;
525+
multifunction_leds_control(colors, 3, 1000);
526+
return;
527+
}
528+
529+
/* GPU Bay Module Fault */
530+
if (gpu_module_fault() && extpower_is_present()) {
531+
colors[0] = LED_RED;
532+
colors[1] = LED_AMBER;
533+
colors[2] = LED_OFF;
534+
multifunction_leds_control(colors, 3, 1000);
535+
return;
536+
}
537+
538+
/* Input Deck not fully populated */
539+
if (!input_deck_is_fully_populated() && !get_standalone_mode()) {
540+
colors[0] = LED_RED;
541+
colors[1] = LED_BLUE;
542+
colors[2] = LED_OFF;
543+
multifunction_leds_control(colors, 3, 500);
490544
return;
491545
}
546+
#endif
492547

493548
board_led_set_color();
494549
}

0 commit comments

Comments
 (0)