2 * Intel CHT Whiskey Cove PMIC operation region driver
3 * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
5 * Based on various non upstream patches to support the CHT Whiskey Cove PMIC:
6 * Copyright (C) 2013-2015 Intel Corporation. All rights reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/acpi.h>
19 #include <linux/init.h>
20 #include <linux/mfd/intel_soc_pmic.h>
21 #include <linux/platform_device.h>
22 #include <linux/regmap.h>
23 #include "intel_pmic.h"
25 #define CHT_WC_V1P05A_CTRL 0x6e3b
26 #define CHT_WC_V1P15_CTRL 0x6e3c
27 #define CHT_WC_V1P05A_VSEL 0x6e3d
28 #define CHT_WC_V1P15_VSEL 0x6e3e
29 #define CHT_WC_V1P8A_CTRL 0x6e56
30 #define CHT_WC_V1P8SX_CTRL 0x6e57
31 #define CHT_WC_VDDQ_CTRL 0x6e58
32 #define CHT_WC_V1P2A_CTRL 0x6e59
33 #define CHT_WC_V1P2SX_CTRL 0x6e5a
34 #define CHT_WC_V1P8A_VSEL 0x6e5b
35 #define CHT_WC_VDDQ_VSEL 0x6e5c
36 #define CHT_WC_V2P8SX_CTRL 0x6e5d
37 #define CHT_WC_V3P3A_CTRL 0x6e5e
38 #define CHT_WC_V3P3SD_CTRL 0x6e5f
39 #define CHT_WC_VSDIO_CTRL 0x6e67
40 #define CHT_WC_V3P3A_VSEL 0x6e68
41 #define CHT_WC_VPROG1A_CTRL 0x6e90
42 #define CHT_WC_VPROG1B_CTRL 0x6e91
43 #define CHT_WC_VPROG1F_CTRL 0x6e95
44 #define CHT_WC_VPROG2D_CTRL 0x6e99
45 #define CHT_WC_VPROG3A_CTRL 0x6e9a
46 #define CHT_WC_VPROG3B_CTRL 0x6e9b
47 #define CHT_WC_VPROG4A_CTRL 0x6e9c
48 #define CHT_WC_VPROG4B_CTRL 0x6e9d
49 #define CHT_WC_VPROG4C_CTRL 0x6e9e
50 #define CHT_WC_VPROG4D_CTRL 0x6e9f
51 #define CHT_WC_VPROG5A_CTRL 0x6ea0
52 #define CHT_WC_VPROG5B_CTRL 0x6ea1
53 #define CHT_WC_VPROG6A_CTRL 0x6ea2
54 #define CHT_WC_VPROG6B_CTRL 0x6ea3
55 #define CHT_WC_VPROG1A_VSEL 0x6ec0
56 #define CHT_WC_VPROG1B_VSEL 0x6ec1
57 #define CHT_WC_V1P8SX_VSEL 0x6ec2
58 #define CHT_WC_V1P2SX_VSEL 0x6ec3
59 #define CHT_WC_V1P2A_VSEL 0x6ec4
60 #define CHT_WC_VPROG1F_VSEL 0x6ec5
61 #define CHT_WC_VSDIO_VSEL 0x6ec6
62 #define CHT_WC_V2P8SX_VSEL 0x6ec7
63 #define CHT_WC_V3P3SD_VSEL 0x6ec8
64 #define CHT_WC_VPROG2D_VSEL 0x6ec9
65 #define CHT_WC_VPROG3A_VSEL 0x6eca
66 #define CHT_WC_VPROG3B_VSEL 0x6ecb
67 #define CHT_WC_VPROG4A_VSEL 0x6ecc
68 #define CHT_WC_VPROG4B_VSEL 0x6ecd
69 #define CHT_WC_VPROG4C_VSEL 0x6ece
70 #define CHT_WC_VPROG4D_VSEL 0x6ecf
71 #define CHT_WC_VPROG5A_VSEL 0x6ed0
72 #define CHT_WC_VPROG5B_VSEL 0x6ed1
73 #define CHT_WC_VPROG6A_VSEL 0x6ed2
74 #define CHT_WC_VPROG6B_VSEL 0x6ed3
77 * Regulator support is based on the non upstream patch:
78 * "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support"
79 * https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch
81 static struct pmic_table power_table
[] = {
84 .reg
= CHT_WC_V1P8A_CTRL
,
89 .reg
= CHT_WC_V1P8SX_CTRL
,
94 .reg
= CHT_WC_VDDQ_CTRL
,
99 .reg
= CHT_WC_V1P2A_CTRL
,
104 .reg
= CHT_WC_V1P2SX_CTRL
,
109 .reg
= CHT_WC_V2P8SX_CTRL
,
114 .reg
= CHT_WC_V3P3A_CTRL
,
119 .reg
= CHT_WC_V3P3SD_CTRL
,
124 .reg
= CHT_WC_VSDIO_CTRL
,
149 .reg
= CHT_WC_VPROG1A_CTRL
,
154 .reg
= CHT_WC_VPROG1B_CTRL
,
159 .reg
= CHT_WC_VPROG1F_CTRL
,
164 .reg
= CHT_WC_VPROG2D_CTRL
,
169 .reg
= CHT_WC_VPROG3A_CTRL
,
174 .reg
= CHT_WC_VPROG3B_CTRL
,
179 .reg
= CHT_WC_VPROG4A_CTRL
,
184 .reg
= CHT_WC_VPROG4B_CTRL
,
189 .reg
= CHT_WC_VPROG4C_CTRL
,
194 .reg
= CHT_WC_VPROG4D_CTRL
,
199 .reg
= CHT_WC_VPROG5A_CTRL
,
204 .reg
= CHT_WC_VPROG5B_CTRL
,
209 .reg
= CHT_WC_VPROG6A_CTRL
,
214 .reg
= CHT_WC_VPROG6B_CTRL
,
224 static int intel_cht_wc_pmic_get_power(struct regmap
*regmap
, int reg
,
229 if (regmap_read(regmap
, reg
, &data
))
232 *value
= (data
& bit
) ? 1 : 0;
236 static int intel_cht_wc_pmic_update_power(struct regmap
*regmap
, int reg
,
237 int bitmask
, bool on
)
239 return regmap_update_bits(regmap
, reg
, bitmask
, on
? 1 : 0);
243 * The thermal table and ops are empty, we do not support the Thermal opregion
244 * (DPTF) due to lacking documentation.
246 static struct intel_pmic_opregion_data intel_cht_wc_pmic_opregion_data
= {
247 .get_power
= intel_cht_wc_pmic_get_power
,
248 .update_power
= intel_cht_wc_pmic_update_power
,
249 .power_table
= power_table
,
250 .power_table_count
= ARRAY_SIZE(power_table
),
253 static int intel_cht_wc_pmic_opregion_probe(struct platform_device
*pdev
)
255 struct intel_soc_pmic
*pmic
= dev_get_drvdata(pdev
->dev
.parent
);
257 return intel_pmic_install_opregion_handler(&pdev
->dev
,
258 ACPI_HANDLE(pdev
->dev
.parent
),
260 &intel_cht_wc_pmic_opregion_data
);
263 static const struct platform_device_id cht_wc_opregion_id_table
[] = {
264 { .name
= "cht_wcove_region" },
268 static struct platform_driver intel_cht_wc_pmic_opregion_driver
= {
269 .probe
= intel_cht_wc_pmic_opregion_probe
,
271 .name
= "cht_whiskey_cove_pmic",
273 .id_table
= cht_wc_opregion_id_table
,
275 builtin_platform_driver(intel_cht_wc_pmic_opregion_driver
);