Agah: Add command to block power sequence
This patch adds blockseq commands, which blocks PG_PP3300_S5_OD. This
patch also makes the down arrow key block the PG signal as well.
BRANCH=None
TEST=None
#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 "gpio_list.h" /* Must come after other header files. */
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+static int block_sequence;
+
__override void board_cbi_init(void)
{
}
@@ -51,6 +56,11 @@ 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);
}
@@ -61,9 +71,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 +86,18 @@ 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, 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);
