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