arm: tegra: sh532u focuser board support
[linux-2.6.git] / arch / arm / mach-tegra / board-ventana-sensors.c
1 /*
2  * arch/arm/mach-tegra/board-ventana-sensors.c
3  *
4  * Copyright (c) 2011-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/delay.h>
35 #include <linux/i2c.h>
36 #include <linux/mpu.h>
37 #include <linux/i2c/pca954x.h>
38 #include <linux/i2c/pca953x.h>
39 #include <linux/nct1008.h>
40 #include <linux/err.h>
41 #include <linux/regulator/consumer.h>
42
43 #include <mach/gpio.h>
44
45 #include <media/ov5650.h>
46 #include <media/ov2710.h>
47 #include <media/sh532u.h>
48 #include <media/ssl3250a.h>
49 #include <generated/mach-types.h>
50
51 #include "gpio-names.h"
52 #include "board.h"
53 #include "board-ventana.h"
54 #include "cpu-tegra.h"
55
56 static struct regulator *cam1_2v8, *cam2_2v8;
57
58 /* left ov5650 is CAM2 which is on csi_a */
59 static int ventana_left_ov5650_power_on(void)
60 {
61         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
62         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 1);
63         regulator_enable(cam2_2v8);
64         mdelay(5);
65         gpio_direction_output(CAM2_PWR_DN_GPIO, 0);
66         mdelay(5);
67         gpio_direction_output(CAM2_RST_L_GPIO, 0);
68         mdelay(1);
69         gpio_direction_output(CAM2_RST_L_GPIO, 1);
70         mdelay(20);
71         return 0;
72 }
73
74 static int ventana_left_ov5650_power_off(void)
75 {
76         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 0);
77         gpio_direction_output(CAM2_RST_L_GPIO, 0);
78         gpio_direction_output(CAM2_PWR_DN_GPIO, 1);
79         regulator_disable(cam2_2v8);
80         return 0;
81 }
82
83 struct ov5650_platform_data ventana_left_ov5650_data = {
84         .power_on = ventana_left_ov5650_power_on,
85         .power_off = ventana_left_ov5650_power_off,
86 };
87
88 /* right ov5650 is CAM1 which is on csi_b */
89 static int ventana_right_ov5650_power_on(void)
90 {
91         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 1);
92         regulator_enable(cam1_2v8);
93         mdelay(5);
94         gpio_direction_output(CAM1_PWR_DN_GPIO, 0);
95         mdelay(5);
96         gpio_direction_output(CAM1_RST_L_GPIO, 0);
97         mdelay(1);
98         gpio_direction_output(CAM1_RST_L_GPIO, 1);
99         mdelay(20);
100         return 0;
101 }
102
103 static int ventana_right_ov5650_power_off(void)
104 {
105         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 0);
106         gpio_direction_output(CAM1_RST_L_GPIO, 0);
107         gpio_direction_output(CAM1_PWR_DN_GPIO, 1);
108         regulator_disable(cam1_2v8);
109         return 0;
110 }
111
112 struct ov5650_platform_data ventana_right_ov5650_data = {
113         .power_on = ventana_right_ov5650_power_on,
114         .power_off = ventana_right_ov5650_power_off,
115 };
116
117 static int ventana_ov2710_power_on(void)
118 {
119         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
120         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 1);
121         mdelay(5);
122         gpio_direction_output(CAM3_PWR_DN_GPIO, 0);
123         mdelay(5);
124         gpio_direction_output(CAM3_RST_L_GPIO, 0);
125         mdelay(1);
126         gpio_direction_output(CAM3_RST_L_GPIO, 1);
127         mdelay(20);
128         return 0;
129 }
130
131 static int ventana_ov2710_power_off(void)
132 {
133         gpio_direction_output(CAM3_RST_L_GPIO, 0);
134         gpio_direction_output(CAM3_PWR_DN_GPIO, 1);
135         gpio_direction_output(AVDD_DSI_CSI_ENB_GPIO, 0);
136         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
137         return 0;
138 }
139
140 struct ov2710_platform_data ventana_ov2710_data = {
141         .power_on = ventana_ov2710_power_on,
142         .power_off = ventana_ov2710_power_off,
143 };
144
145
146 static struct nvc_gpio_pdata sh532u_left_gpio_pdata[] = {
147         { SH532U_GPIO_RESET, CAM2_RST_L_GPIO, false, 0, },
148         { SH532U_GPIO_GP1, CAM2_LDO_SHUTDN_L_GPIO, false, true, },
149 };
150
151 static struct sh532u_platform_data sh532u_left_pdata = {
152         .cfg            = NVC_CFG_NODEV,
153         .num            = 1,
154         .sync           = 2,
155         .dev_name       = "focuser",
156         .gpio_count     = ARRAY_SIZE(sh532u_left_gpio_pdata),
157         .gpio           = sh532u_left_gpio_pdata,
158 };
159
160 static struct nvc_gpio_pdata sh532u_right_gpio_pdata[] = {
161         { SH532U_GPIO_RESET, CAM1_RST_L_GPIO, false, 0, },
162         { SH532U_GPIO_GP1, CAM1_LDO_SHUTDN_L_GPIO, false, true, },
163 };
164
165 static struct sh532u_platform_data sh532u_right_pdata = {
166         .cfg            = NVC_CFG_NODEV,
167         .num            = 2,
168         .sync           = 1,
169         .dev_name       = "focuser",
170         .gpio_count     = ARRAY_SIZE(sh532u_right_gpio_pdata),
171         .gpio           = sh532u_right_gpio_pdata,
172 };
173
174
175 static struct nvc_torch_pin_state ventana_ssl3250a_pinstate = {
176         .mask           = 0x0040, /* VGP6 */
177         .values         = 0x0040,
178 };
179
180 static struct ssl3250a_platform_data ventana_ssl3250a_pdata = {
181         .dev_name       = "torch",
182         .pinstate       = &ventana_ssl3250a_pinstate,
183         .gpio_act       = CAMERA_FLASH_ACT_GPIO,
184 };
185
186
187 static void ventana_isl29018_init(void)
188 {
189         tegra_gpio_enable(ISL29018_IRQ_GPIO);
190         gpio_request(ISL29018_IRQ_GPIO, "isl29018");
191         gpio_direction_input(ISL29018_IRQ_GPIO);
192 }
193
194 #ifdef CONFIG_SENSORS_AK8975
195 static void ventana_akm8975_init(void)
196 {
197         tegra_gpio_enable(AKM8975_IRQ_GPIO);
198         gpio_request(AKM8975_IRQ_GPIO, "akm8975");
199         gpio_direction_input(AKM8975_IRQ_GPIO);
200 }
201 #endif
202
203 static void ventana_nct1008_init(void)
204 {
205         tegra_gpio_enable(NCT1008_THERM2_GPIO);
206         gpio_request(NCT1008_THERM2_GPIO, "temp_alert");
207         gpio_direction_input(NCT1008_THERM2_GPIO);
208 }
209
210 static struct nct1008_platform_data ventana_nct1008_pdata = {
211         .supported_hwrev = true,
212         .ext_range = false,
213         .conv_rate = 0x08,
214         .offset = 0,
215         .hysteresis = 0,
216         .shutdown_ext_limit = 115,
217         .shutdown_local_limit = 120,
218         .throttling_ext_limit = 90,
219         .alarm_fn = tegra_throttling_enable,
220 };
221
222 static const struct i2c_board_info ventana_i2c0_board_info[] = {
223         {
224                 I2C_BOARD_INFO("isl29018", 0x44),
225                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PZ2),
226         },
227 };
228
229 static const struct i2c_board_info ventana_i2c2_board_info[] = {
230         {
231                 I2C_BOARD_INFO("bq20z75", 0x0B),
232         },
233 };
234
235 static struct pca953x_platform_data ventana_tca6416_data = {
236         .gpio_base = TCA6416_GPIO_BASE,
237 };
238
239 static struct pca954x_platform_mode ventana_pca9546_modes[] = {
240         { .adap_id = PCA954x_I2C_BUS0, .deselect_on_exit = 1 }, /* REAR CAM1 */
241         { .adap_id = PCA954x_I2C_BUS1, .deselect_on_exit = 1 }, /* REAR CAM2 */
242         { .adap_id = PCA954x_I2C_BUS2, .deselect_on_exit = 1 }, /* FRONT CAM3 */
243 };
244
245 static struct pca954x_platform_data ventana_pca9546_data = {
246         .modes = ventana_pca9546_modes,
247         .num_modes = ARRAY_SIZE(ventana_pca9546_modes),
248 };
249
250 static const struct i2c_board_info ventana_i2c3_board_info_tca6416[] = {
251         {
252                 I2C_BOARD_INFO("tca6416", 0x20),
253                 .platform_data = &ventana_tca6416_data,
254         },
255 };
256
257 static const struct i2c_board_info ventana_i2c3_board_info_pca9546[] = {
258         {
259                 I2C_BOARD_INFO("pca9546", 0x70),
260                 .platform_data = &ventana_pca9546_data,
261         },
262 };
263
264 static const struct i2c_board_info ventana_i2c3_board_info_ssl3250a[] = {
265         {
266                 I2C_BOARD_INFO("ssl3250a", 0x30),
267                 .platform_data = &ventana_ssl3250a_pdata,
268         },
269 };
270
271 static struct i2c_board_info ventana_i2c4_board_info[] = {
272         {
273                 I2C_BOARD_INFO("nct1008", 0x4C),
274                 .irq = TEGRA_GPIO_TO_IRQ(NCT1008_THERM2_GPIO),
275                 .platform_data = &ventana_nct1008_pdata,
276         },
277
278 #ifdef CONFIG_SENSORS_AK8975
279         {
280                 I2C_BOARD_INFO("akm8975", 0x0C),
281                 .irq = TEGRA_GPIO_TO_IRQ(AKM8975_IRQ_GPIO),
282         },
283 #endif
284 };
285
286 static struct i2c_board_info ventana_i2c6_board_info[] = {
287         {
288                 I2C_BOARD_INFO("ov5650R", 0x36),
289                 .platform_data = &ventana_right_ov5650_data,
290         },
291         {
292                 I2C_BOARD_INFO("sh532u", 0x72),
293                 .platform_data = &sh532u_right_pdata,
294         },
295 };
296
297 static struct i2c_board_info ventana_i2c7_board_info[] = {
298         {
299                 I2C_BOARD_INFO("ov5650L", 0x36),
300                 .platform_data = &ventana_left_ov5650_data,
301         },
302         {
303                 I2C_BOARD_INFO("sh532u", 0x72),
304                 .platform_data = &sh532u_left_pdata,
305         },
306 };
307
308 static struct i2c_board_info ventana_i2c8_board_info[] = {
309         {
310                 I2C_BOARD_INFO("ov2710", 0x36),
311                 .platform_data = &ventana_ov2710_data,
312         },
313 };
314
315 /* MPU board file definition   */
316 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
317 #define MPU_GYRO_NAME           "mpu3050"
318 #endif
319 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU6050)
320 #define MPU_GYRO_NAME           "mpu6050"
321 #endif
322 static struct mpu_platform_data mpu_gyro_data = {
323         .int_config     = 0x10,
324         .level_shifter  = 0,
325         .orientation    = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h    */
326 };
327
328 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
329 static struct ext_slave_platform_data mpu_accel_data = {
330         .address        = MPU_ACCEL_ADDR,
331         .irq            = 0,
332         .adapt_num      = MPU_ACCEL_BUS_NUM,
333         .bus            = EXT_SLAVE_BUS_SECONDARY,
334         .orientation    = MPU_ACCEL_ORIENTATION,        /* Located in board_[platformname].h    */
335 };
336 #endif
337
338 static struct ext_slave_platform_data mpu_compass_data = {
339         .address        = MPU_COMPASS_ADDR,
340         .irq            = 0,
341         .adapt_num      = MPU_COMPASS_BUS_NUM,
342         .bus            = EXT_SLAVE_BUS_PRIMARY,
343         .orientation    = MPU_COMPASS_ORIENTATION,      /* Located in board_[platformname].h    */
344 };
345
346 static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
347         {
348                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
349                 .irq = TEGRA_GPIO_TO_IRQ(MPU_GYRO_IRQ_GPIO),
350                 .platform_data = &mpu_gyro_data,
351         },
352 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
353         {
354                 I2C_BOARD_INFO(MPU_ACCEL_NAME, MPU_ACCEL_ADDR),
355 #if     MPU_ACCEL_IRQ_GPIO
356                 .irq = TEGRA_GPIO_TO_IRQ(MPU_ACCEL_IRQ_GPIO),
357 #endif
358                 .platform_data = &mpu_accel_data,
359         },
360 #endif
361 };
362
363 static struct i2c_board_info __initdata inv_mpu_i2c4_board_info[] = {
364         {
365                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
366 #if     MPU_COMPASS_IRQ_GPIO
367                 .irq = TEGRA_GPIO_TO_IRQ(MPU_COMPASS_IRQ_GPIO),
368 #endif
369                 .platform_data = &mpu_compass_data,
370         },
371 };
372
373 static void mpuirq_init(void)
374 {
375         int ret = 0;
376
377         pr_info("*** MPU START *** mpuirq_init...\n");
378
379 #if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
380 #if     MPU_ACCEL_IRQ_GPIO
381         /* ACCEL-IRQ assignment */
382         tegra_gpio_enable(MPU_ACCEL_IRQ_GPIO);
383         ret = gpio_request(MPU_ACCEL_IRQ_GPIO, MPU_ACCEL_NAME);
384         if (ret < 0) {
385                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
386                 return;
387         }
388
389         ret = gpio_direction_input(MPU_ACCEL_IRQ_GPIO);
390         if (ret < 0) {
391                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
392                 gpio_free(MPU_ACCEL_IRQ_GPIO);
393                 return;
394         }
395 #endif
396 #endif
397
398         /* MPU-IRQ assignment */
399         tegra_gpio_enable(MPU_GYRO_IRQ_GPIO);
400         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
401         if (ret < 0) {
402                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
403                 return;
404         }
405
406         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
407         if (ret < 0) {
408                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
409                 gpio_free(MPU_GYRO_IRQ_GPIO);
410                 return;
411         }
412         pr_info("*** MPU END *** mpuirq_init...\n");
413
414         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
415                 ARRAY_SIZE(inv_mpu_i2c2_board_info));
416         i2c_register_board_info(MPU_COMPASS_BUS_NUM, inv_mpu_i2c4_board_info,
417                 ARRAY_SIZE(inv_mpu_i2c4_board_info));
418 }
419
420 int __init ventana_sensors_init(void)
421 {
422         struct board_info BoardInfo;
423
424         ventana_isl29018_init();
425 #ifdef CONFIG_SENSORS_AK8975
426         ventana_akm8975_init();
427 #endif
428         mpuirq_init();
429         ventana_nct1008_init();
430
431         i2c_register_board_info(0, ventana_i2c0_board_info,
432                 ARRAY_SIZE(ventana_i2c0_board_info));
433
434         tegra_get_board_info(&BoardInfo);
435
436         /*
437          * battery driver is supported on FAB.D boards and above only,
438          * since they have the necessary hardware rework
439          */
440         if (BoardInfo.sku > 0) {
441                 i2c_register_board_info(2, ventana_i2c2_board_info,
442                         ARRAY_SIZE(ventana_i2c2_board_info));
443         }
444
445         i2c_register_board_info(3, ventana_i2c3_board_info_ssl3250a,
446                 ARRAY_SIZE(ventana_i2c3_board_info_ssl3250a));
447
448         i2c_register_board_info(4, ventana_i2c4_board_info,
449                 ARRAY_SIZE(ventana_i2c4_board_info));
450
451         i2c_register_board_info(6, ventana_i2c6_board_info,
452                 ARRAY_SIZE(ventana_i2c6_board_info));
453
454         i2c_register_board_info(7, ventana_i2c7_board_info,
455                 ARRAY_SIZE(ventana_i2c7_board_info));
456
457         i2c_register_board_info(8, ventana_i2c8_board_info,
458                 ARRAY_SIZE(ventana_i2c8_board_info));
459
460         return 0;
461 }
462
463 #ifdef CONFIG_TEGRA_CAMERA
464
465 struct tegra_camera_gpios {
466         const char *name;
467         int gpio;
468         bool tegra_internal_gpio;
469         int enabled;
470 };
471
472 #define TEGRA_CAMERA_GPIO(_name, _gpio, _tegra_internal_gpio, _enabled) \
473         {                                                               \
474                 .name = _name,                                          \
475                 .gpio = _gpio,                                          \
476                 .tegra_internal_gpio = _tegra_internal_gpio,            \
477                 .enabled = _enabled,                                    \
478         }
479
480 static struct tegra_camera_gpios ventana_camera_gpio_keys[] = {
481         [0] = TEGRA_CAMERA_GPIO("camera_power_en", CAMERA_POWER_GPIO, true, 1),
482         [1] = TEGRA_CAMERA_GPIO("camera_csi_sel", CAMERA_CSI_MUX_SEL_GPIO, true, 0),
483         [2] = TEGRA_CAMERA_GPIO("torch_gpio_act", CAMERA_FLASH_ACT_GPIO, true, 0),
484
485         [3] = TEGRA_CAMERA_GPIO("en_avdd_csi", AVDD_DSI_CSI_ENB_GPIO, false, 1),
486         [4] = TEGRA_CAMERA_GPIO("cam_i2c_mux_rst_lo", CAM_I2C_MUX_RST_GPIO, false, 1),
487
488         [5] = TEGRA_CAMERA_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, false, 0),
489         [6] = TEGRA_CAMERA_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, false, 0),
490         [7] = TEGRA_CAMERA_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, false, 1),
491
492         [8] = TEGRA_CAMERA_GPIO("cam3_af_pwdn_lo", CAM3_AF_PWR_DN_L_GPIO, false, 0),
493         [9] = TEGRA_CAMERA_GPIO("cam3_pwdn", CAM3_PWR_DN_GPIO, false, 0),
494         [10] = TEGRA_CAMERA_GPIO("cam3_rst_lo", CAM3_RST_L_GPIO, false, 1),
495
496         [11] = TEGRA_CAMERA_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, false, 0),
497         [12] = TEGRA_CAMERA_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, false, 0),
498         [13] = TEGRA_CAMERA_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, false, 1),
499 };
500
501 int __init ventana_camera_late_init(void)
502 {
503         int ret;
504         int i;
505         struct regulator *cam_ldo6 = NULL;
506
507         if (!machine_is_ventana())
508                 return 0;
509
510         cam_ldo6 = regulator_get(NULL, "vdd_ldo6");
511         if (IS_ERR_OR_NULL(cam_ldo6)) {
512                 pr_err("%s: Couldn't get regulator ldo6\n", __func__);
513                 return PTR_ERR(cam_ldo6);
514         }
515
516         ret = regulator_enable(cam_ldo6);
517         if (ret){
518                 pr_err("%s: Failed to enable ldo6\n", __func__);
519                 goto fail_put_regulator_ldo6;
520         }
521
522         i2c_new_device(i2c_get_adapter(3), ventana_i2c3_board_info_tca6416);
523
524         for (i = 0; i < ARRAY_SIZE(ventana_camera_gpio_keys); i++) {
525
526                 if (ventana_camera_gpio_keys[i].tegra_internal_gpio)
527                         tegra_gpio_enable(ventana_camera_gpio_keys[i].gpio);
528
529                 ret = gpio_request(ventana_camera_gpio_keys[i].gpio,
530                         ventana_camera_gpio_keys[i].name);
531                 if (ret < 0) {
532                         pr_err("%s: gpio_request failed for gpio #%d\n",
533                                 __func__, i);
534                         goto fail_free_gpio;
535                 }
536
537                 gpio_direction_output(ventana_camera_gpio_keys[i].gpio,
538                         ventana_camera_gpio_keys[i].enabled);
539
540                 gpio_export(ventana_camera_gpio_keys[i].gpio, false);
541         }
542
543         ventana_cam_fixed_voltage_regulator_init();
544
545         cam1_2v8 = regulator_get(NULL, "cam1_2v8");
546         if (WARN_ON(IS_ERR(cam1_2v8))) {
547                 pr_err("%s: couldn't get regulator cam1_2v8: %ld\n",
548                                 __func__, PTR_ERR(cam1_2v8));
549                 ret = PTR_ERR(cam1_2v8);
550                 goto fail_free_gpio;
551         } else {
552                 regulator_enable(cam1_2v8);
553         }
554
555         cam2_2v8 = regulator_get(NULL, "cam2_2v8");
556         if (WARN_ON(IS_ERR(cam2_2v8))) {
557                 pr_err("%s: couldn't get regulator cam2_2v8: %ld\n",
558                                 __func__, PTR_ERR(cam2_2v8));
559                 ret = PTR_ERR(cam2_2v8);
560                 goto fail_put_regulator_cam1_2v8;
561         } else {
562                 regulator_enable(cam2_2v8);
563         }
564
565         i2c_new_device(i2c_get_adapter(3), ventana_i2c3_board_info_pca9546);
566
567         ventana_ov2710_power_off();
568         ventana_left_ov5650_power_off();
569         ventana_right_ov5650_power_off();
570
571         ret = regulator_disable(cam_ldo6);
572         if (ret){
573                 pr_err("%s: Failed to disable ldo6\n", __func__);
574                 goto fail_put_regulator_cam2_2v8;
575         }
576
577         regulator_put(cam_ldo6);
578         return 0;
579
580 fail_put_regulator_cam2_2v8:
581         regulator_put(cam2_2v8);
582
583 fail_put_regulator_cam1_2v8:
584         regulator_put(cam1_2v8);
585
586 fail_free_gpio:
587         while (i--)
588                 gpio_free(ventana_camera_gpio_keys[i].gpio);
589
590 fail_put_regulator_ldo6:
591         regulator_put(cam_ldo6);
592         return ret;
593 }
594
595 late_initcall(ventana_camera_late_init);
596
597 #endif /* CONFIG_TEGRA_CAMERA */