Skip to content

Commit 8e33f6f

Browse files
authored
Merge pull request #709 from FrameworkComputer/fwk.led_control_ersx5
Follow the ERS to modify the LED behavior
2 parents eea52e0 + 3e031e1 commit 8e33f6f

File tree

9 files changed

+135
-14
lines changed

9 files changed

+135
-14
lines changed

util/config_allowed.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ CONFIG_FAKE_SHMEM
373373
CONFIG_FANS
374374
CONFIG_FAN_DSLEEP
375375
CONFIG_FAN_DYNAMIC
376-
CONFIG_FAN_INIT_SPEED
377376
CONFIG_FAN_RPM_CUSTOM
378377
CONFIG_FAN_UPDATE_PERIOD
379378
CONFIG_FINGERPRINT_MCU

zephyr/program/lotus/azalea/src/project_diagnostics.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "board_adc.h"
88
#include "console.h"
99
#include "diagnostics.h"
10+
#include "dptf.h"
1011
#include "driver/temp_sensor/f75303.h"
1112
#include "fan.h"
1213
#include "hooks.h"
@@ -22,6 +23,13 @@
2223
#define F75303_PRODUCT_ID 0xFD
2324
#define F75303_ID 0x21
2425

26+
void start_fan_deferred(void)
27+
{
28+
/* force turn on the fan for diagnostic */
29+
dptf_set_fan_duty_target(20);
30+
}
31+
DECLARE_DEFERRED(start_fan_deferred);
32+
2533
void check_device_deferred(void)
2634
{
2735
int touchpad = get_hardware_id(ADC_TOUCHPAD_ID);
@@ -42,16 +50,19 @@ void check_device_deferred(void)
4250
if (product_id != F75303_ID)
4351
set_diagnostic(DIAGNOSTICS_THERMAL_SENSOR, true);
4452

45-
4653
if (!(fan_get_rpm_actual(0) > 100))
4754
set_diagnostic(DIAGNOSTICS_NOFAN, true);
4855

56+
/* Exit the duty mode and let thermal to control the fan */
57+
dptf_set_fan_duty_target(-1);
58+
4959
if (amd_ddr_initialized_check())
5060
set_bios_diagnostic(CODE_DDR_FAIL);
5161
}
5262
DECLARE_DEFERRED(check_device_deferred);
5363

5464
void project_diagnostics(void)
5565
{
66+
hook_call_deferred(&start_fan_deferred_data, 500 * MSEC);
5667
hook_call_deferred(&check_device_deferred_data, 2000 * MSEC);
5768
}

zephyr/program/lotus/include/lotus/gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
bool gpu_present(void);
1010

11+
bool gpu_module_fault(void);
12+
1113
void set_host_dp_ready(int ready);
1214

1315
#endif /* __BOARD_GPU_H__ */

zephyr/program/lotus/include/lotus/input_module.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ enum input_deck_mux {
4848

4949
int get_deck_state(void);
5050

51+
bool input_deck_is_fully_populated(void);
52+
5153
void input_modules_powerdown(void);
5254

5355
void set_detect_mode(int mode);

zephyr/program/lotus/lotus/src/gpu.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ LOG_MODULE_REGISTER(gpu, LOG_LEVEL_INF);
2828
#define GPU_F75303_I2C_ADDR_FLAGS 0x4D
2929

3030
static int module_present;
31+
static int module_fault;
32+
3133
bool gpu_present(void)
3234
{
3335
return module_present;
3436
}
3537

38+
bool gpu_module_fault(void)
39+
{
40+
return module_fault;
41+
}
42+
3643
static void update_gpu_ac_power_state(void)
3744
{
3845
if (extpower_is_present() && module_present) {
@@ -67,11 +74,14 @@ void check_gpu_module(void)
6774
LOG_INF("Detected single interposer device");
6875
module_present = 1;
6976
break;
70-
71-
default:
77+
case VALID_BOARDID(BOARD_VERSION_15, BOARD_VERSION_15):
7278
LOG_INF("No gpu module detected %d %d", gpu_id_0, gpu_id_1);
73-
/* Framework TODO remove for DVT, for now force on unless feature is enabled */
7479
module_present = 0;
80+
break;
81+
default:
82+
LOG_INF("GPU module Fault");
83+
module_present = 0;
84+
module_fault = 1;
7585
break;
7686
}
7787

zephyr/program/lotus/lotus/src/input_module.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ int get_detect_mode(void)
4747
return detect_mode;
4848
}
4949

50+
bool input_deck_is_fully_populated(void)
51+
{
52+
int idx;
53+
int input_deck_sum = 0;
54+
55+
/* Touchpad disconnected */
56+
if (hub_board_id[TOUCHPAD] != BOARD_VERSION_13)
57+
return false;
58+
59+
for (idx = 0; idx < TOUCHPAD; idx++) {
60+
if (hub_board_id[idx] != BOARD_VERSION_15)
61+
input_deck_sum += hub_board_id[idx];
62+
}
63+
64+
/* The minimum value is BOARD_ID_8 (Generic A) + BOARD_ID_9 (Generic B)*/
65+
if (input_deck_sum < 17)
66+
return false;
67+
68+
return true;
69+
}
5070

5171
static void set_hub_mux(uint8_t input)
5272
{

zephyr/program/lotus/lotus/src/project_diagnostics.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "board_host_command.h"
77
#include "console.h"
88
#include "diagnostics.h"
9+
#include "dptf.h"
910
#include "fan.h"
1011
#include "gpu.h"
1112
#include "hooks.h"
@@ -16,26 +17,40 @@
1617
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
1718
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
1819

20+
void start_fan_deferred(void)
21+
{
22+
/* force turn on the fan for diagnostic */
23+
dptf_set_fan_duty_target(5);
24+
}
25+
DECLARE_DEFERRED(start_fan_deferred);
26+
1927
void check_device_deferred(void)
2028
{
21-
if (!gpu_present())
29+
if (gpu_module_fault())
2230
set_diagnostic(DIAGNOSTICS_GPU_MODULE_FAULT, true);
2331

2432
if (get_deck_state() != DECK_ON && !get_standalone_mode())
2533
set_diagnostic(DIAGNOSTICS_INPUT_MODULE_FAULT, true);
2634

35+
/* force turn on the fan for diagnostic */
36+
dptf_set_fan_duty_target(5);
37+
2738
if (!(fan_get_rpm_actual(0) > 100))
2839
set_diagnostic(DIAGNOSTICS_NO_RIGHT_FAN, true);
2940

3041
if (!(fan_get_rpm_actual(1) > 100))
3142
set_diagnostic(DIAGNOSTICS_NO_LEFT_FAN, true);
3243

44+
/* Exit the duty mode and let thermal to control the fan */
45+
dptf_set_fan_duty_target(-1);
46+
3347
if (amd_ddr_initialized_check())
3448
set_bios_diagnostic(CODE_DDR_FAIL);
3549
}
3650
DECLARE_DEFERRED(check_device_deferred);
3751

3852
void project_diagnostics(void)
3953
{
54+
hook_call_deferred(&start_fan_deferred_data, 500 * MSEC);
4055
hook_call_deferred(&check_device_deferred_data, 2000 * MSEC);
4156
}

zephyr/program/lotus/src/led.c

Lines changed: 68 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,67 @@ 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+
#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 */
487514
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_chassis_open_l)) == 0 &&
488515
!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);
490549
return;
491550
}
551+
#endif
492552

493553
board_led_set_color();
494554
}

zephyr/shim/include/config_chip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,10 @@ BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(mps_mp2964)) == 1,
31203120
#endif
31213121

31223122
#undef CONFIG_CUSTOMIZED_DESIGN
3123+
#undef CONFIG_FAN_INIT_SPEED
31233124
#ifdef CONFIG_PLATFORM_EC_CUSTOMIZED_DESIGN
31243125
#define CONFIG_CUSTOMIZED_DESIGN
3126+
#define CONFIG_FAN_INIT_SPEED 20
31253127
#endif
31263128

31273129
#undef CONFIG_SYSTEM_SAFE_MODE

0 commit comments

Comments
 (0)