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