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