Keith Hui has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81883?usp=email )
Change subject: superio/nuvoton/nct6779d: Add power_on_after_fail support ......................................................................
superio/nuvoton/nct6779d: Add power_on_after_fail support
Using code from superio/nuvoton/nct5572d (which has the same registers as '6779), add support for configuring power state after power failure using power_on_after_fail nvram option.
TEST=Set nvram option to "enable" on mainboard/asus/p8z77-m, pulled power plug, board powers on after restoring power. Board remains off after power restore with nvram option set to "keep". Super I/O configured correctly per datasheet and superiotool -d.
Change-Id: Ia08cf8daac971397e832996ed364d41e9e7b1c5d Signed-off-by: Keith Hui buurin@gmail.com --- M src/superio/nuvoton/nct6779d/Kconfig M src/superio/nuvoton/nct6779d/superio.c 2 files changed, 31 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/81883/1
diff --git a/src/superio/nuvoton/nct6779d/Kconfig b/src/superio/nuvoton/nct6779d/Kconfig index ce2af16..f60cf1c 100644 --- a/src/superio/nuvoton/nct6779d/Kconfig +++ b/src/superio/nuvoton/nct6779d/Kconfig @@ -3,3 +3,5 @@ config SUPERIO_NUVOTON_NCT6779D bool select SUPERIO_NUVOTON_COMMON_PRE_RAM + select HAVE_POWER_STATE_AFTER_FAILURE + select HAVE_POWER_STATE_PREVIOUS_AFTER_FAILURE diff --git a/src/superio/nuvoton/nct6779d/superio.c b/src/superio/nuvoton/nct6779d/superio.c index 1360476..e908c9c 100644 --- a/src/superio/nuvoton/nct6779d/superio.c +++ b/src/superio/nuvoton/nct6779d/superio.c @@ -3,12 +3,16 @@ #include <device/device.h> #include <device/pnp.h> #include <pc80/keyboard.h> +#include <option.h> #include <superio/conf_mode.h>
#include "nct6779d.h"
static void nct6779d_init(struct device *dev) { + uint8_t byte; + uint8_t power_status; + if (!dev->enabled) return;
@@ -17,6 +21,31 @@ case NCT6779D_KBC: pc_keyboard_init(NO_AUX_DEVICE); break; + case NCT6779D_ACPI: + /* Set power state after power fail. + * NOTE: This depends on CONFIG_MAINBOARD_POWER_FAILURE_STATE to be defined as: + * + * config MAINBOARD_POWER_FAILURE_STATE + * int + * default 2 if POWER_STATE_PREVIOUS_AFTER_FAILURE + * default 1 if POWER_STATE_ON_AFTER_FAILURE + * default 0 + * + * ... matching this hardware. + * If this definition changes, this code has to be adapted similar to + * NCT5572D. + */ + + power_status = get_uint_option("power_on_after_fail", + CONFIG_MAINBOARD_POWER_FAILURE_STATE) & 0x03; + pnp_enter_conf_mode(dev); + pnp_set_logical_device(dev); + byte = pnp_read_config(dev, 0xe4); + byte &= ~0x60; + byte |= (power_status << 5); + pnp_write_config(dev, 0xe4, byte); + pnp_exit_conf_mode(dev); + break; } }