summaryrefslogtreecommitdiff
path: root/drivers/hwmon/fam15h_power.c
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2015-08-27 11:07:38 +0300
committerGuenter Roeck <linux@roeck-us.net>2015-08-27 17:53:19 +0300
commit1ed32160dba643e61504b334f45b002198c88254 (patch)
tree57fd52b4175d960c2c778c78015cd619d8d50fd6 /drivers/hwmon/fam15h_power.c
parent5aeb5d205e122b70742df94a7d51a3502f1a8277 (diff)
downloadlinux-1ed32160dba643e61504b334f45b002198c88254.tar.xz
hwmon: (fam15h_power) Add ratio of Tsample to the PTSC period
This patch adds a member (cpu_pwr_sample_ratio) of fam15h_power_data, that represents the ratio of compute unit power accumulator sample period to the PTSC counter period. Tsample: compute unit power accumulator sample period Tref: the performance timestamp counter period PTSC: performance timestamp counter Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/fam15h_power.c')
-rw-r--r--drivers/hwmon/fam15h_power.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 41174903009c..e80ee23b62d3 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -46,6 +46,7 @@ struct fam15h_power_data {
unsigned int tdp_to_watts;
unsigned int base_tdp;
unsigned int processor_pwr_watts;
+ unsigned int cpu_pwr_sample_ratio;
};
static ssize_t show_power(struct device *dev,
@@ -188,7 +189,7 @@ static int fam15h_power_resume(struct pci_dev *pdev)
static void fam15h_power_init_data(struct pci_dev *f4,
struct fam15h_power_data *data)
{
- u32 val;
+ u32 val, eax, ebx, ecx, edx;
u64 tmp;
pci_read_config_dword(f4, REG_PROCESSOR_TDP, &val);
@@ -209,6 +210,19 @@ static void fam15h_power_init_data(struct pci_dev *f4,
/* convert to microWatt */
data->processor_pwr_watts = (tmp * 15625) >> 10;
+
+ cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
+
+ /* CPUID Fn8000_0007:EDX[12] indicates to support accumulated power */
+ if (!(edx & BIT(12)))
+ return;
+
+ /*
+ * determine the ratio of the compute unit power accumulator
+ * sample period to the PTSC counter period by executing CPUID
+ * Fn8000_0007:ECX
+ */
+ data->cpu_pwr_sample_ratio = ecx;
}
static int fam15h_power_probe(struct pci_dev *pdev,