diff options
Diffstat (limited to 'board/agah/board.c')
-rw-r--r-- | board/agah/board.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/board/agah/board.c b/board/agah/board.c index d1cc519402..c8c98621d3 100644 --- a/board/agah/board.c +++ b/board/agah/board.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -15,19 +15,32 @@ #include "hooks.h" #include "fw_config.h" #include "hooks.h" +#include "keyboard_scan.h" #include "lid_switch.h" #include "power_button.h" #include "power.h" #include "registers.h" #include "switch.h" +#include "system.h" #include "throttle_ap.h" #include "usbc_config.h" +#include "util.h" + +#include "driver/nvidia_gpu.h" #include "gpio_list.h" /* Must come after other header files. */ /* Console output macros */ -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) -#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) + +static int block_sequence; + +struct d_notify_policy d_notify_policies[] = { + AC_ATLEAST_W(100), AC_ATLEAST_W(65), AC_DC, + DC_ATLEAST_SOC(20), DC_ATLEAST_SOC(5), +}; +BUILD_ASSERT(ARRAY_SIZE(d_notify_policies) == D_NOTIFY_COUNT); __override void board_cbi_init(void) { @@ -51,8 +64,15 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); static void board_init(void) { + if ((system_get_reset_flags() & EC_RESET_FLAG_AP_OFF) || + (keyboard_scan_get_boot_keys() & BOOT_KEY_DOWN_ARROW)) { + CPRINTS("PG_PP3300_S5_OD block is enabled"); + block_sequence = 1; + } gpio_enable_interrupt(GPIO_PG_PP3300_S5_OD); gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_ODL); + + nvidia_gpu_init_policy(d_notify_policies); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -61,9 +81,13 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); */ static void bypass_pp3300_s5_deferred(void) { - int pg_pp3300_s5 = gpio_get_level(GPIO_PG_PP3300_S5_OD); + if (block_sequence) { + CPRINTS("PG_PP3300_S5_OD is blocked."); + return; + } - gpio_set_level(GPIO_PG_PP3300_S5_EC_SEQ_OD, pg_pp3300_s5); + gpio_set_level(GPIO_PG_PP3300_S5_EC_SEQ_OD, + gpio_get_level(GPIO_PG_PP3300_S5_OD)); } DECLARE_DEFERRED(bypass_pp3300_s5_deferred); @@ -72,3 +96,23 @@ void board_power_interrupt(enum gpio_signal signal) /* Trigger deferred notification of gpio PG_PP3300_S5_OD change */ hook_call_deferred(&bypass_pp3300_s5_deferred_data, 0); } + +static int cc_blockseq(int argc, const char *argv[]) +{ + if (argc > 1) { + if (!parse_bool(argv[1], &block_sequence)) { + ccprintf("Invalid argument: %s\n", argv[1]); + return EC_ERROR_INVAL; + } + } + + ccprintf("PG_PP3300_S5_OD block is %s\n", + block_sequence ? "enabled" : "disabled"); + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(blockseq, cc_blockseq, "[on/off]", NULL); + +void gpu_overt_interrupt(enum gpio_signal signal) +{ + nvidia_gpu_over_temp(gpio_get_level(signal)); +} |