Skip to content

Commit 2ce6324

Browse files
spandruvadarafaeljw
authored andcommitted
ACPI: DPTF: Add PCH FIVR participant driver
This driver adds support for Dynamic Platform and Thermal Framework (DPTF) PCH (Platform Controller Hub) FIVR (Fully Integrated Voltage Regulator) participant support. This participant is responsible for exposing platform telemetry and control for: freq_mhz_high_clock freq_mhz_low_clock These attributes are used to get and set PCH FIVR switching frequency for thermal and radio frequency interference mitigation. Refer to Documentation/ABI/testing/sysfs-platform-dptf for ABI details. ACPI methods description used in this driver: RFC0: This ACPI method to set PCH FIVR switching frequency when FIVR clock is 19.2MHz or 24MHz. The ACPI method takes a DWORD value. GFC0: This ACPI method to get PCH FIVR switching frequency when FIVR clock is 19.2MHz or 24MHz. RFC1: This ACPI method to set PCH FIVR switching frequency when FIVR clock is 38.4MHz. The ACPI method takes a DWORD value. GFC1: This ACPI method to get PCH FIVR switching frequency when FIVR clock is 38.4MHz. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 856deb8 commit 2ce6324

5 files changed

Lines changed: 158 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-platform-dptf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,19 @@ Contact: linux-acpi@vger.kernel.org
9292
Description:
9393
(RO) The battery discharge current capability obtained from battery fuel gauge in
9494
milli Amps.
95+
96+
What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/freq_mhz_low_clock
97+
Date: November, 2020
98+
KernelVersion: v5.10
99+
Contact: linux-acpi@vger.kernel.org
100+
Description:
101+
(RW) The PCH FIVR (Fully Integrated Voltage Regulator) switching frequency in MHz,
102+
when FIVR clock is 19.2MHz or 24MHz.
103+
104+
What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/freq_mhz_high_clock
105+
Date: November, 2020
106+
KernelVersion: v5.10
107+
Contact: linux-acpi@vger.kernel.org
108+
Description:
109+
(RW) The PCH FIVR (Fully Integrated Voltage Regulator) switching frequency in MHz,
110+
when FIVR clock is 38.4MHz.

drivers/acpi/dptf/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ config DPTF_POWER
1414

1515
To compile this driver as a module, choose M here:
1616
the module will be called dptf_power.
17+
18+
config DPTF_PCH_FIVR
19+
tristate "DPTF PCH FIVR Participant"
20+
depends on X86
21+
help
22+
This driver adds support for Dynamic Platform and Thermal Framework
23+
(DPTF) PCH FIVR Participant device support. This driver allows to
24+
switch PCH FIVR (Fully Integrated Voltage Regulator) frequency.
25+
This participant is responsible for exposing:
26+
freq_mhz_low_clock
27+
freq_mhz_high_clock
28+
29+
To compile this driver as a module, choose M here:
30+
the module will be called dptf_pch_fivr.

drivers/acpi/dptf/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_ACPI) += int340x_thermal.o
33
obj-$(CONFIG_DPTF_POWER) += dptf_power.o
4+
obj-$(CONFIG_DPTF_PCH_FIVR) += dptf_pch_fivr.o

drivers/acpi/dptf/dptf_pch_fivr.c

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* dptf_pch_fivr: DPTF PCH FIVR Participant driver
4+
* Copyright (c) 2020, Intel Corporation.
5+
*/
6+
7+
#include <linux/acpi.h>
8+
#include <linux/kernel.h>
9+
#include <linux/module.h>
10+
#include <linux/platform_device.h>
11+
12+
/*
13+
* Presentation of attributes which are defined for INT1045
14+
* They are:
15+
* freq_mhz_low_clock : Set PCH FIVR switching freq for
16+
* FIVR clock 19.2MHz and 24MHz
17+
* freq_mhz_high_clock : Set PCH FIVR switching freq for
18+
* FIVR clock 38.4MHz
19+
*/
20+
#define PCH_FIVR_SHOW(name, method) \
21+
static ssize_t name##_show(struct device *dev,\
22+
struct device_attribute *attr,\
23+
char *buf)\
24+
{\
25+
struct acpi_device *acpi_dev = dev_get_drvdata(dev);\
26+
unsigned long long val;\
27+
acpi_status status;\
28+
\
29+
status = acpi_evaluate_integer(acpi_dev->handle, #method,\
30+
NULL, &val);\
31+
if (ACPI_SUCCESS(status))\
32+
return sprintf(buf, "%d\n", (int)val);\
33+
else\
34+
return -EINVAL;\
35+
}
36+
37+
#define PCH_FIVR_STORE(name, method) \
38+
static ssize_t name##_store(struct device *dev,\
39+
struct device_attribute *attr,\
40+
const char *buf, size_t count)\
41+
{\
42+
struct acpi_device *acpi_dev = dev_get_drvdata(dev);\
43+
acpi_status status;\
44+
u32 val;\
45+
\
46+
if (kstrtouint(buf, 0, &val) < 0)\
47+
return -EINVAL;\
48+
\
49+
status = acpi_execute_simple_method(acpi_dev->handle, #method, val);\
50+
if (ACPI_SUCCESS(status))\
51+
return count;\
52+
\
53+
return -EINVAL;\
54+
}
55+
56+
PCH_FIVR_SHOW(freq_mhz_low_clock, GFC0)
57+
PCH_FIVR_SHOW(freq_mhz_high_clock, GFC1)
58+
PCH_FIVR_STORE(freq_mhz_low_clock, RFC0)
59+
PCH_FIVR_STORE(freq_mhz_high_clock, RFC1)
60+
61+
static DEVICE_ATTR_RW(freq_mhz_low_clock);
62+
static DEVICE_ATTR_RW(freq_mhz_high_clock);
63+
64+
static struct attribute *fivr_attrs[] = {
65+
&dev_attr_freq_mhz_low_clock.attr,
66+
&dev_attr_freq_mhz_high_clock.attr,
67+
NULL
68+
};
69+
70+
static const struct attribute_group pch_fivr_attribute_group = {
71+
.attrs = fivr_attrs,
72+
.name = "pch_fivr_switch_frequency"
73+
};
74+
75+
static int pch_fivr_add(struct platform_device *pdev)
76+
{
77+
struct acpi_device *acpi_dev;
78+
unsigned long long ptype;
79+
acpi_status status;
80+
int result;
81+
82+
acpi_dev = ACPI_COMPANION(&(pdev->dev));
83+
if (!acpi_dev)
84+
return -ENODEV;
85+
86+
status = acpi_evaluate_integer(acpi_dev->handle, "PTYP", NULL, &ptype);
87+
if (ACPI_FAILURE(status) || ptype != 0x05)
88+
return -ENODEV;
89+
90+
result = sysfs_create_group(&pdev->dev.kobj,
91+
&pch_fivr_attribute_group);
92+
if (result)
93+
return result;
94+
95+
platform_set_drvdata(pdev, acpi_dev);
96+
97+
return 0;
98+
}
99+
100+
static int pch_fivr_remove(struct platform_device *pdev)
101+
{
102+
sysfs_remove_group(&pdev->dev.kobj, &pch_fivr_attribute_group);
103+
104+
return 0;
105+
}
106+
107+
static const struct acpi_device_id pch_fivr_device_ids[] = {
108+
{"INTC1045", 0},
109+
{"", 0},
110+
};
111+
MODULE_DEVICE_TABLE(acpi, pch_fivr_device_ids);
112+
113+
static struct platform_driver pch_fivr_driver = {
114+
.probe = pch_fivr_add,
115+
.remove = pch_fivr_remove,
116+
.driver = {
117+
.name = "DPTF PCH FIVR",
118+
.acpi_match_table = pch_fivr_device_ids,
119+
},
120+
};
121+
122+
module_platform_driver(pch_fivr_driver);
123+
124+
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
125+
MODULE_LICENSE("GPL v2");
126+
MODULE_DESCRIPTION("ACPI DPTF PCH FIVR driver");

drivers/acpi/dptf/int340x_thermal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {
2727
{"INTC1040"},
2828
{"INTC1043"},
2929
{"INTC1044"},
30+
{"INTC1045"},
3031
{"INTC1047"},
3132
{""},
3233
};

0 commit comments

Comments
 (0)