Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/27774
Change subject: sb/intel/common/pmutil: Add and use method to switch sleep state ......................................................................
sb/intel/common/pmutil: Add and use method to switch sleep state
Add pm_enter_sleepstate() to switch to a different sleep state. Make use of it on google mainboards.
Change-Id: I0cc7aebd672f3c30b55cfe591a77ee1c65036d28 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/mainboard/google/link/mainboard_smi.c M src/mainboard/google/parrot/smihandler.c M src/mainboard/google/stout/ec.c M src/mainboard/google/stout/mainboard_smi.c M src/mainboard/samsung/lumpy/smihandler.c M src/southbridge/intel/common/pmutil.c M src/southbridge/intel/common/pmutil.h 7 files changed, 48 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/27774/1
diff --git a/src/mainboard/google/link/mainboard_smi.c b/src/mainboard/google/link/mainboard_smi.c index 0bd164e..2b1bf5c 100644 --- a/src/mainboard/google/link/mainboard_smi.c +++ b/src/mainboard/google/link/mainboard_smi.c @@ -20,7 +20,7 @@ #include <southbridge/intel/bd82x6x/nvs.h> #include <southbridge/intel/bd82x6x/pch.h> #include <southbridge/intel/bd82x6x/me.h> -#include <southbridge/intel/common/pmbase.h> +#include <southbridge/intel/common/pmutil.h> #include <northbridge/intel/sandybridge/sandybridge.h> #include <cpu/intel/model_206ax/model_206ax.h> #include <elog.h> @@ -44,7 +44,7 @@ printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n");
/* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); break; }
diff --git a/src/mainboard/google/parrot/smihandler.c b/src/mainboard/google/parrot/smihandler.c index e30f78f..694aa7a 100644 --- a/src/mainboard/google/parrot/smihandler.c +++ b/src/mainboard/google/parrot/smihandler.c @@ -20,7 +20,6 @@ #include <southbridge/intel/bd82x6x/pch.h> #include <southbridge/intel/bd82x6x/me.h> #include <southbridge/intel/common/pmutil.h> -#include <southbridge/intel/common/pmbase.h> #include <northbridge/intel/sandybridge/sandybridge.h> #include <cpu/intel/model_206ax/model_206ax.h> #include <elog.h> @@ -54,7 +53,7 @@ elog_add_event_byte(ELOG_TYPE_EC_EVENT, EC_EVENT_LID_CLOSED); #endif /* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); break; }
@@ -75,7 +74,7 @@ elog_add_event_byte(ELOG_TYPE_EC_EVENT, EC_EVENT_LID_CLOSED); #endif /* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); } }
diff --git a/src/mainboard/google/stout/ec.c b/src/mainboard/google/stout/ec.c index 229f919..eaf0870 100644 --- a/src/mainboard/google/stout/ec.c +++ b/src/mainboard/google/stout/ec.c @@ -115,7 +115,7 @@ printk(BIOS_ERR, "EC critical_shutdown");
/* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); } } #endif //__SMM__ diff --git a/src/mainboard/google/stout/mainboard_smi.c b/src/mainboard/google/stout/mainboard_smi.c index 6a51645..ce693dc 100644 --- a/src/mainboard/google/stout/mainboard_smi.c +++ b/src/mainboard/google/stout/mainboard_smi.c @@ -19,7 +19,7 @@ #include <southbridge/intel/bd82x6x/nvs.h> #include <southbridge/intel/bd82x6x/pch.h> #include <southbridge/intel/bd82x6x/me.h> -#include <southbridge/intel/common/pmbase.h> +#include <southbridge/intel/common/pmutil.h> #include <northbridge/intel/sandybridge/sandybridge.h> #include <cpu/intel/model_206ax/model_206ax.h>
@@ -35,7 +35,7 @@ case EC_SMI_LID_CLOSED: printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); /* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); break; }
diff --git a/src/mainboard/samsung/lumpy/smihandler.c b/src/mainboard/samsung/lumpy/smihandler.c index f2c2dc3..f2c8d10 100644 --- a/src/mainboard/samsung/lumpy/smihandler.c +++ b/src/mainboard/samsung/lumpy/smihandler.c @@ -19,7 +19,7 @@ #include <southbridge/intel/bd82x6x/nvs.h> #include <southbridge/intel/bd82x6x/pch.h> #include <southbridge/intel/bd82x6x/me.h> -#include <southbridge/intel/common/pmbase.h> +#include <southbridge/intel/common/pmutil.h> #include <northbridge/intel/sandybridge/sandybridge.h> #include <cpu/intel/model_206ax/model_206ax.h> #include <ec/smsc/mec1308/ec.h> @@ -36,7 +36,7 @@ printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n");
/* Go to S5 */ - write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); + pm_enter_sleepstate(5); break; }
diff --git a/src/southbridge/intel/common/pmutil.c b/src/southbridge/intel/common/pmutil.c index ac72eba..06d0882 100644 --- a/src/southbridge/intel/common/pmutil.c +++ b/src/southbridge/intel/common/pmutil.c @@ -24,6 +24,8 @@ #include <pc80/mc146818rtc.h> #include <southbridge/intel/common/pmbase.h> #include <southbridge/intel/common/gpio.h> +#include <arch/acpi.h> +
#include "pmutil.h"
@@ -234,3 +236,39 @@
return reg16; } + +/** + * @brief Enter the requested sleep state + * @arg Sx_state sleep state (0 - 5) + */ +void pm_enter_sleepstate(u8 Sx_state) +{ + u32 reg32; + + reg32 = read_pmbase32(PM1_CNT); + reg32 &= ~SLP_TYP; + + switch (Sx_state) { + case 0: + reg32 |= SLP_TYP_S0 << SLP_TYP_SHIFT; + break; + case 1: + reg32 |= SLP_TYP_S1 << SLP_TYP_SHIFT; + break; + case 3: + reg32 |= SLP_TYP_S3 << SLP_TYP_SHIFT; + break; + case 4: + reg32 |= SLP_TYP_S4 << SLP_TYP_SHIFT; + break; + case 5: + reg32 |= SLP_TYP_S5 << SLP_TYP_SHIFT; + break; + default: + return; + } + + reg32 |= SLP_EN; + + write_pmbase32(PM1_CNT, reg32); +} diff --git a/src/southbridge/intel/common/pmutil.h b/src/southbridge/intel/common/pmutil.h index 273e0f8..983ba41 100644 --- a/src/southbridge/intel/common/pmutil.h +++ b/src/southbridge/intel/common/pmutil.h @@ -119,6 +119,7 @@ u16 reset_alt_gp_smi_status(void); void southbridge_smm_xhci_sleep(u8 slp_type); void gpi_route_interrupt(u8 gpi, u8 mode); +void pm_enter_sleepstate(u8 Sx_state); void southbridge_gate_memory_reset(void); void southbridge_update_gnvs(u8 apm_cnt, int *smm_done); void southbridge_finalize_all(void);