arm: tegra: cardhu: add support for PM315
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-sensors.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-sensors.c
3  *
4  * Copyright (c) 2010-2012, NVIDIA CORPORATION, All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * Neither the name of NVIDIA CORPORATION nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <linux/i2c.h>
35 #include <linux/delay.h>
36 #include <linux/regulator/consumer.h>
37 #include <linux/i2c/pca954x.h>
38 #include <linux/i2c/pca953x.h>
39 #include <linux/nct1008.h>
40 #include <linux/gpio.h>
41
42 #include <mach/gpio-tegra.h>
43 #include <mach/fb.h>
44 #include <media/ov5650.h>
45 #include <media/ov5640.h>
46 #include <media/ov14810.h>
47 #include <media/ov2710.h>
48 #include <media/tps61050.h>
49 #include <generated/mach-types.h>
50 #include "board.h"
51 #include <linux/mpu.h>
52 #include <media/sh532u.h>
53 #include <media/ad5816.h>
54 #include <linux/bq27x00.h>
55 #include <mach/edp.h>
56 #include <linux/therm_est.h>
57
58 #include "gpio-names.h"
59 #include "board-cardhu.h"
60 #include "cpu-tegra.h"
61 #include "devices.h"
62
63 static struct regulator *cardhu_1v8_cam1 = NULL;
64 static struct regulator *cardhu_1v8_cam2 = NULL;
65 static struct regulator *cardhu_1v8_cam3 = NULL;
66 static struct regulator *cardhu_vdd_2v8_cam1 = NULL;
67 static struct regulator *cardhu_vdd_2v8_cam2 = NULL;
68 static struct regulator *cardhu_vdd_cam3 = NULL;
69
70 static struct board_info board_info;
71
72 static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
73         { .adap_id = PCA954x_I2C_BUS0, .deselect_on_exit = true, },
74         { .adap_id = PCA954x_I2C_BUS1, .deselect_on_exit = true, },
75         { .adap_id = PCA954x_I2C_BUS2, .deselect_on_exit = true, },
76         { .adap_id = PCA954x_I2C_BUS3, .deselect_on_exit = true, },
77 };
78
79 static struct pca954x_platform_data cardhu_pca954x_data = {
80         .modes    = cardhu_pca954x_modes,
81         .num_modes      = ARRAY_SIZE(cardhu_pca954x_modes),
82 };
83
84 static int cardhu_camera_init(void)
85 {
86         int ret;
87
88         /* Boards E1198 and E1291 are of Cardhu personality
89          * and donot have TCA6416 exp for camera */
90         if ((board_info.board_id == BOARD_E1198) ||
91                 (board_info.board_id == BOARD_E1291) ||
92                 (board_info.board_id == BOARD_PM315)) {
93                 ret = gpio_request(CAM1_POWER_DWN_GPIO, "camera_power_en");
94                 if (ret < 0)
95                         pr_err("%s: gpio_request failed for gpio %s\n",
96                                 __func__, "CAM1_POWER_DWN_GPIO");
97                 ret = gpio_request(CAM3_POWER_DWN_GPIO, "cam3_power_en");
98                 if (ret < 0)
99                         pr_err("%s: gpio_request failed for gpio %s\n",
100                                 __func__, "CAM3_POWER_DWN_GPIO");
101
102                 ret = gpio_request(CAM2_POWER_DWN_GPIO, "camera2_power_en");
103                 if (ret < 0)
104                         pr_err("%s: gpio_request failed for gpio %s\n",
105                                 __func__, "CAM2_POWER_DWN_GPIO");
106
107                 ret = gpio_request(OV5650_RESETN_GPIO, "camera_reset");
108                 if (ret < 0)
109                         pr_err("%s: gpio_request failed for gpio %s\n",
110                                 __func__, "OV5650_RESETN_GPIO");
111
112                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
113                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
114                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
115                 mdelay(10);
116
117                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
118                 mdelay(5);
119                 gpio_direction_output(OV5650_RESETN_GPIO, 0);
120                 mdelay(5);
121                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
122                 mdelay(5);
123         }
124
125         /* To select the CSIB MUX either for cam2 or cam3 */
126         ret = gpio_request(CAMERA_CSI_MUX_SEL_GPIO, "camera_csi_sel");
127         if (ret < 0)
128                 pr_err("%s: gpio_request failed for gpio %s\n",
129                         __func__, "CAMERA_CSI_MUX_SEL_GPIO");
130         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
131         gpio_export(CAMERA_CSI_MUX_SEL_GPIO, false);
132
133         return 0;
134 }
135
136 static int cardhu_left_ov5650_power_on(struct device *dev)
137 {
138         /* Boards E1198 and E1291 are of Cardhu personality
139          * and donot have TCA6416 exp for camera */
140         if ((board_info.board_id == BOARD_E1198) ||
141                 (board_info.board_id == BOARD_E1291) ||
142                 (board_info.board_id == BOARD_PM315)) {
143
144                 if (cardhu_vdd_2v8_cam1 == NULL) {
145                         cardhu_vdd_2v8_cam1 =
146                                 regulator_get(dev, "vdd_2v8_cam1");
147                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam1))) {
148                                 pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n",
149                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam1));
150                                 goto reg_alloc_fail;
151                         }
152                 }
153                 regulator_enable(cardhu_vdd_2v8_cam1);
154                 mdelay(5);
155         }
156
157         /* Enable VDD_1V8_Cam1 */
158         if (cardhu_1v8_cam1 == NULL) {
159                 cardhu_1v8_cam1 = regulator_get(dev, "vdd_1v8_cam1");
160                 if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
161                         pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
162                                 __func__, PTR_ERR(cardhu_1v8_cam1));
163                         goto reg_alloc_fail;
164                 }
165         }
166         regulator_enable(cardhu_1v8_cam1);
167
168         mdelay(5);
169         if ((board_info.board_id == BOARD_E1198) ||
170                 (board_info.board_id == BOARD_E1291) ||
171                 (board_info.board_id == BOARD_PM315)) {
172                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
173                 mdelay(20);
174                 gpio_direction_output(OV5650_RESETN_GPIO, 0);
175                 mdelay(100);
176                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
177         }
178
179         if (board_info.board_id == BOARD_PM269) {
180                 gpio_direction_output(CAM1_RST_L_GPIO, 0);
181                 mdelay(100);
182                 gpio_direction_output(CAM1_RST_L_GPIO, 1);
183         }
184
185         return 0;
186
187 reg_alloc_fail:
188         if (cardhu_1v8_cam1) {
189                 regulator_put(cardhu_1v8_cam1);
190                 cardhu_1v8_cam1 = NULL;
191         }
192         if (cardhu_vdd_2v8_cam1) {
193                 regulator_put(cardhu_vdd_2v8_cam1);
194                 cardhu_vdd_2v8_cam1 = NULL;
195         }
196
197         return -ENODEV;
198
199 }
200
201 static int cardhu_left_ov5650_power_off(struct device *dev)
202 {
203         /* Boards E1198 and E1291 are of Cardhu personality
204          * and donot have TCA6416 exp for camera */
205         if ((board_info.board_id == BOARD_E1198) ||
206                 (board_info.board_id == BOARD_E1291) ||
207                 (board_info.board_id == BOARD_PM315)) {
208                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
209                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
210                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
211         }
212         if (cardhu_1v8_cam1)
213                 regulator_disable(cardhu_1v8_cam1);
214         if (cardhu_vdd_2v8_cam1)
215                 regulator_disable(cardhu_vdd_2v8_cam1);
216
217         return 0;
218 }
219
220 struct ov5650_platform_data cardhu_left_ov5650_data = {
221         .power_on = cardhu_left_ov5650_power_on,
222         .power_off = cardhu_left_ov5650_power_off,
223 };
224
225 #ifdef CONFIG_VIDEO_OV14810
226 static int cardhu_ov14810_power_on(void)
227 {
228         if (board_info.board_id == BOARD_E1198) {
229                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
230                 mdelay(20);
231                 gpio_direction_output(OV14810_RESETN_GPIO, 0);
232                 mdelay(100);
233                 gpio_direction_output(OV14810_RESETN_GPIO, 1);
234         }
235
236         return 0;
237 }
238
239 static int cardhu_ov14810_power_off(void)
240 {
241         if (board_info.board_id == BOARD_E1198) {
242                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
243                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
244                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
245         }
246
247         return 0;
248 }
249
250 struct ov14810_platform_data cardhu_ov14810_data = {
251         .power_on = cardhu_ov14810_power_on,
252         .power_off = cardhu_ov14810_power_off,
253 };
254
255 struct ov14810_platform_data cardhu_ov14810uC_data = {
256         .power_on = NULL,
257         .power_off = NULL,
258 };
259
260 struct ov14810_platform_data cardhu_ov14810SlaveDev_data = {
261         .power_on = NULL,
262         .power_off = NULL,
263 };
264
265 static struct i2c_board_info cardhu_i2c_board_info_e1214[] = {
266         {
267                 I2C_BOARD_INFO("ov14810", 0x36),
268                 .platform_data = &cardhu_ov14810_data,
269         },
270         {
271                 I2C_BOARD_INFO("ov14810uC", 0x67),
272                 .platform_data = &cardhu_ov14810uC_data,
273         },
274         {
275                 I2C_BOARD_INFO("ov14810SlaveDev", 0x69),
276                 .platform_data = &cardhu_ov14810SlaveDev_data,
277         }
278 };
279 #endif
280
281 static int cardhu_right_ov5650_power_on(struct device *dev)
282 {
283         /* CSI-B and front sensor are muxed on cardhu */
284         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
285
286         /* Boards E1198 and E1291 are of Cardhu personality
287          * and donot have TCA6416 exp for camera */
288         if ((board_info.board_id == BOARD_E1198) ||
289                 (board_info.board_id == BOARD_E1291) ||
290                 (board_info.board_id == BOARD_PM315)) {
291
292                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
293                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
294                 mdelay(10);
295
296                 if (cardhu_vdd_2v8_cam2 == NULL) {
297                         cardhu_vdd_2v8_cam2 =
298                                 regulator_get(dev, "vdd_2v8_cam2");
299                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam2))) {
300                                 pr_err("%s: couldn't get regulator vdd_2v8_cam2: %ld\n",
301                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam2));
302                                 goto reg_alloc_fail;
303                         }
304                 }
305                 regulator_enable(cardhu_vdd_2v8_cam2);
306                 mdelay(5);
307         }
308
309         /* Enable VDD_1V8_Cam2 */
310         if (cardhu_1v8_cam2 == NULL) {
311                 cardhu_1v8_cam2 = regulator_get(dev, "vdd_1v8_cam2");
312                 if (WARN_ON(IS_ERR(cardhu_1v8_cam2))) {
313                         pr_err("%s: couldn't get regulator vdd_1v8_cam2: %ld\n",
314                                 __func__, PTR_ERR(cardhu_1v8_cam2));
315                         goto reg_alloc_fail;
316                 }
317         }
318         regulator_enable(cardhu_1v8_cam2);
319
320         mdelay(5);
321
322         if (board_info.board_id == BOARD_PM269) {
323                 gpio_direction_output(CAM2_RST_L_GPIO, 0);
324                 mdelay(100);
325                 gpio_direction_output(CAM2_RST_L_GPIO, 1);
326         }
327
328         return 0;
329
330 reg_alloc_fail:
331         if (cardhu_1v8_cam2) {
332                 regulator_put(cardhu_1v8_cam2);
333                 cardhu_1v8_cam2 = NULL;
334         }
335         if (cardhu_vdd_2v8_cam2) {
336                 regulator_put(cardhu_vdd_2v8_cam2);
337                 cardhu_vdd_2v8_cam2 = NULL;
338         }
339
340         return -ENODEV;
341
342 }
343
344 static int cardhu_right_ov5650_power_off(struct device *dev)
345 {
346         /* CSI-B and front sensor are muxed on cardhu */
347         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
348
349         /* Boards E1198 and E1291 are of Cardhu personality
350          * and do not have TCA6416 for camera */
351         if ((board_info.board_id == BOARD_E1198) ||
352                 (board_info.board_id == BOARD_E1291) ||
353                 (board_info.board_id == BOARD_PM315)) {
354                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
355                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
356                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
357         }
358
359         if (cardhu_1v8_cam2)
360                 regulator_disable(cardhu_1v8_cam2);
361         if (cardhu_vdd_2v8_cam2)
362                 regulator_disable(cardhu_vdd_2v8_cam2);
363
364         return 0;
365 }
366
367 static void cardhu_ov5650_synchronize_sensors(void)
368 {
369         if (board_info.board_id == BOARD_E1198) {
370                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
371                 mdelay(50);
372                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
373                 mdelay(50);
374         } else if ((board_info.board_id == BOARD_E1291) ||
375                         (board_info.board_id == BOARD_PM315)) {
376                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
377                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
378                 mdelay(50);
379                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
380                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
381                 mdelay(50);
382         }
383         else
384                 pr_err("%s: UnSupported BoardId\n", __func__);
385 }
386
387 struct ov5650_platform_data cardhu_right_ov5650_data = {
388         .power_on = cardhu_right_ov5650_power_on,
389         .power_off = cardhu_right_ov5650_power_off,
390         .synchronize_sensors = cardhu_ov5650_synchronize_sensors,
391 };
392
393 static int cardhu_ov2710_power_on(struct device *dev)
394 {
395         /* CSI-B and front sensor are muxed on cardhu */
396         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
397
398         /* Enable VDD_1V8_Cam3 */
399         if (cardhu_1v8_cam3 == NULL) {
400                 cardhu_1v8_cam3 = regulator_get(dev, "vdd_1v8_cam3");
401                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
402                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
403                                 __func__, PTR_ERR(cardhu_1v8_cam3));
404                         goto reg_alloc_fail;
405                 }
406         }
407         regulator_enable(cardhu_1v8_cam3);
408
409         /* Boards E1198 and E1291 are of Cardhu personality
410          * and do not have TCA6416 for camera */
411         if ((board_info.board_id == BOARD_E1198) ||
412                 (board_info.board_id == BOARD_E1291) ||
413                 (board_info.board_id == BOARD_PM315)) {
414                 if (cardhu_vdd_cam3 == NULL) {
415                         cardhu_vdd_cam3 = regulator_get(dev, "vdd_cam3");
416                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
417                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
418                                         __func__, PTR_ERR(cardhu_vdd_cam3));
419                                 goto reg_alloc_fail;
420                         }
421                 }
422                 regulator_enable(cardhu_vdd_cam3);
423
424                 mdelay(5);
425
426                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
427                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
428                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
429                 mdelay(10);
430
431         }
432
433         mdelay(20);
434
435         return 0;
436
437 reg_alloc_fail:
438         if (cardhu_1v8_cam3) {
439                 regulator_put(cardhu_1v8_cam3);
440                 cardhu_1v8_cam3 = NULL;
441         }
442         if (cardhu_vdd_cam3) {
443                 regulator_put(cardhu_vdd_cam3);
444                 cardhu_vdd_cam3 = NULL;
445         }
446
447         return -ENODEV;
448 }
449
450 static int cardhu_ov2710_power_off(struct device *dev)
451 {
452         /* CSI-B and front sensor are muxed on cardhu */
453         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
454
455         /* Boards E1198 and E1291 are of Cardhu personality
456          * and donot have TCA6416 exp for camera */
457         if ((board_info.board_id == BOARD_E1198) ||
458                 (board_info.board_id == BOARD_E1291) ||
459                 (board_info.board_id == BOARD_PM315)) {
460                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
461                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
462                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
463                 if (cardhu_vdd_cam3)
464                         regulator_disable(cardhu_vdd_cam3);
465         }
466
467         if (cardhu_1v8_cam3)
468                 regulator_disable(cardhu_1v8_cam3);
469
470         return 0;
471 }
472
473 struct ov2710_platform_data cardhu_ov2710_data = {
474         .power_on = cardhu_ov2710_power_on,
475         .power_off = cardhu_ov2710_power_off,
476 };
477
478 static int cardhu_ov5640_power_on(struct device *dev)
479 {
480         /* CSI-B and front sensor are muxed on cardhu */
481         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
482
483         /* Boards E1198 and E1291 are of Cardhu personality
484          * and donot have TCA6416 exp for camera */
485         if ((board_info.board_id == BOARD_E1198) ||
486                 (board_info.board_id == BOARD_E1291) ||
487                 (board_info.board_id == BOARD_PM315)) {
488
489                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
490                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
491                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
492                 mdelay(10);
493
494                 if (cardhu_vdd_cam3 == NULL) {
495                         cardhu_vdd_cam3 = regulator_get(dev, "vdd_cam3");
496                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
497                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
498                                         __func__, PTR_ERR(cardhu_vdd_cam3));
499                                 goto reg_alloc_fail;
500                         }
501                 }
502                 regulator_enable(cardhu_vdd_cam3);
503         }
504
505         /* Enable VDD_1V8_Cam3 */
506         if (cardhu_1v8_cam3 == NULL) {
507                 cardhu_1v8_cam3 = regulator_get(dev, "vdd_1v8_cam3");
508                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
509                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
510                                 __func__, PTR_ERR(cardhu_1v8_cam3));
511                         goto reg_alloc_fail;
512                 }
513         }
514         regulator_enable(cardhu_1v8_cam3);
515         mdelay(5);
516
517         return 0;
518
519 reg_alloc_fail:
520         if (cardhu_1v8_cam3) {
521                 regulator_put(cardhu_1v8_cam3);
522                 cardhu_1v8_cam3 = NULL;
523         }
524         if (cardhu_vdd_cam3) {
525                 regulator_put(cardhu_vdd_cam3);
526                 cardhu_vdd_cam3 = NULL;
527         }
528
529         return -ENODEV;
530 }
531
532 static int cardhu_ov5640_power_off(struct device *dev)
533 {
534         /* CSI-B and front sensor are muxed on cardhu */
535         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
536
537         /* Boards E1198 and E1291 are of Cardhu personality
538          * and donot have TCA6416 exp for camera */
539         if ((board_info.board_id == BOARD_E1198) ||
540                 (board_info.board_id == BOARD_E1291) ||
541                 (board_info.board_id == BOARD_PM315)) {
542                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
543                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
544                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
545         }
546
547         if (cardhu_1v8_cam3)
548                 regulator_disable(cardhu_1v8_cam3);
549         if (cardhu_vdd_cam3)
550                 regulator_disable(cardhu_vdd_cam3);
551
552         return 0;
553 }
554
555 struct ov5640_platform_data cardhu_ov5640_data = {
556         .power_on = cardhu_ov5640_power_on,
557         .power_off = cardhu_ov5640_power_off,
558 };
559
560 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
561         {
562                 I2C_BOARD_INFO("pca9546", 0x70),
563                 .platform_data = &cardhu_pca954x_data,
564         },
565 };
566
567
568 static struct nvc_gpio_pdata sh532u_gpio_pdata[] = {
569         { SH532U_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
570 };
571
572 static struct sh532u_platform_data sh532u_left_pdata = {
573         .cfg            = NVC_CFG_NODEV,
574         .num            = 1,
575         .sync           = 2,
576         .dev_name       = "focuser",
577         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
578         .gpio           = sh532u_gpio_pdata,
579 };
580
581 static struct sh532u_platform_data sh532u_right_pdata = {
582         .cfg            = NVC_CFG_NODEV,
583         .num            = 2,
584         .sync           = 1,
585         .dev_name       = "focuser",
586         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
587         .gpio           = sh532u_gpio_pdata,
588 };
589
590 static struct nvc_gpio_pdata pm269_sh532u_left_gpio_pdata[] = {
591         { SH532U_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
592 };
593
594 static struct sh532u_platform_data pm269_sh532u_left_pdata = {
595         .cfg            = 0,
596         .num            = 1,
597         .sync           = 2,
598         .dev_name       = "focuser",
599         .gpio_count     = ARRAY_SIZE(pm269_sh532u_left_gpio_pdata),
600         .gpio           = pm269_sh532u_left_gpio_pdata,
601 };
602
603 static struct nvc_gpio_pdata pm269_sh532u_right_gpio_pdata[] = {
604         { SH532U_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
605 };
606
607 static struct sh532u_platform_data pm269_sh532u_right_pdata = {
608         .cfg            = 0,
609         .num            = 2,
610         .sync           = 1,
611         .dev_name       = "focuser",
612         .gpio_count     = ARRAY_SIZE(pm269_sh532u_right_gpio_pdata),
613         .gpio           = pm269_sh532u_right_gpio_pdata,
614 };
615
616 static struct nvc_gpio_pdata ad5816_gpio_pdata[] = {
617         { AD5816_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
618 };
619
620 static struct ad5816_platform_data ad5816_left_pdata = {
621         .cfg            = 0,
622         .num            = 1,
623         .sync           = 2,
624         .dev_name       = "focuser",
625         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
626         .gpio           = ad5816_gpio_pdata,
627 };
628
629 static struct ad5816_platform_data ad5816_right_pdata = {
630         .cfg            = 0,
631         .num            = 2,
632         .sync           = 1,
633         .dev_name       = "focuser",
634         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
635         .gpio           = ad5816_gpio_pdata,
636 };
637
638 static struct nvc_gpio_pdata pm269_ad5816_left_gpio_pdata[] = {
639         { AD5816_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
640 };
641
642 static struct ad5816_platform_data pm269_ad5816_left_pdata = {
643         .cfg            = NVC_CFG_NODEV,
644         .num            = 1,
645         .sync           = 2,
646         .dev_name       = "focuser",
647         .gpio_count     = ARRAY_SIZE(pm269_ad5816_left_gpio_pdata),
648         .gpio           = pm269_ad5816_left_gpio_pdata,
649 };
650
651 static struct nvc_gpio_pdata pm269_ad5816_right_gpio_pdata[] = {
652         { AD5816_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
653 };
654
655 static struct ad5816_platform_data pm269_ad5816_right_pdata = {
656         .cfg            = NVC_CFG_NODEV,
657         .num            = 2,
658         .sync           = 1,
659         .dev_name       = "focuser",
660         .gpio_count     = ARRAY_SIZE(pm269_ad5816_right_gpio_pdata),
661         .gpio           = pm269_ad5816_right_gpio_pdata,
662 };
663
664
665 static struct nvc_torch_pin_state cardhu_tps61050_pinstate = {
666         .mask           = 0x0008, /*VGP3*/
667         .values         = 0x0008,
668 };
669
670 static struct tps61050_platform_data cardhu_tps61050_pdata = {
671         .dev_name       = "torch",
672         .pinstate       = &cardhu_tps61050_pinstate,
673 };
674
675 static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
676         {
677                 I2C_BOARD_INFO("tps61050", 0x33),
678                 .platform_data = &cardhu_tps61050_pdata,
679         },
680 };
681
682 static struct i2c_board_info cardhu_i2c6_board_info[] = {
683         {
684                 I2C_BOARD_INFO("ov5650L", 0x36),
685                 .platform_data = &cardhu_left_ov5650_data,
686         },
687         {
688                 I2C_BOARD_INFO("sh532u", 0x72),
689                 .platform_data = &sh532u_left_pdata,
690         },
691         {
692                 I2C_BOARD_INFO("ad5816", 0x0E),
693                 .platform_data = &ad5816_left_pdata,
694         },
695 };
696
697 static struct i2c_board_info cardhu_i2c7_board_info[] = {
698         {
699                 I2C_BOARD_INFO("ov5650R", 0x36),
700                 .platform_data = &cardhu_right_ov5650_data,
701         },
702         {
703                 I2C_BOARD_INFO("sh532u", 0x72),
704                 .platform_data = &sh532u_right_pdata,
705         },
706         {
707                 I2C_BOARD_INFO("ad5816", 0x0E),
708                 .platform_data = &ad5816_right_pdata,
709         },
710 };
711
712 static struct i2c_board_info pm269_i2c6_board_info[] = {
713         {
714                 I2C_BOARD_INFO("ov5650L", 0x36),
715                 .platform_data = &cardhu_left_ov5650_data,
716         },
717         {
718                 I2C_BOARD_INFO("sh532u", 0x72),
719                 .platform_data = &pm269_sh532u_left_pdata,
720         },
721         {
722                 I2C_BOARD_INFO("ad5816", 0x0E),
723                 .platform_data = &pm269_ad5816_left_pdata,
724         },
725 };
726
727 static struct i2c_board_info pm269_i2c7_board_info[] = {
728         {
729                 I2C_BOARD_INFO("ov5650R", 0x36),
730                 .platform_data = &cardhu_right_ov5650_data,
731         },
732         {
733                 I2C_BOARD_INFO("sh532u", 0x72),
734                 .platform_data = &pm269_sh532u_right_pdata,
735         },
736         {
737                 I2C_BOARD_INFO("ad5816", 0x0E),
738                 .platform_data = &pm269_ad5816_right_pdata,
739         },
740 };
741
742 static struct i2c_board_info cardhu_i2c8_board_info[] = {
743         {
744                 I2C_BOARD_INFO("ov2710", 0x36),
745                 .platform_data = &cardhu_ov2710_data,
746         },
747         {
748                 I2C_BOARD_INFO("ov5640", 0x3C),
749                 .platform_data = &cardhu_ov5640_data,
750         },
751 };
752
753 static struct balanced_throttle tj_throttle = {
754         .throt_tab_size = 10,
755         .throt_tab = {
756                 {      0, 1000 },
757                 { 640000, 1000 },
758                 { 640000, 1000 },
759                 { 640000, 1000 },
760                 { 640000, 1000 },
761                 { 640000, 1000 },
762                 { 760000, 1000 },
763                 { 760000, 1050 },
764                 {1000000, 1050 },
765                 {1000000, 1100 },
766         },
767 };
768
769 static struct nct1008_platform_data cardhu_nct1008_pdata = {
770         .supported_hwrev = true,
771         .ext_range = true,
772         .conv_rate = 0x08,
773         .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
774         .shutdown_ext_limit = 90, /* C */
775         .shutdown_local_limit = 100, /* C */
776
777         /* Thermal Throttling */
778         .passive = {
779                 .create_cdev = (struct thermal_cooling_device *(*)(void *))
780                                 balanced_throttle_register,
781                 .cdev_data = &tj_throttle,
782                 .trip_temp = 85000,
783                 .tc1 = 0,
784                 .tc2 = 1,
785                 .passive_delay = 2000,
786         }
787 };
788
789 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
790         {
791                 I2C_BOARD_INFO("bq27510", 0x55),
792         },
793 };
794
795 static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
796         {
797                 I2C_BOARD_INFO("nct1008", 0x4C),
798                 .platform_data = &cardhu_nct1008_pdata,
799                 .irq = -1,
800         }
801 };
802
803 static int cardhu_nct1008_init(void)
804 {
805         int nct1008_port = -1;
806         int ret = 0;
807
808         if ((board_info.board_id == BOARD_E1198) ||
809                 (board_info.board_id == BOARD_E1291) ||
810                 (board_info.board_id == BOARD_E1257) ||
811                 (board_info.board_id == BOARD_PM269) ||
812                 (board_info.board_id == BOARD_PM305) ||
813                 (board_info.board_id == BOARD_PM311) ||
814                 (board_info.board_id == BOARD_PM315)) {
815                 nct1008_port = TEGRA_GPIO_PCC2;
816         } else if ((board_info.board_id == BOARD_E1186) ||
817                 (board_info.board_id == BOARD_E1187) ||
818                 (board_info.board_id == BOARD_E1256)) {
819                 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
820                 /* nct1008_port = TEGRA_GPIO_PH7; */
821         }
822
823         if (nct1008_port >= 0) {
824 #ifdef CONFIG_TEGRA_EDP_LIMITS
825                 const struct tegra_edp_limits *cpu_edp_limits;
826                 int cpu_edp_limits_size;
827                 int i;
828
829                 /* edp capping */
830                 tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);
831
832                 if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
833                         BUG();
834
835                 for (i = 0; i < cpu_edp_limits_size-1; i++) {
836                         cardhu_nct1008_pdata.active[i].create_cdev =
837                                 (struct thermal_cooling_device *(*)(void *))
838                                         edp_cooling_device_create;
839                         cardhu_nct1008_pdata.active[i].cdev_data = (void *)i;
840                         cardhu_nct1008_pdata.active[i].trip_temp =
841                                 cpu_edp_limits[i].temperature * 1000;
842                         cardhu_nct1008_pdata.active[i].hysteresis = 1000;
843                 }
844                 cardhu_nct1008_pdata.active[i].create_cdev = NULL;
845 #endif
846
847                 /* FIXME: enable irq when throttling is supported */
848                 cardhu_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
849
850                 ret = gpio_request(nct1008_port, "temp_alert");
851                 if (ret < 0)
852                         return ret;
853
854                 ret = gpio_direction_input(nct1008_port);
855                 if (ret < 0)
856                         gpio_free(nct1008_port);
857         }
858
859         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
860                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
861
862         return ret;
863 }
864
865 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
866 static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
867 {
868         return strcmp((char *)data, thz->type) == 0;
869 }
870
871 static int tegra_skin_get_temp(void *data, long *temp)
872 {
873         struct thermal_zone_device *thz;
874
875         thz = thermal_zone_device_find(data, tegra_skin_match);
876
877         if (!thz || thz->ops->get_temp(thz, temp))
878                 *temp = 25000;
879
880         return 0;
881 }
882
883 static struct therm_est_data skin_data = {
884         .toffset = 9793,
885         .polling_period = 1100,
886         .ndevs = 2,
887         .devs = {
888                         {
889                                 .dev_data = "nct_ext",
890                                 .get_temp = tegra_skin_get_temp,
891                                 .coeffs = {
892                                         2, 1, 1, 1,
893                                         1, 1, 1, 1,
894                                         1, 1, 1, 0,
895                                         1, 1, 0, 0,
896                                         0, 0, -1, -7
897                                 },
898                         },
899                         {
900                                 .dev_data = "nct_int",
901                                 .get_temp = tegra_skin_get_temp,
902                                 .coeffs = {
903                                         -11, -7, -5, -3,
904                                         -3, -2, -1, 0,
905                                         0, 0, 1, 1,
906                                         1, 2, 2, 3,
907                                         4, 6, 11, 18
908                                 },
909                         },
910         },
911         .trip_temp = 43000,
912         .tc1 = 1,
913         .tc2 = 15,
914         .passive_delay = 15000,
915 };
916
917 static struct balanced_throttle skin_throttle = {
918         .throt_tab_size = 6,
919         .throt_tab = {
920                 { 640000, 1200 },
921                 { 640000, 1200 },
922                 { 760000, 1200 },
923                 { 760000, 1200 },
924                 {1000000, 1200 },
925                 {1000000, 1200 },
926         },
927 };
928
929 static int __init cardhu_skin_init(void)
930 {
931         struct thermal_cooling_device *skin_cdev;
932
933         skin_cdev = balanced_throttle_register(&skin_throttle);
934
935         skin_data.cdev = skin_cdev;
936         tegra_skin_therm_est_device.dev.platform_data = &skin_data;
937         platform_device_register(&tegra_skin_therm_est_device);
938
939         return 0;
940 }
941 late_initcall(cardhu_skin_init);
942 #endif
943
944 #if defined(CONFIG_GPIO_PCA953X)
945 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
946         .gpio_base      = PMU_TCA6416_GPIO_BASE,
947 };
948
949 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
950         {
951                 I2C_BOARD_INFO("tca6416", 0x20),
952                 .platform_data = &cardhu_pmu_tca6416_data,
953         },
954 };
955
956 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
957         .gpio_base      = CAM_TCA6416_GPIO_BASE,
958 };
959
960 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
961         {
962                 I2C_BOARD_INFO("tca6416", 0x20),
963                 .platform_data = &cardhu_cam_tca6416_data,
964         },
965 };
966
967 static int __init pmu_tca6416_init(void)
968 {
969         if ((board_info.board_id == BOARD_E1198) ||
970                 (board_info.board_id == BOARD_E1291))
971                         return 0;
972
973         pr_info("Registering pmu pca6416\n");
974         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
975                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
976         return 0;
977 }
978
979 static int __init cam_tca6416_init(void)
980 {
981         /* Boards E1198 and E1291 are of Cardhu personality
982          * and donot have TCA6416 exp for camera */
983         if ((board_info.board_id == BOARD_E1198) ||
984                 (board_info.board_id == BOARD_E1291))
985                 return 0;
986
987         pr_info("Registering cam pca6416\n");
988         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
989                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
990         return 0;
991 }
992 #else
993 static int __init pmu_tca6416_init(void)
994 {
995         return 0;
996 }
997
998 static int __init cam_tca6416_init(void)
999 {
1000         return 0;
1001 }
1002 #endif
1003
1004 /* MPU board file definition    */
1005 static struct mpu_platform_data mpu_gyro_data = {
1006         .int_config     = 0x10,
1007         .level_shifter  = 0,
1008         .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
1009         .sec_slave_type = SECONDARY_SLAVE_TYPE_ACCEL,
1010         .sec_slave_id   = ACCEL_ID_KXTF9,
1011         .secondary_i2c_addr     = MPU_ACCEL_ADDR,
1012         .secondary_read_reg     = 0x06,
1013         .secondary_orientation  = MPU_ACCEL_ORIENTATION,
1014         .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
1015                            0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
1016 };
1017
1018 static struct mpu_platform_data mpu_compass_data = {
1019         .orientation    = MPU_COMPASS_ORIENTATION,
1020         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
1021 };
1022
1023 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
1024         {
1025                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
1026                 .platform_data = &mpu_gyro_data,
1027         },
1028         {
1029                 I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
1030         },
1031         {
1032                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
1033                 .platform_data = &mpu_compass_data,
1034         },
1035 };
1036
1037 static void mpuirq_init(void)
1038 {
1039         int ret = 0;
1040         int i = 0;
1041
1042         pr_info("*** MPU START *** mpuirq_init...\n");
1043
1044 #if     MPU_ACCEL_IRQ_GPIO
1045         /* ACCEL-IRQ assignment */
1046         ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
1047         if (ret < 0) {
1048                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1049                 return;
1050         }
1051
1052         ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
1053         if (ret < 0) {
1054                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1055                 gpio_free(MPU_ACCEL_IRQ_GPIO);
1056                 return;
1057         }
1058 #endif
1059
1060         /* MPU-IRQ assignment */
1061         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
1062         if (ret < 0) {
1063                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1064                 return;
1065         }
1066
1067         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
1068         if (ret < 0) {
1069                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1070                 gpio_free(MPU_GYRO_IRQ_GPIO);
1071                 return;
1072         }
1073         pr_info("*** MPU END *** mpuirq_init...\n");
1074
1075         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
1076 #if MPU_ACCEL_IRQ_GPIO
1077         inv_mpu_i2c2_board_info[i].irq = gpio_to_irq(MPU_ACCEL_IRQ_GPIO);
1078 #endif
1079         i++;
1080 #if MPU_COMPASS_IRQ_GPIO
1081         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_COMPAS_IRQ_GPIO);
1082 #endif
1083         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
1084                 ARRAY_SIZE(inv_mpu_i2c2_board_info));
1085 }
1086
1087 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
1088         {
1089                 I2C_BOARD_INFO("isl29028", 0x44),
1090         }
1091 };
1092
1093 static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
1094         {
1095                 I2C_BOARD_INFO("LTR_558ALS", 0x23),
1096         }
1097 };
1098
1099 int __init cardhu_sensors_init(void)
1100 {
1101         int err;
1102
1103         tegra_get_board_info(&board_info);
1104
1105         cardhu_camera_init();
1106         cam_tca6416_init();
1107
1108         i2c_register_board_info(2, cardhu_i2c3_board_info,
1109                 ARRAY_SIZE(cardhu_i2c3_board_info));
1110
1111         i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
1112                 ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
1113
1114 #ifdef CONFIG_VIDEO_OV14810
1115         /* This is disabled by default; To enable this change Kconfig;
1116          * there should be some way to detect dynamically which board
1117          * is connected (E1211/E1214), till that time sensor selection
1118          * logic is static;
1119          * e1214 corresponds to ov14810 sensor */
1120         i2c_register_board_info(2, cardhu_i2c_board_info_e1214,
1121                 ARRAY_SIZE(cardhu_i2c_board_info_e1214));
1122 #else
1123         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
1124          * Front camera is on BUS2 */
1125         if (board_info.board_id != BOARD_PM269) {
1126                 i2c_register_board_info(PCA954x_I2C_BUS0,
1127                                         cardhu_i2c6_board_info,
1128                                         ARRAY_SIZE(cardhu_i2c6_board_info));
1129
1130                 i2c_register_board_info(PCA954x_I2C_BUS1,
1131                                         cardhu_i2c7_board_info,
1132                                         ARRAY_SIZE(cardhu_i2c7_board_info));
1133         } else {
1134                 i2c_register_board_info(PCA954x_I2C_BUS0,
1135                                         pm269_i2c6_board_info,
1136                                         ARRAY_SIZE(pm269_i2c6_board_info));
1137
1138                 i2c_register_board_info(PCA954x_I2C_BUS1,
1139                                         pm269_i2c7_board_info,
1140                                         ARRAY_SIZE(pm269_i2c7_board_info));
1141         }
1142         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
1143                 ARRAY_SIZE(cardhu_i2c8_board_info));
1144
1145 #endif
1146         pmu_tca6416_init();
1147
1148         if (board_info.board_id == BOARD_E1291)
1149                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
1150                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
1151
1152         if (board_info.sku == BOARD_SKU_B11)
1153                 i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
1154                         ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
1155         else if (board_info.board_id != BOARD_PM315)
1156                 i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
1157                         ARRAY_SIZE(cardhu_i2c2_isl_board_info));
1158
1159         err = cardhu_nct1008_init();
1160         if (err)
1161                 return err;
1162
1163         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
1164                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
1165
1166         mpuirq_init();
1167         return 0;
1168 }
1169
1170 #if defined(CONFIG_GPIO_PCA953X)
1171 struct ov5650_gpios {
1172         const char *name;
1173         int gpio;
1174         int enabled;
1175 };
1176
1177 #define OV5650_GPIO(_name, _gpio, _enabled)             \
1178         {                                               \
1179                 .name = _name,                          \
1180                 .gpio = _gpio,                          \
1181                 .enabled = _enabled,                    \
1182         }
1183
1184 static struct ov5650_gpios ov5650_gpio_keys[] = {
1185         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
1186         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
1187         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0),
1188         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
1189         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
1190         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
1191         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0),
1192         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
1193         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
1194         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
1195         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 0),
1196         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
1197         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
1198         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
1199         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
1200 };
1201
1202 int __init cardhu_ov5650_late_init(void)
1203 {
1204         int ret;
1205         int i;
1206
1207         if (!machine_is_cardhu())
1208                 return 0;
1209
1210         if ((board_info.board_id == BOARD_E1198) ||
1211                 (board_info.board_id == BOARD_E1291) ||
1212                 (board_info.board_id == BOARD_PM315))
1213                 return 0;
1214
1215         printk(KERN_INFO "%s:\n", __func__);
1216         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
1217                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
1218                         ov5650_gpio_keys[i].name);
1219                 if (ret < 0) {
1220                         printk(KERN_INFO "%s: gpio_request failed for gpio #%d\n",
1221                                 __func__, i);
1222                         goto fail;
1223                 }
1224                 printk(KERN_INFO "%s: enable - %d\n", __func__, i);
1225                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
1226                         ov5650_gpio_keys[i].enabled);
1227                 gpio_export(ov5650_gpio_keys[i].gpio, false);
1228         }
1229
1230         return 0;
1231
1232 fail:
1233         while (i--)
1234                 gpio_free(ov5650_gpio_keys[i].gpio);
1235         return ret;
1236 }
1237
1238 late_initcall(cardhu_ov5650_late_init);
1239 #endif