summaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-09-04 10:43:40 -0400
committerLee Jones <lee.jones@linaro.org>2017-10-13 05:42:58 -0400
commit31374972321d1639d1a8bb1213b66688132d103f (patch)
treea66a9761c074ef5e18903050d152045f499b6bf6 /drivers/acpi
parent6bac0606fdba97a2666bc8f0460a05fb7352b7e2 (diff)
ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at: https://github.com/01org/ProductionKernelQuilts with many cleanups and rewrites. The driver is currently provided only as built-in to follow other PMIC opregion drivers convention. The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689 Signed-off-by: Takashi Iwai <tiwai@suse.de> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig6
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/pmic/intel_pmic_chtdc_ti.c137
3 files changed, 144 insertions, 0 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 1ce52f84dc23..176fae699891 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
521 help 521 help
522 This config adds ACPI operation region support for CHT Whiskey Cove PMIC. 522 This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
523 523
524config CHT_DC_TI_PMIC_OPREGION
525 bool "ACPI operation region support for Dollar Cove TI PMIC"
526 depends on INTEL_SOC_PMIC_CHTDC_TI
527 help
528 This config adds ACPI operation region support for Dollar Cove TI PMIC.
529
524endif 530endif
525 531
526config ACPI_CONFIGFS 532config ACPI_CONFIGFS
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 90265ab4437a..21185613bc9b 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -104,6 +104,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
104obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 104obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
105obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o 105obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
106obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o 106obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
107obj-$(CONFIG_CHT_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o
107 108
108obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o 109obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o
109 110
diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
new file mode 100644
index 000000000000..109c1e9c9c7a
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
@@ -0,0 +1,137 @@
1/*
2 * Dollar Cove TI PMIC operation region driver
3 * Copyright (C) 2014 Intel Corporation. All rights reserved.
4 *
5 * Rewritten and cleaned up
6 * Copyright (C) 2017 Takashi Iwai <tiwai@suse.de>
7 */
8
9#include <linux/acpi.h>
10#include <linux/init.h>
11#include <linux/mfd/intel_soc_pmic.h>
12#include <linux/platform_device.h>
13#include "intel_pmic.h"
14
15/* registers stored in 16bit BE (high:low, total 10bit) */
16#define CHTDC_TI_VBAT 0x54
17#define CHTDC_TI_DIETEMP 0x56
18#define CHTDC_TI_BPTHERM 0x58
19#define CHTDC_TI_GPADC 0x5a
20
21static struct pmic_table chtdc_ti_power_table[] = {
22 { .address = 0x00, .reg = 0x41 },
23 { .address = 0x04, .reg = 0x42 },
24 { .address = 0x08, .reg = 0x43 },
25 { .address = 0x0c, .reg = 0x45 },
26 { .address = 0x10, .reg = 0x46 },
27 { .address = 0x14, .reg = 0x47 },
28 { .address = 0x18, .reg = 0x48 },
29 { .address = 0x1c, .reg = 0x49 },
30 { .address = 0x20, .reg = 0x4a },
31 { .address = 0x24, .reg = 0x4b },
32 { .address = 0x28, .reg = 0x4c },
33 { .address = 0x2c, .reg = 0x4d },
34 { .address = 0x30, .reg = 0x4e },
35};
36
37static struct pmic_table chtdc_ti_thermal_table[] = {
38 {
39 .address = 0x00,
40 .reg = CHTDC_TI_GPADC
41 },
42 {
43 .address = 0x0c,
44 .reg = CHTDC_TI_GPADC
45 },
46 /* TMP2 -> SYSTEMP */
47 {
48 .address = 0x18,
49 .reg = CHTDC_TI_GPADC
50 },
51 /* TMP3 -> BPTHERM */
52 {
53 .address = 0x24,
54 .reg = CHTDC_TI_BPTHERM
55 },
56 {
57 .address = 0x30,
58 .reg = CHTDC_TI_GPADC
59 },
60 /* TMP5 -> DIETEMP */
61 {
62 .address = 0x3c,
63 .reg = CHTDC_TI_DIETEMP
64 },
65};
66
67static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit,
68 u64 *value)
69{
70 int data;
71
72 if (regmap_read(regmap, reg, &data))
73 return -EIO;
74
75 *value = data & 1;
76 return 0;
77}
78
79static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
80 bool on)
81{
82 return regmap_update_bits(regmap, reg, 1, on);
83}
84
85static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
86{
87 u8 buf[2];
88
89 if (regmap_bulk_read(regmap, reg, buf, 2))
90 return -EIO;
91
92 /* stored in big-endian */
93 return ((buf[0] & 0x03) << 8) | buf[1];
94}
95
96static struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
97 .get_power = chtdc_ti_pmic_get_power,
98 .update_power = chtdc_ti_pmic_update_power,
99 .get_raw_temp = chtdc_ti_pmic_get_raw_temp,
100 .power_table = chtdc_ti_power_table,
101 .power_table_count = ARRAY_SIZE(chtdc_ti_power_table),
102 .thermal_table = chtdc_ti_thermal_table,
103 .thermal_table_count = ARRAY_SIZE(chtdc_ti_thermal_table),
104};
105
106static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev)
107{
108 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
109 int err;
110
111 err = intel_pmic_install_opregion_handler(&pdev->dev,
112 ACPI_HANDLE(pdev->dev.parent), pmic->regmap,
113 &chtdc_ti_pmic_opregion_data);
114 if (err < 0)
115 return err;
116
117 /* Re-enumerate devices depending on PMIC */
118 acpi_walk_dep_device_list(ACPI_HANDLE(pdev->dev.parent));
119 return 0;
120}
121
122static const struct platform_device_id chtdc_ti_pmic_opregion_id_table[] = {
123 { .name = "chtdc_ti_region" },
124 {},
125};
126
127static struct platform_driver chtdc_ti_pmic_opregion_driver = {
128 .probe = chtdc_ti_pmic_opregion_probe,
129 .driver = {
130 .name = "cht_dollar_cove_ti_pmic",
131 },
132 .id_table = chtdc_ti_pmic_opregion_id_table,
133};
134module_platform_driver(chtdc_ti_pmic_opregion_driver);
135
136MODULE_DESCRIPTION("Dollar Cove TI PMIC opregion driver");
137MODULE_LICENSE("GPL v2");