aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd
diff options
context:
space:
mode:
authorRobby Cai <R63905@freescale.com>2013-08-13 22:14:26 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:01:34 -0400
commit204ee4b0312a3dcfa84e196f3981d10a9017e462 (patch)
treefbfdec23f813858b4fd784eee2e786fd133e6c9e /include/linux/mfd
parent3133b6cfb31b202805d31d449bfa70383e5e1c75 (diff)
ENGR00276832-1 pmic: max17135: port driver codes to 3.10 kernel
It's ported from v3.5.7 kernel, which contains a sensor driver and regulator driver. It's used for E-Ink panel. add a parameter for mfd_add_devices() due to the propotype change. use IS_ERR() to check the return value for devm_regulator_get(). Signed-off-by: Robby Cai <R63905@freescale.com>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r--include/linux/mfd/max17135.h220
1 files changed, 220 insertions, 0 deletions
diff --git a/include/linux/mfd/max17135.h b/include/linux/mfd/max17135.h
new file mode 100644
index 000000000000..99c797ae1d57
--- /dev/null
+++ b/include/linux/mfd/max17135.h
@@ -0,0 +1,220 @@
1/*
2 * Copyright (C) 2010-2013 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19#ifndef __LINUX_REGULATOR_MAX17135_H_
20#define __LINUX_REGULATOR_MAX17135_H_
21
22/*
23 * PMIC Register Addresses
24 */
25enum {
26 REG_MAX17135_EXT_TEMP = 0x0,
27 REG_MAX17135_CONFIG,
28 REG_MAX17135_INT_TEMP = 0x4,
29 REG_MAX17135_STATUS,
30 REG_MAX17135_PRODUCT_REV,
31 REG_MAX17135_PRODUCT_ID,
32 REG_MAX17135_DVR,
33 REG_MAX17135_ENABLE,
34 REG_MAX17135_FAULT, /*0x0A*/
35 REG_MAX17135_HVINP,
36 REG_MAX17135_PRGM_CTRL,
37 REG_MAX17135_TIMING1 = 0x10, /* Timing regs base address is 0x10 */
38 REG_MAX17135_TIMING2,
39 REG_MAX17135_TIMING3,
40 REG_MAX17135_TIMING4,
41 REG_MAX17135_TIMING5,
42 REG_MAX17135_TIMING6,
43 REG_MAX17135_TIMING7,
44 REG_MAX17135_TIMING8,
45};
46#define MAX17135_REG_NUM 21
47#define MAX17135_MAX_REGISTER 0xFF
48
49/*
50 * Bitfield macros that use rely on bitfield width/shift information.
51 */
52#define BITFMASK(field) (((1U << (field ## _WID)) - 1) << (field ## _LSH))
53#define BITFVAL(field, val) ((val) << (field ## _LSH))
54#define BITFEXT(var, bit) ((var & BITFMASK(bit)) >> (bit ## _LSH))
55
56/*
57 * Shift and width values for each register bitfield
58 */
59#define EXT_TEMP_LSH 7
60#define EXT_TEMP_WID 9
61
62#define THERMAL_SHUTDOWN_LSH 0
63#define THERMAL_SHUTDOWN_WID 1
64
65#define INT_TEMP_LSH 7
66#define INT_TEMP_WID 9
67
68#define STAT_BUSY_LSH 0
69#define STAT_BUSY_WID 1
70#define STAT_OPEN_LSH 1
71#define STAT_OPEN_WID 1
72#define STAT_SHRT_LSH 2
73#define STAT_SHRT_WID 1
74
75#define PROD_REV_LSH 0
76#define PROD_REV_WID 8
77
78#define PROD_ID_LSH 0
79#define PROD_ID_WID 8
80
81#define DVR_LSH 0
82#define DVR_WID 8
83
84#define ENABLE_LSH 0
85#define ENABLE_WID 1
86#define VCOM_ENABLE_LSH 1
87#define VCOM_ENABLE_WID 1
88
89#define FAULT_FBPG_LSH 0
90#define FAULT_FBPG_WID 1
91#define FAULT_HVINP_LSH 1
92#define FAULT_HVINP_WID 1
93#define FAULT_HVINN_LSH 2
94#define FAULT_HVINN_WID 1
95#define FAULT_FBNG_LSH 3
96#define FAULT_FBNG_WID 1
97#define FAULT_HVINPSC_LSH 4
98#define FAULT_HVINPSC_WID 1
99#define FAULT_HVINNSC_LSH 5
100#define FAULT_HVINNSC_WID 1
101#define FAULT_OT_LSH 6
102#define FAULT_OT_WID 1
103#define FAULT_POK_LSH 7
104#define FAULT_POK_WID 1
105
106#define HVINP_LSH 0
107#define HVINP_WID 4
108
109#define CTRL_DVR_LSH 0
110#define CTRL_DVR_WID 1
111#define CTRL_TIMING_LSH 1
112#define CTRL_TIMING_WID 1
113
114#define TIMING1_LSH 0
115#define TIMING1_WID 8
116#define TIMING2_LSH 0
117#define TIMING2_WID 8
118#define TIMING3_LSH 0
119#define TIMING3_WID 8
120#define TIMING4_LSH 0
121#define TIMING4_WID 8
122#define TIMING5_LSH 0
123#define TIMING5_WID 8
124#define TIMING6_LSH 0
125#define TIMING6_WID 8
126#define TIMING7_LSH 0
127#define TIMING7_WID 8
128#define TIMING8_LSH 0
129#define TIMING8_WID 8
130
131struct max17135 {
132 /* chip revision */
133 int rev;
134
135 struct device *dev;
136 struct max17135_platform_data *pdata;
137
138 /* Platform connection */
139 struct i2c_client *i2c_client;
140
141 /* Timings */
142 unsigned int gvee_pwrup;
143 unsigned int vneg_pwrup;
144 unsigned int vpos_pwrup;
145 unsigned int gvdd_pwrup;
146 unsigned int gvdd_pwrdn;
147 unsigned int vpos_pwrdn;
148 unsigned int vneg_pwrdn;
149 unsigned int gvee_pwrdn;
150
151 /* GPIOs */
152 int gpio_pmic_pwrgood;
153 int gpio_pmic_vcom_ctrl;
154 int gpio_pmic_wakeup;
155 int gpio_pmic_v3p3;
156 int gpio_pmic_intr;
157
158 /* MAX17135 part variables */
159 int pass_num;
160 int vcom_uV;
161
162 /* One-time VCOM setup marker */
163 bool vcom_setup;
164
165 /* powerup/powerdown wait time */
166 int max_wait;
167};
168
169enum {
170 /* In alphabetical order */
171 MAX17135_DISPLAY, /* virtual master enable */
172 MAX17135_GVDD,
173 MAX17135_GVEE,
174 MAX17135_HVINN,
175 MAX17135_HVINP,
176 MAX17135_VCOM,
177 MAX17135_VNEG,
178 MAX17135_VPOS,
179 MAX17135_V3P3,
180 MAX17135_NUM_REGULATORS,
181};
182
183/*
184 * Declarations
185 */
186struct regulator_init_data;
187struct max17135_regulator_data;
188
189struct max17135_platform_data {
190 unsigned int gvee_pwrup;
191 unsigned int vneg_pwrup;
192 unsigned int vpos_pwrup;
193 unsigned int gvdd_pwrup;
194 unsigned int gvdd_pwrdn;
195 unsigned int vpos_pwrdn;
196 unsigned int vneg_pwrdn;
197 unsigned int gvee_pwrdn;
198 int gpio_pmic_pwrgood;
199 int gpio_pmic_vcom_ctrl;
200 int gpio_pmic_wakeup;
201 int gpio_pmic_v3p3;
202 int gpio_pmic_intr;
203 int pass_num;
204 int vcom_uV;
205
206 /* PMIC */
207 struct max17135_regulator_data *regulators;
208 int num_regulators;
209};
210
211struct max17135_regulator_data {
212 int id;
213 struct regulator_init_data *initdata;
214 struct device_node *reg_node;
215};
216
217int max17135_reg_read(int reg_num, unsigned int *reg_val);
218int max17135_reg_write(int reg_num, const unsigned int reg_val);
219
220#endif