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