aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-09-01 16:37:10 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-09-08 17:02:14 -0400
commita6cbcdd5ab5f242d49f511127f0a601b71be2cc4 (patch)
tree6c7b1fad06bc5dfce0d10ffa9c6903959060df8e /arch/x86
parent5448f14698b916e5b04112b104433b90247e01c7 (diff)
ACPI / CPPC: Add support for functional fixed hardware address
The CPPC registers can also be accessed via functional fixed hardware addresse(FFH) in X86. Add support by modifying cpc_read and cpc_write to be able to read/write MSRs on x86 platform on per cpu basis. Also with this change, acpi_cppc_processor_probe doesn't bail out if address space id is not equal to PCC or memory address space and FFH is supported on the system. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/acpi/Makefile1
-rw-r--r--arch/x86/kernel/acpi/cppc_msr.c58
2 files changed, 59 insertions, 0 deletions
diff --git a/arch/x86/kernel/acpi/Makefile b/arch/x86/kernel/acpi/Makefile
index 3242e591fa82..26b78d86f25a 100644
--- a/arch/x86/kernel/acpi/Makefile
+++ b/arch/x86/kernel/acpi/Makefile
@@ -1,6 +1,7 @@
1obj-$(CONFIG_ACPI) += boot.o 1obj-$(CONFIG_ACPI) += boot.o
2obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup_$(BITS).o 2obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup_$(BITS).o
3obj-$(CONFIG_ACPI_APEI) += apei.o 3obj-$(CONFIG_ACPI_APEI) += apei.o
4obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_msr.o
4 5
5ifneq ($(CONFIG_ACPI_PROCESSOR),) 6ifneq ($(CONFIG_ACPI_PROCESSOR),)
6obj-y += cstate.o 7obj-y += cstate.o
diff --git a/arch/x86/kernel/acpi/cppc_msr.c b/arch/x86/kernel/acpi/cppc_msr.c
new file mode 100644
index 000000000000..6fb478bf82fd
--- /dev/null
+++ b/arch/x86/kernel/acpi/cppc_msr.c
@@ -0,0 +1,58 @@
1/*
2 * cppc_msr.c: MSR Interface for CPPC
3 * Copyright (c) 2016, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 */
15
16#include <acpi/cppc_acpi.h>
17#include <asm/msr.h>
18
19/* Refer to drivers/acpi/cppc_acpi.c for the description of functions */
20
21bool cpc_ffh_supported(void)
22{
23 return true;
24}
25
26int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val)
27{
28 int err;
29
30 err = rdmsrl_safe_on_cpu(cpunum, reg->address, val);
31 if (!err) {
32 u64 mask = GENMASK_ULL(reg->bit_offset + reg->bit_width - 1,
33 reg->bit_offset);
34
35 *val &= mask;
36 *val >>= reg->bit_offset;
37 }
38 return err;
39}
40
41int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
42{
43 u64 rd_val;
44 int err;
45
46 err = rdmsrl_safe_on_cpu(cpunum, reg->address, &rd_val);
47 if (!err) {
48 u64 mask = GENMASK_ULL(reg->bit_offset + reg->bit_width - 1,
49 reg->bit_offset);
50
51 val <<= reg->bit_offset;
52 val &= mask;
53 rd_val &= ~mask;
54 rd_val |= val;
55 err = wrmsrl_safe_on_cpu(cpunum, reg->address, rd_val);
56 }
57 return err;
58}