SANTHOSH JANARDHANA HASSAN has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31173
Change subject: google/mistral: Support triggering Recovery/FDR. ......................................................................
google/mistral: Support triggering Recovery/FDR.
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com --- M src/mainboard/google/mistral/Kconfig A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 4 files changed, 142 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/1
diff --git a/src/mainboard/google/mistral/Kconfig b/src/mainboard/google/mistral/Kconfig index 5e97bb6..f28a382 100644 --- a/src/mainboard/google/mistral/Kconfig +++ b/src/mainboard/google/mistral/Kconfig @@ -23,6 +23,7 @@ select GBB_FLAG_DEV_SCREEN_SHORT_DELAY select GBB_FLAG_FORCE_DEV_SWITCH_ON select GBB_FLAG_FORCE_MANUAL_RECOVERY + select VBOOT_WIPEOUT_SUPPORTED
config MAINBOARD_DIR string diff --git a/src/mainboard/google/mistral/board.h b/src/mainboard/google/mistral/board.h new file mode 100644 index 0000000..2e23ce3 --- /dev/null +++ b/src/mainboard/google/mistral/board.h @@ -0,0 +1,29 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2018, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __COREBOOT_SRC_MAINBOARD_GOOGLE_MISTRAL_BOARD_H +#define __COREBOOT_SRC_MAINBOARD_GOOGLE_MISTRAL_BOARD_H + +#include <gpio.h> +#include <soc/gpio.h> + + +#define GPIO_H1_AP_INT GPIO(53) +#define GPIO_WP_STATE GPIO(54) +#define GPIO_REC_STATE GPIO(77) + +void setup_chromeos_gpios(void); + +#endif /* ! __COREBOOT_SRC_MAINBOARD_GOOGLE_MISTRAL_BOARD_H */ diff --git a/src/mainboard/google/mistral/chromeos.c b/src/mainboard/google/mistral/chromeos.c index ba0b1da..0405c4e 100644 --- a/src/mainboard/google/mistral/chromeos.c +++ b/src/mainboard/google/mistral/chromeos.c @@ -14,11 +14,18 @@ */
#include <boot/coreboot_tables.h> -#include <gpio.h> #include <security/tpm/tis.h> -#include <soc/gpio.h> +#include <bootmode.h> +#include <timer.h> +#include <console/console.h> +#include "board.h"
-#define GPIO_H1_AP_INT GPIO(53) +void setup_chromeos_gpios(void) +{ + gpio_input_pullup(GPIO_H1_AP_INT); + gpio_input(GPIO_WP_STATE); + gpio_input(GPIO_REC_STATE); +}
void fill_lb_gpios(struct lb_gpios *gpios) { @@ -27,9 +34,109 @@ {GPIO_H1_AP_INT.addr, ACTIVE_LOW, gpio_get(GPIO_H1_AP_INT), "TPM interrupt"}, }; +#endif + struct lb_gpio chromeos_gpios[] = { + {GPIO_REC_STATE.addr, ACTIVE_LOW, + gpio_get(GPIO_REC_STATE), "recovery"}, + {GPIO_WP_STATE.addr, ACTIVE_LOW, + gpio_get(GPIO_WP_STATE), "write protect"}, + {-1, ACTIVE_LOW, 1, "power"}, + {-1, ACTIVE_LOW, 0, "lid"}, + };
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios)); -#endif +} + +#define WIPEOUT_MODE_DELAY_MS (8 * 1000) +#define RECOVERY_MODE_EXTRA_DELAY_MS (8 * 1000) + +/* + * The recovery switch: it needs to be pressed for a + * certain duration at startup to signal different requests: + * + * - keeping it pressed for 8 to 16 seconds after startup signals the need for + * factory reset (wipeout); + * - keeping it pressed for longer than 16 seconds signals the need for Chrome + * OS recovery. + * + * The state is read once and cached for following inquiries. The below enum + * lists possible states. + */ +enum switch_state { + not_probed = -1, + no_req, + recovery_req, + wipeout_req +}; + +static enum switch_state get_rec_sw_state(void) +{ + struct stopwatch sw; + int sampled_value; + gpio_t rec_sw; + static enum switch_state saved_state = not_probed; + + if (saved_state != not_probed) + return saved_state; + + rec_sw = GPIO_REC_STATE; + sampled_value = !gpio_get(rec_sw); + + if (!sampled_value) { + saved_state = no_req; + //display_pattern(WWR_NORMAL_BOOT); + return saved_state; + } + + //display_pattern(WWR_RECOVERY_PUSHED); + printk(BIOS_INFO, "recovery button pressed\n"); + + stopwatch_init_msecs_expire(&sw, WIPEOUT_MODE_DELAY_MS); + + do { + sampled_value = !gpio_get(rec_sw); + if (!sampled_value) + break; + } while (!stopwatch_expired(&sw)); + + if (sampled_value) { + //display_pattern(WWR_WIPEOUT_REQUEST); + printk(BIOS_INFO, "wipeout requested, checking recovery\n"); + stopwatch_init_msecs_expire(&sw, RECOVERY_MODE_EXTRA_DELAY_MS); + do { + sampled_value = !gpio_get(rec_sw); + if (!sampled_value) + break; + } while (!stopwatch_expired(&sw)); + + if (sampled_value) { + saved_state = recovery_req; + //display_pattern(WWR_RECOVERY_REQUEST); + printk(BIOS_INFO, "recovery requested\n"); + } else { + saved_state = wipeout_req; + } + } else { + saved_state = no_req; + //display_pattern(WWR_NORMAL_BOOT); + } + + return saved_state; +} + +int get_recovery_mode_switch(void) +{ + return get_rec_sw_state() == recovery_req; +} + +int get_wipeout_mode_switch(void) +{ + return get_rec_sw_state() == wipeout_req; +} + +int get_write_protect_state(void) +{ + return !gpio_get(GPIO_WP_STATE); }
#if 0 diff --git a/src/mainboard/google/mistral/verstage.c b/src/mainboard/google/mistral/verstage.c index 7ea21c7..a63f61e 100644 --- a/src/mainboard/google/mistral/verstage.c +++ b/src/mainboard/google/mistral/verstage.c @@ -15,18 +15,10 @@ */
#include <console/console.h> -#include <gpio.h> #include <security/vboot/vboot_common.h> #include <spi-generic.h> #include <soc/clock.h> -#include <soc/gpio.h> - -#define GPIO_H1_AP_INT GPIO(53) - -static void setup_chromeos_gpios(void) -{ - gpio_input_pullup(GPIO_H1_AP_INT); -} +#include "board.h"
void verstage_mainboard_init(void) {
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR. ......................................................................
Patch Set 1:
(5 comments)
https://review.coreboot.org/#/c/31173/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/31173/1//COMMIT_MSG@7 PS1, Line 7: google/mistral: Support triggering Recovery/FDR. Please remove the dot/period at the end of the commit message summary.
https://review.coreboot.org/#/c/31173/1//COMMIT_MSG@10 PS1, Line 10: switch(GPIO77) Please add a space before the (.
https://review.coreboot.org/#/c/31173/1//COMMIT_MSG@11 PS1, Line 11: Please elaborate why vboot wipeout needs to be selected.
Tested how?
https://review.coreboot.org/#/c/31173/1/src/mainboard/google/mistral/board.h File src/mainboard/google/mistral/board.h:
https://review.coreboot.org/#/c/31173/1/src/mainboard/google/mistral/board.h... PS1, Line 4: * Copyright (C) 2018, The Linux Foundation. All rights reserved. Is that the correct line?
https://review.coreboot.org/#/c/31173/1/src/mainboard/google/mistral/chromeo... File src/mainboard/google/mistral/chromeos.c:
https://review.coreboot.org/#/c/31173/1/src/mainboard/google/mistral/chromeo... PS1, Line 87: //display_pattern(WWR_NORMAL_BOOT); What is the comment good for?
Patrick Georgi has uploaded a new patch set (#2) to the change originally created by SANTHOSH JANARDHANA HASSAN. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR. ......................................................................
google/mistral: Support triggering Recovery/FDR.
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com --- M src/mainboard/google/mistral/Kconfig A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 4 files changed, 144 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/2
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR. ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/#/c/31173/5//COMMIT_MSG Commit Message:
https://review.coreboot.org/#/c/31173/5//COMMIT_MSG@7 PS5, Line 7: google/mistral: Support triggering Recovery/FDR. Please remove the dot at the end.
https://review.coreboot.org/#/c/31173/5//COMMIT_MSG@10 PS5, Line 10: switch(GPIO77) Please add a space before the (.
Hello build bot (Jenkins), nsekar@codeaurora.org, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/31173
to look at the new patch set (#8).
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR. ......................................................................
TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR.
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com --- M src/mainboard/google/mistral/Kconfig A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 4 files changed, 144 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/8
Hello build bot (Jenkins), nsekar@codeaurora.org, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/31173
to look at the new patch set (#9).
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR ......................................................................
TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com --- M src/mainboard/google/mistral/Kconfig M src/mainboard/google/mistral/Makefile.inc A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 5 files changed, 145 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/9
nsekar@codeaurora.org has uploaded a new patch set (#10) to the change originally created by SANTHOSH JANARDHANA HASSAN. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR. ......................................................................
TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR.
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com --- M src/mainboard/google/mistral/Kconfig A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 4 files changed, 144 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/10
SANTHOSH JANARDHANA HASSAN has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR. ......................................................................
Patch Set 10:
@Nitheesh, Why did you overwrite the patch set 9 with old changes?
Patrick Georgi has uploaded a new patch set (#12) to the change originally created by SANTHOSH JANARDHANA HASSAN. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR ......................................................................
TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/mainboard/google/mistral/Kconfig M src/mainboard/google/mistral/Makefile.inc A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 5 files changed, 145 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/12
Patrick Georgi has uploaded a new patch set (#14) to the change originally created by SANTHOSH JANARDHANA HASSAN. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR ......................................................................
TEMP: NOT FOR REVIEW: google/mistral: Support triggering Recovery/FDR
Implement triggering factory data reset and recovery mechanism based on Recovery/FDR switch(GPIO77) value.
Change-Id: Ifdbd696ee3fd9f073cc44a49ad341cad7e33845e Signed-off-by: Santhosh Hassan sahassan@google.com Signed-off-by: Nitheesh Sekar nsekar@codeaurora.org --- M src/mainboard/google/mistral/Kconfig M src/mainboard/google/mistral/Makefile.inc A src/mainboard/google/mistral/board.h M src/mainboard/google/mistral/chromeos.c M src/mainboard/google/mistral/verstage.c 5 files changed, 145 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/31173/14
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR ......................................................................
Patch Set 28:
(1 comment)
https://review.coreboot.org/c/coreboot/+/31173/28/src/mainboard/google/mistr... File src/mainboard/google/mistral/verstage.c:
https://review.coreboot.org/c/coreboot/+/31173/28/src/mainboard/google/mistr... PS28, Line 29: if (spi_setup_slave(CONFIG_DRIVER_TPM_SPI_BUS, CONFIG_DRIVER_TPM_SPI_CHIP, &spi)) { braces {} are not necessary for single statement blocks
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR ......................................................................
Patch Set 28:
(1 comment)
https://review.coreboot.org/c/coreboot/+/31173/28//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/31173/28//COMMIT_MSG@10 PS28, Line 10: switch(GPIO77) Please add a space before the (.
Patrick Georgi has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/31173 )
Change subject: google/mistral: Support triggering Recovery/FDR ......................................................................
Abandoned
won't be finished here