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