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