From ef19ce5346ff33375b483f0f97c29bf86e913ae1 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Mon, 5 Aug 2019 19:19:59 +0200 Subject: soc/intel/common: Implement power-failure-state handling This is a consolidation of the respective feature in `soc/intel/*lake/`, including additional support for MAINBOARD_POWER_STATE_PREVIOUS. For the latter, firmware has to keep track of the `previous` state. The feature was already advertised in Kconfig long ago, but not implemented. SoC code has to call pmc_set_power_failure_state() at least once during boot and needs to implement pmc_soc_set_afterg3_en() for the actual register write. Change-Id: Ic6970a79d9b95373c2855f4c92232d2aa05963bb Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/34724 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Furquan Shaikh --- src/soc/intel/common/block/pmc/pmclib.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/soc/intel/common/block/pmc') diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c index 564aacb55e..ee99735547 100644 --- a/src/soc/intel/common/block/pmc/pmclib.c +++ b/src/soc/intel/common/block/pmc/pmclib.c @@ -579,3 +579,30 @@ void pmc_gpe_init(void) /* Set the routes in the GPIO communities as well. */ gpio_route_gpe(dw0, dw1, dw2); } + +void pmc_set_power_failure_state(const bool target_on) +{ + const int state = CONFIG_MAINBOARD_POWER_FAILURE_STATE; + bool on; + + switch (state) { + case MAINBOARD_POWER_STATE_OFF: + printk(BIOS_INFO, "Set power off after power failure.\n"); + on = false; + break; + case MAINBOARD_POWER_STATE_ON: + printk(BIOS_INFO, "Set power on after power failure.\n"); + on = true; + break; + case MAINBOARD_POWER_STATE_PREVIOUS: + printk(BIOS_INFO, "Keep power state after power failure.\n"); + on = target_on; + break; + default: + printk(BIOS_WARNING, "WARNING: Unknown power-failure state: %d\n", state); + on = false; + break; + } + + pmc_soc_set_afterg3_en(on); +} -- cgit v1.2.3