From: rjingar <rajvi.jingar@linux.intel.com>
To: irenic.rajneesh@gmail.com, david.e.box@intel.com,
hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: rajvi.jingar@linux.intel.com,
Michael Bottini <michael.a.bottini@linux.intel.com>,
"David E . Box" <david.e.box@linux.intel.com>
Subject: [PATCH 2/8] platform/x86/intel/pmc: Add PSON residency counter
Date: Mon, 18 Dec 2023 20:22:10 -0800 [thread overview]
Message-ID: <20231219042216.2592029-2-rajvi.jingar@linux.intel.com> (raw)
In-Reply-To: <20231219042216.2592029-1-rajvi.jingar@linux.intel.com>
From: Rajvi Jingar <rajvi.jingar@linux.intel.com>
Tiger Lake platform onwards, devices have the capability to track the
duration of time that their Power Supply Units (PSUs) are turned off
during S0ix. This patch adds a debugfs file `pson_residency_usec` to
provide access to this counter.
Signed-off-by: Michael Bottini <michael.a.bottini@linux.intel.com>
Signed-off-by: Rajvi Jingar <rajvi.jingar@linux.intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
drivers/platform/x86/intel/pmc/core.c | 37 +++++++++++++++++++++++++++
drivers/platform/x86/intel/pmc/core.h | 2 ++
2 files changed, 39 insertions(+)
diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
index 983e3a8f4910..91e5e500eb41 100644
--- a/drivers/platform/x86/intel/pmc/core.c
+++ b/drivers/platform/x86/intel/pmc/core.c
@@ -208,6 +208,20 @@ static int pmc_core_dev_state_get(void *data, u64 *val)
DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get, NULL, "%llu\n");
+static int pmc_core_pson_residency_get(void *data, u64 *val)
+{
+ struct pmc *pmc = data;
+ const struct pmc_reg_map *map = pmc->map;
+ u32 value;
+
+ value = pmc_core_reg_read(pmc, map->pson_residency_offset);
+ *val = (u64)value * map->pson_residency_counter_step;
+
+ return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_pson_residency, pmc_core_pson_residency_get, NULL, "%llu\n");
+
static int pmc_core_check_read_lock_bit(struct pmc *pmc)
{
u32 value;
@@ -1092,6 +1106,24 @@ int get_primary_reg_base(struct pmc *pmc)
return 0;
}
+static bool pmc_core_is_pson_residency_enabled(struct pmc_dev *pmcdev)
+{
+ struct platform_device *pdev = pmcdev->pdev;
+ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+ u8 val;
+
+ if (!adev)
+ return false;
+
+ if (fwnode_property_read_u8(acpi_fwnode_handle(adev),
+ "intel-cec-pson-switching-enabled-in-s0",
+ &val))
+ return false;
+
+ return val == 1;
+}
+
+
static void pmc_core_dbgfs_unregister(struct pmc_dev *pmcdev)
{
debugfs_remove_recursive(pmcdev->dbgfs_dir);
@@ -1162,6 +1194,11 @@ static void pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
&pmc_core_substate_req_regs_fops);
}
+ if (primary_pmc->map->pson_residency_offset && pmc_core_is_pson_residency_enabled(pmcdev)) {
+ debugfs_create_file("pson_residency_usec", 0444,
+ pmcdev->dbgfs_dir, primary_pmc, &pmc_core_pson_residency);
+ }
+
if (pmcdev->has_die_c6) {
debugfs_create_file("die_c6_us_show", 0444,
pmcdev->dbgfs_dir, pmcdev,
diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h
index 6d7673145f90..91cb34a6505c 100644
--- a/drivers/platform/x86/intel/pmc/core.h
+++ b/drivers/platform/x86/intel/pmc/core.h
@@ -323,6 +323,8 @@ struct pmc_reg_map {
const u32 lpm_live_status_offset;
const u32 etr3_offset;
const u8 *lpm_reg_index;
+ const u32 pson_residency_offset;
+ const u32 pson_residency_counter_step;
};
/**
--
2.34.1
next prev parent reply other threads:[~2023-12-19 4:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 4:22 [PATCH 1/8] platform/x86/intel/pmc: Fix in mtl_punit_pmt_init() rjingar
2023-12-19 4:22 ` rjingar [this message]
2023-12-19 4:22 ` [PATCH 3/8] platform/x86/intel/pmc: Add regmap for Tiger Lake H PCH rjingar
2023-12-19 4:22 ` [PATCH 4/8] platform/x86/intel/pmc: Add PSON residency counter for Alder Lake rjingar
2023-12-19 4:22 ` [PATCH 5/8] platform/x86/intel/pmc: Move common code to core.c rjingar
2023-12-19 4:22 ` [PATCH 6/8] platform/x86/intel/pmc: Add ssram_init flag in PMC discovery in Meteor Lake rjingar
2023-12-19 4:22 ` [PATCH 7/8] platform/x86/intel/pmc: Add Arrow Lake S support to intel_pmc_core driver rjingar
2023-12-19 4:22 ` [PATCH 8/8] platform/x86/intel/pmc: Add Lunar Lake M " rjingar
2023-12-19 15:49 ` [PATCH 1/8] platform/x86/intel/pmc: Fix in mtl_punit_pmt_init() Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231219042216.2592029-2-rajvi.jingar@linux.intel.com \
--to=rajvi.jingar@linux.intel.com \
--cc=david.e.box@intel.com \
--cc=david.e.box@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=irenic.rajneesh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.a.bottini@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®