Skip to content

Commit 9ce38ce

Browse files
JohnWC-YehTerrails
authored andcommitted
fwk: lotus: adjust power limit based on the GPU power state
The EC should be monitoring GPU power enable GPIO, and adjust the CPU power limit based on the GPU power state. BRANCH=fwk-lotus-azalea-19573 BUG=https://app.clickup.com/t/86eq3pjxh TEST=when gpu enters BOCO mode (gpio_dgpu_pwr_en = 0), PMF will switch to UMA table Signed-off-by: johnwc_yeh <JohnWC_Yeh@compal.com>
1 parent 5471ca5 commit 9ce38ce

File tree

3 files changed

+52
-42
lines changed

3 files changed

+52
-42
lines changed

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

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

1313
bool gpu_power_enable(void);
1414

15+
bool gpu_is_working(void);
16+
1517
bool gpu_module_fault(void);
1618

1719
void gpu_fan_control(int enable);

zephyr/program/framework/lotus/src/cpu_power.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -46,83 +46,83 @@ static void update_os_power_slider(int mode, bool with_dc, int active_mpower)
4646
switch (mode) {
4747
case EC_DC_BEST_PERFORMANCE:
4848
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
49-
(gpu_present() ? 60000 : 40000);
49+
(gpu_is_working() ? 60000 : 40000);
5050
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
51-
(gpu_present() ? 60000 : 48000);
51+
(gpu_is_working() ? 60000 : 48000);
5252
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
53-
(gpu_present() ? 60000 : 58000);
53+
(gpu_is_working() ? 60000 : 58000);
5454
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
55-
(gpu_present() ? 30000 : 0);
56-
slider_stt_table = (gpu_present() ? 21 : 23);
55+
(gpu_is_working() ? 30000 : 0);
56+
slider_stt_table = (gpu_is_working() ? 21 : 23);
5757
CPRINTS("DC BEST PERFORMANCE");
5858
break;
5959
case EC_DC_BALANCED:
6060
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
61-
(gpu_present() ? 50000 : 30000);
61+
(gpu_is_working() ? 50000 : 30000);
6262
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
63-
(gpu_present() ? 50000 : 36000);
63+
(gpu_is_working() ? 50000 : 36000);
6464
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
65-
(gpu_present() ? 50000 : 44000);
65+
(gpu_is_working() ? 50000 : 44000);
6666
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
67-
(gpu_present() ? 20000 : 0);
68-
slider_stt_table = (gpu_present() ? 22 : 24);
67+
(gpu_is_working() ? 20000 : 0);
68+
slider_stt_table = (gpu_is_working() ? 22 : 24);
6969
CPRINTS("DC BALANCED");
7070
break;
7171
case EC_DC_BEST_EFFICIENCY:
7272
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
73-
(gpu_present() ? 50000 : 20000);
73+
(gpu_is_working() ? 50000 : 20000);
7474
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
75-
(gpu_present() ? 50000 : 24000);
75+
(gpu_is_working() ? 50000 : 24000);
7676
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
77-
(gpu_present() ? 50000 : 29000);
77+
(gpu_is_working() ? 50000 : 29000);
7878
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
79-
(gpu_present() ? 20000 : 0);
80-
slider_stt_table = (gpu_present() ? 22 : 25);
79+
(gpu_is_working() ? 20000 : 0);
80+
slider_stt_table = (gpu_is_working() ? 22 : 25);
8181
CPRINTS("DC BEST EFFICIENCY");
8282
break;
8383
case EC_DC_BATTERY_SAVER:
8484
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 20000;
8585
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 20000;
8686
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 20000;
8787
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
88-
(gpu_present() ? 20000 : 0);
89-
slider_stt_table = (gpu_present() ? 7 : 14);
88+
(gpu_is_working() ? 20000 : 0);
89+
slider_stt_table = (gpu_is_working() ? 7 : 14);
9090
CPRINTS("DC BATTERY SAVER");
9191
break;
9292
case EC_AC_BEST_PERFORMANCE:
9393
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
94-
(gpu_present() ? 145000 : 45000);
94+
(gpu_is_working() ? 145000 : 45000);
9595
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
96-
(gpu_present() ? 145000 : 54000);
96+
(gpu_is_working() ? 145000 : 54000);
9797
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
98-
(gpu_present() ? 145000 : 65000);
98+
(gpu_is_working() ? 145000 : 65000);
9999
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
100-
(gpu_present() ? 54000 : 0);
101-
slider_stt_table = (gpu_present() ? 1 : 8);
100+
(gpu_is_working() ? 54000 : 0);
101+
slider_stt_table = (gpu_is_working() ? 1 : 8);
102102
CPRINTS("AC BEST PERFORMANCE");
103103
break;
104104
case EC_AC_BALANCED:
105105
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
106-
(gpu_present() ? 120000 : 40000);
106+
(gpu_is_working() ? 120000 : 40000);
107107
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
108-
(gpu_present() ? 120000 : 48000);
108+
(gpu_is_working() ? 120000 : 48000);
109109
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
110-
(gpu_present() ? 120000 : 58000);
110+
(gpu_is_working() ? 120000 : 58000);
111111
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
112-
(gpu_present() ? 50000 : 0);
113-
slider_stt_table = (gpu_present() ? 32 : 9);
112+
(gpu_is_working() ? 50000 : 0);
113+
slider_stt_table = (gpu_is_working() ? 32 : 9);
114114
CPRINTS("AC BALANCED");
115115
break;
116116
case EC_AC_BEST_EFFICIENCY:
117117
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] =
118-
(gpu_present() ? 85000 : 30000);
118+
(gpu_is_working() ? 85000 : 30000);
119119
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
120-
(gpu_present() ? 85000 : 36000);
120+
(gpu_is_working() ? 85000 : 36000);
121121
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
122-
(gpu_present() ? 85000 : 44000);
122+
(gpu_is_working() ? 85000 : 44000);
123123
power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT] =
124-
(gpu_present() ? 40000 : 0);
125-
slider_stt_table = (gpu_present() ? 3 : 10);
124+
(gpu_is_working() ? 40000 : 0);
125+
slider_stt_table = (gpu_is_working() ? 3 : 10);
126126
CPRINTS("AC BEST EFFICIENCY");
127127
break;
128128
default:
@@ -135,7 +135,7 @@ static void update_os_power_slider(int mode, bool with_dc, int active_mpower)
135135
static void update_thermal_power_limit(int battery_percent, int active_mpower,
136136
bool with_dc, int mode)
137137
{
138-
if (gpu_present()) {
138+
if (gpu_is_working()) {
139139
if ((active_mpower >= 240000) && with_dc) {
140140
/* limited by update_os_power_slider */
141141
power_limit[FUNCTION_THERMAL_PMF].mwatt[TYPE_SPL] =
@@ -359,7 +359,7 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
359359
{
360360
static int new_index;
361361

362-
if (gpu_present()) {
362+
if (gpu_is_working()) {
363363
if (with_dc) {
364364
if (active_mpower >= 240000) {
365365
new_index =
@@ -759,7 +759,7 @@ static void tune_PLs(int delta)
759759
= MAX(power_limit[FUNCTION_SAFETY].mwatt[TYPE_FPPT] + delta, 20000);
760760
power_limit[FUNCTION_SAFETY].mwatt[TYPE_P3T]
761761
= MAX(power_limit[FUNCTION_SAFETY].mwatt[TYPE_P3T] + delta, 20000);
762-
if (gpu_present())
762+
if (gpu_is_working())
763763
power_limit[FUNCTION_SAFETY].mwatt[TYPE_APU_ONLY_SPPT]
764764
= MAX(power_limit[FUNCTION_SAFETY].mwatt[TYPE_APU_ONLY_SPPT]
765765
+ delta, 20000);
@@ -804,7 +804,7 @@ static void update_safety_power_limit(int active_mpower)
804804
= power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT];
805805
power_limit[FUNCTION_SAFETY].mwatt[TYPE_P3T]
806806
= power_limit[FUNCTION_POWER].mwatt[TYPE_P3T];
807-
if (gpu_present())
807+
if (gpu_is_working())
808808
power_limit[FUNCTION_SAFETY].mwatt[TYPE_APU_ONLY_SPPT]
809809
= power_limit[FUNCTION_SLIDER].mwatt[TYPE_APU_ONLY_SPPT];
810810
else
@@ -826,7 +826,7 @@ static void update_safety_power_limit(int active_mpower)
826826
break;
827827
case LEVEL_TUNE_PLS:
828828
/* tuning CPU and GPU PLs */
829-
if (gpu_present()) {
829+
if (gpu_is_working()) {
830830
delta = 10000;
831831
if (level_increase) {
832832
tune_PLs((-1) * delta);
@@ -872,7 +872,7 @@ static void update_safety_power_limit(int active_mpower)
872872
break;
873873
case LEVEL_DISABLE_GPU:
874874
/* disable GPU and tune CPU PLs */
875-
if (gpu_present()) {
875+
if (gpu_is_working()) {
876876
if (level_increase) {
877877
tune_PLs(-10000);
878878
if (power_limit[FUNCTION_SAFETY].mwatt[TYPE_SPL] <= 20000)
@@ -896,12 +896,12 @@ static void update_safety_power_limit(int active_mpower)
896896
/* prochot */
897897
if (level_increase) {
898898
throttle_ap(THROTTLE_ON, THROTTLE_HARD, THROTTLE_SRC_BAT_DISCHG_CURRENT);
899-
thermal_stt_table = (gpu_present() ? 7 : 14);
899+
thermal_stt_table = (gpu_is_working() ? 7 : 14);
900900
safety_stt = 1;
901901
safety_level++;
902902
} else {
903903
throttle_ap(THROTTLE_OFF, THROTTLE_HARD, THROTTLE_SRC_BAT_DISCHG_CURRENT);
904-
thermal_stt_table = (gpu_present() ? 7 : 14);
904+
thermal_stt_table = (gpu_is_working() ? 7 : 14);
905905
safety_stt = 1;
906906
safety_level--;
907907
}
@@ -927,7 +927,7 @@ static void update_safety_power_limit(int active_mpower)
927927
}
928928
break;
929929
case LEVEL_COUNT:
930-
thermal_stt_table = (gpu_present() ? 7 : 14);
930+
thermal_stt_table = (gpu_is_working() ? 7 : 14);
931931
if (!level_increase)
932932
safety_level--;
933933
break;
@@ -1082,7 +1082,7 @@ void update_soc_power_limit(bool force_update, bool force_no_adapter)
10821082
}
10831083

10841084
/* when trigger thermal warm, reduce TYPE_APU_ONLY_SPPT to 45W */
1085-
if (gpu_present()) {
1085+
if (gpu_is_working()) {
10861086
if (thermal_warn_trigger())
10871087
power_limit[FUNCTION_THERMAL].mwatt[TYPE_APU_ONLY_SPPT] = 45000;
10881088
else

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ bool gpu_power_enable(void)
4646
return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_dgpu_pwr_en));
4747
}
4848

49+
bool gpu_is_working(void)
50+
{
51+
if (gpu_present() && gpu_power_enable())
52+
return true;
53+
54+
return false;
55+
}
56+
4957
bool gpu_module_fault(void)
5058
{
5159
return module_fault;

0 commit comments

Comments
 (0)