google/butterfly: Refactor get_recovery_mode_switch()

Do not place console output in low-level GPIO functions.

The caller of get_recovery_mode_switch() is in vboot_logic.c
that is linked in romstage. So presumably recovery mode
is broken and is not fixed with this commit either.

Change-Id: I2a0fdbb370d54898c72adb29a0e9b990a5fc0ce1
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59003
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Kyösti Mälkki 2021-11-06 18:52:22 +02:00
parent 4f021e554f
commit 071d1787fd
1 changed files with 4 additions and 17 deletions

View File

@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <bootmode.h> #include <bootmode.h>
#include <boot/coreboot_tables.h> #include <boot/coreboot_tables.h>
#include <device/device.h> #include <device/device.h>
@ -13,8 +12,6 @@
#include "ec.h" #include "ec.h"
#include "onboard.h" #include "onboard.h"
#define FORCE_RECOVERY_MODE 0
void fill_lb_gpios(struct lb_gpios *gpios) void fill_lb_gpios(struct lb_gpios *gpios)
{ {
struct lb_gpio chromeos_gpios[] = { struct lb_gpio chromeos_gpios[] = {
@ -42,23 +39,13 @@ int get_lid_switch(void)
return (ec_mem_read(EC_HW_GPI_STATUS) >> EC_GPI_LID_STAT_BIT) & 1; return (ec_mem_read(EC_HW_GPI_STATUS) >> EC_GPI_LID_STAT_BIT) & 1;
} }
/* FIXME: VBOOT reads this in ENV_ROMSTAGE. */
int get_recovery_mode_switch(void) int get_recovery_mode_switch(void)
{ {
int ec_rec_mode = 0; if (ENV_RAMSTAGE)
return (ec_mem_read(EC_CODE_STATE) == EC_COS_EC_RO);
if (FORCE_RECOVERY_MODE) { return 0;
printk(BIOS_DEBUG, "FORCING RECOVERY MODE.\n");
return 1;
}
if (ENV_RAMSTAGE) {
if (ec_mem_read(EC_CODE_STATE) == EC_COS_EC_RO)
ec_rec_mode = 1;
printk(BIOS_DEBUG, "RECOVERY MODE FROM EC: %x\n", ec_rec_mode);
}
return ec_rec_mode;
} }
static const struct cros_gpio cros_gpios[] = { static const struct cros_gpio cros_gpios[] = {