platform/x86: intel_pmc_core: Handle sub-states generically
authorGayatri Kammela <gayatri.kammela@intel.com>
Sat, 17 Apr 2021 03:12:46 +0000 (20:12 -0700)
committerHans de Goede <hdegoede@redhat.com>
Mon, 19 Apr 2021 08:41:24 +0000 (10:41 +0200)
commit005125bfd70eb5532d284cc6e23396e161eb679e
tree05b7831f71b6fb43723bf3bd463f07a7c129242f
parent7dc4dc563dd40c596f72aa4e8ba4d61c82ab73c5
platform/x86: intel_pmc_core: Handle sub-states generically

The current implementation of pmc_core_substate_res_show() is written
specifically for Tiger Lake. However, new platform will also have
sub-states and may support different modes. Therefore rewrite the code to
handle sub-states generically.

Obtain the number and type of enabled states form the PMC. Use the Low
Power Mode (LPM) priority register to store the states in order from
shallowest to deepest for displays. Add a for_each macro to simplify
this. While changing the sub-state display it makes sense to show only the
"enabled" sub-states instead of showing all possible ones. After this
patch, the debugfs file looks like this:

Substate   Residency
S0i2.0     0
S0i3.0     0
S0i2.1     9329279
S0i3.1     0
S0i3.2     0

Suggested-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Gayatri Kammela <gayatri.kammela@intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Rajneesh Bhardwaj <irenic.rajneesh@gmail.com>
Link: https://lore.kernel.org/r/20210417031252.3020837-4-david.e.box@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel_pmc_core.c
drivers/platform/x86/intel_pmc_core.h