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