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 <mach/fb.h>
41 #include <mach/gpio.h>
42 #include <media/ov5650.h>
43 #include <media/ov5640.h>
44 #include <media/ov14810.h>
45 #include <media/ov2710.h>
46 #include <media/tps61050.h>
47 #include <generated/mach-types.h>
48 #include "gpio-names.h"
49 #include "board.h"
50 #include <linux/mpu.h>
51 #include <media/sh532u.h>
52 #include <media/ad5816.h>
53 #include <linux/bq27x00.h>
54 #include <mach/gpio.h>
55 #include <mach/edp.h>
56 #include <mach/thermal.h>
57 #include <linux/therm_est.h>
58
59 #include "gpio-names.h"
60 #include "board-cardhu.h"
61 #include "cpu-tegra.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(void)
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 = regulator_get(NULL, "vdd_2v8_cam1");
146                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam1))) {
147                                 pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n",
148                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam1));
149                                 goto reg_alloc_fail;
150                         }
151                 }
152                 regulator_enable(cardhu_vdd_2v8_cam1);
153                 mdelay(5);
154         }
155
156         /* Enable VDD_1V8_Cam1 */
157         if (cardhu_1v8_cam1 == NULL) {
158                 cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
159                 if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
160                         pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
161                                 __func__, PTR_ERR(cardhu_1v8_cam1));
162                         goto reg_alloc_fail;
163                 }
164         }
165         regulator_enable(cardhu_1v8_cam1);
166
167         mdelay(5);
168         if ((board_info.board_id == BOARD_E1198) ||
169                 (board_info.board_id == BOARD_E1291) ||
170                 (board_info.board_id == BOARD_PM315)) {
171                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
172                 mdelay(20);
173                 gpio_direction_output(OV5650_RESETN_GPIO, 0);
174                 mdelay(100);
175                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
176         }
177
178         if (board_info.board_id == BOARD_PM269) {
179                 gpio_direction_output(CAM1_RST_L_GPIO, 0);
180                 mdelay(100);
181                 gpio_direction_output(CAM1_RST_L_GPIO, 1);
182         }
183
184         return 0;
185
186 reg_alloc_fail:
187         if (cardhu_1v8_cam1) {
188                 regulator_put(cardhu_1v8_cam1);
189                 cardhu_1v8_cam1 = NULL;
190         }
191         if (cardhu_vdd_2v8_cam1) {
192                 regulator_put(cardhu_vdd_2v8_cam1);
193                 cardhu_vdd_2v8_cam1 = NULL;
194         }
195
196         return -ENODEV;
197
198 }
199
200 static int cardhu_left_ov5650_power_off(void)
201 {
202         /* Boards E1198 and E1291 are of Cardhu personality
203          * and donot have TCA6416 exp for camera */
204         if ((board_info.board_id == BOARD_E1198) ||
205                 (board_info.board_id == BOARD_E1291) ||
206                 (board_info.board_id == BOARD_PM315)) {
207                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
208                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
209                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
210         }
211         if (cardhu_1v8_cam1)
212                 regulator_disable(cardhu_1v8_cam1);
213         if (cardhu_vdd_2v8_cam1)
214                 regulator_disable(cardhu_vdd_2v8_cam1);
215
216         return 0;
217 }
218
219 struct ov5650_platform_data cardhu_left_ov5650_data = {
220         .power_on = cardhu_left_ov5650_power_on,
221         .power_off = cardhu_left_ov5650_power_off,
222 };
223
224 #ifdef CONFIG_VIDEO_OV14810
225 static int cardhu_ov14810_power_on(void)
226 {
227         if (board_info.board_id == BOARD_E1198) {
228                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
229                 mdelay(20);
230                 gpio_direction_output(OV14810_RESETN_GPIO, 0);
231                 mdelay(100);
232                 gpio_direction_output(OV14810_RESETN_GPIO, 1);
233         }
234
235         return 0;
236 }
237
238 static int cardhu_ov14810_power_off(void)
239 {
240         if (board_info.board_id == BOARD_E1198) {
241                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
242                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
243                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
244         }
245
246         return 0;
247 }
248
249 struct ov14810_platform_data cardhu_ov14810_data = {
250         .power_on = cardhu_ov14810_power_on,
251         .power_off = cardhu_ov14810_power_off,
252 };
253
254 struct ov14810_platform_data cardhu_ov14810uC_data = {
255         .power_on = NULL,
256         .power_off = NULL,
257 };
258
259 struct ov14810_platform_data cardhu_ov14810SlaveDev_data = {
260         .power_on = NULL,
261         .power_off = NULL,
262 };
263
264 static struct i2c_board_info cardhu_i2c_board_info_e1214[] = {
265         {
266                 I2C_BOARD_INFO("ov14810", 0x36),
267                 .platform_data = &cardhu_ov14810_data,
268         },
269         {
270                 I2C_BOARD_INFO("ov14810uC", 0x67),
271                 .platform_data = &cardhu_ov14810uC_data,
272         },
273         {
274                 I2C_BOARD_INFO("ov14810SlaveDev", 0x69),
275                 .platform_data = &cardhu_ov14810SlaveDev_data,
276         }
277 };
278 #endif
279
280 static int cardhu_right_ov5650_power_on(void)
281 {
282         /* CSI-B and front sensor are muxed on cardhu */
283         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
284
285         /* Boards E1198 and E1291 are of Cardhu personality
286          * and donot have TCA6416 exp for camera */
287         if ((board_info.board_id == BOARD_E1198) ||
288                 (board_info.board_id == BOARD_E1291) ||
289                 (board_info.board_id == BOARD_PM315)) {
290
291                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
292                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
293                 mdelay(10);
294
295                 if (cardhu_vdd_2v8_cam2 == NULL) {
296                         cardhu_vdd_2v8_cam2 = regulator_get(NULL, "vdd_2v8_cam2");
297                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam2))) {
298                                 pr_err("%s: couldn't get regulator vdd_2v8_cam2: %ld\n",
299                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam2));
300                                 goto reg_alloc_fail;
301                         }
302                 }
303                 regulator_enable(cardhu_vdd_2v8_cam2);
304                 mdelay(5);
305         }
306
307         /* Enable VDD_1V8_Cam2 */
308         if (cardhu_1v8_cam2 == NULL) {
309                 cardhu_1v8_cam2 = regulator_get(NULL, "vdd_1v8_cam2");
310                 if (WARN_ON(IS_ERR(cardhu_1v8_cam2))) {
311                         pr_err("%s: couldn't get regulator vdd_1v8_cam2: %ld\n",
312                                 __func__, PTR_ERR(cardhu_1v8_cam2));
313                         goto reg_alloc_fail;
314                 }
315         }
316         regulator_enable(cardhu_1v8_cam2);
317
318         mdelay(5);
319
320         if (board_info.board_id == BOARD_PM269) {
321                 gpio_direction_output(CAM2_RST_L_GPIO, 0);
322                 mdelay(100);
323                 gpio_direction_output(CAM2_RST_L_GPIO, 1);
324         }
325
326         return 0;
327
328 reg_alloc_fail:
329         if (cardhu_1v8_cam2) {
330                 regulator_put(cardhu_1v8_cam2);
331                 cardhu_1v8_cam2 = NULL;
332         }
333         if (cardhu_vdd_2v8_cam2) {
334                 regulator_put(cardhu_vdd_2v8_cam2);
335                 cardhu_vdd_2v8_cam2 = NULL;
336         }
337
338         return -ENODEV;
339
340 }
341
342 static int cardhu_right_ov5650_power_off(void)
343 {
344         /* CSI-B and front sensor are muxed on cardhu */
345         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
346
347         /* Boards E1198 and E1291 are of Cardhu personality
348          * and do not have TCA6416 for camera */
349         if ((board_info.board_id == BOARD_E1198) ||
350                 (board_info.board_id == BOARD_E1291) ||
351                 (board_info.board_id == BOARD_PM315)) {
352                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
353                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
354                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
355         }
356
357         if (cardhu_1v8_cam2)
358                 regulator_disable(cardhu_1v8_cam2);
359         if (cardhu_vdd_2v8_cam2)
360                 regulator_disable(cardhu_vdd_2v8_cam2);
361
362         return 0;
363 }
364
365 static void cardhu_ov5650_synchronize_sensors(void)
366 {
367         if (board_info.board_id == BOARD_E1198) {
368                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
369                 mdelay(50);
370                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
371                 mdelay(50);
372         } else if ((board_info.board_id == BOARD_E1291) ||
373                         (board_info.board_id == BOARD_PM315)) {
374                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
375                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
376                 mdelay(50);
377                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
378                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
379                 mdelay(50);
380         }
381         else
382                 pr_err("%s: UnSupported BoardId\n", __func__);
383 }
384
385 struct ov5650_platform_data cardhu_right_ov5650_data = {
386         .power_on = cardhu_right_ov5650_power_on,
387         .power_off = cardhu_right_ov5650_power_off,
388         .synchronize_sensors = cardhu_ov5650_synchronize_sensors,
389 };
390
391 static int cardhu_ov2710_power_on(void)
392 {
393         /* CSI-B and front sensor are muxed on cardhu */
394         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
395
396         /* Enable VDD_1V8_Cam3 */
397         if (cardhu_1v8_cam3 == NULL) {
398                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
399                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
400                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
401                                 __func__, PTR_ERR(cardhu_1v8_cam3));
402                         goto reg_alloc_fail;
403                 }
404         }
405         regulator_enable(cardhu_1v8_cam3);
406
407         /* Boards E1198 and E1291 are of Cardhu personality
408          * and do not have TCA6416 for camera */
409         if ((board_info.board_id == BOARD_E1198) ||
410                 (board_info.board_id == BOARD_E1291) ||
411                 (board_info.board_id == BOARD_PM315)) {
412                 if (cardhu_vdd_cam3 == NULL) {
413                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
414                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
415                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
416                                         __func__, PTR_ERR(cardhu_vdd_cam3));
417                                 goto reg_alloc_fail;
418                         }
419                 }
420                 regulator_enable(cardhu_vdd_cam3);
421
422                 mdelay(5);
423
424                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
425                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
426                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
427                 mdelay(10);
428
429         }
430
431         mdelay(20);
432
433         return 0;
434
435 reg_alloc_fail:
436         if (cardhu_1v8_cam3) {
437                 regulator_put(cardhu_1v8_cam3);
438                 cardhu_1v8_cam3 = NULL;
439         }
440         if (cardhu_vdd_cam3) {
441                 regulator_put(cardhu_vdd_cam3);
442                 cardhu_vdd_cam3 = NULL;
443         }
444
445         return -ENODEV;
446 }
447
448 static int cardhu_ov2710_power_off(void)
449 {
450         /* CSI-B and front sensor are muxed on cardhu */
451         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
452
453         /* Boards E1198 and E1291 are of Cardhu personality
454          * and donot have TCA6416 exp for camera */
455         if ((board_info.board_id == BOARD_E1198) ||
456                 (board_info.board_id == BOARD_E1291) ||
457                 (board_info.board_id == BOARD_PM315)) {
458                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
459                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
460                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
461                 if (cardhu_vdd_cam3)
462                         regulator_disable(cardhu_vdd_cam3);
463         }
464
465         if (cardhu_1v8_cam3)
466                 regulator_disable(cardhu_1v8_cam3);
467
468         return 0;
469 }
470
471 struct ov2710_platform_data cardhu_ov2710_data = {
472         .power_on = cardhu_ov2710_power_on,
473         .power_off = cardhu_ov2710_power_off,
474 };
475
476 static int cardhu_ov5640_power_on(void)
477 {
478         /* CSI-B and front sensor are muxed on cardhu */
479         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
480
481         /* Boards E1198 and E1291 are of Cardhu personality
482          * and donot have TCA6416 exp for camera */
483         if ((board_info.board_id == BOARD_E1198) ||
484                 (board_info.board_id == BOARD_E1291) ||
485                 (board_info.board_id == BOARD_PM315)) {
486
487                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
488                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
489                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
490                 mdelay(10);
491
492                 if (cardhu_vdd_cam3 == NULL) {
493                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
494                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
495                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
496                                         __func__, PTR_ERR(cardhu_vdd_cam3));
497                                 goto reg_alloc_fail;
498                         }
499                 }
500                 regulator_enable(cardhu_vdd_cam3);
501         }
502
503         /* Enable VDD_1V8_Cam3 */
504         if (cardhu_1v8_cam3 == NULL) {
505                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
506                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
507                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
508                                 __func__, PTR_ERR(cardhu_1v8_cam3));
509                         goto reg_alloc_fail;
510                 }
511         }
512         regulator_enable(cardhu_1v8_cam3);
513         mdelay(5);
514
515         return 0;
516
517 reg_alloc_fail:
518         if (cardhu_1v8_cam3) {
519                 regulator_put(cardhu_1v8_cam3);
520                 cardhu_1v8_cam3 = NULL;
521         }
522         if (cardhu_vdd_cam3) {
523                 regulator_put(cardhu_vdd_cam3);
524                 cardhu_vdd_cam3 = NULL;
525         }
526
527         return -ENODEV;
528 }
529
530 static int cardhu_ov5640_power_off(void)
531 {
532         /* CSI-B and front sensor are muxed on cardhu */
533         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
534
535         /* Boards E1198 and E1291 are of Cardhu personality
536          * and donot have TCA6416 exp for camera */
537         if ((board_info.board_id == BOARD_E1198) ||
538                 (board_info.board_id == BOARD_E1291) ||
539                 (board_info.board_id == BOARD_PM315)) {
540                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
541                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
542                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
543         }
544
545         if (cardhu_1v8_cam3)
546                 regulator_disable(cardhu_1v8_cam3);
547         if (cardhu_vdd_cam3)
548                 regulator_disable(cardhu_vdd_cam3);
549
550         return 0;
551 }
552
553 struct ov5640_platform_data cardhu_ov5640_data = {
554         .power_on = cardhu_ov5640_power_on,
555         .power_off = cardhu_ov5640_power_off,
556 };
557
558 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
559         {
560                 I2C_BOARD_INFO("pca9546", 0x70),
561                 .platform_data = &cardhu_pca954x_data,
562         },
563 };
564
565
566 static struct nvc_gpio_pdata sh532u_gpio_pdata[] = {
567         { SH532U_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
568 };
569
570 static struct sh532u_platform_data sh532u_left_pdata = {
571         .cfg            = NVC_CFG_NODEV,
572         .num            = 1,
573         .sync           = 2,
574         .dev_name       = "focuser",
575         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
576         .gpio           = sh532u_gpio_pdata,
577 };
578
579 static struct sh532u_platform_data sh532u_right_pdata = {
580         .cfg            = NVC_CFG_NODEV,
581         .num            = 2,
582         .sync           = 1,
583         .dev_name       = "focuser",
584         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
585         .gpio           = sh532u_gpio_pdata,
586 };
587
588 static struct nvc_gpio_pdata pm269_sh532u_left_gpio_pdata[] = {
589         { SH532U_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
590 };
591
592 static struct sh532u_platform_data pm269_sh532u_left_pdata = {
593         .cfg            = 0,
594         .num            = 1,
595         .sync           = 2,
596         .dev_name       = "focuser",
597         .gpio_count     = ARRAY_SIZE(pm269_sh532u_left_gpio_pdata),
598         .gpio           = pm269_sh532u_left_gpio_pdata,
599 };
600
601 static struct nvc_gpio_pdata pm269_sh532u_right_gpio_pdata[] = {
602         { SH532U_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
603 };
604
605 static struct sh532u_platform_data pm269_sh532u_right_pdata = {
606         .cfg            = 0,
607         .num            = 2,
608         .sync           = 1,
609         .dev_name       = "focuser",
610         .gpio_count     = ARRAY_SIZE(pm269_sh532u_right_gpio_pdata),
611         .gpio           = pm269_sh532u_right_gpio_pdata,
612 };
613
614 static struct nvc_gpio_pdata ad5816_gpio_pdata[] = {
615         { AD5816_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
616 };
617
618 static struct ad5816_platform_data ad5816_left_pdata = {
619         .cfg            = 0,
620         .num            = 1,
621         .sync           = 2,
622         .dev_name       = "focuser",
623         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
624         .gpio           = ad5816_gpio_pdata,
625 };
626
627 static struct ad5816_platform_data ad5816_right_pdata = {
628         .cfg            = 0,
629         .num            = 2,
630         .sync           = 1,
631         .dev_name       = "focuser",
632         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
633         .gpio           = ad5816_gpio_pdata,
634 };
635
636 static struct nvc_gpio_pdata pm269_ad5816_left_gpio_pdata[] = {
637         { AD5816_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
638 };
639
640 static struct ad5816_platform_data pm269_ad5816_left_pdata = {
641         .cfg            = NVC_CFG_NODEV,
642         .num            = 1,
643         .sync           = 2,
644         .dev_name       = "focuser",
645         .gpio_count     = ARRAY_SIZE(pm269_ad5816_left_gpio_pdata),
646         .gpio           = pm269_ad5816_left_gpio_pdata,
647 };
648
649 static struct nvc_gpio_pdata pm269_ad5816_right_gpio_pdata[] = {
650         { AD5816_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
651 };
652
653 static struct ad5816_platform_data pm269_ad5816_right_pdata = {
654         .cfg            = NVC_CFG_NODEV,
655         .num            = 2,
656         .sync           = 1,
657         .dev_name       = "focuser",
658         .gpio_count     = ARRAY_SIZE(pm269_ad5816_right_gpio_pdata),
659         .gpio           = pm269_ad5816_right_gpio_pdata,
660 };
661
662
663 static struct nvc_torch_pin_state cardhu_tps61050_pinstate = {
664         .mask           = 0x0008, /*VGP3*/
665         .values         = 0x0008,
666 };
667
668 static struct tps61050_platform_data cardhu_tps61050_pdata = {
669         .dev_name       = "torch",
670         .pinstate       = &cardhu_tps61050_pinstate,
671 };
672
673 static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
674         {
675                 I2C_BOARD_INFO("tps61050", 0x33),
676                 .platform_data = &cardhu_tps61050_pdata,
677         },
678 };
679
680 static struct i2c_board_info cardhu_i2c6_board_info[] = {
681         {
682                 I2C_BOARD_INFO("ov5650L", 0x36),
683                 .platform_data = &cardhu_left_ov5650_data,
684         },
685         {
686                 I2C_BOARD_INFO("sh532u", 0x72),
687                 .platform_data = &sh532u_left_pdata,
688         },
689         {
690                 I2C_BOARD_INFO("ad5816", 0x0E),
691                 .platform_data = &ad5816_left_pdata,
692         },
693 };
694
695 static struct i2c_board_info cardhu_i2c7_board_info[] = {
696         {
697                 I2C_BOARD_INFO("ov5650R", 0x36),
698                 .platform_data = &cardhu_right_ov5650_data,
699         },
700         {
701                 I2C_BOARD_INFO("sh532u", 0x72),
702                 .platform_data = &sh532u_right_pdata,
703         },
704         {
705                 I2C_BOARD_INFO("ad5816", 0x0E),
706                 .platform_data = &ad5816_right_pdata,
707         },
708 };
709
710 static struct i2c_board_info pm269_i2c6_board_info[] = {
711         {
712                 I2C_BOARD_INFO("ov5650L", 0x36),
713                 .platform_data = &cardhu_left_ov5650_data,
714         },
715         {
716                 I2C_BOARD_INFO("sh532u", 0x72),
717                 .platform_data = &pm269_sh532u_left_pdata,
718         },
719         {
720                 I2C_BOARD_INFO("ad5816", 0x0E),
721                 .platform_data = &pm269_ad5816_left_pdata,
722         },
723 };
724
725 static struct i2c_board_info pm269_i2c7_board_info[] = {
726         {
727                 I2C_BOARD_INFO("ov5650R", 0x36),
728                 .platform_data = &cardhu_right_ov5650_data,
729         },
730         {
731                 I2C_BOARD_INFO("sh532u", 0x72),
732                 .platform_data = &pm269_sh532u_right_pdata,
733         },
734         {
735                 I2C_BOARD_INFO("ad5816", 0x0E),
736                 .platform_data = &pm269_ad5816_right_pdata,
737         },
738 };
739
740 static struct i2c_board_info cardhu_i2c8_board_info[] = {
741         {
742                 I2C_BOARD_INFO("ov2710", 0x36),
743                 .platform_data = &cardhu_ov2710_data,
744         },
745         {
746                 I2C_BOARD_INFO("ov5640", 0x3C),
747                 .platform_data = &cardhu_ov5640_data,
748         },
749 };
750
751 static int nct_get_temp(void *_data, long *temp)
752 {
753         struct nct1008_data *data = _data;
754         return nct1008_thermal_get_temp(data, temp);
755 }
756
757 static int nct_get_temp_low(void *_data, long *temp)
758 {
759         struct nct1008_data *data = _data;
760         return nct1008_thermal_get_temp_low(data, temp);
761 }
762
763 static int nct_set_limits(void *_data,
764                         long lo_limit_milli,
765                         long hi_limit_milli)
766 {
767         struct nct1008_data *data = _data;
768         return nct1008_thermal_set_limits(data,
769                                         lo_limit_milli,
770                                         hi_limit_milli);
771 }
772
773 static int nct_set_alert(void *_data,
774                                 void (*alert_func)(void *),
775                                 void *alert_data)
776 {
777         struct nct1008_data *data = _data;
778         return nct1008_thermal_set_alert(data, alert_func, alert_data);
779 }
780
781 static int nct_set_shutdown_temp(void *_data, long shutdown_temp)
782 {
783         struct nct1008_data *data = _data;
784         return nct1008_thermal_set_shutdown_temp(data, shutdown_temp);
785 }
786
787 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
788 static int nct_get_itemp(void *dev_data, long *temp)
789 {
790         struct nct1008_data *data = dev_data;
791         return nct1008_thermal_get_temps(data, NULL, temp);
792 }
793 #endif
794
795 static void nct1008_probe_callback(struct nct1008_data *data)
796 {
797         struct tegra_thermal_device *ext_nct;
798
799         ext_nct = kzalloc(sizeof(struct tegra_thermal_device),
800                                         GFP_KERNEL);
801         if (!ext_nct) {
802                 pr_err("unable to allocate thermal device\n");
803                 return;
804         }
805
806         ext_nct->name = "nct_ext";
807         ext_nct->id = THERMAL_DEVICE_ID_NCT_EXT;
808         ext_nct->data = data;
809         ext_nct->offset = TDIODE_OFFSET;
810         ext_nct->get_temp = nct_get_temp;
811         ext_nct->get_temp_low = nct_get_temp_low;
812         ext_nct->set_limits = nct_set_limits;
813         ext_nct->set_alert = nct_set_alert;
814         ext_nct->set_shutdown_temp = nct_set_shutdown_temp;
815
816         tegra_thermal_device_register(ext_nct);
817
818 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
819         {
820                 struct tegra_thermal_device *int_nct;
821                 int_nct = kzalloc(sizeof(struct tegra_thermal_device),
822                                                 GFP_KERNEL);
823                 if (!int_nct) {
824                         kfree(int_nct);
825                         pr_err("unable to allocate thermal device\n");
826                         return;
827                 }
828
829                 int_nct->name = "nct_int";
830                 int_nct->id = THERMAL_DEVICE_ID_NCT_INT;
831                 int_nct->data = data;
832                 int_nct->get_temp = nct_get_itemp;
833
834                 tegra_thermal_device_register(int_nct);
835         }
836 #endif
837 }
838
839 static struct nct1008_platform_data cardhu_nct1008_pdata = {
840         .supported_hwrev = true,
841         .ext_range = true,
842         .conv_rate = 0x08,
843         .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
844         .probe_callback = nct1008_probe_callback,
845 };
846
847 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
848         {
849                 I2C_BOARD_INFO("bq27510", 0x55),
850         },
851 };
852
853 static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
854         {
855                 I2C_BOARD_INFO("nct1008", 0x4C),
856                 .platform_data = &cardhu_nct1008_pdata,
857                 .irq = -1,
858         }
859 };
860
861 static int cardhu_nct1008_init(void)
862 {
863         int nct1008_port = -1;
864         int ret = 0;
865
866         if ((board_info.board_id == BOARD_E1198) ||
867                 (board_info.board_id == BOARD_E1291) ||
868                 (board_info.board_id == BOARD_E1257) ||
869                 (board_info.board_id == BOARD_PM269) ||
870                 (board_info.board_id == BOARD_PM305) ||
871                 (board_info.board_id == BOARD_PM311) ||
872                 (board_info.board_id == BOARD_PM315)) {
873                 nct1008_port = TEGRA_GPIO_PCC2;
874         } else if ((board_info.board_id == BOARD_E1186) ||
875                 (board_info.board_id == BOARD_E1187) ||
876                 (board_info.board_id == BOARD_E1256)) {
877                 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
878                 /* nct1008_port = TEGRA_GPIO_PH7; */
879         }
880
881         if (nct1008_port >= 0) {
882                 /* FIXME: enable irq when throttling is supported */
883                 cardhu_i2c4_nct1008_board_info[0].irq = TEGRA_GPIO_TO_IRQ(nct1008_port);
884
885                 ret = gpio_request(nct1008_port, "temp_alert");
886                 if (ret < 0)
887                         return ret;
888
889                 ret = gpio_direction_input(nct1008_port);
890                 if (ret < 0)
891                         gpio_free(nct1008_port);
892         }
893
894         return ret;
895 }
896
897 #if defined(CONFIG_GPIO_PCA953X)
898 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
899         .gpio_base      = PMU_TCA6416_GPIO_BASE,
900 };
901
902 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
903         {
904                 I2C_BOARD_INFO("tca6416", 0x20),
905                 .platform_data = &cardhu_pmu_tca6416_data,
906         },
907 };
908
909 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
910         .gpio_base      = CAM_TCA6416_GPIO_BASE,
911 };
912
913 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
914         {
915                 I2C_BOARD_INFO("tca6416", 0x20),
916                 .platform_data = &cardhu_cam_tca6416_data,
917         },
918 };
919
920 static int __init pmu_tca6416_init(void)
921 {
922         if ((board_info.board_id == BOARD_E1198) ||
923                 (board_info.board_id == BOARD_E1291))
924                         return 0;
925
926         pr_info("Registering pmu pca6416\n");
927         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
928                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
929         return 0;
930 }
931
932 static int __init cam_tca6416_init(void)
933 {
934         /* Boards E1198 and E1291 are of Cardhu personality
935          * and donot have TCA6416 exp for camera */
936         if ((board_info.board_id == BOARD_E1198) ||
937                 (board_info.board_id == BOARD_E1291))
938                 return 0;
939
940         pr_info("Registering cam pca6416\n");
941         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
942                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
943         return 0;
944 }
945 #else
946 static int __init pmu_tca6416_init(void)
947 {
948         return 0;
949 }
950
951 static int __init cam_tca6416_init(void)
952 {
953         return 0;
954 }
955 #endif
956
957 /* MPU board file definition    */
958 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
959 #define MPU_GYRO_NAME           "mpu3050"
960 #endif
961 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU6050)
962 #define MPU_GYRO_NAME           "mpu6050"
963 #endif
964 static struct mpu_platform_data mpu_gyro_data = {
965         .int_config     = 0x10,
966         .level_shifter  = 0,
967         .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
968 };
969
970 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
971 static struct ext_slave_platform_data mpu_accel_data = {
972         .address        = MPU_ACCEL_ADDR,
973         .irq            = 0,
974         .adapt_num      = MPU_ACCEL_BUS_NUM,
975         .bus            = EXT_SLAVE_BUS_SECONDARY,
976         .orientation    = MPU_ACCEL_ORIENTATION,        /* Located in board_[platformname].h    */
977 };
978 #endif
979
980 static struct ext_slave_platform_data mpu_compass_data = {
981         .address        = MPU_COMPASS_ADDR,
982         .irq            = 0,
983         .adapt_num      = MPU_COMPASS_BUS_NUM,
984         .bus            = EXT_SLAVE_BUS_PRIMARY,
985         .orientation    = MPU_COMPASS_ORIENTATION,      /* Located in board_[platformname].h    */
986 };
987
988 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
989         {
990                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
991                 .irq = TEGRA_GPIO_TO_IRQ(MPU_GYRO_IRQ_GPIO),
992                 .platform_data = &mpu_gyro_data,
993         },
994 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
995         {
996                 I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
997 #if     MPU_ACCEL_IRQ_GPIO
998                 .irq = TEGRA_GPIO_TO_IRQ(MPU_ACCEL_IRQ_GPIO),
999 #endif
1000                 .platform_data = &mpu_accel_data,
1001         },
1002 #endif
1003         {
1004                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
1005 #if     MPU_COMPASS_IRQ_GPIO
1006                 .irq = TEGRA_GPIO_TO_IRQ(MPU_COMPASS_IRQ_GPIO),
1007 #endif
1008                 .platform_data = &mpu_compass_data,
1009         },
1010 };
1011
1012 static void mpuirq_init(void)
1013 {
1014         int ret = 0;
1015
1016         pr_info("*** MPU START *** mpuirq_init...\n");
1017
1018 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
1019 #if     MPU_ACCEL_IRQ_GPIO
1020         /* ACCEL-IRQ assignment */
1021         ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
1022         if (ret < 0) {
1023                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1024                 return;
1025         }
1026
1027         ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
1028         if (ret < 0) {
1029                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1030                 gpio_free(MPU_ACCEL_IRQ_GPIO);
1031                 return;
1032         }
1033 #endif
1034 #endif
1035
1036         /* MPU-IRQ assignment */
1037         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
1038         if (ret < 0) {
1039                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1040                 return;
1041         }
1042
1043         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
1044         if (ret < 0) {
1045                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1046                 gpio_free(MPU_GYRO_IRQ_GPIO);
1047                 return;
1048         }
1049         pr_info("*** MPU END *** mpuirq_init...\n");
1050
1051         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
1052                 ARRAY_SIZE(inv_mpu_i2c2_board_info));
1053 }
1054
1055 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
1056         {
1057                 I2C_BOARD_INFO("isl29028", 0x44),
1058         }
1059 };
1060
1061 static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
1062         {
1063                 I2C_BOARD_INFO("LTR_558ALS", 0x23),
1064         }
1065 };
1066
1067 int __init cardhu_sensors_init(void)
1068 {
1069         int err;
1070
1071         tegra_get_board_info(&board_info);
1072
1073         cardhu_camera_init();
1074         cam_tca6416_init();
1075
1076         i2c_register_board_info(2, cardhu_i2c3_board_info,
1077                 ARRAY_SIZE(cardhu_i2c3_board_info));
1078
1079         i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
1080                 ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
1081
1082 #ifdef CONFIG_VIDEO_OV14810
1083         /* This is disabled by default; To enable this change Kconfig;
1084          * there should be some way to detect dynamically which board
1085          * is connected (E1211/E1214), till that time sensor selection
1086          * logic is static;
1087          * e1214 corresponds to ov14810 sensor */
1088         i2c_register_board_info(2, cardhu_i2c_board_info_e1214,
1089                 ARRAY_SIZE(cardhu_i2c_board_info_e1214));
1090 #else
1091         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
1092          * Front camera is on BUS2 */
1093         if (board_info.board_id != BOARD_PM269) {
1094                 i2c_register_board_info(PCA954x_I2C_BUS0,
1095                                         cardhu_i2c6_board_info,
1096                                         ARRAY_SIZE(cardhu_i2c6_board_info));
1097
1098                 i2c_register_board_info(PCA954x_I2C_BUS1,
1099                                         cardhu_i2c7_board_info,
1100                                         ARRAY_SIZE(cardhu_i2c7_board_info));
1101         } else {
1102                 i2c_register_board_info(PCA954x_I2C_BUS0,
1103                                         pm269_i2c6_board_info,
1104                                         ARRAY_SIZE(pm269_i2c6_board_info));
1105
1106                 i2c_register_board_info(PCA954x_I2C_BUS1,
1107                                         pm269_i2c7_board_info,
1108                                         ARRAY_SIZE(pm269_i2c7_board_info));
1109         }
1110         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
1111                 ARRAY_SIZE(cardhu_i2c8_board_info));
1112
1113 #endif
1114         pmu_tca6416_init();
1115
1116         if (board_info.board_id == BOARD_E1291)
1117                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
1118                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
1119
1120         if (board_info.sku == BOARD_SKU_B11)
1121                 i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
1122                         ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
1123         else if (board_info.board_id != BOARD_PM315)
1124                 i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
1125                         ARRAY_SIZE(cardhu_i2c2_isl_board_info));
1126
1127         err = cardhu_nct1008_init();
1128         if (err)
1129                 return err;
1130
1131         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
1132                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
1133
1134         mpuirq_init();
1135         return 0;
1136 }
1137
1138 #if defined(CONFIG_GPIO_PCA953X)
1139 struct ov5650_gpios {
1140         const char *name;
1141         int gpio;
1142         int enabled;
1143 };
1144
1145 #define OV5650_GPIO(_name, _gpio, _enabled)             \
1146         {                                               \
1147                 .name = _name,                          \
1148                 .gpio = _gpio,                          \
1149                 .enabled = _enabled,                    \
1150         }
1151
1152 static struct ov5650_gpios ov5650_gpio_keys[] = {
1153         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
1154         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
1155         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0),
1156         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
1157         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
1158         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
1159         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0),
1160         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
1161         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
1162         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
1163         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 0),
1164         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
1165         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
1166         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
1167         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
1168 };
1169
1170 int __init cardhu_ov5650_late_init(void)
1171 {
1172         int ret;
1173         int i;
1174
1175         if (!machine_is_cardhu())
1176                 return 0;
1177
1178         if ((board_info.board_id == BOARD_E1198) ||
1179                 (board_info.board_id == BOARD_E1291) ||
1180                 (board_info.board_id == BOARD_PM315))
1181                 return 0;
1182
1183         printk(KERN_INFO "%s:\n", __func__);
1184         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
1185                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
1186                         ov5650_gpio_keys[i].name);
1187                 if (ret < 0) {
1188                         printk(KERN_INFO "%s: gpio_request failed for gpio #%d\n",
1189                                 __func__, i);
1190                         goto fail;
1191                 }
1192                 printk(KERN_INFO "%s: enable - %d\n", __func__, i);
1193                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
1194                         ov5650_gpio_keys[i].enabled);
1195                 gpio_export(ov5650_gpio_keys[i].gpio, false);
1196         }
1197
1198         return 0;
1199
1200 fail:
1201         while (i--)
1202                 gpio_free(ov5650_gpio_keys[i].gpio);
1203         return ret;
1204 }
1205
1206 late_initcall(cardhu_ov5650_late_init);
1207 #endif