diff options
author | Graeme Gregory <gg@slimlogic.co.uk> | 2012-08-28 07:47:37 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-23 14:41:44 -0400 |
commit | 190ef1a6e1e493340281d10a9dbda2eac205884c (patch) | |
tree | a2935d53fb975d198d2e5a50bd59d22fe811fbbd | |
parent | 8664fade0d235eeed2f2cfdeb10d3f243ec01e4f (diff) |
mfd: palmas: Add pdata/data for rest of children
Add the platform data and data structures for children that shall be
added by a future set of commits.
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/palmas.c | 13 | ||||
-rw-r--r-- | include/linux/mfd/palmas.h | 172 |
2 files changed, 185 insertions, 0 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index 942d1d3813a5..7c1a1942d334 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
@@ -389,6 +389,19 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, | |||
389 | children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata; | 389 | children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata; |
390 | children[PALMAS_PMIC_ID].pdata_size = sizeof(*pdata->pmic_pdata); | 390 | children[PALMAS_PMIC_ID].pdata_size = sizeof(*pdata->pmic_pdata); |
391 | 391 | ||
392 | children[PALMAS_GPADC_ID].platform_data = pdata->gpadc_pdata; | ||
393 | children[PALMAS_GPADC_ID].pdata_size = sizeof(*pdata->gpadc_pdata); | ||
394 | |||
395 | children[PALMAS_RESOURCE_ID].platform_data = pdata->resource_pdata; | ||
396 | children[PALMAS_RESOURCE_ID].pdata_size = | ||
397 | sizeof(*pdata->resource_pdata); | ||
398 | |||
399 | children[PALMAS_USB_ID].platform_data = pdata->usb_pdata; | ||
400 | children[PALMAS_USB_ID].pdata_size = sizeof(*pdata->usb_pdata); | ||
401 | |||
402 | children[PALMAS_CLK_ID].platform_data = pdata->clk_pdata; | ||
403 | children[PALMAS_CLK_ID].pdata_size = sizeof(*pdata->clk_pdata); | ||
404 | |||
392 | ret = mfd_add_devices(palmas->dev, -1, | 405 | ret = mfd_add_devices(palmas->dev, -1, |
393 | children, ARRAY_SIZE(palmas_children), | 406 | children, ARRAY_SIZE(palmas_children), |
394 | NULL, regmap_irq_chip_get_base(palmas->irq_data), | 407 | NULL, regmap_irq_chip_get_base(palmas->irq_data), |
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 9cbc642d40ad..cfbf79464c19 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 | ||
25 | struct palmas_pmic; | 25 | struct palmas_pmic; |
26 | struct palmas_gpadc; | ||
27 | struct palmas_resource; | ||
28 | struct palmas_usb; | ||
26 | 29 | ||
27 | struct palmas { | 30 | struct 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 | ||
57 | struct 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 | |||
51 | struct palmas_reg_init { | 74 | struct 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 | * |
@@ -120,8 +143,53 @@ struct palmas_pmic_platform_data { | |||
120 | 143 | ||
121 | /* use LDO6 for vibrator control */ | 144 | /* use LDO6 for vibrator control */ |
122 | int ldo6_vibrator; | 145 | int ldo6_vibrator; |
146 | }; | ||
147 | |||
148 | struct palmas_usb_platform_data { | ||
149 | /* Set this if platform wishes its own vbus control */ | ||
150 | int no_control_vbus; | ||
123 | 151 | ||
152 | /* Do we enable the wakeup comparator on probe */ | ||
153 | int wakeup; | ||
154 | }; | ||
155 | |||
156 | struct palmas_resource_platform_data { | ||
157 | int regen1_mode_sleep; | ||
158 | int regen2_mode_sleep; | ||
159 | int sysen1_mode_sleep; | ||
160 | int sysen2_mode_sleep; | ||
161 | |||
162 | /* bitfield to be loaded to NSLEEP_RES_ASSIGN */ | ||
163 | u8 nsleep_res; | ||
164 | /* bitfield to be loaded to NSLEEP_SMPS_ASSIGN */ | ||
165 | u8 nsleep_smps; | ||
166 | /* bitfield to be loaded to NSLEEP_LDO_ASSIGN1 */ | ||
167 | u8 nsleep_ldo1; | ||
168 | /* bitfield to be loaded to NSLEEP_LDO_ASSIGN2 */ | ||
169 | u8 nsleep_ldo2; | ||
170 | |||
171 | /* bitfield to be loaded to ENABLE1_RES_ASSIGN */ | ||
172 | u8 enable1_res; | ||
173 | /* bitfield to be loaded to ENABLE1_SMPS_ASSIGN */ | ||
174 | u8 enable1_smps; | ||
175 | /* bitfield to be loaded to ENABLE1_LDO_ASSIGN1 */ | ||
176 | u8 enable1_ldo1; | ||
177 | /* bitfield to be loaded to ENABLE1_LDO_ASSIGN2 */ | ||
178 | u8 enable1_ldo2; | ||
179 | |||
180 | /* bitfield to be loaded to ENABLE2_RES_ASSIGN */ | ||
181 | u8 enable2_res; | ||
182 | /* bitfield to be loaded to ENABLE2_SMPS_ASSIGN */ | ||
183 | u8 enable2_smps; | ||
184 | /* bitfield to be loaded to ENABLE2_LDO_ASSIGN1 */ | ||
185 | u8 enable2_ldo1; | ||
186 | /* bitfield to be loaded to ENABLE2_LDO_ASSIGN2 */ | ||
187 | u8 enable2_ldo2; | ||
188 | }; | ||
124 | 189 | ||
190 | struct palmas_clk_platform_data { | ||
191 | int clk32kg_mode_sleep; | ||
192 | int clk32kgaudio_mode_sleep; | ||
125 | }; | 193 | }; |
126 | 194 | ||
127 | struct palmas_platform_data { | 195 | struct palmas_platform_data { |
@@ -138,8 +206,49 @@ struct palmas_platform_data { | |||
138 | u8 pad1, pad2; | 206 | u8 pad1, pad2; |
139 | 207 | ||
140 | struct palmas_pmic_platform_data *pmic_pdata; | 208 | struct palmas_pmic_platform_data *pmic_pdata; |
209 | struct palmas_gpadc_platform_data *gpadc_pdata; | ||
210 | struct palmas_usb_platform_data *usb_pdata; | ||
211 | struct palmas_resource_platform_data *resource_pdata; | ||
212 | struct palmas_clk_platform_data *clk_pdata; | ||
141 | }; | 213 | }; |
142 | 214 | ||
215 | struct palmas_gpadc_calibration { | ||
216 | s32 gain; | ||
217 | s32 gain_error; | ||
218 | s32 offset_error; | ||
219 | }; | ||
220 | |||
221 | struct palmas_gpadc { | ||
222 | struct device *dev; | ||
223 | struct palmas *palmas; | ||
224 | |||
225 | int ch3_current; | ||
226 | int ch0_current; | ||
227 | |||
228 | int gpadc_force; | ||
229 | |||
230 | int bat_removal; | ||
231 | |||
232 | struct mutex reading_lock; | ||
233 | struct completion irq_complete; | ||
234 | |||
235 | int eoc_sw_irq; | ||
236 | |||
237 | struct palmas_gpadc_calibration *palmas_cal_tbl; | ||
238 | |||
239 | int conv0_channel; | ||
240 | int conv1_channel; | ||
241 | int rt_channel; | ||
242 | }; | ||
243 | |||
244 | struct palmas_gpadc_result { | ||
245 | s32 raw_code; | ||
246 | s32 corrected_code; | ||
247 | s32 result; | ||
248 | }; | ||
249 | |||
250 | #define PALMAS_MAX_CHANNELS 16 | ||
251 | |||
143 | /* Define the palmas IRQ numbers */ | 252 | /* Define the palmas IRQ numbers */ |
144 | enum palmas_irqs { | 253 | enum palmas_irqs { |
145 | /* INT1 registers */ | 254 | /* INT1 registers */ |
@@ -223,6 +332,69 @@ struct palmas_pmic { | |||
223 | int range[PALMAS_REG_SMPS10]; | 332 | int range[PALMAS_REG_SMPS10]; |
224 | }; | 333 | }; |
225 | 334 | ||
335 | struct palmas_resource { | ||
336 | struct palmas *palmas; | ||
337 | struct device *dev; | ||
338 | }; | ||
339 | |||
340 | struct 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 | |||
364 | enum 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) |