Skip to content

Commit 3ed7daa

Browse files
LeoCX-Tsaiquinchou77
authored andcommitted
fwk: main: fix lotus power limit behavior
at mainboard ERS, has comment when the best performance mode needs to dynamic switch PMF table according to battery percentage 30% and 60%. but EC didn't check the mode, it will switch anyway. so add condition only switch at performance mode. BRANCH=fwk-lotus-azalea-19573 BUG=FrameworkComputer/SoftwareFirmwareIssueTracker#33 TEST=test on lotus, use 180w adp rund fumark cpu+gpu burn, make sure at Balanced mode battery wouldn't drains. Signed-off-by: LeoCX_Tsai <[email protected]> (cherry picked from commit 55ad7727e9d4a2916c718487400282cb4ccb9782)
1 parent 1d7bcf1 commit 3ed7daa

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,15 @@ static void update_thermal_power_limit(int battery_percent, int active_mpower,
344344
}
345345
}
346346

347-
static int get_adapter_power_limit_index(int old_index, int battery_percent)
347+
static int get_adapter_power_limit_index(int old_index, int battery_percent, int mode)
348348
{
349-
if (battery_percent > 60)
350-
old_index = 0;
351-
else if (battery_percent < 30)
349+
/* at ERS only performance mode need to adjust limit */
350+
if (mode == EC_AC_BEST_PERFORMANCE) {
351+
if (battery_percent > 60)
352+
old_index = 0;
353+
else if (battery_percent < 30)
354+
old_index = 1;
355+
} else
352356
old_index = 1;
353357

354358
return old_index;
@@ -363,7 +367,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
363367
if (with_dc) {
364368
if (active_mpower >= 240000) {
365369
new_index =
366-
get_adapter_power_limit_index(new_index, battery_percent);
370+
get_adapter_power_limit_index(new_index,
371+
battery_percent, mode);
367372
switch (new_index) {
368373
case 0:
369374
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 145000;
@@ -389,7 +394,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
389394
}
390395
} else if (active_mpower >= 180000) {
391396
new_index =
392-
get_adapter_power_limit_index(new_index, battery_percent);
397+
get_adapter_power_limit_index(new_index,
398+
battery_percent, mode);
393399
switch (new_index) {
394400
case 0:
395401
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 120000;
@@ -415,7 +421,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
415421
}
416422
} else if (active_mpower >= 140000) {
417423
new_index =
418-
get_adapter_power_limit_index(new_index, battery_percent);
424+
get_adapter_power_limit_index(new_index,
425+
battery_percent, mode);
419426
switch (new_index) {
420427
case 0:
421428
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 95000;
@@ -441,7 +448,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
441448
}
442449
} else if (active_mpower >= 100000) {
443450
new_index =
444-
get_adapter_power_limit_index(new_index, battery_percent);
451+
get_adapter_power_limit_index(new_index,
452+
battery_percent, mode);
445453
switch (new_index) {
446454
case 0:
447455
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 60000;
@@ -468,7 +476,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
468476
} else if (active_mpower >= 5000) {
469477
/* DC + AC under 100W */
470478
new_index =
471-
get_adapter_power_limit_index(new_index, battery_percent);
479+
get_adapter_power_limit_index(new_index,
480+
battery_percent, mode);
472481
switch (new_index) {
473482
case 0:
474483
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 60000;
@@ -567,7 +576,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
567576
if (with_dc) {
568577
if (active_mpower >= 240000) {
569578
new_index =
570-
get_adapter_power_limit_index(new_index, battery_percent);
579+
get_adapter_power_limit_index(new_index,
580+
battery_percent, mode);
571581
switch (new_index) {
572582
case 0:
573583
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 45000;
@@ -591,7 +601,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
591601
}
592602
} else if (active_mpower >= 180000) {
593603
new_index =
594-
get_adapter_power_limit_index(new_index, battery_percent);
604+
get_adapter_power_limit_index(new_index,
605+
battery_percent, mode);
595606
switch (new_index) {
596607
case 0:
597608
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 45000;
@@ -613,7 +624,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
613624
}
614625
} else if (active_mpower >= 140000) {
615626
new_index =
616-
get_adapter_power_limit_index(new_index, battery_percent);
627+
get_adapter_power_limit_index(new_index,
628+
battery_percent, mode);
617629
switch (new_index) {
618630
case 0:
619631
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 45000;
@@ -635,7 +647,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
635647
}
636648
} else if (active_mpower >= 65000) {
637649
new_index =
638-
get_adapter_power_limit_index(new_index, battery_percent);
650+
get_adapter_power_limit_index(new_index,
651+
battery_percent, mode);
639652
switch (new_index) {
640653
case 0:
641654
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 45000;
@@ -658,7 +671,8 @@ static void update_adapter_power_limit(int battery_percent, int active_mpower,
658671
} else if (active_mpower >= 5000) {
659672
/* DC + AC under 65W */
660673
new_index =
661-
get_adapter_power_limit_index(new_index, battery_percent);
674+
get_adapter_power_limit_index(new_index,
675+
battery_percent, mode);
662676
switch (new_index) {
663677
case 0:
664678
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 45000;

0 commit comments

Comments
 (0)