Skip to content

Commit 88727e6

Browse files
JohnWC-Yehamstan
authored andcommitted
fwk: 16-inch: add GPU_PWR_LEVEL control
To prevent GPU power spikes before the OS driver is loaded, control GPU_PWR_LEVEL GPIO during power-on: - At 0x3E07 (non-ACPI/PMF update), force GPU_PWR_LEVEL low to limit GPU power. - At 0x3E10 (ACPI driver ready), keep GPU_PWR_LEVEL low for an additional 60s, then release (pull high) once OS is stable. This ensures NV GPU systems can successfully boot to OS on AC-only with 100W adapter. BRANCH=fwk-tulip-29169 BUG=https://app.clickup.com/t/86euq09pq TEST=Verified AC-only boot with 100W adapter reaches OS with NV GPU on Tulip Used gpucfg console command to confirm GPIO2 (GPU_PWR_LEVEL) state: - At HC 0x3E07: GPIO2 = Low - At HC 0x3E10 + 60s: GPIO2 = High Signed-off-by: johnwc_yeh <JohnWC_Yeh@compal.com>
1 parent cffc589 commit 88727e6

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

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

99
#include <gpu_configuration.h>
1010
#include "common_cpu_power.h"
11+
#include "throttle_ap.h"
1112

1213

1314
bool gpu_power_enable(void);
@@ -52,4 +53,12 @@ void gpu_set_pd_state(void);
5253

5354
void gpu_update_pd_vdm(int controller, int port, uint8_t *data, int len);
5455

56+
/**
57+
* Set the NV GPU throttle
58+
*
59+
* @param level Level of throttling desired
60+
* @param delay Delay (in seconds) before applying the throttle.
61+
*/
62+
void set_nv_gpu_throttle(enum throttle_level level, int delay);
63+
5564
#endif /* __BOARD_GPU_H__ */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ void update_soc_power_limit(bool force_update, bool force_no_adapter)
475475
set_gpu_gpio(GPIO_FUNC_ACDC, 1);
476476
#endif
477477

478+
if (force_update)
479+
set_nv_gpu_throttle(THROTTLE_ON, 0);
480+
478481
if (mode_ctl)
479482
mode = mode_ctl;
480483

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static int gpu_id_0;
4343
static int gpu_id_1;
4444
static int switch_status;
4545
static enum gpu_pd pd_type = PD_TYPE_INVALID;
46+
static bool curr_throttle_level;
4647

4748
bool gpu_power_enable(void)
4849
{
@@ -366,3 +367,31 @@ void gpu_update_pd_vdm(int controller, int port, uint8_t *data, int len)
366367
}
367368
}
368369
}
370+
371+
static void nv_gpu_throttle_apply(void)
372+
{
373+
if (curr_throttle_level == THROTTLE_ON) {
374+
if (get_gpu_gpio(GPIO_FUNC_GPU_PWR_LEVEL)) {
375+
set_gpu_gpio(GPIO_FUNC_GPU_PWR_LEVEL, 0);
376+
}
377+
} else {
378+
if (!get_gpu_gpio(GPIO_FUNC_GPU_PWR_LEVEL)) {
379+
set_gpu_gpio(GPIO_FUNC_GPU_PWR_LEVEL, 1);
380+
}
381+
}
382+
}
383+
DECLARE_DEFERRED(nv_gpu_throttle_apply);
384+
385+
void set_nv_gpu_throttle(enum throttle_level level, int delay)
386+
{
387+
/* Cancel pending deferred call. */
388+
hook_call_deferred(&nv_gpu_throttle_apply_data, -1);
389+
390+
curr_throttle_level = level;
391+
392+
if (delay == 0) {
393+
nv_gpu_throttle_apply();
394+
} else {
395+
hook_call_deferred(&nv_gpu_throttle_apply_data, delay * SECOND);
396+
}
397+
}

zephyr/program/framework/src/board_host_command.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ static void sci_enable(void)
7070
#ifdef CONFIG_PLATFORM_EC_FRAMEWORK_LAPTOP_16
7171
/* hook_call_deferred(&gpu_typec_detect_data, 500 * MSEC); */
7272
gpu_typec_detect();
73+
74+
set_nv_gpu_throttle(THROTTLE_OFF, 60);
7375
#endif
7476
} else
7577
hook_call_deferred(&sci_enable_data, 250 * MSEC);

0 commit comments

Comments
 (0)