From 69b054137502008c09d499d0d4773cf2d9388304 Mon Sep 17 00:00:00 2001 From: Keith Hui Date: Sat, 26 Jul 2025 23:57:51 -0400 Subject: [PATCH] sio/nuvoton/nct6779d: Add power loss resume support Adds long overdue power loss resume support to nct6779d using code from nct5572d. Change-Id: I91bf01a176716b97c6ca6a841c68cd3d4a39d23d Signed-off-by: Keith Hui Reviewed-on: https://review.coreboot.org/c/coreboot/+/88701 Reviewed-by: Angel Pons Reviewed-by: Paul Menzel Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/superio/nuvoton/nct6779d/Kconfig | 1 + src/superio/nuvoton/nct6779d/superio.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/superio/nuvoton/nct6779d/Kconfig b/src/superio/nuvoton/nct6779d/Kconfig index ce2af16627..9f20f7b936 100644 --- a/src/superio/nuvoton/nct6779d/Kconfig +++ b/src/superio/nuvoton/nct6779d/Kconfig @@ -3,3 +3,4 @@ config SUPERIO_NUVOTON_NCT6779D bool select SUPERIO_NUVOTON_COMMON_PRE_RAM + select HAVE_POWER_STATE_AFTER_FAILURE diff --git a/src/superio/nuvoton/nct6779d/superio.c b/src/superio/nuvoton/nct6779d/superio.c index 13604769ab..0381be2beb 100644 --- a/src/superio/nuvoton/nct6779d/superio.c +++ b/src/superio/nuvoton/nct6779d/superio.c @@ -2,13 +2,20 @@ #include #include +#include #include #include #include "nct6779d.h" +#define MAINBOARD_POWER_OFF 0 +#define MAINBOARD_POWER_ON 1 +#define MAINBOARD_POWER_KEEP 2 + static void nct6779d_init(struct device *dev) { + uint8_t byte, power_status; + if (!dev->enabled) return; @@ -17,6 +24,21 @@ static void nct6779d_init(struct device *dev) case NCT6779D_KBC: pc_keyboard_init(NO_AUX_DEVICE); break; + case NCT6779D_ACPI: + /* Set power state after power fail */ + power_status = get_uint_option("power_on_after_fail", + CONFIG_MAINBOARD_POWER_FAILURE_STATE); + pnp_enter_conf_mode(dev); + pnp_set_logical_device(dev); + byte = pnp_read_config(dev, 0xe4) & ~0x60; + if (power_status == MAINBOARD_POWER_ON) + byte |= (MAINBOARD_POWER_ON << 5); + else if (power_status == MAINBOARD_POWER_KEEP) + byte |= (MAINBOARD_POWER_KEEP << 5); + pnp_write_config(dev, 0xe4, byte); + pnp_exit_conf_mode(dev); + printk(BIOS_INFO, "set power %s after power fail\n", power_status ? "on" : "off"); + break; } }