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