arm: tegra: cardhu: Setting the gpio pins properly.
[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) 2011, NVIDIA, All Rights Reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include <linux/i2c.h>
22 #include <linux/delay.h>
23 #include <linux/regulator/consumer.h>
24 #include <linux/i2c/pca954x.h>
25 #include <linux/i2c/pca953x.h>
26 #include <linux/nct1008.h>
27 #include <mach/fb.h>
28 #include <mach/gpio.h>
29 #include <media/ov5650.h>
30 #include <media/ov2710.h>
31 #include <generated/mach-types.h>
32 #include "gpio-names.h"
33 #include "board.h"
34 #include <linux/mpu.h>
35
36 #include <mach/gpio.h>
37
38 #include "gpio-names.h"
39 #include "board-cardhu.h"
40
41 static struct regulator *cardhu_1v8_cam1 = NULL;
42 static struct regulator *cardhu_1v8_cam2 = NULL;
43 static struct regulator *cardhu_1v8_cam3 = NULL;
44 static struct regulator *cardhu_avdd_dsi_csi = NULL;
45 static struct regulator *cardhu_vdd_2v8_cam1 = NULL;
46 static struct regulator *cardhu_vdd_2v8_cam2 = NULL;
47 static struct regulator *cardhu_vdd_cam3 = NULL;
48
49 static struct board_info board_info;
50
51 #ifdef CONFIG_I2C_MUX_PCA954x
52 static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
53         { .adap_id = PCA954x_I2C_BUS0, },
54         { .adap_id = PCA954x_I2C_BUS1, },
55         { .adap_id = PCA954x_I2C_BUS2, },
56         { .adap_id = PCA954x_I2C_BUS3, },
57 };
58
59 static struct pca954x_platform_data cardhu_pca954x_data = {
60         .modes    = cardhu_pca954x_modes,
61         .num_modes      = ARRAY_SIZE(cardhu_pca954x_modes),
62 };
63 #endif
64
65 static int cardhu_camera_init(void)
66 {
67         int ret;
68
69         /* Boards E1198 and E1291 are of Cardhu personality
70          * and donot have TCA6416 exp for camera */
71         if ((board_info.board_id == BOARD_E1198) ||
72                 (board_info.board_id == BOARD_E1291)) {
73                 tegra_gpio_enable(CAM1_POWER_DWN_GPIO);
74                 ret = gpio_request(CAM1_POWER_DWN_GPIO, "camera_power_en");
75                 if (ret < 0)
76                         pr_err("%s: gpio_request failed for gpio %s\n",
77                                 __func__, "CAM1_POWER_DWN_GPIO");
78                                 tegra_gpio_enable(CAM3_POWER_DWN_GPIO);
79                 ret = gpio_request(CAM3_POWER_DWN_GPIO, "cam3_power_en");
80                 if (ret < 0)
81                         pr_err("%s: gpio_request failed for gpio %s\n",
82                                 __func__, "CAM3_POWER_DWN_GPIO");
83
84                 tegra_gpio_enable(CAM2_POWER_DWN_GPIO);
85                 ret = gpio_request(CAM2_POWER_DWN_GPIO, "camera2_power_en");
86                 if (ret < 0)
87                         pr_err("%s: gpio_request failed for gpio %s\n",
88                                 __func__, "CAM2_POWER_DWN_GPIO");
89
90                 tegra_gpio_enable(OV5650_RESETN_GPIO);
91                 ret = gpio_request(OV5650_RESETN_GPIO, "camera_reset");
92                 if (ret < 0)
93                         pr_err("%s: gpio_request failed for gpio %s\n",
94                                 __func__, "OV5650_RESETN_GPIO");
95
96                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
97                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
98                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
99                 mdelay(10);
100
101                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
102                 mdelay(5);
103                 gpio_direction_output(OV5650_RESETN_GPIO, 0);
104                 mdelay(5);
105                 gpio_direction_output(OV5650_RESETN_GPIO, 1);
106                 mdelay(5);
107         }
108
109         /* To select the CSIB MUX either for cam2 or cam3 */
110         tegra_gpio_enable(CAMERA_CSI_MUX_SEL_GPIO);
111         ret = gpio_request(CAMERA_CSI_MUX_SEL_GPIO, "camera_csi_sel");
112         if (ret < 0)
113                 pr_err("%s: gpio_request failed for gpio %s\n",
114                         __func__, "CAMERA_CSI_MUX_SEL_GPIO");
115         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
116         gpio_export(CAMERA_CSI_MUX_SEL_GPIO, false);
117
118         return 0;
119 }
120
121 static int cardhu_left_ov5650_power_on(void)
122 {
123         /* Boards E1198 and E1291 are of Cardhu personality
124          * and donot have TCA6416 exp for camera */
125         if ((board_info.board_id == BOARD_E1198) ||
126                 (board_info.board_id == BOARD_E1291)) {
127
128                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
129                 mdelay(10);
130
131                 if (cardhu_vdd_2v8_cam1 == NULL) {
132                         cardhu_vdd_2v8_cam1 = regulator_get(NULL, "vdd_2v8_cam1");
133                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam1))) {
134                                 pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n",
135                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam1));
136                                 goto reg_alloc_fail;
137                         }
138                 }
139                 regulator_enable(cardhu_vdd_2v8_cam1);
140                 mdelay(5);
141         }
142
143         /* Enable VDD_1V8_Cam1 */
144         if (cardhu_1v8_cam1 == NULL) {
145                 cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
146                 if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
147                         pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
148                                 __func__, PTR_ERR(cardhu_1v8_cam1));
149                         goto reg_alloc_fail;
150                 }
151         }
152         regulator_enable(cardhu_1v8_cam1);
153
154         /* Enable AVDD_CSI_DSI */
155         if (cardhu_avdd_dsi_csi == NULL) {
156                 cardhu_avdd_dsi_csi = regulator_get(NULL, "avdd_dsi_csi");
157                 if (WARN_ON(IS_ERR(cardhu_avdd_dsi_csi))) {
158                         pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
159                                 __func__, PTR_ERR(cardhu_avdd_dsi_csi));
160                         goto reg_alloc_fail;
161                 }
162         }
163         regulator_enable(cardhu_avdd_dsi_csi);
164
165         mdelay(5);
166         return 0;
167
168 reg_alloc_fail:
169         if (cardhu_1v8_cam1) {
170                 regulator_put(cardhu_1v8_cam1);
171                 cardhu_1v8_cam1 = NULL;
172         }
173         if (cardhu_avdd_dsi_csi) {
174                 regulator_put(cardhu_avdd_dsi_csi);
175                 cardhu_avdd_dsi_csi = NULL;
176         }
177         if (cardhu_vdd_2v8_cam1) {
178                 regulator_put(cardhu_vdd_2v8_cam1);
179                 cardhu_vdd_2v8_cam1 = NULL;
180         }
181
182         return -ENODEV;
183
184 }
185
186 static int cardhu_left_ov5650_power_off(void)
187 {
188         /* Boards E1198 and E1291 are of Cardhu personality
189          * and donot have TCA6416 exp for camera */
190         if ((board_info.board_id == BOARD_E1198) ||
191                 (board_info.board_id == BOARD_E1291)) {
192                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
193         }
194         if (cardhu_1v8_cam1)
195                 regulator_disable(cardhu_1v8_cam1);
196         if (cardhu_avdd_dsi_csi)
197                 regulator_disable(cardhu_avdd_dsi_csi);
198         if (cardhu_vdd_2v8_cam1)
199                 regulator_disable(cardhu_vdd_2v8_cam1);
200
201         return 0;
202 }
203
204 struct ov5650_platform_data cardhu_left_ov5650_data = {
205         .power_on = cardhu_left_ov5650_power_on,
206         .power_off = cardhu_left_ov5650_power_off,
207 };
208
209 static int cardhu_right_ov5650_power_on(void)
210 {
211         /* Boards E1198 and E1291 are of Cardhu personality
212          * and donot have TCA6416 exp for camera */
213         if (board_info.board_id == BOARD_E1198)
214                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
215         if (board_info.board_id == BOARD_E1291)
216                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
217         mdelay(10);
218
219         if ((board_info.board_id == BOARD_E1198) ||
220                 (board_info.board_id == BOARD_E1291)) {
221
222                 if (cardhu_vdd_2v8_cam2 == NULL) {
223                         cardhu_vdd_2v8_cam2 = regulator_get(NULL, "vdd_2v8_cam2");
224                         if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam2))) {
225                                 pr_err("%s: couldn't get regulator vdd_2v8_cam2: %ld\n",
226                                         __func__, PTR_ERR(cardhu_vdd_2v8_cam2));
227                                 goto reg_alloc_fail;
228                         }
229                 }
230                 regulator_enable(cardhu_vdd_2v8_cam2);
231                 mdelay(5);
232         }
233
234         /* Enable VDD_1V8_Cam2 */
235         if (cardhu_1v8_cam2 == NULL) {
236                 cardhu_1v8_cam2 = regulator_get(NULL, "vdd_1v8_cam2");
237                 if (WARN_ON(IS_ERR(cardhu_1v8_cam2))) {
238                         pr_err("%s: couldn't get regulator vdd_1v8_cam2: %ld\n",
239                                 __func__, PTR_ERR(cardhu_1v8_cam2));
240                         goto reg_alloc_fail;
241                 }
242         }
243         regulator_enable(cardhu_1v8_cam2);
244
245         /* Enable AVDD_CSI_DSI */
246         if (cardhu_avdd_dsi_csi == NULL) {
247                 cardhu_avdd_dsi_csi = regulator_get(NULL, "avdd_dsi_csi");
248                 if (WARN_ON(IS_ERR(cardhu_avdd_dsi_csi))) {
249                         pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
250                                 __func__, PTR_ERR(cardhu_avdd_dsi_csi));
251                         goto reg_alloc_fail;
252                 }
253         }
254         regulator_enable(cardhu_avdd_dsi_csi);
255
256         mdelay(5);
257         return 0;
258
259 reg_alloc_fail:
260         if (cardhu_1v8_cam2) {
261                 regulator_put(cardhu_1v8_cam2);
262                 cardhu_1v8_cam2 = NULL;
263         }
264         if (cardhu_avdd_dsi_csi) {
265                 regulator_put(cardhu_avdd_dsi_csi);
266                 cardhu_avdd_dsi_csi = NULL;
267         }
268         if (cardhu_vdd_2v8_cam2) {
269                 regulator_put(cardhu_vdd_2v8_cam2);
270                 cardhu_vdd_2v8_cam2 = NULL;
271         }
272
273         return -ENODEV;
274
275 }
276
277 static int cardhu_right_ov5650_power_off(void)
278 {
279         /* Boards E1198 and E1291 are of Cardhu personality
280          * and donot have TCA6416 exp for camera */
281         if (board_info.board_id == BOARD_E1198)
282                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
283         if (board_info.board_id == BOARD_E1291)
284                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
285
286         if (cardhu_1v8_cam2)
287                 regulator_disable(cardhu_1v8_cam2);
288         if (cardhu_avdd_dsi_csi)
289                 regulator_disable(cardhu_avdd_dsi_csi);
290         if (cardhu_vdd_2v8_cam2)
291                 regulator_disable(cardhu_vdd_2v8_cam2);
292
293         return 0;
294 }
295
296
297 struct ov5650_platform_data cardhu_right_ov5650_data = {
298         .power_on = cardhu_right_ov5650_power_on,
299         .power_off = cardhu_right_ov5650_power_off,
300 };
301
302 static int cardhu_ov2710_power_on(void)
303 {
304         /* CSI-B and front sensor are muxed on verbier */
305         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
306
307         /* Boards E1198 and E1291 are of Cardhu personality
308          * and donot have TCA6416 exp for camera */
309         if ((board_info.board_id == BOARD_E1198) ||
310                 (board_info.board_id == BOARD_E1291)) {
311                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
312                 mdelay(10);
313
314                 if (cardhu_vdd_cam3 == NULL) {
315                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
316                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
317                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
318                                         __func__, PTR_ERR(cardhu_vdd_cam3));
319                                 goto reg_alloc_fail;
320                         }
321                 }
322                 regulator_enable(cardhu_vdd_cam3);
323         }
324
325         /* Enable VDD_1V8_Cam3 */
326         if (cardhu_1v8_cam3 == NULL) {
327                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
328                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
329                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
330                                 __func__, PTR_ERR(cardhu_1v8_cam3));
331                         goto reg_alloc_fail;
332                 }
333         }
334         regulator_enable(cardhu_1v8_cam3);
335
336         /* Enable AVDD_CSI_DSI */
337         if (cardhu_avdd_dsi_csi == NULL) {
338                 cardhu_avdd_dsi_csi = regulator_get(NULL, "avdd_dsi_csi");
339                 if (WARN_ON(IS_ERR(cardhu_avdd_dsi_csi))) {
340                         pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
341                                 __func__, PTR_ERR(cardhu_avdd_dsi_csi));
342                         goto reg_alloc_fail;
343                 }
344         }
345         regulator_enable(cardhu_avdd_dsi_csi);
346         mdelay(5);
347
348         return 0;
349
350 reg_alloc_fail:
351         if (cardhu_1v8_cam3) {
352                 regulator_put(cardhu_1v8_cam3);
353                 cardhu_1v8_cam3 = NULL;
354         }
355         if (cardhu_avdd_dsi_csi) {
356                 regulator_put(cardhu_avdd_dsi_csi);
357                 cardhu_avdd_dsi_csi = NULL;
358         }
359         if (cardhu_vdd_cam3) {
360                 regulator_put(cardhu_vdd_cam3);
361                 cardhu_vdd_cam3 = NULL;
362         }
363
364         return -ENODEV;
365 }
366
367 static int cardhu_ov2710_power_off(void)
368 {
369         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
370
371         /* Boards E1198 and E1291 are of Cardhu personality
372          * and donot have TCA6416 exp for camera */
373         if ((board_info.board_id == BOARD_E1198) ||
374                 (board_info.board_id == BOARD_E1291))
375                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
376
377         if (cardhu_1v8_cam3)
378                 regulator_disable(cardhu_1v8_cam3);
379         if (cardhu_avdd_dsi_csi)
380                 regulator_disable(cardhu_avdd_dsi_csi);
381         if (cardhu_vdd_cam3)
382                 regulator_disable(cardhu_vdd_cam3);
383
384         return 0;
385 }
386
387 struct ov2710_platform_data cardhu_ov2710_data = {
388         .power_on = cardhu_ov2710_power_on,
389         .power_off = cardhu_ov2710_power_off,
390 };
391
392 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
393 #ifdef CONFIG_I2C_MUX_PCA954x
394         {
395                 I2C_BOARD_INFO("pca9546", 0x70),
396                 .platform_data = &cardhu_pca954x_data,
397         },
398 #endif
399 };
400 static struct i2c_board_info cardhu_i2c6_board_info[] = {
401         {
402                 I2C_BOARD_INFO("ov5650L", 0x36),
403                 .platform_data = &cardhu_left_ov5650_data,
404         },
405         {
406                 I2C_BOARD_INFO("sh532u", 0x72),
407         },
408 };
409
410 static struct i2c_board_info cardhu_i2c7_board_info[] = {
411         {
412                 I2C_BOARD_INFO("ov5650R", 0x36),
413                 .platform_data = &cardhu_right_ov5650_data,
414         },
415 };
416
417 static struct i2c_board_info cardhu_i2c8_board_info[] = {
418         {
419                 I2C_BOARD_INFO("ov2710", 0x36),
420                 .platform_data = &cardhu_ov2710_data,
421         },
422 };
423
424 static struct nct1008_platform_data cardhu_nct1008_pdata = {
425         .supported_hwrev = true,
426         .ext_range = false,
427         .conv_rate = 0x08,
428         .offset = 0,
429         .hysteresis = 5,
430         .shutdown_ext_limit = 75,
431         .shutdown_local_limit = 75,
432         .throttling_ext_limit = 60,
433         .alarm_fn = NULL,
434 };
435
436 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
437         {
438                 I2C_BOARD_INFO("bq27510", 0x55),
439                 .irq = AC_PRESENT_GPIO,
440         },
441 };
442
443 static struct i2c_board_info cardhu_i2c4_board_info[] = {
444         {
445                 I2C_BOARD_INFO("nct1008", 0x4C),
446                 .platform_data = &cardhu_nct1008_pdata,
447                 .irq = -1,
448         }
449 };
450
451 static int cardhu_nct1008_init(void)
452 {
453         int nct1008_port = -1;
454         int ret;
455
456         if ((board_info.board_id == BOARD_E1198) ||
457                 (board_info.board_id == BOARD_E1291)) {
458                 nct1008_port = TEGRA_GPIO_PCC2;
459         } else if ((board_info.board_id == BOARD_E1186) ||
460                 (board_info.board_id == BOARD_E1187)) {
461                 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
462                 /* nct1008_port = TEGRA_GPIO_PH7; */
463         }
464
465         if (nct1008_port >= 0) {
466                 /* FIXME: enable irq when throttling is supported */
467                 /* cardhu_i2c4_board_info[0].irq = */
468                 /* TEGRA_GPIO_TO_IRQ(nct1008_port); */
469
470                 ret = gpio_request(nct1008_port, "temp_alert");
471                 if (ret < 0)
472                         return ret;
473
474                 ret = gpio_direction_input(nct1008_port);
475                 if (ret < 0)
476                         gpio_free(nct1008_port);
477                 else
478                         tegra_gpio_enable(nct1008_port);
479
480         }
481         return ret;
482 }
483
484 #if defined(CONFIG_GPIO_PCA953X)
485 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
486         .gpio_base      = PMU_TCA6416_GPIO_BASE,
487 };
488
489 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
490         {
491                 I2C_BOARD_INFO("tca6416", 0x20),
492                 .platform_data = &cardhu_pmu_tca6416_data,
493         },
494 };
495
496 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
497         .gpio_base      = CAM_TCA6416_GPIO_BASE,
498 };
499
500 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
501         {
502                 I2C_BOARD_INFO("tca6416", 0x20),
503                 .platform_data = &cardhu_cam_tca6416_data,
504         },
505 };
506
507 static int __init pmu_tca6416_init(void)
508 {
509         if ((board_info.board_id == BOARD_E1198) ||
510                 (board_info.board_id == BOARD_E1291))
511                         return 0;
512
513         pr_info("Registering pmu pca6416\n");
514         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
515                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
516         return 0;
517 }
518
519 static int __init cam_tca6416_init(void)
520 {
521         /* Boards E1198 and E1291 are of Cardhu personality
522          * and donot have TCA6416 exp for camera */
523         if ((board_info.board_id == BOARD_E1198) ||
524                 (board_info.board_id == BOARD_E1291))
525                 return 0;
526
527         pr_info("Registering cam pca6416\n");
528         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
529                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
530         return 0;
531 }
532 #else
533 static int __init pmu_tca6416_init(void)
534 {
535         return 0;
536 }
537
538 static int __init cam_tca6416_init(void)
539 {
540         return 0;
541 }
542 #endif
543
544 #ifdef CONFIG_SENSORS_MPU3050
545 #define SENSOR_MPU_NAME "mpu3050"
546 static struct mpu3050_platform_data mpu3050_data = {
547         .int_config  = 0x10,
548         .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for MPU on cardhu */
549         .level_shifter = 0,
550
551         .accel = {
552         .get_slave_descr = get_accel_slave_descr,
553         .adapt_num   = 2,
554         .bus         = EXT_SLAVE_BUS_SECONDARY,
555         .address     = 0x0F,
556         .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for Kionix on cardhu */
557         },
558
559         .compass = {
560         .get_slave_descr = get_compass_slave_descr,
561         .adapt_num   = 2,
562         .bus         = EXT_SLAVE_BUS_PRIMARY,
563         .address     = 0x0C,
564         .orientation = { 1, 0, 0, 0, -1, 0, 0, 0, -1 },  /* Orientation matrix for AKM on cardhu */
565         },
566 };
567
568 static struct i2c_board_info __initdata mpu3050_i2c0_boardinfo[] = {
569         {
570                 I2C_BOARD_INFO(SENSOR_MPU_NAME, 0x68),
571                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PX1),
572                 .platform_data = &mpu3050_data,
573         },
574 };
575
576 static void cardhu_mpuirq_init(void)
577 {
578         pr_info("*** MPU START *** cardhu_mpuirq_init...\n");
579         tegra_gpio_enable(TEGRA_GPIO_PX1);
580         gpio_request(TEGRA_GPIO_PX1, SENSOR_MPU_NAME);
581         gpio_direction_input(TEGRA_GPIO_PX1);
582         pr_info("*** MPU END *** cardhu_mpuirq_init...\n");
583 }
584 #endif
585
586
587 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
588         {
589                 I2C_BOARD_INFO("isl29028", 0x44),
590         }
591 };
592
593 int __init cardhu_sensors_init(void)
594 {
595         int err;
596
597         tegra_get_board_info(&board_info);
598
599         cardhu_camera_init();
600         cam_tca6416_init();
601
602         i2c_register_board_info(2, cardhu_i2c3_board_info,
603                 ARRAY_SIZE(cardhu_i2c3_board_info));
604
605         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
606          * Front camera is on BUS2 */
607         i2c_register_board_info(PCA954x_I2C_BUS0, cardhu_i2c6_board_info,
608                 ARRAY_SIZE(cardhu_i2c6_board_info));
609
610         i2c_register_board_info(PCA954x_I2C_BUS1, cardhu_i2c7_board_info,
611                 ARRAY_SIZE(cardhu_i2c7_board_info));
612
613         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
614                 ARRAY_SIZE(cardhu_i2c8_board_info));
615
616         pmu_tca6416_init();
617
618         i2c_register_board_info(4, cardhu_i2c4_board_info,
619                 ARRAY_SIZE(cardhu_i2c4_board_info));
620
621         if (board_info.board_id == BOARD_E1291)
622                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
623                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
624
625         i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
626                 ARRAY_SIZE(cardhu_i2c2_isl_board_info));
627
628         err = cardhu_nct1008_init();
629         if (err)
630                 return err;
631
632 #ifdef CONFIG_SENSORS_MPU3050
633         cardhu_mpuirq_init();
634 #endif
635
636         if (ARRAY_SIZE(cardhu_i2c3_board_info))
637                 i2c_register_board_info(3, cardhu_i2c3_board_info,
638                         ARRAY_SIZE(cardhu_i2c3_board_info));
639
640 #ifdef CONFIG_SENSORS_MPU3050
641         i2c_register_board_info(2, mpu3050_i2c0_boardinfo,
642                 ARRAY_SIZE(mpu3050_i2c0_boardinfo));
643 #endif
644
645         return 0;
646 }
647
648 #if defined(CONFIG_GPIO_PCA953X)
649 struct ov5650_gpios {
650         const char *name;
651         int gpio;
652         int enabled;
653 };
654
655 #define OV5650_GPIO(_name, _gpio, _enabled)             \
656         {                                               \
657                 .name = _name,                          \
658                 .gpio = _gpio,                          \
659                 .enabled = _enabled,                    \
660         }
661
662 static struct ov5650_gpios ov5650_gpio_keys[] = {
663         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
664         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
665         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 1),
666         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
667         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
668         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
669         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 1),
670         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
671         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
672         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
673         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 1),
674         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
675         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
676         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
677         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
678 };
679
680 int __init cardhu_ov5650_late_init(void)
681 {
682         int ret;
683         int i;
684
685         printk("%s: \n", __func__);
686         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
687                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
688                         ov5650_gpio_keys[i].name);
689                 if (ret < 0) {
690                         printk("%s: gpio_request failed for gpio #%d\n",
691                                 __func__, i);
692                         goto fail;
693                 }
694                 printk("%s: enable - %d\n", __func__, i);
695                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
696                         ov5650_gpio_keys[i].enabled);
697                 gpio_export(ov5650_gpio_keys[i].gpio, false);
698         }
699
700         return 0;
701
702 fail:
703         while (i--)
704                 gpio_free(ov5650_gpio_keys[i].gpio);
705         return ret;
706 }
707
708 late_initcall(cardhu_ov5650_late_init);
709 #endif