summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/soc/intel/common/block/include/intelblocks/pmclib.h17
-rw-r--r--src/soc/intel/common/block/pmc/pmclib.c27
2 files changed, 44 insertions, 0 deletions
diff --git a/src/soc/intel/common/block/include/intelblocks/pmclib.h b/src/soc/intel/common/block/include/intelblocks/pmclib.h
index 82eb2ae4c4..8947a22653 100644
--- a/src/soc/intel/common/block/include/intelblocks/pmclib.h
+++ b/src/soc/intel/common/block/include/intelblocks/pmclib.h
@@ -16,6 +16,7 @@
#ifndef SOC_INTEL_COMMON_BLOCK_PMCLIB_H
#define SOC_INTEL_COMMON_BLOCK_PMCLIB_H
+#include <device/pci_type.h>
#include <stdint.h>
/* Forward declare the power state struct here */
@@ -214,4 +215,20 @@ enum {
MAINBOARD_POWER_STATE_PREVIOUS,
};
+/*
+ * Implemented by SoC code to set PMC register to know which state
+ * system should go into after power is reapplied.
+ */
+void pmc_soc_set_afterg3_en(bool on);
+/*
+ * Configure power state to go into when power is reapplied.
+ *
+ * To be called by SoC code once during boot and will be called by
+ * the "sleep" SMI handler when going into S5.
+ *
+ * `target_on` signifies that we are currently powering on, so that
+ * MAINBOARD_POWER_STATE_PREVIOUS can be handled accordingly.
+ */
+void pmc_set_power_failure_state(bool target_on);
+
#endif /* SOC_INTEL_COMMON_BLOCK_PMCLIB_H */
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);
+}