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