aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/dptf/Kconfig15
-rw-r--r--drivers/acpi/dptf/Makefile1
-rw-r--r--drivers/acpi/dptf/dptf_power.c128
5 files changed, 146 insertions, 0 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index b7e2e776397d..b91a35bfc999 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -475,6 +475,7 @@ config ACPI_NFIT_DEBUG
475 issue. 475 issue.
476 476
477source "drivers/acpi/apei/Kconfig" 477source "drivers/acpi/apei/Kconfig"
478source "drivers/acpi/dptf/Kconfig"
478 479
479config ACPI_EXTLOG 480config ACPI_EXTLOG
480 tristate "Extended Error Log support" 481 tristate "Extended Error Log support"
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 251ce85a66fb..f6d0cc0fb4e1 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -101,3 +101,4 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
101obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 101obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
102 102
103video-objs += acpi_video.o video_detect.o 103video-objs += acpi_video.o video_detect.o
104obj-y += dptf/
diff --git a/drivers/acpi/dptf/Kconfig b/drivers/acpi/dptf/Kconfig
new file mode 100644
index 000000000000..ac0a6ed0cf46
--- /dev/null
+++ b/drivers/acpi/dptf/Kconfig
@@ -0,0 +1,15 @@
1config DPTF_POWER
2 tristate "DPTF Platform Power Participant"
3 depends on X86
4 help
5 This driver adds support for Dynamic Platform and Thermal Framework
6 (DPTF) Platform Power Participant device (INT3407) support.
7 This participant is responsible for exposing platform telemetry:
8 max_platform_power
9 platform_power_source
10 adapter_rating
11 battery_steady_power
12 charger_type
13
14 To compile this driver as a module, choose M here:
15 the module will be called dptf_power.
diff --git a/drivers/acpi/dptf/Makefile b/drivers/acpi/dptf/Makefile
new file mode 100644
index 000000000000..62cbe8753a19
--- /dev/null
+++ b/drivers/acpi/dptf/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_DPTF_POWER) += dptf_power.o
diff --git a/drivers/acpi/dptf/dptf_power.c b/drivers/acpi/dptf/dptf_power.c
new file mode 100644
index 000000000000..734642dc5008
--- /dev/null
+++ b/drivers/acpi/dptf/dptf_power.c
@@ -0,0 +1,128 @@
1/*
2 * dptf_power: DPTF platform power driver
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 <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/acpi.h>
19#include <linux/platform_device.h>
20
21/*
22 * Presentation of attributes which are defined for INT3407. They are:
23 * PMAX : Maximum platform powe
24 * PSRC : Platform power source
25 * ARTG : Adapter rating
26 * CTYP : Charger type
27 * PBSS : Battery steady power
28 */
29#define DPTF_POWER_SHOW(name, object) \
30static ssize_t name##_show(struct device *dev,\
31 struct device_attribute *attr,\
32 char *buf)\
33{\
34 struct platform_device *pdev = to_platform_device(dev);\
35 struct acpi_device *acpi_dev = platform_get_drvdata(pdev);\
36 unsigned long long val;\
37 acpi_status status;\
38\
39 status = acpi_evaluate_integer(acpi_dev->handle, #object,\
40 NULL, &val);\
41 if (ACPI_SUCCESS(status))\
42 return sprintf(buf, "%d\n", (int)val);\
43 else \
44 return -EINVAL;\
45}
46
47DPTF_POWER_SHOW(max_platform_power_mw, PMAX)
48DPTF_POWER_SHOW(platform_power_source, PSRC)
49DPTF_POWER_SHOW(adapter_rating_mw, ARTG)
50DPTF_POWER_SHOW(battery_steady_power_mw, PBSS)
51DPTF_POWER_SHOW(charger_type, CTYP)
52
53static DEVICE_ATTR_RO(max_platform_power_mw);
54static DEVICE_ATTR_RO(platform_power_source);
55static DEVICE_ATTR_RO(adapter_rating_mw);
56static DEVICE_ATTR_RO(battery_steady_power_mw);
57static DEVICE_ATTR_RO(charger_type);
58
59static struct attribute *dptf_power_attrs[] = {
60 &dev_attr_max_platform_power_mw.attr,
61 &dev_attr_platform_power_source.attr,
62 &dev_attr_adapter_rating_mw.attr,
63 &dev_attr_battery_steady_power_mw.attr,
64 &dev_attr_charger_type.attr,
65 NULL
66};
67
68static struct attribute_group dptf_power_attribute_group = {
69 .attrs = dptf_power_attrs,
70 .name = "dptf_power"
71};
72
73static int dptf_power_add(struct platform_device *pdev)
74{
75 struct acpi_device *acpi_dev;
76 acpi_status status;
77 unsigned long long ptype;
78 int result;
79
80 acpi_dev = ACPI_COMPANION(&(pdev->dev));
81 if (!acpi_dev)
82 return -ENODEV;
83
84 status = acpi_evaluate_integer(acpi_dev->handle, "PTYP", NULL, &ptype);
85 if (ACPI_FAILURE(status))
86 return -ENODEV;
87
88 if (ptype != 0x11)
89 return -ENODEV;
90
91 result = sysfs_create_group(&pdev->dev.kobj,
92 &dptf_power_attribute_group);
93 if (result)
94 return result;
95
96 platform_set_drvdata(pdev, acpi_dev);
97
98 return 0;
99}
100
101static int dptf_power_remove(struct platform_device *pdev)
102{
103
104 sysfs_remove_group(&pdev->dev.kobj, &dptf_power_attribute_group);
105
106 return 0;
107}
108
109static const struct acpi_device_id int3407_device_ids[] = {
110 {"INT3407", 0},
111 {"", 0},
112};
113MODULE_DEVICE_TABLE(acpi, int3407_device_ids);
114
115static struct platform_driver dptf_power_driver = {
116 .probe = dptf_power_add,
117 .remove = dptf_power_remove,
118 .driver = {
119 .name = "DPTF Platform Power",
120 .acpi_match_table = int3407_device_ids,
121 },
122};
123
124module_platform_driver(dptf_power_driver);
125
126MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
127MODULE_LICENSE("GPL v2");
128MODULE_DESCRIPTION("ACPI DPTF platform power driver");