[coreboot-gerrit] Change in coreboot[master]: soc/intel/common/block: Manage power state variable from common PMC b...

Shaunak Saha (Code Review) gerrit at coreboot.org
Tue Oct 3 00:25:37 CEST 2017


Shaunak Saha has uploaded this change for review. ( https://review.coreboot.org/21851


Change subject: soc/intel/common/block: Manage power state variable from common PMC block
......................................................................

soc/intel/common/block: Manage power state variable from common PMC block

This patch helps managing power state variables from within
the library. Adds migrate_power_state which migrates the chipset
power state variable,reads global power variable and adds it in cbmem
for future use. This also adds get_soc_power_state_values
function which returns the power state variable from
cbmem or global power state variable if cbmem is not
populated yet.

Change-Id: If65341c1492e3a35a1a927100e0d893f923b9e68
Signed-off-by: Shaunak Saha <shaunak.saha at intel.com>
---
M src/soc/intel/common/block/include/intelblocks/pmclib.h
M src/soc/intel/common/block/pmc/pmclib.c
2 files changed, 40 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/21851/1

diff --git a/src/soc/intel/common/block/include/intelblocks/pmclib.h b/src/soc/intel/common/block/include/intelblocks/pmclib.h
index fe0a765..69b0a09 100644
--- a/src/soc/intel/common/block/include/intelblocks/pmclib.h
+++ b/src/soc/intel/common/block/include/intelblocks/pmclib.h
@@ -22,6 +22,13 @@
 struct chipset_power_state;
 
 /*
+ * This function checks if cbmem is possibly online at the stage when
+ * its called. If variable is present in cbmem then fetch it from cbmem
+ * and return or else returns the global power state variable.
+ */
+struct chipset_power_state *get_soc_power_state_values(void);
+
+/*
  * This is implemented as weak function in common pmc lib.
  * Clears all power management related registers as the boot
  * flow is past the point of needing to maintain the values.
diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c
index 78b43e4..ae26696 100644
--- a/src/soc/intel/common/block/pmc/pmclib.c
+++ b/src/soc/intel/common/block/pmc/pmclib.c
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include <arch/early_variables.h>
 #include <arch/io.h>
 #include <cbmem.h>
 #include <console/console.h>
@@ -20,9 +21,41 @@
 #include <intelblocks/pmclib.h>
 #include <intelblocks/gpio.h>
 #include <soc/pm.h>
+#include <string.h>
 #include <timer.h>
 #include <vboot/vboot_common.h>
 
+static struct chipset_power_state power_state CAR_GLOBAL;
+
+struct chipset_power_state *get_soc_power_state_values(void)
+{
+	struct chipset_power_state *ptr;
+
+	if (cbmem_possibly_online()) {
+		ptr = cbmem_find(CBMEM_ID_POWER_STATE);
+		if (ptr)
+			return ptr;
+	}
+
+	return car_get_var_ptr(&power_state);
+}
+
+static void migrate_power_state(int is_recovery)
+{
+	struct chipset_power_state *ps_cbmem;
+	struct chipset_power_state *ps_car;
+
+	ps_car = car_get_var_ptr(&power_state);
+	ps_cbmem = cbmem_add(CBMEM_ID_POWER_STATE, sizeof(*ps_cbmem));
+
+	if (ps_cbmem == NULL) {
+		printk(BIOS_DEBUG, "Not adding power state to cbmem!\n");
+		return;
+	}
+	memcpy(ps_cbmem, ps_car, sizeof(*ps_cbmem));
+}
+ROMSTAGE_CBMEM_INIT_HOOK(migrate_power_state)
+
 static void print_num_status_bits(int num_bits, uint32_t status,
 				  const char *const bit_names[])
 {

-- 
To view, visit https://review.coreboot.org/21851
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If65341c1492e3a35a1a927100e0d893f923b9e68
Gerrit-Change-Number: 21851
Gerrit-PatchSet: 1
Gerrit-Owner: Shaunak Saha <shaunak.saha at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171002/e97de7cd/attachment-0001.html>


More information about the coreboot-gerrit mailing list