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