drivers: skin: Skin prediction algorithm
[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
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 donot have TCA6416 exp 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         /* Boards E1198 and E1291 are of Cardhu personality
391          * and donot have TCA6416 exp for camera */
392         if ((board_info.board_id == BOARD_E1198) ||
393                 (board_info.board_id == BOARD_E1291)) {
394
395                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
396                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
397                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
398                 mdelay(10);
399
400                 if (cardhu_vdd_cam3 == NULL) {
401                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
402                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
403                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
404                                         __func__, PTR_ERR(cardhu_vdd_cam3));
405                                 goto reg_alloc_fail;
406                         }
407                 }
408                 regulator_enable(cardhu_vdd_cam3);
409         }
410
411         /* Enable VDD_1V8_Cam3 */
412         if (cardhu_1v8_cam3 == NULL) {
413                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
414                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
415                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
416                                 __func__, PTR_ERR(cardhu_1v8_cam3));
417                         goto reg_alloc_fail;
418                 }
419         }
420         regulator_enable(cardhu_1v8_cam3);
421         mdelay(5);
422
423         return 0;
424
425 reg_alloc_fail:
426         if (cardhu_1v8_cam3) {
427                 regulator_put(cardhu_1v8_cam3);
428                 cardhu_1v8_cam3 = NULL;
429         }
430         if (cardhu_vdd_cam3) {
431                 regulator_put(cardhu_vdd_cam3);
432                 cardhu_vdd_cam3 = NULL;
433         }
434
435         return -ENODEV;
436 }
437
438 static int cardhu_ov2710_power_off(void)
439 {
440         /* CSI-B and front sensor are muxed on cardhu */
441         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
442
443         /* Boards E1198 and E1291 are of Cardhu personality
444          * and donot have TCA6416 exp for camera */
445         if ((board_info.board_id == BOARD_E1198) ||
446                 (board_info.board_id == BOARD_E1291)) {
447                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
448                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
449                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
450         }
451
452         if (cardhu_1v8_cam3)
453                 regulator_disable(cardhu_1v8_cam3);
454         if (cardhu_vdd_cam3)
455                 regulator_disable(cardhu_vdd_cam3);
456
457         return 0;
458 }
459
460 struct ov2710_platform_data cardhu_ov2710_data = {
461         .power_on = cardhu_ov2710_power_on,
462         .power_off = cardhu_ov2710_power_off,
463 };
464
465 static int cardhu_ov5640_power_on(void)
466 {
467         /* CSI-B and front sensor are muxed on cardhu */
468         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
469
470         /* Boards E1198 and E1291 are of Cardhu personality
471          * and donot have TCA6416 exp for camera */
472         if ((board_info.board_id == BOARD_E1198) ||
473                 (board_info.board_id == BOARD_E1291)) {
474
475                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
476                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
477                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
478                 mdelay(10);
479
480                 if (cardhu_vdd_cam3 == NULL) {
481                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
482                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
483                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
484                                         __func__, PTR_ERR(cardhu_vdd_cam3));
485                                 goto reg_alloc_fail;
486                         }
487                 }
488                 regulator_enable(cardhu_vdd_cam3);
489         }
490
491         /* Enable VDD_1V8_Cam3 */
492         if (cardhu_1v8_cam3 == NULL) {
493                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
494                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
495                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
496                                 __func__, PTR_ERR(cardhu_1v8_cam3));
497                         goto reg_alloc_fail;
498                 }
499         }
500         regulator_enable(cardhu_1v8_cam3);
501         mdelay(5);
502
503         return 0;
504
505 reg_alloc_fail:
506         if (cardhu_1v8_cam3) {
507                 regulator_put(cardhu_1v8_cam3);
508                 cardhu_1v8_cam3 = NULL;
509         }
510         if (cardhu_vdd_cam3) {
511                 regulator_put(cardhu_vdd_cam3);
512                 cardhu_vdd_cam3 = NULL;
513         }
514
515         return -ENODEV;
516 }
517
518 static int cardhu_ov5640_power_off(void)
519 {
520         /* CSI-B and front sensor are muxed on cardhu */
521         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
522
523         /* Boards E1198 and E1291 are of Cardhu personality
524          * and donot have TCA6416 exp for camera */
525         if ((board_info.board_id == BOARD_E1198) ||
526                 (board_info.board_id == BOARD_E1291)) {
527                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
528                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
529                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
530         }
531
532         if (cardhu_1v8_cam3)
533                 regulator_disable(cardhu_1v8_cam3);
534         if (cardhu_vdd_cam3)
535                 regulator_disable(cardhu_vdd_cam3);
536
537         return 0;
538 }
539
540 struct ov5640_platform_data cardhu_ov5640_data = {
541         .power_on = cardhu_ov5640_power_on,
542         .power_off = cardhu_ov5640_power_off,
543 };
544
545 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
546         {
547                 I2C_BOARD_INFO("pca9546", 0x70),
548                 .platform_data = &cardhu_pca954x_data,
549         },
550 };
551
552
553 static struct nvc_gpio_pdata sh532u_gpio_pdata[] = {
554         { SH532U_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
555 };
556
557 static struct sh532u_platform_data sh532u_left_pdata = {
558         .cfg            = NVC_CFG_NODEV,
559         .num            = 1,
560         .sync           = 2,
561         .dev_name       = "focuser",
562         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
563         .gpio           = sh532u_gpio_pdata,
564 };
565
566 static struct sh532u_platform_data sh532u_right_pdata = {
567         .cfg            = NVC_CFG_NODEV,
568         .num            = 2,
569         .sync           = 1,
570         .dev_name       = "focuser",
571         .gpio_count     = ARRAY_SIZE(sh532u_gpio_pdata),
572         .gpio           = sh532u_gpio_pdata,
573 };
574
575 static struct nvc_gpio_pdata pm269_sh532u_left_gpio_pdata[] = {
576         { SH532U_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
577 };
578
579 static struct sh532u_platform_data pm269_sh532u_left_pdata = {
580         .cfg            = 0,
581         .num            = 1,
582         .sync           = 2,
583         .dev_name       = "focuser",
584         .gpio_count     = ARRAY_SIZE(pm269_sh532u_left_gpio_pdata),
585         .gpio           = pm269_sh532u_left_gpio_pdata,
586 };
587
588 static struct nvc_gpio_pdata pm269_sh532u_right_gpio_pdata[] = {
589         { SH532U_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
590 };
591
592 static struct sh532u_platform_data pm269_sh532u_right_pdata = {
593         .cfg            = 0,
594         .num            = 2,
595         .sync           = 1,
596         .dev_name       = "focuser",
597         .gpio_count     = ARRAY_SIZE(pm269_sh532u_right_gpio_pdata),
598         .gpio           = pm269_sh532u_right_gpio_pdata,
599 };
600
601 static struct nvc_gpio_pdata ad5816_gpio_pdata[] = {
602         { AD5816_GPIO_RESET, TEGRA_GPIO_PBB0, false, 0, },
603 };
604
605 static struct ad5816_platform_data ad5816_left_pdata = {
606         .cfg            = 0,
607         .num            = 1,
608         .sync           = 2,
609         .dev_name       = "focuser",
610         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
611         .gpio           = ad5816_gpio_pdata,
612 };
613
614 static struct ad5816_platform_data ad5816_right_pdata = {
615         .cfg            = 0,
616         .num            = 2,
617         .sync           = 1,
618         .dev_name       = "focuser",
619         .gpio_count     = ARRAY_SIZE(ad5816_gpio_pdata),
620         .gpio           = ad5816_gpio_pdata,
621 };
622
623 static struct nvc_gpio_pdata pm269_ad5816_left_gpio_pdata[] = {
624         { AD5816_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
625 };
626
627 static struct ad5816_platform_data pm269_ad5816_left_pdata = {
628         .cfg            = NVC_CFG_NODEV,
629         .num            = 1,
630         .sync           = 2,
631         .dev_name       = "focuser",
632         .gpio_count     = ARRAY_SIZE(pm269_ad5816_left_gpio_pdata),
633         .gpio           = pm269_ad5816_left_gpio_pdata,
634 };
635
636 static struct nvc_gpio_pdata pm269_ad5816_right_gpio_pdata[] = {
637         { AD5816_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
638 };
639
640 static struct ad5816_platform_data pm269_ad5816_right_pdata = {
641         .cfg            = NVC_CFG_NODEV,
642         .num            = 2,
643         .sync           = 1,
644         .dev_name       = "focuser",
645         .gpio_count     = ARRAY_SIZE(pm269_ad5816_right_gpio_pdata),
646         .gpio           = pm269_ad5816_right_gpio_pdata,
647 };
648
649
650 static struct nvc_torch_pin_state cardhu_tps61050_pinstate = {
651         .mask           = 0x0008, /*VGP3*/
652         .values         = 0x0008,
653 };
654
655 static struct tps61050_platform_data cardhu_tps61050_pdata = {
656         .dev_name       = "torch",
657         .pinstate       = &cardhu_tps61050_pinstate,
658 };
659
660 static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
661         {
662                 I2C_BOARD_INFO("tps61050", 0x33),
663                 .platform_data = &cardhu_tps61050_pdata,
664         },
665 };
666
667 static struct i2c_board_info cardhu_i2c6_board_info[] = {
668         {
669                 I2C_BOARD_INFO("ov5650L", 0x36),
670                 .platform_data = &cardhu_left_ov5650_data,
671         },
672         {
673                 I2C_BOARD_INFO("sh532u", 0x72),
674                 .platform_data = &sh532u_left_pdata,
675         },
676         {
677                 I2C_BOARD_INFO("ad5816", 0x0E),
678                 .platform_data = &ad5816_left_pdata,
679         },
680 };
681
682 static struct i2c_board_info cardhu_i2c7_board_info[] = {
683         {
684                 I2C_BOARD_INFO("ov5650R", 0x36),
685                 .platform_data = &cardhu_right_ov5650_data,
686         },
687         {
688                 I2C_BOARD_INFO("sh532u", 0x72),
689                 .platform_data = &sh532u_right_pdata,
690         },
691         {
692                 I2C_BOARD_INFO("ad5816", 0x0E),
693                 .platform_data = &ad5816_right_pdata,
694         },
695 };
696
697 static struct i2c_board_info pm269_i2c6_board_info[] = {
698         {
699                 I2C_BOARD_INFO("ov5650L", 0x36),
700                 .platform_data = &cardhu_left_ov5650_data,
701         },
702         {
703                 I2C_BOARD_INFO("sh532u", 0x72),
704                 .platform_data = &pm269_sh532u_left_pdata,
705         },
706         {
707                 I2C_BOARD_INFO("ad5816", 0x0E),
708                 .platform_data = &pm269_ad5816_left_pdata,
709         },
710 };
711
712 static struct i2c_board_info pm269_i2c7_board_info[] = {
713         {
714                 I2C_BOARD_INFO("ov5650R", 0x36),
715                 .platform_data = &cardhu_right_ov5650_data,
716         },
717         {
718                 I2C_BOARD_INFO("sh532u", 0x72),
719                 .platform_data = &pm269_sh532u_right_pdata,
720         },
721         {
722                 I2C_BOARD_INFO("ad5816", 0x0E),
723                 .platform_data = &pm269_ad5816_right_pdata,
724         },
725 };
726
727 static struct i2c_board_info cardhu_i2c8_board_info[] = {
728         {
729                 I2C_BOARD_INFO("ov2710", 0x36),
730                 .platform_data = &cardhu_ov2710_data,
731         },
732         {
733                 I2C_BOARD_INFO("ov5640", 0x3C),
734                 .platform_data = &cardhu_ov5640_data,
735         },
736 };
737
738 static int nct_get_temp(void *_data, long *temp)
739 {
740         struct nct1008_data *data = _data;
741         return nct1008_thermal_get_temp(data, temp);
742 }
743
744 static int nct_get_temp_low(void *_data, long *temp)
745 {
746         struct nct1008_data *data = _data;
747         return nct1008_thermal_get_temp_low(data, temp);
748 }
749
750 static int nct_set_limits(void *_data,
751                         long lo_limit_milli,
752                         long hi_limit_milli)
753 {
754         struct nct1008_data *data = _data;
755         return nct1008_thermal_set_limits(data,
756                                         lo_limit_milli,
757                                         hi_limit_milli);
758 }
759
760 static int nct_set_alert(void *_data,
761                                 void (*alert_func)(void *),
762                                 void *alert_data)
763 {
764         struct nct1008_data *data = _data;
765         return nct1008_thermal_set_alert(data, alert_func, alert_data);
766 }
767
768 static int nct_set_shutdown_temp(void *_data, long shutdown_temp)
769 {
770         struct nct1008_data *data = _data;
771         return nct1008_thermal_set_shutdown_temp(data, shutdown_temp);
772 }
773
774 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
775 static int nct_get_itemp(void *dev_data, long *temp)
776 {
777         struct nct1008_data *data = dev_data;
778         return nct1008_thermal_get_temps(data, NULL, temp);
779 }
780 #endif
781
782 static void nct1008_probe_callback(struct nct1008_data *data)
783 {
784         struct tegra_thermal_device *ext_nct;
785
786         ext_nct = kzalloc(sizeof(struct tegra_thermal_device),
787                                         GFP_KERNEL);
788         if (!ext_nct) {
789                 pr_err("unable to allocate thermal device\n");
790                 return;
791         }
792
793         ext_nct->name = "nct_ext";
794         ext_nct->id = THERMAL_DEVICE_ID_NCT_EXT;
795         ext_nct->data = data;
796         ext_nct->offset = TDIODE_OFFSET;
797         ext_nct->get_temp = nct_get_temp;
798         ext_nct->get_temp_low = nct_get_temp_low;
799         ext_nct->set_limits = nct_set_limits;
800         ext_nct->set_alert = nct_set_alert;
801         ext_nct->set_shutdown_temp = nct_set_shutdown_temp;
802
803         tegra_thermal_device_register(ext_nct);
804
805 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
806         {
807                 struct tegra_thermal_device *int_nct;
808                 int_nct = kzalloc(sizeof(struct tegra_thermal_device),
809                                                 GFP_KERNEL);
810                 if (!int_nct) {
811                         kfree(int_nct);
812                         pr_err("unable to allocate thermal device\n");
813                         return;
814                 }
815
816                 int_nct->name = "nct_int";
817                 int_nct->id = THERMAL_DEVICE_ID_NCT_INT;
818                 int_nct->data = data;
819                 int_nct->get_temp = nct_get_itemp;
820
821                 tegra_thermal_device_register(int_nct);
822         }
823 #endif
824 }
825
826 static struct nct1008_platform_data cardhu_nct1008_pdata = {
827         .supported_hwrev = true,
828         .ext_range = true,
829         .conv_rate = 0x08,
830         .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
831         .probe_callback = nct1008_probe_callback,
832 };
833
834 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
835         {
836                 I2C_BOARD_INFO("bq27510", 0x55),
837         },
838 };
839
840 static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
841         {
842                 I2C_BOARD_INFO("nct1008", 0x4C),
843                 .platform_data = &cardhu_nct1008_pdata,
844                 .irq = -1,
845         }
846 };
847
848 static int cardhu_nct1008_init(void)
849 {
850         int nct1008_port = -1;
851         int ret = 0;
852
853         if ((board_info.board_id == BOARD_E1198) ||
854                 (board_info.board_id == BOARD_E1291) ||
855                 (board_info.board_id == BOARD_E1257) ||
856                 (board_info.board_id == BOARD_PM269) ||
857                 (board_info.board_id == BOARD_PM305) ||
858                 (board_info.board_id == BOARD_PM311)) {
859                 nct1008_port = TEGRA_GPIO_PCC2;
860         } else if ((board_info.board_id == BOARD_E1186) ||
861                 (board_info.board_id == BOARD_E1187) ||
862                 (board_info.board_id == BOARD_E1256)) {
863                 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
864                 /* nct1008_port = TEGRA_GPIO_PH7; */
865         }
866
867         if (nct1008_port >= 0) {
868                 /* FIXME: enable irq when throttling is supported */
869                 cardhu_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
870
871                 ret = gpio_request(nct1008_port, "temp_alert");
872                 if (ret < 0)
873                         return ret;
874
875                 ret = gpio_direction_input(nct1008_port);
876                 if (ret < 0)
877                         gpio_free(nct1008_port);
878         }
879
880         return ret;
881 }
882
883 #if defined(CONFIG_GPIO_PCA953X)
884 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
885         .gpio_base      = PMU_TCA6416_GPIO_BASE,
886 };
887
888 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
889         {
890                 I2C_BOARD_INFO("tca6416", 0x20),
891                 .platform_data = &cardhu_pmu_tca6416_data,
892         },
893 };
894
895 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
896         .gpio_base      = CAM_TCA6416_GPIO_BASE,
897 };
898
899 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
900         {
901                 I2C_BOARD_INFO("tca6416", 0x20),
902                 .platform_data = &cardhu_cam_tca6416_data,
903         },
904 };
905
906 static int __init pmu_tca6416_init(void)
907 {
908         if ((board_info.board_id == BOARD_E1198) ||
909                 (board_info.board_id == BOARD_E1291))
910                         return 0;
911
912         pr_info("Registering pmu pca6416\n");
913         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
914                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
915         return 0;
916 }
917
918 static int __init cam_tca6416_init(void)
919 {
920         /* Boards E1198 and E1291 are of Cardhu personality
921          * and donot have TCA6416 exp for camera */
922         if ((board_info.board_id == BOARD_E1198) ||
923                 (board_info.board_id == BOARD_E1291))
924                 return 0;
925
926         pr_info("Registering cam pca6416\n");
927         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
928                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
929         return 0;
930 }
931 #else
932 static int __init pmu_tca6416_init(void)
933 {
934         return 0;
935 }
936
937 static int __init cam_tca6416_init(void)
938 {
939         return 0;
940 }
941 #endif
942
943 /* MPU board file definition    */
944 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
945 #define MPU_GYRO_NAME           "mpu3050"
946 #endif
947 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU6050)
948 #define MPU_GYRO_NAME           "mpu6050"
949 #endif
950 static struct mpu_platform_data mpu_gyro_data = {
951         .int_config     = 0x10,
952         .level_shifter  = 0,
953         .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
954 };
955
956 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
957 static struct ext_slave_platform_data mpu_accel_data = {
958         .address        = MPU_ACCEL_ADDR,
959         .irq            = 0,
960         .adapt_num      = MPU_ACCEL_BUS_NUM,
961         .bus            = EXT_SLAVE_BUS_SECONDARY,
962         .orientation    = MPU_ACCEL_ORIENTATION,        /* Located in board_[platformname].h    */
963 };
964 #endif
965
966 static struct ext_slave_platform_data mpu_compass_data = {
967         .address        = MPU_COMPASS_ADDR,
968         .irq            = 0,
969         .adapt_num      = MPU_COMPASS_BUS_NUM,
970         .bus            = EXT_SLAVE_BUS_PRIMARY,
971         .orientation    = MPU_COMPASS_ORIENTATION,      /* Located in board_[platformname].h    */
972 };
973
974 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
975         {
976                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
977                 .platform_data = &mpu_gyro_data,
978         },
979 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
980         {
981                 I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
982                 .platform_data = &mpu_accel_data,
983         },
984 #endif
985         {
986                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
987                 .platform_data = &mpu_compass_data,
988         },
989 };
990
991 static void mpuirq_init(void)
992 {
993         int ret = 0;
994         int i = 0;
995
996         pr_info("*** MPU START *** mpuirq_init...\n");
997
998 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
999 #if     MPU_ACCEL_IRQ_GPIO
1000         /* ACCEL-IRQ assignment */
1001         ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
1002         if (ret < 0) {
1003                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1004                 return;
1005         }
1006
1007         ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
1008         if (ret < 0) {
1009                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1010                 gpio_free(MPU_ACCEL_IRQ_GPIO);
1011                 return;
1012         }
1013 #endif
1014 #endif
1015
1016         /* MPU-IRQ assignment */
1017         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
1018         if (ret < 0) {
1019                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
1020                 return;
1021         }
1022
1023         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
1024         if (ret < 0) {
1025                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
1026                 gpio_free(MPU_GYRO_IRQ_GPIO);
1027                 return;
1028         }
1029         pr_info("*** MPU END *** mpuirq_init...\n");
1030
1031         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
1032 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
1033 #if MPU_ACCEL_IRQ_GPIO
1034         inv_mpu_i2c2_board_info[i].irq = gpio_to_irq(MPU_ACCEL_IRQ_GPIO);
1035 #endif
1036         i++;
1037 #endif
1038 #if MPU_COMPASS_IRQ_GPIO
1039         inv_mpu_i2c2_board_info[i++].irq = gpio_to_irq(MPU_COMPAS_IRQ_GPIO);
1040 #endif
1041         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
1042                 ARRAY_SIZE(inv_mpu_i2c2_board_info));
1043 }
1044
1045 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
1046         {
1047                 I2C_BOARD_INFO("isl29028", 0x44),
1048         }
1049 };
1050
1051 static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
1052         {
1053                 I2C_BOARD_INFO("LTR_558ALS", 0x23),
1054         }
1055 };
1056
1057 int __init cardhu_sensors_init(void)
1058 {
1059         int err;
1060
1061         tegra_get_board_info(&board_info);
1062
1063         cardhu_camera_init();
1064         cam_tca6416_init();
1065
1066         i2c_register_board_info(2, cardhu_i2c3_board_info,
1067                 ARRAY_SIZE(cardhu_i2c3_board_info));
1068
1069         i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
1070                 ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
1071
1072 #ifdef CONFIG_VIDEO_OV14810
1073         /* This is disabled by default; To enable this change Kconfig;
1074          * there should be some way to detect dynamically which board
1075          * is connected (E1211/E1214), till that time sensor selection
1076          * logic is static;
1077          * e1214 corresponds to ov14810 sensor */
1078         i2c_register_board_info(2, cardhu_i2c_board_info_e1214,
1079                 ARRAY_SIZE(cardhu_i2c_board_info_e1214));
1080 #else
1081         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
1082          * Front camera is on BUS2 */
1083         if (board_info.board_id != BOARD_PM269) {
1084                 i2c_register_board_info(PCA954x_I2C_BUS0,
1085                                         cardhu_i2c6_board_info,
1086                                         ARRAY_SIZE(cardhu_i2c6_board_info));
1087
1088                 i2c_register_board_info(PCA954x_I2C_BUS1,
1089                                         cardhu_i2c7_board_info,
1090                                         ARRAY_SIZE(cardhu_i2c7_board_info));
1091         } else {
1092                 i2c_register_board_info(PCA954x_I2C_BUS0,
1093                                         pm269_i2c6_board_info,
1094                                         ARRAY_SIZE(pm269_i2c6_board_info));
1095
1096                 i2c_register_board_info(PCA954x_I2C_BUS1,
1097                                         pm269_i2c7_board_info,
1098                                         ARRAY_SIZE(pm269_i2c7_board_info));
1099         }
1100         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
1101                 ARRAY_SIZE(cardhu_i2c8_board_info));
1102
1103 #endif
1104         pmu_tca6416_init();
1105
1106         if (board_info.board_id == BOARD_E1291)
1107                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
1108                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
1109
1110         if (board_info.sku == BOARD_SKU_B11)
1111                 i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
1112                         ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
1113         else
1114                 i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
1115                         ARRAY_SIZE(cardhu_i2c2_isl_board_info));
1116
1117         err = cardhu_nct1008_init();
1118         if (err)
1119                 return err;
1120
1121         i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
1122                 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
1123
1124         mpuirq_init();
1125         return 0;
1126 }
1127
1128 #if defined(CONFIG_GPIO_PCA953X)
1129 struct ov5650_gpios {
1130         const char *name;
1131         int gpio;
1132         int enabled;
1133 };
1134
1135 #define OV5650_GPIO(_name, _gpio, _enabled)             \
1136         {                                               \
1137                 .name = _name,                          \
1138                 .gpio = _gpio,                          \
1139                 .enabled = _enabled,                    \
1140         }
1141
1142 static struct ov5650_gpios ov5650_gpio_keys[] = {
1143         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
1144         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
1145         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0),
1146         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
1147         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
1148         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
1149         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0),
1150         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
1151         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
1152         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
1153         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 0),
1154         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
1155         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
1156         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
1157         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
1158 };
1159
1160 int __init cardhu_ov5650_late_init(void)
1161 {
1162         int ret;
1163         int i;
1164
1165         if (!machine_is_cardhu())
1166                 return 0;
1167
1168         if ((board_info.board_id == BOARD_E1198) ||
1169                 (board_info.board_id == BOARD_E1291))
1170                 return 0;
1171
1172         printk("%s: \n", __func__);
1173         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
1174                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
1175                         ov5650_gpio_keys[i].name);
1176                 if (ret < 0) {
1177                         printk("%s: gpio_request failed for gpio #%d\n",
1178                                 __func__, i);
1179                         goto fail;
1180                 }
1181                 printk("%s: enable - %d\n", __func__, i);
1182                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
1183                         ov5650_gpio_keys[i].enabled);
1184                 gpio_export(ov5650_gpio_keys[i].gpio, false);
1185         }
1186
1187         return 0;
1188
1189 fail:
1190         while (i--)
1191                 gpio_free(ov5650_gpio_keys[i].gpio);
1192         return ret;
1193 }
1194
1195 late_initcall(cardhu_ov5650_late_init);
1196 #endif