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 <buurin@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88701
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Keith Hui 2025-07-26 23:57:51 -04:00 committed by Matt DeVillier
commit 69b0541375
2 changed files with 23 additions and 0 deletions

View file

@ -3,3 +3,4 @@
config SUPERIO_NUVOTON_NCT6779D
bool
select SUPERIO_NUVOTON_COMMON_PRE_RAM
select HAVE_POWER_STATE_AFTER_FAILURE

View file

@ -2,13 +2,20 @@
#include <device/device.h>
#include <device/pnp.h>
#include <option.h>
#include <pc80/keyboard.h>
#include <superio/conf_mode.h>
#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;
}
}