From 9faae2b939d0c83632baeefe80bef1739e125018 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Wed, 14 Nov 2018 00:00:35 +0100 Subject: Kconfig: Unify power-after-failure options The newest and most useful incarnation was hiding in soc/intel/common/. We move it into the Mainboard menu and extend it with various flags to be selected to control the default and which options are visible. Also add a new `int` config MAINBOARD_POWER_FAILURE_STATE that moves the boolean to int conversion into Kconfig: 0 - S5 1 - S0 2 - previous state This patch focuses on the Kconfig code. The C code could be unified as well, e.g. starting with a common enum and safe wrapper around the get_option() call. TEST=Did what-jenkins-does with and without this commit and compared binaries. Nothing changed for the default configurations. Change-Id: I61259f864c8a8cfc7099cc2699059f972fa056c0 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/29680 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- src/superio/winbond/w83667hg-a/Kconfig | 2 ++ src/superio/winbond/w83667hg-a/superio.c | 19 ++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/superio/winbond') diff --git a/src/superio/winbond/w83667hg-a/Kconfig b/src/superio/winbond/w83667hg-a/Kconfig index 5614023764..dc14c5fa14 100644 --- a/src/superio/winbond/w83667hg-a/Kconfig +++ b/src/superio/winbond/w83667hg-a/Kconfig @@ -17,3 +17,5 @@ config SUPERIO_WINBOND_W83667HG_A bool select SUPERIO_WINBOND_COMMON_PRE_RAM + select HAVE_POWER_STATE_AFTER_FAILURE + select HAVE_POWER_STATE_PREVIOUS_AFTER_FAILURE diff --git a/src/superio/winbond/w83667hg-a/superio.c b/src/superio/winbond/w83667hg-a/superio.c index 09859cf2c7..4a8f0fd4a7 100644 --- a/src/superio/winbond/w83667hg-a/superio.c +++ b/src/superio/winbond/w83667hg-a/superio.c @@ -28,12 +28,9 @@ #include "w83667hg-a.h" -#define MAINBOARD_POWER_OFF 0 -#define MAINBOARD_POWER_ON 1 - -#ifndef CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL -#define CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBOARD_POWER_ON -#endif +#define MAINBOARD_POWER_OFF 0 +#define MAINBOARD_POWER_ON 1 +#define MAINBOARD_POWER_KEEP 2 static void w83667hg_a_init(struct device *dev) { @@ -68,16 +65,16 @@ static void w83667hg_a_init(struct device *dev) break; case W83667HG_A_ACPI: /* Set power state after power fail */ - power_status = CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL; + power_status = CONFIG_MAINBOARD_POWER_FAILURE_STATE; get_option(&power_status, "power_on_after_fail"); pnp_enter_conf_mode_8787(dev); pnp_set_logical_device(dev); byte = pnp_read_config(dev, 0xe4); byte &= ~0x60; - if (power_status == 1) - byte |= (0x1 << 5); /* Force power on */ - else if (power_status == 2) - byte |= (0x2 << 5); /* Use last power state */ + if (power_status == MAINBOARD_POWER_ON) + byte |= (0x1 << 5); + else if (power_status == MAINBOARD_POWER_KEEP) + byte |= (0x2 << 5); pnp_write_config(dev, 0xe4, byte); pnp_exit_conf_mode_aa(dev); printk(BIOS_INFO, "set power %s after power fail\n", power_status ? "on" : "off"); -- cgit v1.2.3