|
15 | 15 | #include "charge_state.h" |
16 | 16 | #include "chipset.h" |
17 | 17 | #include "ec_commands.h" |
| 18 | +#include "extpower.h" |
18 | 19 | #include "hooks.h" |
19 | 20 | #include "host_command.h" |
20 | 21 | #include "led.h" |
|
27 | 28 | #include "diagnostics.h" |
28 | 29 | #include "lid_switch.h" |
29 | 30 |
|
| 31 | +#ifdef CONFIG_BOARD_LOTUS |
| 32 | +#include "gpu.h" |
| 33 | +#include "input_module.h" |
| 34 | +#endif |
| 35 | + |
30 | 36 |
|
31 | 37 | #include <zephyr/devicetree.h> |
32 | 38 | #include <zephyr/drivers/gpio.h> |
@@ -430,19 +436,25 @@ static void board_led_set_power(void) |
430 | 436 | led_set_color(LED_OFF, EC_LED_ID_POWER_LED); |
431 | 437 | } |
432 | 438 |
|
433 | | -static void chassis_open_blink_leds(void) |
| 439 | +static void multifunction_leds_control(int *colors, int num_color, int period) |
434 | 440 | { |
435 | 441 | static uint32_t ticks; |
| 442 | + static int idx; |
436 | 443 |
|
437 | 444 | gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_right_side), 1); |
438 | 445 | gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_left_side), 1); |
439 | 446 |
|
440 | 447 | ticks++; |
441 | 448 |
|
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); |
446 | 458 | } |
447 | 459 |
|
448 | 460 | /* =============================== */ |
@@ -476,19 +488,67 @@ static void board_led_set_color(void) |
476 | 488 | /* Called by hook task every HOOK_TICK_INTERVAL_MS */ |
477 | 489 | static void led_tick(void) |
478 | 490 | { |
| 491 | + int colors[3] = {LED_OFF, LED_OFF, LED_OFF}; |
| 492 | + |
479 | 493 | if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) |
480 | 494 | board_led_set_power(); |
481 | 495 |
|
482 | | - /* we have an error, override LED control*/ |
| 496 | + /* Debug Active */ |
483 | 497 | if (diagnostics_tick()) |
484 | 498 | return; |
485 | 499 |
|
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 | +#ifdef CONFIG_BOARD_LOUTS |
| 506 | + multifunction_leds_control(colors, 2, 1000); |
| 507 | +#else |
| 508 | + multifunction_leds_control(colors, 2, 500); |
| 509 | +#endif |
| 510 | + return; |
| 511 | + } |
| 512 | + |
| 513 | + /* C cover detect switch open */ |
487 | 514 | if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_chassis_open_l)) == 0 && |
488 | 515 | !get_standalone_mode()) { |
489 | | - chassis_open_blink_leds(); |
| 516 | + colors[0] = LED_RED; |
| 517 | + colors[1] = LED_OFF; |
| 518 | + colors[2] = LED_OFF; |
| 519 | + multifunction_leds_control(colors, 2, 1000); |
| 520 | + return; |
| 521 | + } |
| 522 | + |
| 523 | +#ifdef CONFIG_BOARD_LOTUS |
| 524 | + /* GPU bay cover detect switch open */ |
| 525 | + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_f_beam_open_l)) == 0 && |
| 526 | + !get_standalone_mode()) { |
| 527 | + colors[0] = LED_RED; |
| 528 | + colors[1] = LED_AMBER; |
| 529 | + colors[2] = LED_OFF; |
| 530 | + multifunction_leds_control(colors, 3, 1000); |
| 531 | + return; |
| 532 | + } |
| 533 | + |
| 534 | + /* GPU Bay Module Fault */ |
| 535 | + if (gpu_module_fault() && extpower_is_present()) { |
| 536 | + colors[0] = LED_RED; |
| 537 | + colors[1] = LED_AMBER; |
| 538 | + colors[2] = LED_OFF; |
| 539 | + multifunction_leds_control(colors, 3, 1000); |
| 540 | + return; |
| 541 | + } |
| 542 | + |
| 543 | + /* Input Deck not fully populated */ |
| 544 | + if (!input_deck_is_fully_populated() && !get_standalone_mode()) { |
| 545 | + colors[0] = LED_RED; |
| 546 | + colors[1] = LED_BLUE; |
| 547 | + colors[2] = LED_OFF; |
| 548 | + multifunction_leds_control(colors, 3, 500); |
490 | 549 | return; |
491 | 550 | } |
| 551 | +#endif |
492 | 552 |
|
493 | 553 | board_led_set_color(); |
494 | 554 | } |
|
0 commit comments