aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/palmas.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mfd/palmas.h')
-rw-r--r--include/linux/mfd/palmas.h232
1 files changed, 202 insertions, 30 deletions
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 9cbc642d40ad..29f6616e12f0 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -23,6 +23,9 @@
23#define PALMAS_NUM_CLIENTS 3 23#define PALMAS_NUM_CLIENTS 3
24 24
25struct palmas_pmic; 25struct palmas_pmic;
26struct palmas_gpadc;
27struct palmas_resource;
28struct palmas_usb;
26 29
27struct palmas { 30struct palmas {
28 struct device *dev; 31 struct device *dev;
@@ -41,6 +44,9 @@ struct palmas {
41 44
42 /* Child Devices */ 45 /* Child Devices */
43 struct palmas_pmic *pmic; 46 struct palmas_pmic *pmic;
47 struct palmas_gpadc *gpadc;
48 struct palmas_resource *resource;
49 struct palmas_usb *usb;
44 50
45 /* GPIO MUXing */ 51 /* GPIO MUXing */
46 u8 gpio_muxed; 52 u8 gpio_muxed;
@@ -48,6 +54,23 @@ struct palmas {
48 u8 pwm_muxed; 54 u8 pwm_muxed;
49}; 55};
50 56
57struct palmas_gpadc_platform_data {
58 /* Channel 3 current source is only enabled during conversion */
59 int ch3_current;
60
61 /* Channel 0 current source can be used for battery detection.
62 * If used for battery detection this will cause a permanent current
63 * consumption depending on current level set here.
64 */
65 int ch0_current;
66
67 /* default BAT_REMOVAL_DAT setting on device probe */
68 int bat_removal;
69
70 /* Sets the START_POLARITY bit in the RT_CTRL register */
71 int start_polarity;
72};
73
51struct palmas_reg_init { 74struct palmas_reg_init {
52 /* warm_rest controls the voltage levels after a warm reset 75 /* warm_rest controls the voltage levels after a warm reset
53 * 76 *
@@ -107,21 +130,94 @@ struct palmas_reg_init {
107 130
108}; 131};
109 132
133enum palmas_regulators {
134 /* SMPS regulators */
135 PALMAS_REG_SMPS12,
136 PALMAS_REG_SMPS123,
137 PALMAS_REG_SMPS3,
138 PALMAS_REG_SMPS45,
139 PALMAS_REG_SMPS457,
140 PALMAS_REG_SMPS6,
141 PALMAS_REG_SMPS7,
142 PALMAS_REG_SMPS8,
143 PALMAS_REG_SMPS9,
144 PALMAS_REG_SMPS10,
145 /* LDO regulators */
146 PALMAS_REG_LDO1,
147 PALMAS_REG_LDO2,
148 PALMAS_REG_LDO3,
149 PALMAS_REG_LDO4,
150 PALMAS_REG_LDO5,
151 PALMAS_REG_LDO6,
152 PALMAS_REG_LDO7,
153 PALMAS_REG_LDO8,
154 PALMAS_REG_LDO9,
155 PALMAS_REG_LDOLN,
156 PALMAS_REG_LDOUSB,
157 /* Total number of regulators */
158 PALMAS_NUM_REGS,
159};
160
110struct palmas_pmic_platform_data { 161struct palmas_pmic_platform_data {
111 /* An array of pointers to regulator init data indexed by regulator 162 /* An array of pointers to regulator init data indexed by regulator
112 * ID 163 * ID
113 */ 164 */
114 struct regulator_init_data **reg_data; 165 struct regulator_init_data *reg_data[PALMAS_NUM_REGS];
115 166
116 /* An array of pointers to structures containing sleep mode and DVS 167 /* An array of pointers to structures containing sleep mode and DVS
117 * configuration for regulators indexed by ID 168 * configuration for regulators indexed by ID
118 */ 169 */
119 struct palmas_reg_init **reg_init; 170 struct palmas_reg_init *reg_init[PALMAS_NUM_REGS];
120 171
121 /* use LDO6 for vibrator control */ 172 /* use LDO6 for vibrator control */
122 int ldo6_vibrator; 173 int ldo6_vibrator;
174};
123 175
176struct palmas_usb_platform_data {
177 /* Set this if platform wishes its own vbus control */
178 int no_control_vbus;
124 179
180 /* Do we enable the wakeup comparator on probe */
181 int wakeup;
182};
183
184struct palmas_resource_platform_data {
185 int regen1_mode_sleep;
186 int regen2_mode_sleep;
187 int sysen1_mode_sleep;
188 int sysen2_mode_sleep;
189
190 /* bitfield to be loaded to NSLEEP_RES_ASSIGN */
191 u8 nsleep_res;
192 /* bitfield to be loaded to NSLEEP_SMPS_ASSIGN */
193 u8 nsleep_smps;
194 /* bitfield to be loaded to NSLEEP_LDO_ASSIGN1 */
195 u8 nsleep_ldo1;
196 /* bitfield to be loaded to NSLEEP_LDO_ASSIGN2 */
197 u8 nsleep_ldo2;
198
199 /* bitfield to be loaded to ENABLE1_RES_ASSIGN */
200 u8 enable1_res;
201 /* bitfield to be loaded to ENABLE1_SMPS_ASSIGN */
202 u8 enable1_smps;
203 /* bitfield to be loaded to ENABLE1_LDO_ASSIGN1 */
204 u8 enable1_ldo1;
205 /* bitfield to be loaded to ENABLE1_LDO_ASSIGN2 */
206 u8 enable1_ldo2;
207
208 /* bitfield to be loaded to ENABLE2_RES_ASSIGN */
209 u8 enable2_res;
210 /* bitfield to be loaded to ENABLE2_SMPS_ASSIGN */
211 u8 enable2_smps;
212 /* bitfield to be loaded to ENABLE2_LDO_ASSIGN1 */
213 u8 enable2_ldo1;
214 /* bitfield to be loaded to ENABLE2_LDO_ASSIGN2 */
215 u8 enable2_ldo2;
216};
217
218struct palmas_clk_platform_data {
219 int clk32kg_mode_sleep;
220 int clk32kgaudio_mode_sleep;
125}; 221};
126 222
127struct palmas_platform_data { 223struct palmas_platform_data {
@@ -138,8 +234,49 @@ struct palmas_platform_data {
138 u8 pad1, pad2; 234 u8 pad1, pad2;
139 235
140 struct palmas_pmic_platform_data *pmic_pdata; 236 struct palmas_pmic_platform_data *pmic_pdata;
237 struct palmas_gpadc_platform_data *gpadc_pdata;
238 struct palmas_usb_platform_data *usb_pdata;
239 struct palmas_resource_platform_data *resource_pdata;
240 struct palmas_clk_platform_data *clk_pdata;
241};
242
243struct palmas_gpadc_calibration {
244 s32 gain;
245 s32 gain_error;
246 s32 offset_error;
141}; 247};
142 248
249struct palmas_gpadc {
250 struct device *dev;
251 struct palmas *palmas;
252
253 int ch3_current;
254 int ch0_current;
255
256 int gpadc_force;
257
258 int bat_removal;
259
260 struct mutex reading_lock;
261 struct completion irq_complete;
262
263 int eoc_sw_irq;
264
265 struct palmas_gpadc_calibration *palmas_cal_tbl;
266
267 int conv0_channel;
268 int conv1_channel;
269 int rt_channel;
270};
271
272struct palmas_gpadc_result {
273 s32 raw_code;
274 s32 corrected_code;
275 s32 result;
276};
277
278#define PALMAS_MAX_CHANNELS 16
279
143/* Define the palmas IRQ numbers */ 280/* Define the palmas IRQ numbers */
144enum palmas_irqs { 281enum palmas_irqs {
145 /* INT1 registers */ 282 /* INT1 registers */
@@ -182,34 +319,6 @@ enum palmas_irqs {
182 PALMAS_NUM_IRQ, 319 PALMAS_NUM_IRQ,
183}; 320};
184 321
185enum palmas_regulators {
186 /* SMPS regulators */
187 PALMAS_REG_SMPS12,
188 PALMAS_REG_SMPS123,
189 PALMAS_REG_SMPS3,
190 PALMAS_REG_SMPS45,
191 PALMAS_REG_SMPS457,
192 PALMAS_REG_SMPS6,
193 PALMAS_REG_SMPS7,
194 PALMAS_REG_SMPS8,
195 PALMAS_REG_SMPS9,
196 PALMAS_REG_SMPS10,
197 /* LDO regulators */
198 PALMAS_REG_LDO1,
199 PALMAS_REG_LDO2,
200 PALMAS_REG_LDO3,
201 PALMAS_REG_LDO4,
202 PALMAS_REG_LDO5,
203 PALMAS_REG_LDO6,
204 PALMAS_REG_LDO7,
205 PALMAS_REG_LDO8,
206 PALMAS_REG_LDO9,
207 PALMAS_REG_LDOLN,
208 PALMAS_REG_LDOUSB,
209 /* Total number of regulators */
210 PALMAS_NUM_REGS,
211};
212
213struct palmas_pmic { 322struct palmas_pmic {
214 struct palmas *palmas; 323 struct palmas *palmas;
215 struct device *dev; 324 struct device *dev;
@@ -223,6 +332,69 @@ struct palmas_pmic {
223 int range[PALMAS_REG_SMPS10]; 332 int range[PALMAS_REG_SMPS10];
224}; 333};
225 334
335struct palmas_resource {
336 struct palmas *palmas;
337 struct device *dev;
338};
339
340struct palmas_usb {
341 struct palmas *palmas;
342 struct device *dev;
343
344 /* for vbus reporting with irqs disabled */
345 spinlock_t lock;
346
347 struct regulator *vbus_reg;
348
349 /* used to set vbus, in atomic path */
350 struct work_struct set_vbus_work;
351
352 int irq1;
353 int irq2;
354 int irq3;
355 int irq4;
356
357 int vbus_enable;
358
359 u8 linkstat;
360};
361
362#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
363
364enum usb_irq_events {
365 /* Wakeup events from INT3 */
366 PALMAS_USB_ID_WAKEPUP,
367 PALMAS_USB_VBUS_WAKEUP,
368
369 /* ID_OTG_EVENTS */
370 PALMAS_USB_ID_GND,
371 N_PALMAS_USB_ID_GND,
372 PALMAS_USB_ID_C,
373 N_PALMAS_USB_ID_C,
374 PALMAS_USB_ID_B,
375 N_PALMAS_USB_ID_B,
376 PALMAS_USB_ID_A,
377 N_PALMAS_USB_ID_A,
378 PALMAS_USB_ID_FLOAT,
379 N_PALMAS_USB_ID_FLOAT,
380
381 /* VBUS_OTG_EVENTS */
382 PALMAS_USB_VB_SESS_END,
383 N_PALMAS_USB_VB_SESS_END,
384 PALMAS_USB_VB_SESS_VLD,
385 N_PALMAS_USB_VB_SESS_VLD,
386 PALMAS_USB_VA_SESS_VLD,
387 N_PALMAS_USB_VA_SESS_VLD,
388 PALMAS_USB_VA_VBUS_VLD,
389 N_PALMAS_USB_VA_VBUS_VLD,
390 PALMAS_USB_VADP_SNS,
391 N_PALMAS_USB_VADP_SNS,
392 PALMAS_USB_VADP_PRB,
393 N_PALMAS_USB_VADP_PRB,
394 PALMAS_USB_VOTG_SESS_VLD,
395 N_PALMAS_USB_VOTG_SESS_VLD,
396};
397
226/* defines so we can store the mux settings */ 398/* defines so we can store the mux settings */
227#define PALMAS_GPIO_0_MUXED (1 << 0) 399#define PALMAS_GPIO_0_MUXED (1 << 0)
228#define PALMAS_GPIO_1_MUXED (1 << 1) 400#define PALMAS_GPIO_1_MUXED (1 << 1)