ARM: tegra: Fix temperature trend control logic
[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                 .tc2 = 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                         cardhu_nct1008_pdata.active[i].hysteresis = 1000;
832                 }
833                 cardhu_nct1008_pdata.active[i].create_cdev = NULL;
834 #endif
835
836                 /* FIXME: enable irq when throttling is supported */
837                 cardhu_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
838
839                 ret = gpio_request(nct1008_port, "temp_alert");
840                 if (ret < 0)
841                         return ret;
842
843                 ret = gpio_direction_input(nct1008_port);
844                 if (ret < 0)
845                         gpio_free(nct1008_port);
846         }
847
848         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
849                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
850
851         return ret;
852 }
853
854 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
855 static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
856 {
857         return strcmp((char *)data, thz->type) == 0;
858 }
859
860 static int tegra_skin_get_temp(void *data, long *temp)
861 {
862         struct thermal_zone_device *thz;
863
864         thz = thermal_zone_device_find(data, tegra_skin_match);
865
866         if (!thz || thz->ops->get_temp(thz, temp))
867                 *temp = 25000;
868
869         return 0;
870 }
871
872 static struct therm_est_data skin_data = {
873         .toffset = 9793,
874         .polling_period = 1100,
875         .ndevs = 2,
876         .devs = {
877                         {
878                                 .dev_data = "nct_ext",
879                                 .get_temp = tegra_skin_get_temp,
880                                 .coeffs = {
881                                         2, 1, 1, 1,
882                                         1, 1, 1, 1,
883                                         1, 1, 1, 0,
884                                         1, 1, 0, 0,
885                                         0, 0, -1, -7
886                                 },
887                         },
888                         {
889                                 .dev_data = "nct_int",
890                                 .get_temp = tegra_skin_get_temp,
891                                 .coeffs = {
892                                         -11, -7, -5, -3,
893                                         -3, -2, -1, 0,
894                                         0, 0, 1, 1,
895                                         1, 2, 2, 3,
896                                         4, 6, 11, 18
897                                 },
898                         },
899         },
900         .trip_temp = 43000,
901         .tc1 = 1,
902         .tc2 = 15,
903         .passive_delay = 15000,
904 };
905
906 static struct balanced_throttle skin_throttle = {
907         .throt_tab_size = 6,
908         .throt_tab = {
909                 { 640000, 1200 },
910                 { 640000, 1200 },
911                 { 760000, 1200 },
912                 { 760000, 1200 },
913                 {1000000, 1200 },
914                 {1000000, 1200 },
915         },
916 };
917
918 static int __init cardhu_skin_init(void)
919 {
920         struct thermal_cooling_device *skin_cdev;
921
922         skin_cdev = balanced_throttle_register(&skin_throttle);
923
924         skin_data.cdev = skin_cdev;
925         tegra_skin_therm_est_device.dev.platform_data = &skin_data;
926         platform_device_register(&tegra_skin_therm_est_device);
927
928         return 0;
929 }
930 late_initcall(cardhu_skin_init);
931 #endif
932
933 #if defined(CONFIG_GPIO_PCA953X)
934 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
935         .gpio_base      = PMU_TCA6416_GPIO_BASE,
936 };
937
938 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
939         {
940                 I2C_BOARD_INFO("tca6416", 0x20),
941                 .platform_data = &cardhu_pmu_tca6416_data,
942         },
943 };
944
945 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
946         .gpio_base      = CAM_TCA6416_GPIO_BASE,
947 };
948
949 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
950         {
951                 I2C_BOARD_INFO("tca6416", 0x20),
952                 .platform_data = &cardhu_cam_tca6416_data,
953         },
954 };
955
956 static int __init pmu_tca6416_init(void)
957 {
958         if ((board_info.board_id == BOARD_E1198) ||
959                 (board_info.board_id == BOARD_E1291))
960                         return 0;
961
962         pr_info("Registering pmu pca6416\n");
963         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
964                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
965         return 0;
966 }
967
968 static int __init cam_tca6416_init(void)
969 {
970         /* Boards E1198 and E1291 are of Cardhu personality
971          * and donot have TCA6416 exp for camera */
972         if ((board_info.board_id == BOARD_E1198) ||
973                 (board_info.board_id == BOARD_E1291))
974                 return 0;
975
976         pr_info("Registering cam pca6416\n");
977         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
978                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
979         return 0;
980 }
981 #else
982 static int __init pmu_tca6416_init(void)
983 {
984         return 0;
985 }
986
987 static int __init cam_tca6416_init(void)
988 {
989         return 0;
990 }
991 #endif
992
993 /* MPU board file definition    */
994 static struct mpu_platform_data mpu_gyro_data = {
995         .int_config     = 0x10,
996         .level_shifter  = 0,
997         .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
998         .sec_slave_type = SECONDARY_SLAVE_TYPE_ACCEL,
999         .sec_slave_id   = ACCEL_ID_KXTF9,
1000         .secondary_i2c_addr     = MPU_ACCEL_ADDR,
1001         .secondary_read_reg     = 0x06,
1002         .secondary_orientation  = MPU_ACCEL_ORIENTATION,
1003         .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
1004                            0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
1005 };
1006
1007 static struct mpu_platform_data mpu_compass_data = {
1008         .orientation    = MPU_COMPASS_ORIENTATION,
1009         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
1010 };
1011
1012 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
1013         {
1014                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
1015                 .platform_data = &mpu_gyro_data,
1016         },
1017         {
1018                 I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
1019         },
1020         {
1021                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
1022                 .platform_data = &mpu_compass_data,
1023         },
1024 };
1025
1026 static void mpuirq_init(void)
1027 {
1028         int ret = 0;
1029         int i = 0;
1030
1031         pr_info("*** MPU START *** mpuirq_init...\n");
1032
1033 #if     MPU_ACCEL_IRQ_GPIO
1034         /* ACCEL-IRQ assignment */
1035         ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
1036         if (ret < 0) {
1037                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1038                 return;
1039         }
1040
1041         ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
1042         if (ret < 0) {
1043                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1044                 gpio_free(MPU_ACCEL_IRQ_GPIO);
1045                 return;
1046         }
1047 #endif
1048
1049         /* MPU-IRQ assignment */
1050         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
1051         if (ret < 0) {
1052                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1053                 return;
1054         }
1055
1056         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
1057         if (ret < 0) {
1058                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1059                 gpio_free(MPU_GYRO_IRQ_GPIO);
1060                 return;
1061         }
1062         pr_info("*** MPU END *** mpuirq_init...\n");
1063
1064         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
1065 #if MPU_ACCEL_IRQ_GPIO
1066         inv_mpu_i2c2_board_info[i].irq = gpio_to_irq(MPU_ACCEL_IRQ_GPIO);
1067 #endif
1068         i++;
1069 #if MPU_COMPASS_IRQ_GPIO
1070         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_COMPAS_IRQ_GPIO);
1071 #endif
1072         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
1073                 ARRAY_SIZE(inv_mpu_i2c2_board_info));
1074 }
1075
1076 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
1077         {
1078                 I2C_BOARD_INFO("isl29028", 0x44),
1079         }
1080 };
1081
1082 static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
1083         {
1084                 I2C_BOARD_INFO("LTR_558ALS", 0x23),
1085         }
1086 };
1087
1088 int __init cardhu_sensors_init(void)
1089 {
1090         int err;
1091
1092         tegra_get_board_info(&board_info);
1093
1094         cardhu_camera_init();
1095         cam_tca6416_init();
1096
1097         i2c_register_board_info(2, cardhu_i2c3_board_info,
1098                 ARRAY_SIZE(cardhu_i2c3_board_info));
1099
1100         i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
1101                 ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
1102
1103 #ifdef CONFIG_VIDEO_OV14810
1104         /* This is disabled by default; To enable this change Kconfig;
1105          * there should be some way to detect dynamically which board
1106          * is connected (E1211/E1214), till that time sensor selection
1107          * logic is static;
1108          * e1214 corresponds to ov14810 sensor */
1109         i2c_register_board_info(2, cardhu_i2c_board_info_e1214,
1110                 ARRAY_SIZE(cardhu_i2c_board_info_e1214));
1111 #else
1112         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
1113          * Front camera is on BUS2 */
1114         if (board_info.board_id != BOARD_PM269) {
1115                 i2c_register_board_info(PCA954x_I2C_BUS0,
1116                                         cardhu_i2c6_board_info,
1117                                         ARRAY_SIZE(cardhu_i2c6_board_info));
1118
1119                 i2c_register_board_info(PCA954x_I2C_BUS1,
1120                                         cardhu_i2c7_board_info,
1121                                         ARRAY_SIZE(cardhu_i2c7_board_info));
1122         } else {
1123                 i2c_register_board_info(PCA954x_I2C_BUS0,
1124                                         pm269_i2c6_board_info,
1125                                         ARRAY_SIZE(pm269_i2c6_board_info));
1126
1127                 i2c_register_board_info(PCA954x_I2C_BUS1,
1128                                         pm269_i2c7_board_info,
1129                                         ARRAY_SIZE(pm269_i2c7_board_info));
1130         }
1131         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
1132                 ARRAY_SIZE(cardhu_i2c8_board_info));
1133
1134 #endif
1135         pmu_tca6416_init();
1136
1137         if (board_info.board_id == BOARD_E1291)
1138                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
1139                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
1140
1141         if (board_info.sku == BOARD_SKU_B11)
1142                 i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
1143                         ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
1144         else
1145                 i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
1146                         ARRAY_SIZE(cardhu_i2c2_isl_board_info));
1147
1148         err = cardhu_nct1008_init();
1149         if (err)
1150                 return err;
1151
1152         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
1153                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
1154
1155         mpuirq_init();
1156         return 0;
1157 }
1158
1159 #if defined(CONFIG_GPIO_PCA953X)
1160 struct ov5650_gpios {
1161         const char *name;
1162         int gpio;
1163         int enabled;
1164 };
1165
1166 #define OV5650_GPIO(_name, _gpio, _enabled)             \
1167         {                                               \
1168                 .name = _name,                          \
1169                 .gpio = _gpio,                          \
1170                 .enabled = _enabled,                    \
1171         }
1172
1173 static struct ov5650_gpios ov5650_gpio_keys[] = {
1174         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
1175         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
1176         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0),
1177         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
1178         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
1179         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
1180         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0),
1181         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
1182         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
1183         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
1184         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 0),
1185         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
1186         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
1187         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
1188         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
1189 };
1190
1191 int __init cardhu_ov5650_late_init(void)
1192 {
1193         int ret;
1194         int i;
1195
1196         if (!machine_is_cardhu())
1197                 return 0;
1198
1199         if ((board_info.board_id == BOARD_E1198) ||
1200                 (board_info.board_id == BOARD_E1291))
1201                 return 0;
1202
1203         printk("%s: \n", __func__);
1204         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
1205                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
1206                         ov5650_gpio_keys[i].name);
1207                 if (ret < 0) {
1208                         printk("%s: gpio_request failed for gpio #%d\n",
1209                                 __func__, i);
1210                         goto fail;
1211                 }
1212                 printk("%s: enable - %d\n", __func__, i);
1213                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
1214                         ov5650_gpio_keys[i].enabled);
1215                 gpio_export(ov5650_gpio_keys[i].gpio, false);
1216         }
1217
1218         return 0;
1219
1220 fail:
1221         while (i--)
1222                 gpio_free(ov5650_gpio_keys[i].gpio);
1223         return ret;
1224 }
1225
1226 late_initcall(cardhu_ov5650_late_init);
1227 #endif