ARM: tegra: cardhu: sensor: support for rear right camera
[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                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
194                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
195         }
196         if (cardhu_1v8_cam1)
197                 regulator_disable(cardhu_1v8_cam1);
198         if (cardhu_avdd_dsi_csi)
199                 regulator_disable(cardhu_avdd_dsi_csi);
200         if (cardhu_vdd_2v8_cam1)
201                 regulator_disable(cardhu_vdd_2v8_cam1);
202
203         return 0;
204 }
205
206 struct ov5650_platform_data cardhu_left_ov5650_data = {
207         .power_on = cardhu_left_ov5650_power_on,
208         .power_off = cardhu_left_ov5650_power_off,
209 };
210
211 static int cardhu_right_ov5650_power_on(void)
212 {
213         /* Boards E1198 and E1291 are of Cardhu personality
214          * and donot have TCA6416 exp for camera */
215         if ((board_info.board_id == BOARD_E1198) ||
216                 (board_info.board_id == BOARD_E1291)) {
217
218                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
219                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
220                 mdelay(10);
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                 (board_info.board_id == BOARD_E1291)) {
283                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
284                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
285         }
286
287         if (cardhu_1v8_cam2)
288                 regulator_disable(cardhu_1v8_cam2);
289         if (cardhu_avdd_dsi_csi)
290                 regulator_disable(cardhu_avdd_dsi_csi);
291         if (cardhu_vdd_2v8_cam2)
292                 regulator_disable(cardhu_vdd_2v8_cam2);
293
294         return 0;
295 }
296
297
298 struct ov5650_platform_data cardhu_right_ov5650_data = {
299         .power_on = cardhu_right_ov5650_power_on,
300         .power_off = cardhu_right_ov5650_power_off,
301 };
302
303 static int cardhu_ov2710_power_on(void)
304 {
305         /* CSI-B and front sensor are muxed on verbier */
306         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
307
308         /* Boards E1198 and E1291 are of Cardhu personality
309          * and donot have TCA6416 exp for camera */
310         if ((board_info.board_id == BOARD_E1198) ||
311                 (board_info.board_id == BOARD_E1291)) {
312
313                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
314                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
315                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
316                 mdelay(10);
317
318                 if (cardhu_vdd_cam3 == NULL) {
319                         cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
320                         if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
321                                 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
322                                         __func__, PTR_ERR(cardhu_vdd_cam3));
323                                 goto reg_alloc_fail;
324                         }
325                 }
326                 regulator_enable(cardhu_vdd_cam3);
327         }
328
329         /* Enable VDD_1V8_Cam3 */
330         if (cardhu_1v8_cam3 == NULL) {
331                 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
332                 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
333                         pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
334                                 __func__, PTR_ERR(cardhu_1v8_cam3));
335                         goto reg_alloc_fail;
336                 }
337         }
338         regulator_enable(cardhu_1v8_cam3);
339
340         /* Enable AVDD_CSI_DSI */
341         if (cardhu_avdd_dsi_csi == NULL) {
342                 cardhu_avdd_dsi_csi = regulator_get(NULL, "avdd_dsi_csi");
343                 if (WARN_ON(IS_ERR(cardhu_avdd_dsi_csi))) {
344                         pr_err("%s: couldn't get regulator avdd_dsi_csi: %ld\n",
345                                 __func__, PTR_ERR(cardhu_avdd_dsi_csi));
346                         goto reg_alloc_fail;
347                 }
348         }
349         regulator_enable(cardhu_avdd_dsi_csi);
350         mdelay(5);
351
352         return 0;
353
354 reg_alloc_fail:
355         if (cardhu_1v8_cam3) {
356                 regulator_put(cardhu_1v8_cam3);
357                 cardhu_1v8_cam3 = NULL;
358         }
359         if (cardhu_avdd_dsi_csi) {
360                 regulator_put(cardhu_avdd_dsi_csi);
361                 cardhu_avdd_dsi_csi = NULL;
362         }
363         if (cardhu_vdd_cam3) {
364                 regulator_put(cardhu_vdd_cam3);
365                 cardhu_vdd_cam3 = NULL;
366         }
367
368         return -ENODEV;
369 }
370
371 static int cardhu_ov2710_power_off(void)
372 {
373         gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
374
375         /* Boards E1198 and E1291 are of Cardhu personality
376          * and donot have TCA6416 exp for camera */
377         if ((board_info.board_id == BOARD_E1198) ||
378                 (board_info.board_id == BOARD_E1291)) {
379                 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
380                 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
381                 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
382         }
383
384         if (cardhu_1v8_cam3)
385                 regulator_disable(cardhu_1v8_cam3);
386         if (cardhu_avdd_dsi_csi)
387                 regulator_disable(cardhu_avdd_dsi_csi);
388         if (cardhu_vdd_cam3)
389                 regulator_disable(cardhu_vdd_cam3);
390
391         return 0;
392 }
393
394 struct ov2710_platform_data cardhu_ov2710_data = {
395         .power_on = cardhu_ov2710_power_on,
396         .power_off = cardhu_ov2710_power_off,
397 };
398
399 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
400 #ifdef CONFIG_I2C_MUX_PCA954x
401         {
402                 I2C_BOARD_INFO("pca9546", 0x70),
403                 .platform_data = &cardhu_pca954x_data,
404         },
405 #endif
406 };
407 static struct i2c_board_info cardhu_i2c6_board_info[] = {
408         {
409                 I2C_BOARD_INFO("ov5650L", 0x36),
410                 .platform_data = &cardhu_left_ov5650_data,
411         },
412         {
413                 I2C_BOARD_INFO("sh532u", 0x72),
414         },
415 };
416
417 static struct i2c_board_info cardhu_i2c7_board_info[] = {
418         {
419                 I2C_BOARD_INFO("ov5650R", 0x36),
420                 .platform_data = &cardhu_right_ov5650_data,
421         },
422 };
423
424 static struct i2c_board_info cardhu_i2c8_board_info[] = {
425         {
426                 I2C_BOARD_INFO("ov2710", 0x36),
427                 .platform_data = &cardhu_ov2710_data,
428         },
429 };
430
431 static struct nct1008_platform_data cardhu_nct1008_pdata = {
432         .supported_hwrev = true,
433         .ext_range = false,
434         .conv_rate = 0x08,
435         .offset = 0,
436         .hysteresis = 5,
437         .shutdown_ext_limit = 75,
438         .shutdown_local_limit = 75,
439         .throttling_ext_limit = 60,
440         .alarm_fn = NULL,
441 };
442
443 static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
444         {
445                 I2C_BOARD_INFO("bq27510", 0x55),
446         },
447 };
448
449 static struct i2c_board_info cardhu_i2c4_board_info[] = {
450         {
451                 I2C_BOARD_INFO("nct1008", 0x4C),
452                 .platform_data = &cardhu_nct1008_pdata,
453                 .irq = -1,
454         }
455 };
456
457 static int cardhu_nct1008_init(void)
458 {
459         int nct1008_port = -1;
460         int ret;
461
462         if ((board_info.board_id == BOARD_E1198) ||
463                 (board_info.board_id == BOARD_E1291)) {
464                 nct1008_port = TEGRA_GPIO_PCC2;
465         } else if ((board_info.board_id == BOARD_E1186) ||
466                 (board_info.board_id == BOARD_E1187)) {
467                 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
468                 /* nct1008_port = TEGRA_GPIO_PH7; */
469         }
470
471         if (nct1008_port >= 0) {
472                 /* FIXME: enable irq when throttling is supported */
473                 /* cardhu_i2c4_board_info[0].irq = */
474                 /* TEGRA_GPIO_TO_IRQ(nct1008_port); */
475
476                 ret = gpio_request(nct1008_port, "temp_alert");
477                 if (ret < 0)
478                         return ret;
479
480                 ret = gpio_direction_input(nct1008_port);
481                 if (ret < 0)
482                         gpio_free(nct1008_port);
483                 else
484                         tegra_gpio_enable(nct1008_port);
485
486         }
487         return ret;
488 }
489
490 #if defined(CONFIG_GPIO_PCA953X)
491 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
492         .gpio_base      = PMU_TCA6416_GPIO_BASE,
493 };
494
495 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
496         {
497                 I2C_BOARD_INFO("tca6416", 0x20),
498                 .platform_data = &cardhu_pmu_tca6416_data,
499         },
500 };
501
502 static struct pca953x_platform_data cardhu_cam_tca6416_data = {
503         .gpio_base      = CAM_TCA6416_GPIO_BASE,
504 };
505
506 static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
507         {
508                 I2C_BOARD_INFO("tca6416", 0x20),
509                 .platform_data = &cardhu_cam_tca6416_data,
510         },
511 };
512
513 static int __init pmu_tca6416_init(void)
514 {
515         if ((board_info.board_id == BOARD_E1198) ||
516                 (board_info.board_id == BOARD_E1291))
517                         return 0;
518
519         pr_info("Registering pmu pca6416\n");
520         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
521                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
522         return 0;
523 }
524
525 static int __init cam_tca6416_init(void)
526 {
527         /* Boards E1198 and E1291 are of Cardhu personality
528          * and donot have TCA6416 exp for camera */
529         if ((board_info.board_id == BOARD_E1198) ||
530                 (board_info.board_id == BOARD_E1291))
531                 return 0;
532
533         pr_info("Registering cam pca6416\n");
534         i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
535                 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
536         return 0;
537 }
538 #else
539 static int __init pmu_tca6416_init(void)
540 {
541         return 0;
542 }
543
544 static int __init cam_tca6416_init(void)
545 {
546         return 0;
547 }
548 #endif
549
550 #ifdef CONFIG_SENSORS_MPU3050
551 #define SENSOR_MPU_NAME "mpu3050"
552 static struct mpu3050_platform_data mpu3050_data = {
553         .int_config  = 0x10,
554         .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for MPU on cardhu */
555         .level_shifter = 0,
556
557         .accel = {
558         .get_slave_descr = get_accel_slave_descr,
559         .adapt_num   = 2,
560         .bus         = EXT_SLAVE_BUS_SECONDARY,
561         .address     = 0x0F,
562         .orientation = { 0, -1, 0, -1, 0, 0, 0, 0, -1 },  /* Orientation matrix for Kionix on cardhu */
563         },
564
565         .compass = {
566         .get_slave_descr = get_compass_slave_descr,
567         .adapt_num   = 2,
568         .bus         = EXT_SLAVE_BUS_PRIMARY,
569         .address     = 0x0C,
570         .orientation = { 1, 0, 0, 0, -1, 0, 0, 0, -1 },  /* Orientation matrix for AKM on cardhu */
571         },
572 };
573
574 static struct i2c_board_info __initdata mpu3050_i2c0_boardinfo[] = {
575         {
576                 I2C_BOARD_INFO(SENSOR_MPU_NAME, 0x68),
577                 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PX1),
578                 .platform_data = &mpu3050_data,
579         },
580 };
581
582 static void cardhu_mpuirq_init(void)
583 {
584         pr_info("*** MPU START *** cardhu_mpuirq_init...\n");
585         tegra_gpio_enable(TEGRA_GPIO_PX1);
586         gpio_request(TEGRA_GPIO_PX1, SENSOR_MPU_NAME);
587         gpio_direction_input(TEGRA_GPIO_PX1);
588         pr_info("*** MPU END *** cardhu_mpuirq_init...\n");
589 }
590 #endif
591
592
593 static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
594         {
595                 I2C_BOARD_INFO("isl29028", 0x44),
596         }
597 };
598
599 int __init cardhu_sensors_init(void)
600 {
601         int err;
602
603         tegra_get_board_info(&board_info);
604
605         cardhu_camera_init();
606         cam_tca6416_init();
607
608         i2c_register_board_info(2, cardhu_i2c3_board_info,
609                 ARRAY_SIZE(cardhu_i2c3_board_info));
610
611         /* Left  camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
612          * Front camera is on BUS2 */
613         i2c_register_board_info(PCA954x_I2C_BUS0, cardhu_i2c6_board_info,
614                 ARRAY_SIZE(cardhu_i2c6_board_info));
615
616         i2c_register_board_info(PCA954x_I2C_BUS1, cardhu_i2c7_board_info,
617                 ARRAY_SIZE(cardhu_i2c7_board_info));
618
619         i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
620                 ARRAY_SIZE(cardhu_i2c8_board_info));
621
622         pmu_tca6416_init();
623
624         i2c_register_board_info(4, cardhu_i2c4_board_info,
625                 ARRAY_SIZE(cardhu_i2c4_board_info));
626
627         if (board_info.board_id == BOARD_E1291)
628                 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
629                         ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
630
631         i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
632                 ARRAY_SIZE(cardhu_i2c2_isl_board_info));
633
634         err = cardhu_nct1008_init();
635         if (err)
636                 return err;
637
638 #ifdef CONFIG_SENSORS_MPU3050
639         cardhu_mpuirq_init();
640 #endif
641
642         if (ARRAY_SIZE(cardhu_i2c3_board_info))
643                 i2c_register_board_info(3, cardhu_i2c3_board_info,
644                         ARRAY_SIZE(cardhu_i2c3_board_info));
645
646 #ifdef CONFIG_SENSORS_MPU3050
647         i2c_register_board_info(2, mpu3050_i2c0_boardinfo,
648                 ARRAY_SIZE(mpu3050_i2c0_boardinfo));
649 #endif
650
651         return 0;
652 }
653
654 #if defined(CONFIG_GPIO_PCA953X)
655 struct ov5650_gpios {
656         const char *name;
657         int gpio;
658         int enabled;
659 };
660
661 #define OV5650_GPIO(_name, _gpio, _enabled)             \
662         {                                               \
663                 .name = _name,                          \
664                 .gpio = _gpio,                          \
665                 .enabled = _enabled,                    \
666         }
667
668 static struct ov5650_gpios ov5650_gpio_keys[] = {
669         [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
670         [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
671         [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 1),
672         [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
673         [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
674         [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
675         [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 1),
676         [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
677         [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
678         [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
679         [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 1),
680         [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
681         [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
682         [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
683         [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
684 };
685
686 int __init cardhu_ov5650_late_init(void)
687 {
688         int ret;
689         int i;
690
691         printk("%s: \n", __func__);
692         for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
693                 ret = gpio_request(ov5650_gpio_keys[i].gpio,
694                         ov5650_gpio_keys[i].name);
695                 if (ret < 0) {
696                         printk("%s: gpio_request failed for gpio #%d\n",
697                                 __func__, i);
698                         goto fail;
699                 }
700                 printk("%s: enable - %d\n", __func__, i);
701                 gpio_direction_output(ov5650_gpio_keys[i].gpio,
702                         ov5650_gpio_keys[i].enabled);
703                 gpio_export(ov5650_gpio_keys[i].gpio, false);
704         }
705
706         return 0;
707
708 fail:
709         while (i--)
710                 gpio_free(ov5650_gpio_keys[i].gpio);
711         return ret;
712 }
713
714 late_initcall(cardhu_ov5650_late_init);
715 #endif