blob: e3f668f8b08c193e564d63099aab27319d3b122b [file] [log] [blame]
Chintan Pandya40762702011-12-06 13:47:06 +05301/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/i2c.h>
14#include <linux/i2c/sx150x.h>
15#include <linux/gpio.h>
16#include <linux/regulator/consumer.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <asm/mach-types.h>
20#include <mach/msm_iomap.h>
21#include <mach/board.h>
22#include <mach/irqs-7xxx.h>
23#include "devices-msm7x2xa.h"
24#include "board-msm7627a.h"
25
Suresh Vankadara87e195b2012-01-18 00:42:58 +053026#ifdef CONFIG_MSM_CAMERA_V4L2
27static uint32_t camera_off_gpio_table[] = {
28 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
29};
30
31static uint32_t camera_on_gpio_table[] = {
32 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
33};
34
35#ifdef CONFIG_MSM_CAMERA_FLASH
36static struct msm_camera_sensor_flash_src msm_flash_src = {
37 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
38 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
39 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
40};
41#endif
42
43static struct regulator_bulk_data regs_camera[] = {
44 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
45 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
46 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
47};
48
49static void msm_camera_vreg_config(int vreg_en)
50{
51 int rc = vreg_en ?
52 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
53 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
54
55 if (rc)
56 pr_err("%s: could not %sable regulators: %d\n",
57 __func__, vreg_en ? "en" : "dis", rc);
58}
59
60static int config_gpio_table(uint32_t *table, int len)
61{
62 int rc = 0, i = 0;
63
64 for (i = 0; i < len; i++) {
65 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
66 if (rc) {
67 pr_err("%s not able to get gpio\n", __func__);
68 for (i--; i >= 0; i--)
69 gpio_tlmm_config(camera_off_gpio_table[i],
70 GPIO_CFG_ENABLE);
71 break;
72 }
73 }
74 return rc;
75}
76
77static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
78/* TODO: static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data; */
79static int config_camera_on_gpios_rear(void)
80{
81 int rc = 0;
82
83 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
84 msm_camera_vreg_config(1);
85
86 rc = config_gpio_table(camera_on_gpio_table,
87 ARRAY_SIZE(camera_on_gpio_table));
88 if (rc < 0) {
89 pr_err("%s: CAMSENSOR gpio table request"
90 "failed\n", __func__);
91 return rc;
92 }
93
94 return rc;
95}
96
97static void config_camera_off_gpios_rear(void)
98{
99 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
100 msm_camera_vreg_config(0);
101
102 config_gpio_table(camera_off_gpio_table,
103 ARRAY_SIZE(camera_off_gpio_table));
104}
105
106static int config_camera_on_gpios_front(void)
107{
108 int rc = 0;
109
110 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
111 msm_camera_vreg_config(1);
112
113 rc = config_gpio_table(camera_on_gpio_table,
114 ARRAY_SIZE(camera_on_gpio_table));
115 if (rc < 0) {
116 pr_err("%s: CAMSENSOR gpio table request"
117 "failed\n", __func__);
118 return rc;
119 }
120
121 return rc;
122}
123
124static void config_camera_off_gpios_front(void)
125{
126 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
127 msm_camera_vreg_config(0);
128
129 config_gpio_table(camera_off_gpio_table,
130 ARRAY_SIZE(camera_off_gpio_table));
131}
132
133struct msm_camera_device_platform_data msm_camera_device_data_csi1 = {
134 .camera_gpio_on = config_camera_on_gpios_rear,
135 .camera_gpio_off = config_camera_off_gpios_rear,
136 .ioclk.mclk_clk_rate = 24000000,
137 .ioclk.vfe_clk_rate = 192000000,
138 .csid_core = 1,
139 .is_csic = 1,
140};
141
142struct msm_camera_device_platform_data msm_camera_device_data_csi0 = {
143 .camera_gpio_on = config_camera_on_gpios_front,
144 .camera_gpio_off = config_camera_off_gpios_front,
145 .ioclk.mclk_clk_rate = 24000000,
146 .ioclk.vfe_clk_rate = 192000000,
147 .csid_core = 0,
148};
149
150#ifdef CONFIG_DW9712_ACT
151static struct i2c_board_info s5k4e1_actuator_i2c_info = {
152 I2C_BOARD_INFO("dw9712_act", 0x8C >> 1),
153};
154
155static struct msm_actuator_info s5k4e1_actuator_info = {
156 .board_info = &s5k4e1_actuator_i2c_info,
157 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
158 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
159 .vcm_enable = 1,
160};
161#endif
162
163#ifdef CONFIG_S5K4E1
164static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
165 .flash_type = MSM_CAMERA_FLASH_LED,
166 .flash_src = &msm_flash_src
167};
168
169static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
170 .mount_angle = 90,
171 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
172 .sensor_pwd = 85,
173 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
174 .vcm_enable = 1,
175};
176
177static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
178 .sensor_name = "s5k4e1",
179 .sensor_reset_enable = 1,
180 .pdata = &msm_camera_device_data_csi1,
181 .flash_data = &flash_s5k4e1,
182 .sensor_platform_info = &sensor_board_info_s5k4e1,
183 .csi_if = 1,
184 .camera_type = BACK_CAMERA_2D,
185#ifdef CONFIG_DW9712_ACT
186 .actuator_info = &s5k4e1_actuator_info
187#endif
188};
189#endif
190
191#ifdef CONFIG_MT9E013
192static struct msm_camera_sensor_flash_data flash_mt9e013 = {
193 .flash_type = MSM_CAMERA_FLASH_LED,
194 .flash_src = &msm_flash_src
195};
196
197static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
198 .mount_angle = 90,
199 .sensor_reset = 0,
200 .sensor_pwd = 85,
201 .vcm_pwd = 1,
202 .vcm_enable = 0,
203};
204
205static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
206 .sensor_name = "mt9e013",
207 .sensor_reset_enable = 1,
208 .pdata = &msm_camera_device_data_csi1,
209 .flash_data = &flash_mt9e013,
210 .sensor_platform_info = &sensor_board_info_mt9e013,
211 .csi_if = 1,
212 .camera_type = BACK_CAMERA_2D,
213};
214#endif
215
216#ifdef CONFIG_IMX072
217static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
218 .mount_angle = 90
219};
220
221static struct msm_camera_sensor_flash_data flash_imx072 = {
222 .flash_type = MSM_CAMERA_FLASH_LED,
223 .flash_src = &msm_flash_src
224};
225
226static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
227 .sensor_name = "imx072",
228 .sensor_reset_enable = 1,
229 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
230 .sensor_pwd = 85,
231 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
232 .vcm_enable = 1,
233 .pdata = &msm_camera_device_data_csi1,
234 .flash_data = &flash_imx072,
235 .sensor_platform_info = &imx072_sensor_7627a_info,
236 .csi_if = 1
237};
238
239static struct platform_device msm_camera_sensor_imx072 = {
240 .name = "msm_camera_imx072",
241 .dev = {
242 .platform_data = &msm_camera_sensor_imx072_data,
243 },
244};
245#endif
246
247#ifdef CONFIG_WEBCAM_OV9726
248static struct msm_camera_sensor_flash_data flash_ov9726 = {
249 .flash_type = MSM_CAMERA_FLASH_LED,
250 .flash_src = &msm_flash_src
251};
252
253static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
254 .mount_angle = 90,
255 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
256 .sensor_pwd = 85,
257 .vcm_pwd = 1,
258 .vcm_enable = 0,
259};
260
261static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
262 .sensor_name = "ov9726",
263 .sensor_reset_enable = 0,
264 .pdata = &msm_camera_device_data_csi0,
265 .flash_data = &flash_ov9726,
266 .sensor_platform_info = &sensor_board_info_ov9726,
267 .csi_if = 1,
268 .camera_type = FRONT_CAMERA_2D,
269};
270#endif
271
272static void __init msm7x27a_init_cam(void)
273{
274 platform_device_register(&msm7x27a_device_csic0);
275 platform_device_register(&msm7x27a_device_csic1);
276 platform_device_register(&msm7x27a_device_clkctl);
277 platform_device_register(&msm7x27a_device_vfe);
278}
279
280static struct i2c_board_info i2c_camera_devices[] = {
281 #ifdef CONFIG_S5K4E1
282 {
283 I2C_BOARD_INFO("s5k4e1", 0x36),
284 .platform_data = &msm_camera_sensor_s5k4e1_data,
285 },
286 #endif
287 #ifdef CONFIG_WEBCAM_OV9726
288 {
289 I2C_BOARD_INFO("ov9726", 0x10),
290 .platform_data = &msm_camera_sensor_ov9726_data,
291 },
292 #endif
293 #ifdef CONFIG_IMX072
294 {
295 I2C_BOARD_INFO("imx072", 0x34),
296 },
297 #endif
298 #ifdef CONFIG_MT9E013
299 {
300 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
301 .platform_data = &msm_camera_sensor_mt9e013_data,
302 },
303 #endif
304 {
305 I2C_BOARD_INFO("sc628a", 0x6E),
306 },
307};
308#else
Chintan Pandya40762702011-12-06 13:47:06 +0530309static uint32_t camera_off_gpio_table[] = {
310 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
311};
312
313static uint32_t camera_on_gpio_table[] = {
314 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
315};
316
317#ifdef CONFIG_MSM_CAMERA_FLASH
318static struct msm_camera_sensor_flash_src msm_flash_src = {
319 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
320 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
321 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
322};
323#endif
324
325static struct regulator_bulk_data regs_camera[] = {
326 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
327 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
328 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
329};
330
331static void qrd1_camera_gpio_cfg(void)
332{
333
334 int rc = 0;
335
336 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
337 if (rc < 0)
338 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
339 __func__);
340
341
342 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
343 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
344 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
345 if (rc < 0) {
346 pr_err("%s: unable to enable Power Down gpio for main"
347 "camera!\n", __func__);
348 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
349 }
350
351
352 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
353 if (rc < 0) {
354 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
355 __func__);
356 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
357 }
358
359
360 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
361 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
362 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
363 if (rc < 0) {
364 pr_err("%s: unable to enable reset gpio for main camera!\n",
365 __func__);
366 gpio_free(QRD_GPIO_CAM_5MP_RESET);
367 }
368
369 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
370 if (rc < 0)
371 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
372 __func__);
373
374 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
375 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
376 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
377 if (rc < 0) {
378 pr_err("%s: unable to enable Power Down gpio for front"
379 "camera!\n", __func__);
380 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
381 }
382
383 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
384 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
385 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
386}
387
388static void msm_camera_vreg_config(int vreg_en)
389{
390 int rc = vreg_en ?
391 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
392 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
393
394 if (rc)
395 pr_err("%s: could not %sable regulators: %d\n",
396 __func__, vreg_en ? "en" : "dis", rc);
397}
398
399static int config_gpio_table(uint32_t *table, int len)
400{
401 int rc = 0, i = 0;
402
403 for (i = 0; i < len; i++) {
404 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
405 if (rc) {
406 pr_err("%s not able to get gpio\n", __func__);
407 for (i--; i >= 0; i--)
408 gpio_tlmm_config(camera_off_gpio_table[i],
409 GPIO_CFG_ENABLE);
410 break;
411 }
412 }
413 return rc;
414}
415
416static int config_camera_on_gpios_rear(void)
417{
418 int rc = 0;
419
420 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
421 || machine_is_msm7627a_qrd1())
422 msm_camera_vreg_config(1);
423
424 rc = config_gpio_table(camera_on_gpio_table,
425 ARRAY_SIZE(camera_on_gpio_table));
426 if (rc < 0) {
427 pr_err("%s: CAMSENSOR gpio table request"
428 "failed\n", __func__);
429 return rc;
430 }
431
432 return rc;
433}
434
435static void config_camera_off_gpios_rear(void)
436{
437 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
438 || machine_is_msm7627a_qrd1())
439 msm_camera_vreg_config(0);
440
441 config_gpio_table(camera_off_gpio_table,
442 ARRAY_SIZE(camera_off_gpio_table));
443}
444
445static int config_camera_on_gpios_front(void)
446{
447 int rc = 0;
448
449 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
450 || machine_is_msm7627a_qrd1())
451 msm_camera_vreg_config(1);
452
453 rc = config_gpio_table(camera_on_gpio_table,
454 ARRAY_SIZE(camera_on_gpio_table));
455 if (rc < 0) {
456 pr_err("%s: CAMSENSOR gpio table request"
457 "failed\n", __func__);
458 return rc;
459 }
460
461 return rc;
462}
463
464static void config_camera_off_gpios_front(void)
465{
466 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
467 || machine_is_msm7627a_qrd1())
468 msm_camera_vreg_config(0);
469
470 config_gpio_table(camera_off_gpio_table,
471 ARRAY_SIZE(camera_off_gpio_table));
472}
473
474struct msm_camera_device_platform_data msm_camera_device_data_rear = {
475 .camera_gpio_on = config_camera_on_gpios_rear,
476 .camera_gpio_off = config_camera_off_gpios_rear,
477 .ioext.csiphy = 0xA1000000,
478 .ioext.csisz = 0x00100000,
479 .ioext.csiirq = INT_CSI_IRQ_1,
480 .ioclk.mclk_clk_rate = 24000000,
481 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530482 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
483 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530484};
485
486struct msm_camera_device_platform_data msm_camera_device_data_front = {
487 .camera_gpio_on = config_camera_on_gpios_front,
488 .camera_gpio_off = config_camera_off_gpios_front,
489 .ioext.csiphy = 0xA0F00000,
490 .ioext.csisz = 0x00100000,
491 .ioext.csiirq = INT_CSI_IRQ_0,
492 .ioclk.mclk_clk_rate = 24000000,
493 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530494 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
495 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530496};
497
498#ifdef CONFIG_S5K4E1
499static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
500 .mount_angle = 90
501};
502
503static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
504 .flash_type = MSM_CAMERA_FLASH_LED,
505 .flash_src = &msm_flash_src
506};
507
508static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
509 .sensor_name = "s5k4e1",
510 .sensor_reset_enable = 1,
511 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
512 .sensor_pwd = 85,
513 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
514 .vcm_enable = 1,
515 .pdata = &msm_camera_device_data_rear,
516 .flash_data = &flash_s5k4e1,
517 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
518 .csi_if = 1
519};
520
521static struct platform_device msm_camera_sensor_s5k4e1 = {
522 .name = "msm_camera_s5k4e1",
523 .dev = {
524 .platform_data = &msm_camera_sensor_s5k4e1_data,
525 },
526};
527#endif
528
529#ifdef CONFIG_IMX072
530static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
531 .mount_angle = 90
532};
533
534static struct msm_camera_sensor_flash_data flash_imx072 = {
535 .flash_type = MSM_CAMERA_FLASH_LED,
536 .flash_src = &msm_flash_src
537};
538
539static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
540 .sensor_name = "imx072",
541 .sensor_reset_enable = 1,
542 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
543 .sensor_pwd = 85,
544 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
545 .vcm_enable = 1,
546 .pdata = &msm_camera_device_data_rear,
547 .flash_data = &flash_imx072,
548 .sensor_platform_info = &imx072_sensor_7627a_info,
549 .csi_if = 1
550};
551
552static struct platform_device msm_camera_sensor_imx072 = {
553 .name = "msm_camera_imx072",
554 .dev = {
555 .platform_data = &msm_camera_sensor_imx072_data,
556 },
557};
558#endif
559
560static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
561#ifdef CONFIG_WEBCAM_OV9726
562static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
563 .mount_angle = 90
564};
565
566static struct msm_camera_sensor_flash_data flash_ov9726 = {
567 .flash_type = MSM_CAMERA_FLASH_NONE,
568 .flash_src = &msm_flash_src
569};
570
571static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
572 .sensor_name = "ov9726",
573 .sensor_reset_enable = 0,
574 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
575 .sensor_pwd = 85,
576 .vcm_pwd = 1,
577 .vcm_enable = 0,
578 .pdata = &msm_camera_device_data_front,
579 .flash_data = &flash_ov9726,
580 .sensor_platform_info = &ov9726_sensor_7627a_info,
581 .csi_if = 1
582};
583
584static struct platform_device msm_camera_sensor_ov9726 = {
585 .name = "msm_camera_ov9726",
586 .dev = {
587 .platform_data = &msm_camera_sensor_ov9726_data,
588 },
589};
590#else
591static inline void msm_camera_vreg_init(void) { }
592#endif
593
594#ifdef CONFIG_MT9E013
595static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
596 .mount_angle = 90
597};
598
599static struct msm_camera_sensor_flash_data flash_mt9e013 = {
600 .flash_type = MSM_CAMERA_FLASH_LED,
601 .flash_src = &msm_flash_src
602};
603
604static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
605 .sensor_name = "mt9e013",
606 .sensor_reset = 0,
607 .sensor_reset_enable = 1,
608 .sensor_pwd = 85,
609 .vcm_pwd = 1,
610 .vcm_enable = 0,
611 .pdata = &msm_camera_device_data_rear,
612 .flash_data = &flash_mt9e013,
613 .sensor_platform_info = &mt9e013_sensor_7627a_info,
614 .csi_if = 1
615};
616
617static struct platform_device msm_camera_sensor_mt9e013 = {
618 .name = "msm_camera_mt9e013",
619 .dev = {
620 .platform_data = &msm_camera_sensor_mt9e013_data,
621 },
622};
623#endif
624
625#ifdef CONFIG_OV5640
626static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
627 .mount_angle = 90
628};
629
630static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
631 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
632 ._fsrc.led_src.led_name = "flashlight",
633 ._fsrc.led_src.led_name_len = 10,
634};
635
636static struct msm_camera_sensor_flash_data flash_ov5640 = {
637 .flash_type = MSM_CAMERA_FLASH_LED,
638 .flash_src = &msm_flash_src_ov5640,
639};
640
641static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
642 .sensor_name = "ov5640",
643 .sensor_reset_enable = 1,
644 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
645 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
646 .vcm_pwd = 0,
647 .vcm_enable = 0,
648 .pdata = &msm_camera_device_data_rear,
649 .flash_data = &flash_ov5640,
650 .sensor_platform_info = &ov5640_sensor_info,
651 .csi_if = 1,
652};
653
654static struct platform_device msm_camera_sensor_ov5640 = {
655 .name = "msm_camera_ov5640",
656 .dev = {
657 .platform_data = &msm_camera_sensor_ov5640_data,
658 },
659};
660#endif
661
662#ifdef CONFIG_WEBCAM_OV7692_QRD
663static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
664 .mount_angle = 90
665};
666
667static struct msm_camera_sensor_flash_data flash_ov7692 = {
668 .flash_type = MSM_CAMERA_FLASH_NONE,
669};
670
671static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
672 .sensor_name = "ov7692",
673 .sensor_reset_enable = 0,
674 .sensor_reset = 0,
675 .sensor_pwd = QRD_GPIO_CAM_3MP_PWDN,
676 .vcm_pwd = 0,
677 .vcm_enable = 0,
678 .pdata = &msm_camera_device_data_front,
679 .flash_data = &flash_ov7692,
680 .sensor_platform_info = &ov7692_sensor_7627a_info,
681 .csi_if = 1,
682};
683
684static struct platform_device msm_camera_sensor_ov7692 = {
685 .name = "msm_camera_ov7692",
686 .dev = {
687 .platform_data = &msm_camera_sensor_ov7692_data,
688 },
689};
690#endif
691
Chintan Pandya40762702011-12-06 13:47:06 +0530692static struct i2c_board_info i2c_camera_devices[] = {
693 #ifdef CONFIG_S5K4E1
694 {
695 I2C_BOARD_INFO("s5k4e1", 0x36),
696 },
697 {
698 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
699 },
700 #endif
701 #ifdef CONFIG_WEBCAM_OV9726
702 {
703 I2C_BOARD_INFO("ov9726", 0x10),
704 },
705 #endif
706 #ifdef CONFIG_IMX072
707 {
708 I2C_BOARD_INFO("imx072", 0x34),
709 },
710 #endif
711 #ifdef CONFIG_MT9E013
712 {
713 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
714 },
715 #endif
716 {
717 I2C_BOARD_INFO("sc628a", 0x6E),
718 },
719};
720
721static struct i2c_board_info i2c_camera_devices_qrd[] = {
722 #ifdef CONFIG_OV5640
723 {
724 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
725 },
726 #endif
727 #ifdef CONFIG_WEBCAM_OV7692_QRD
728 {
729 I2C_BOARD_INFO("ov7692", 0x78),
730 },
731 #endif
732};
733
734static struct platform_device *camera_devices_msm[] __initdata = {
735#ifdef CONFIG_S5K4E1
736 &msm_camera_sensor_s5k4e1,
737#endif
738#ifdef CONFIG_IMX072
739 &msm_camera_sensor_imx072,
740#endif
741#ifdef CONFIG_WEBCAM_OV9726
742 &msm_camera_sensor_ov9726,
743#endif
744#ifdef CONFIG_MT9E013
745 &msm_camera_sensor_mt9e013,
746#endif
747};
748
749static struct platform_device *camera_devices_qrd[] __initdata = {
750#ifdef CONFIG_OV5640
751 &msm_camera_sensor_ov5640,
752#endif
753#ifdef CONFIG_WEBCAM_OV7692_QRD
754 &msm_camera_sensor_ov7692,
755#endif
756};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530757#endif
758
759enum {
760 SX150X_CAM,
761};
762
763static struct sx150x_platform_data sx150x_data[] __initdata = {
764 [SX150X_CAM] = {
765 .gpio_base = GPIO_CAM_EXPANDER_BASE,
766 .oscio_is_gpo = false,
767 .io_pullup_ena = 0,
768 .io_pulldn_ena = 0,
769 .io_open_drain_ena = 0x23,
770 .irq_summary = -1,
771 },
772};
773
774static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
775 {
776 I2C_BOARD_INFO("sx1508q", 0x22),
777 .platform_data = &sx150x_data[SX150X_CAM],
778 },
779};
Chintan Pandya40762702011-12-06 13:47:06 +0530780
781static void __init register_i2c_devices(void)
782{
783 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
784 cam_exp_i2c_info,
785 ARRAY_SIZE(cam_exp_i2c_info));
786}
787
788void __init msm7627a_camera_init(void)
789{
790 int rc;
791
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530792#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +0530793 if (machine_is_msm7627a_qrd1()) {
794 qrd1_camera_gpio_cfg();
795 platform_add_devices(camera_devices_qrd,
796 ARRAY_SIZE(camera_devices_qrd));
Taniya Dasc868a2e2012-01-03 10:18:47 +0530797 } else if (machine_is_msm7627a_evb())
798 return;
799 else
Chintan Pandya40762702011-12-06 13:47:06 +0530800 platform_add_devices(camera_devices_msm,
801 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530802#endif
Chintan Pandya40762702011-12-06 13:47:06 +0530803 if (!machine_is_msm7627a_qrd1())
804 register_i2c_devices();
Chintan Pandya40762702011-12-06 13:47:06 +0530805 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
806
807 if (rc) {
808 pr_err("%s: could not get regulators: %d\n", __func__, rc);
809 return;
810 }
811
812 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
813
814 if (rc) {
815 pr_err("%s: could not set voltages: %d\n", __func__, rc);
816 return;
817 }
818
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530819#if defined(CONFIG_MSM_CAMERA_V4L2)
820 msm7x27a_init_cam();
821#endif
822#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +0530823 if (machine_is_msm7627a_qrd1())
824 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
825 i2c_camera_devices_qrd,
826 ARRAY_SIZE(i2c_camera_devices_qrd));
827 else
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530828#endif
Chintan Pandya40762702011-12-06 13:47:06 +0530829 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
830 i2c_camera_devices,
831 ARRAY_SIZE(i2c_camera_devices));
832}