diff options
author | Samuel Holland <samuel@sholland.org> | 2018-03-30 15:14:17 -0500 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-05-15 11:47:14 +0000 |
commit | c622dc5e822cb849e36386a28efcb88241533a54 (patch) | |
tree | 175c94faf842fcf315ad55a6beace41a9cbee45c /src/superio | |
parent | 9d217bf79ab8c5ab011dab6cea659c37b3603f42 (diff) | |
download | coreboot-c622dc5e822cb849e36386a28efcb88241533a54.tar.xz |
superio/ite/it8720f: Implement power control
Program the Super I/O to turn the machine on or restore its power state
when AC power is restored.
Based on code from src/superio/nuvoton/nct5572d/superio.c.
Change-Id: I1f3432f43b0784c3696bf1d7233b83d3a203af20
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-on: https://review.coreboot.org/25463
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/superio')
-rw-r--r-- | src/superio/ite/it8720f/superio.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/superio/ite/it8720f/superio.c b/src/superio/ite/it8720f/superio.c index 912da3819a..be44e39b17 100644 --- a/src/superio/ite/it8720f/superio.c +++ b/src/superio/ite/it8720f/superio.c @@ -18,12 +18,35 @@ #include <device/device.h> #include <device/pnp.h> #include <pc80/keyboard.h> +#include <pc80/mc146818rtc.h> #include <superio/ite/common/env_ctrl.h> #include <superio/conf_mode.h> +#include <types.h> #include "chip.h" #include "it8720f.h" +#define MAINBOARD_POWER_OFF 0 +#define MAINBOARD_POWER_ON 1 +#define MAINBOARD_POWER_KEEP 2 + +static void power_control_init(struct device *dev) +{ + int power_on = MAINBOARD_POWER_OFF; + u8 addr, value; + + get_option(&power_on, "power_on_after_fail"); + if (power_on == MAINBOARD_POWER_OFF) + return; + pnp_enter_conf_mode(dev); + pnp_set_logical_device(dev); + addr = power_on == MAINBOARD_POWER_KEEP ? 0xf2 : 0xf4; + value = pnp_read_config(dev, addr); + value |= BIT(5); + pnp_write_config(dev, addr, value); + pnp_exit_conf_mode(dev); +} + static void it8720f_init(struct device *dev) { const struct superio_ite_it8720f_config *conf; @@ -39,6 +62,7 @@ static void it8720f_init(struct device *dev) if (!conf || !res) break; ite_ec_init(res->base, &conf->ec); + power_control_init(dev); break; case IT8720F_KBCK: pc_keyboard_init(NO_AUX_DEVICE); |