1 // SPDX-License-Identifier: GPL-2.0
3 * Intel CHT Whiskey Cove PMIC operation region driver
4 * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
6 * Based on various non upstream patches to support the CHT Whiskey Cove PMIC:
7 * Copyright (C) 2013-2015 Intel Corporation. All rights reserved.
10 #include <linux/acpi.h>
11 #include <linux/init.h>
12 #include <linux/mfd/intel_soc_pmic.h>
13 #include <linux/platform_device.h>
14 #include <linux/regmap.h>
15 #include "intel_pmic.h"
17 #define CHT_WC_V1P05A_CTRL 0x6e3b
18 #define CHT_WC_V1P15_CTRL 0x6e3c
19 #define CHT_WC_V1P05A_VSEL 0x6e3d
20 #define CHT_WC_V1P15_VSEL 0x6e3e
21 #define CHT_WC_V1P8A_CTRL 0x6e56
22 #define CHT_WC_V1P8SX_CTRL 0x6e57
23 #define CHT_WC_VDDQ_CTRL 0x6e58
24 #define CHT_WC_V1P2A_CTRL 0x6e59
25 #define CHT_WC_V1P2SX_CTRL 0x6e5a
26 #define CHT_WC_V1P8A_VSEL 0x6e5b
27 #define CHT_WC_VDDQ_VSEL 0x6e5c
28 #define CHT_WC_V2P8SX_CTRL 0x6e5d
29 #define CHT_WC_V3P3A_CTRL 0x6e5e
30 #define CHT_WC_V3P3SD_CTRL 0x6e5f
31 #define CHT_WC_VSDIO_CTRL 0x6e67
32 #define CHT_WC_V3P3A_VSEL 0x6e68
33 #define CHT_WC_VPROG1A_CTRL 0x6e90
34 #define CHT_WC_VPROG1B_CTRL 0x6e91
35 #define CHT_WC_VPROG1F_CTRL 0x6e95
36 #define CHT_WC_VPROG2D_CTRL 0x6e99
37 #define CHT_WC_VPROG3A_CTRL 0x6e9a
38 #define CHT_WC_VPROG3B_CTRL 0x6e9b
39 #define CHT_WC_VPROG4A_CTRL 0x6e9c
40 #define CHT_WC_VPROG4B_CTRL 0x6e9d
41 #define CHT_WC_VPROG4C_CTRL 0x6e9e
42 #define CHT_WC_VPROG4D_CTRL 0x6e9f
43 #define CHT_WC_VPROG5A_CTRL 0x6ea0
44 #define CHT_WC_VPROG5B_CTRL 0x6ea1
45 #define CHT_WC_VPROG6A_CTRL 0x6ea2
46 #define CHT_WC_VPROG6B_CTRL 0x6ea3
47 #define CHT_WC_VPROG1A_VSEL 0x6ec0
48 #define CHT_WC_VPROG1B_VSEL 0x6ec1
49 #define CHT_WC_V1P8SX_VSEL 0x6ec2
50 #define CHT_WC_V1P2SX_VSEL 0x6ec3
51 #define CHT_WC_V1P2A_VSEL 0x6ec4
52 #define CHT_WC_VPROG1F_VSEL 0x6ec5
53 #define CHT_WC_VSDIO_VSEL 0x6ec6
54 #define CHT_WC_V2P8SX_VSEL 0x6ec7
55 #define CHT_WC_V3P3SD_VSEL 0x6ec8
56 #define CHT_WC_VPROG2D_VSEL 0x6ec9
57 #define CHT_WC_VPROG3A_VSEL 0x6eca
58 #define CHT_WC_VPROG3B_VSEL 0x6ecb
59 #define CHT_WC_VPROG4A_VSEL 0x6ecc
60 #define CHT_WC_VPROG4B_VSEL 0x6ecd
61 #define CHT_WC_VPROG4C_VSEL 0x6ece
62 #define CHT_WC_VPROG4D_VSEL 0x6ecf
63 #define CHT_WC_VPROG5A_VSEL 0x6ed0
64 #define CHT_WC_VPROG5B_VSEL 0x6ed1
65 #define CHT_WC_VPROG6A_VSEL 0x6ed2
66 #define CHT_WC_VPROG6B_VSEL 0x6ed3
69 * Regulator support is based on the non upstream patch:
70 * "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support"
71 * https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch
73 static struct pmic_table power_table
[] = {
76 .reg
= CHT_WC_V1P8A_CTRL
,
81 .reg
= CHT_WC_V1P8SX_CTRL
,
86 .reg
= CHT_WC_VDDQ_CTRL
,
91 .reg
= CHT_WC_V1P2A_CTRL
,
96 .reg
= CHT_WC_V1P2SX_CTRL
,
101 .reg
= CHT_WC_V2P8SX_CTRL
,
106 .reg
= CHT_WC_V3P3A_CTRL
,
111 .reg
= CHT_WC_V3P3SD_CTRL
,
116 .reg
= CHT_WC_VSDIO_CTRL
,
141 .reg
= CHT_WC_VPROG1A_CTRL
,
146 .reg
= CHT_WC_VPROG1B_CTRL
,
151 .reg
= CHT_WC_VPROG1F_CTRL
,
156 .reg
= CHT_WC_VPROG2D_CTRL
,
161 .reg
= CHT_WC_VPROG3A_CTRL
,
166 .reg
= CHT_WC_VPROG3B_CTRL
,
171 .reg
= CHT_WC_VPROG4A_CTRL
,
176 .reg
= CHT_WC_VPROG4B_CTRL
,
181 .reg
= CHT_WC_VPROG4C_CTRL
,
186 .reg
= CHT_WC_VPROG4D_CTRL
,
191 .reg
= CHT_WC_VPROG5A_CTRL
,
196 .reg
= CHT_WC_VPROG5B_CTRL
,
201 .reg
= CHT_WC_VPROG6A_CTRL
,
206 .reg
= CHT_WC_VPROG6B_CTRL
,
216 static int intel_cht_wc_pmic_get_power(struct regmap
*regmap
, int reg
,
221 if (regmap_read(regmap
, reg
, &data
))
224 *value
= (data
& bit
) ? 1 : 0;
228 static int intel_cht_wc_pmic_update_power(struct regmap
*regmap
, int reg
,
229 int bitmask
, bool on
)
231 return regmap_update_bits(regmap
, reg
, bitmask
, on
? 1 : 0);
234 static int intel_cht_wc_exec_mipi_pmic_seq_element(struct regmap
*regmap
,
235 u16 i2c_client_address
,
241 if (i2c_client_address
> 0xff || reg_address
> 0xff) {
242 pr_warn("%s warning addresses too big client 0x%x reg 0x%x\n",
243 __func__
, i2c_client_address
, reg_address
);
247 address
= (i2c_client_address
<< 8) | reg_address
;
249 return regmap_update_bits(regmap
, address
, mask
, value
);
253 * The thermal table and ops are empty, we do not support the Thermal opregion
254 * (DPTF) due to lacking documentation.
256 static struct intel_pmic_opregion_data intel_cht_wc_pmic_opregion_data
= {
257 .get_power
= intel_cht_wc_pmic_get_power
,
258 .update_power
= intel_cht_wc_pmic_update_power
,
259 .exec_mipi_pmic_seq_element
= intel_cht_wc_exec_mipi_pmic_seq_element
,
260 .power_table
= power_table
,
261 .power_table_count
= ARRAY_SIZE(power_table
),
264 static int intel_cht_wc_pmic_opregion_probe(struct platform_device
*pdev
)
266 struct intel_soc_pmic
*pmic
= dev_get_drvdata(pdev
->dev
.parent
);
268 return intel_pmic_install_opregion_handler(&pdev
->dev
,
269 ACPI_HANDLE(pdev
->dev
.parent
),
271 &intel_cht_wc_pmic_opregion_data
);
274 static const struct platform_device_id cht_wc_opregion_id_table
[] = {
275 { .name
= "cht_wcove_region" },
279 static struct platform_driver intel_cht_wc_pmic_opregion_driver
= {
280 .probe
= intel_cht_wc_pmic_opregion_probe
,
282 .name
= "cht_whiskey_cove_pmic",
284 .id_table
= cht_wc_opregion_id_table
,
286 builtin_platform_driver(intel_cht_wc_pmic_opregion_driver
);