blob: 7fecf59e688268825a5f3915cd0447cb71404753 [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"
Su Liuaca04702012-02-14 02:27:32 +053025#include <mach/vreg.h>
Chintan Pandya40762702011-12-06 13:47:06 +053026
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053027#define GPIO_SKU1_CAM_VGA_SHDN 18
28#define GPIO_SKU1_CAM_VGA_RESET_N 29
29#define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */
30#define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */
31#define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30
32
Suresh Vankadara87e195b2012-01-18 00:42:58 +053033#ifdef CONFIG_MSM_CAMERA_V4L2
34static uint32_t camera_off_gpio_table[] = {
35 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
36};
37
38static uint32_t camera_on_gpio_table[] = {
39 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
40};
41
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053042static struct gpio s5k4e1_cam_req_gpio[] = {
43 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_DIR_OUT, "CAM_RESET"},
44};
45
46static struct msm_gpio_set_tbl s5k4e1_cam_gpio_set_tbl[] = {
47 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_LOW, 1000},
48 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_HIGH, 4000},
49};
50
51static struct msm_camera_gpio_conf gpio_conf_s5k4e1 = {
52 .camera_off_table = camera_off_gpio_table,
53 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
54 .camera_on_table = camera_on_gpio_table,
55 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
56 .cam_gpio_req_tbl = s5k4e1_cam_req_gpio,
57 .cam_gpio_req_tbl_size = ARRAY_SIZE(s5k4e1_cam_req_gpio),
58 .cam_gpio_set_tbl = s5k4e1_cam_gpio_set_tbl,
59 .cam_gpio_set_tbl_size = ARRAY_SIZE(s5k4e1_cam_gpio_set_tbl),
60 .gpio_no_mux = 1,
61};
62
63static struct msm_camera_gpio_conf gpio_conf_mt9e013 = {
64 .camera_off_table = camera_off_gpio_table,
65 .camera_on_table = camera_on_gpio_table,
66 .gpio_no_mux = 1,
67};
68
69static struct msm_camera_gpio_conf gpio_conf_ov9726 = {
70 .camera_off_table = camera_off_gpio_table,
71 .camera_on_table = camera_on_gpio_table,
72 .gpio_no_mux = 1,
73};
74
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053075#ifdef CONFIG_WEBCAM_OV7692_QRD
76static struct msm_camera_gpio_conf gpio_conf_ov7692 = {
77 .camera_off_table = camera_off_gpio_table,
78 .camera_on_table = camera_on_gpio_table,
79 .gpio_no_mux = 1,
80};
81#endif
82
83#ifdef CONFIG_OV5647
84static struct msm_camera_gpio_conf gpio_conf_ov5647 = {
85 .camera_off_table = camera_off_gpio_table,
86 .camera_on_table = camera_on_gpio_table,
87 .gpio_no_mux = 1,
88};
89#endif
90
Suresh Vankadara87e195b2012-01-18 00:42:58 +053091#ifdef CONFIG_MSM_CAMERA_FLASH
92static struct msm_camera_sensor_flash_src msm_flash_src = {
93 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
94 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
95 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
96};
97#endif
98
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053099static struct camera_vreg_t msm_cam_vreg[] = {
100 {"msme1", REG_LDO, 1800000, 1800000, 0},
101 {"gp2", REG_LDO, 2850000, 2850000, 0},
102 {"usb2", REG_LDO, 1800000, 1800000, 0},
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530103};
104
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530105static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530106
107struct msm_camera_device_platform_data msm_camera_device_data_csi1 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530108 .csid_core = 1,
109 .is_csic = 1,
110};
111
112struct msm_camera_device_platform_data msm_camera_device_data_csi0 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530113 .csid_core = 0,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530114 .is_csic = 1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530115};
116
117#ifdef CONFIG_DW9712_ACT
118static struct i2c_board_info s5k4e1_actuator_i2c_info = {
119 I2C_BOARD_INFO("dw9712_act", 0x8C >> 1),
120};
121
122static struct msm_actuator_info s5k4e1_actuator_info = {
123 .board_info = &s5k4e1_actuator_i2c_info,
124 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
125 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
126 .vcm_enable = 1,
127};
128#endif
129
130#ifdef CONFIG_S5K4E1
131static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
132 .flash_type = MSM_CAMERA_FLASH_LED,
133 .flash_src = &msm_flash_src
134};
135
136static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
137 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530138 .cam_vreg = msm_cam_vreg,
139 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
140 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530141};
142
143static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
144 .sensor_name = "s5k4e1",
145 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530146 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530147 .pdata = &msm_camera_device_data_csi1,
148 .flash_data = &flash_s5k4e1,
149 .sensor_platform_info = &sensor_board_info_s5k4e1,
150 .csi_if = 1,
151 .camera_type = BACK_CAMERA_2D,
152#ifdef CONFIG_DW9712_ACT
153 .actuator_info = &s5k4e1_actuator_info
154#endif
155};
156#endif
157
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530158#ifdef CONFIG_WEBCAM_OV7692_QRD
159static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
160 .mount_angle = 90,
161 .cam_vreg = msm_cam_vreg,
162 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
163 .gpio_conf = &gpio_conf_ov7692,
164};
165
166static struct msm_camera_sensor_flash_data flash_ov7692 = {
167 .flash_type = MSM_CAMERA_FLASH_NONE,
168};
169
170static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
171 .sensor_name = "ov7692",
172 .sensor_reset_enable = 0,
173 .pmic_gpio_enable = 1,
174 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
175 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
176 .pdata = &msm_camera_device_data_csi0,
177 .flash_data = &flash_ov7692,
178 .sensor_platform_info = &sensor_board_info_ov7692,
179 .csi_if = 1,
180 .camera_type = FRONT_CAMERA_2D,
181};
182#endif
183
184#ifdef CONFIG_OV5647
185
186#ifdef CONFIG_AD5046_ACT
187static struct i2c_board_info ad5046_actuator_i2c_info = {
188 I2C_BOARD_INFO("ad5046_act", 0x18 >> 1),
189};
190
191static struct msm_actuator_info ad5046_actuator_info = {
192 .board_info = &ad5046_actuator_i2c_info,
193 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
194 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
195 .vcm_enable = 1,
196};
197#endif
198
199static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
200 .mount_angle = 90,
201 .cam_vreg = msm_cam_vreg,
202 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
203 .gpio_conf = &gpio_conf_ov5647,
204};
205
206static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
207 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
208 ._fsrc.led_src.led_name = "flashlight",
209 ._fsrc.led_src.led_name_len = 10,
210};
211
212static struct msm_camera_sensor_flash_data flash_ov5647 = {
213 .flash_type = MSM_CAMERA_FLASH_LED,
214 .flash_src = &msm_flash_src_ov5647,
215};
216
217static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
218 .sensor_name = "ov5647",
219 .sensor_reset_enable = 1,
220 .pmic_gpio_enable = 1,
221 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
222 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
223 .pdata = &msm_camera_device_data_csi1,
224 .flash_data = &flash_ov5647,
225 .sensor_platform_info = &sensor_board_info_ov5647,
226 .csi_if = 1,
227 .camera_type = BACK_CAMERA_2D,
228
229#ifdef CONFIG_AD5046_ACT
230 .actuator_info = &ad5046_actuator_info
231#endif
232};
233
234#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530235#ifdef CONFIG_MT9E013
236static struct msm_camera_sensor_flash_data flash_mt9e013 = {
237 .flash_type = MSM_CAMERA_FLASH_LED,
238 .flash_src = &msm_flash_src
239};
240
241static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
242 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530243 .cam_vreg = msm_cam_vreg,
244 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
245 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530246};
247
248static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
249 .sensor_name = "mt9e013",
250 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530251 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530252 .pdata = &msm_camera_device_data_csi1,
253 .flash_data = &flash_mt9e013,
254 .sensor_platform_info = &sensor_board_info_mt9e013,
255 .csi_if = 1,
256 .camera_type = BACK_CAMERA_2D,
257};
258#endif
259
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530260#ifdef CONFIG_WEBCAM_OV9726
261static struct msm_camera_sensor_flash_data flash_ov9726 = {
262 .flash_type = MSM_CAMERA_FLASH_LED,
263 .flash_src = &msm_flash_src
264};
265
266static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
267 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530268 .cam_vreg = msm_cam_vreg,
269 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
270 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530271};
272
273static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
274 .sensor_name = "ov9726",
275 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530276 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530277 .pdata = &msm_camera_device_data_csi0,
278 .flash_data = &flash_ov9726,
279 .sensor_platform_info = &sensor_board_info_ov9726,
280 .csi_if = 1,
281 .camera_type = FRONT_CAMERA_2D,
282};
283#endif
284
285static void __init msm7x27a_init_cam(void)
286{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530287 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
288 || machine_is_msm7627a_qrd1())) {
289 sensor_board_info_s5k4e1.cam_vreg = NULL;
290 sensor_board_info_s5k4e1.num_vreg = 0;
291 sensor_board_info_mt9e013.cam_vreg = NULL;
292 sensor_board_info_mt9e013.num_vreg = 0;
293 sensor_board_info_ov9726.cam_vreg = NULL;
294 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530295 sensor_board_info_ov7692.cam_vreg = NULL;
296 sensor_board_info_ov7692.num_vreg = 0;
297 sensor_board_info_ov5647.cam_vreg = NULL;
298 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530299 }
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530300 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()) {
301 platform_device_register(&msm8625_device_csic0);
302 platform_device_register(&msm8625_device_csic1);
303 } else {
304 platform_device_register(&msm7x27a_device_csic0);
305 platform_device_register(&msm7x27a_device_csic1);
306 }
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530307 platform_device_register(&msm7x27a_device_clkctl);
308 platform_device_register(&msm7x27a_device_vfe);
309}
310
311static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530312 {
313 I2C_BOARD_INFO("s5k4e1", 0x36),
314 .platform_data = &msm_camera_sensor_s5k4e1_data,
315 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530316 {
317 I2C_BOARD_INFO("ov9726", 0x10),
318 .platform_data = &msm_camera_sensor_ov9726_data,
319 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530320 {
321 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
322 .platform_data = &msm_camera_sensor_mt9e013_data,
323 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530324 {
325 I2C_BOARD_INFO("ov7692", 0x78),
326 .platform_data = &msm_camera_sensor_ov7692_data,
327 },
328 {
329 I2C_BOARD_INFO("ov5647", 0x36 << 1),
330 .platform_data = &msm_camera_sensor_ov5647_data,
331 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530332 {
333 I2C_BOARD_INFO("sc628a", 0x6E),
334 },
335};
336#else
Chintan Pandya40762702011-12-06 13:47:06 +0530337static uint32_t camera_off_gpio_table[] = {
338 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
339};
340
341static uint32_t camera_on_gpio_table[] = {
342 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
343};
344
345#ifdef CONFIG_MSM_CAMERA_FLASH
346static struct msm_camera_sensor_flash_src msm_flash_src = {
347 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
348 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
349 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
350};
351#endif
352
353static struct regulator_bulk_data regs_camera[] = {
354 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
355 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
356 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
357};
358
359static void qrd1_camera_gpio_cfg(void)
360{
361
362 int rc = 0;
363
364 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
365 if (rc < 0)
366 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
367 __func__);
368
369
370 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
371 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
372 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
373 if (rc < 0) {
374 pr_err("%s: unable to enable Power Down gpio for main"
375 "camera!\n", __func__);
376 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
377 }
378
379
380 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
381 if (rc < 0) {
382 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
383 __func__);
384 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
385 }
386
387
388 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
389 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
390 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
391 if (rc < 0) {
392 pr_err("%s: unable to enable reset gpio for main camera!\n",
393 __func__);
394 gpio_free(QRD_GPIO_CAM_5MP_RESET);
395 }
396
397 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
398 if (rc < 0)
399 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
400 __func__);
401
402 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
403 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
404 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
405 if (rc < 0) {
406 pr_err("%s: unable to enable Power Down gpio for front"
407 "camera!\n", __func__);
408 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
409 }
410
411 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
412 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
413 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
414}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530415#endif
Su Liuaca04702012-02-14 02:27:32 +0530416
417static void evb_camera_gpio_cfg(void)
418{
419 int rc = 0;
420
421 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
422 if (rc < 0)
423 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
424 __func__);
425
426 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
427 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
428 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
429 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
430 if (rc < 0) {
431 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
432 __func__);
433 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
434 }
435
436 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
437
438 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
439 if (rc < 0)
440 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
441 __func__);
442
443 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
444 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
445 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
446 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
447 if (rc < 0) {
448 pr_err("%s: unable to enable reset gpio for main camera!\n",
449 __func__);
450 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
451 }
452
453 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
454
455 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
456 if (rc < 0)
457 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
458 __func__);
459
460 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
461 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
462 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
463 if (rc < 0) {
464 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
465 __func__);
466 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
467 }
468
469 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
470
471 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
472 if (rc < 0)
473 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
474 __func__);
475
476 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
477 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
478 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
479
480 if (rc < 0) {
481 pr_err("%s: unable to enable reset gpio for front camera!\n",
482 __func__);
483 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
484 }
485 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
486
487}
488
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530489#ifndef CONFIG_MSM_CAMERA_V4L2
490
Chintan Pandya40762702011-12-06 13:47:06 +0530491static void msm_camera_vreg_config(int vreg_en)
492{
493 int rc = vreg_en ?
494 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
495 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
496
497 if (rc)
498 pr_err("%s: could not %sable regulators: %d\n",
499 __func__, vreg_en ? "en" : "dis", rc);
500}
501
502static int config_gpio_table(uint32_t *table, int len)
503{
504 int rc = 0, i = 0;
505
506 for (i = 0; i < len; i++) {
507 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
508 if (rc) {
509 pr_err("%s not able to get gpio\n", __func__);
510 for (i--; i >= 0; i--)
511 gpio_tlmm_config(camera_off_gpio_table[i],
512 GPIO_CFG_ENABLE);
513 break;
514 }
515 }
516 return rc;
517}
518
519static int config_camera_on_gpios_rear(void)
520{
521 int rc = 0;
522
523 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
524 || machine_is_msm7627a_qrd1())
525 msm_camera_vreg_config(1);
526
527 rc = config_gpio_table(camera_on_gpio_table,
528 ARRAY_SIZE(camera_on_gpio_table));
529 if (rc < 0) {
530 pr_err("%s: CAMSENSOR gpio table request"
531 "failed\n", __func__);
532 return rc;
533 }
534
535 return rc;
536}
537
538static void config_camera_off_gpios_rear(void)
539{
540 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
541 || machine_is_msm7627a_qrd1())
542 msm_camera_vreg_config(0);
543
544 config_gpio_table(camera_off_gpio_table,
545 ARRAY_SIZE(camera_off_gpio_table));
546}
547
548static int config_camera_on_gpios_front(void)
549{
550 int rc = 0;
551
552 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
553 || machine_is_msm7627a_qrd1())
554 msm_camera_vreg_config(1);
555
556 rc = config_gpio_table(camera_on_gpio_table,
557 ARRAY_SIZE(camera_on_gpio_table));
558 if (rc < 0) {
559 pr_err("%s: CAMSENSOR gpio table request"
560 "failed\n", __func__);
561 return rc;
562 }
563
564 return rc;
565}
566
567static void config_camera_off_gpios_front(void)
568{
569 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
570 || machine_is_msm7627a_qrd1())
571 msm_camera_vreg_config(0);
572
573 config_gpio_table(camera_off_gpio_table,
574 ARRAY_SIZE(camera_off_gpio_table));
575}
576
577struct msm_camera_device_platform_data msm_camera_device_data_rear = {
578 .camera_gpio_on = config_camera_on_gpios_rear,
579 .camera_gpio_off = config_camera_off_gpios_rear,
580 .ioext.csiphy = 0xA1000000,
581 .ioext.csisz = 0x00100000,
582 .ioext.csiirq = INT_CSI_IRQ_1,
583 .ioclk.mclk_clk_rate = 24000000,
584 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530585 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
586 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530587};
588
589struct msm_camera_device_platform_data msm_camera_device_data_front = {
590 .camera_gpio_on = config_camera_on_gpios_front,
591 .camera_gpio_off = config_camera_off_gpios_front,
592 .ioext.csiphy = 0xA0F00000,
593 .ioext.csisz = 0x00100000,
594 .ioext.csiirq = INT_CSI_IRQ_0,
595 .ioclk.mclk_clk_rate = 24000000,
596 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530597 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
598 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530599};
600
Su Liuaca04702012-02-14 02:27:32 +0530601#ifdef CONFIG_OV5647
602
603static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
604 .mount_angle = 90
605};
606
607static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
608 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
609 ._fsrc.led_src.led_name = "flashlight",
610 ._fsrc.led_src.led_name_len = 10,
611};
612
613static struct msm_camera_sensor_flash_data flash_ov5647 = {
614 .flash_type = MSM_CAMERA_FLASH_LED,
615 .flash_src = &msm_flash_src_ov5647,
616};
617
618static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
619 .sensor_name = "ov5647",
620 .sensor_reset_enable = 1,
621 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
622 .pmic_gpio_enable = 1,
623 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
624 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530625 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530626 .pdata = &msm_camera_device_data_rear,
627 .flash_data = &flash_ov5647,
628 .sensor_platform_info = &ov5647_sensor_7627a_info,
629 .csi_if = 1
630};
631
632static struct platform_device msm_camera_sensor_ov5647 = {
633 .name = "msm_camera_ov5647",
634 .dev = {
635 .platform_data = &msm_camera_sensor_ov5647_data,
636 },
637};
638#endif
639
Chintan Pandya40762702011-12-06 13:47:06 +0530640#ifdef CONFIG_S5K4E1
641static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
642 .mount_angle = 90
643};
644
645static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
646 .flash_type = MSM_CAMERA_FLASH_LED,
647 .flash_src = &msm_flash_src
648};
649
650static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
651 .sensor_name = "s5k4e1",
652 .sensor_reset_enable = 1,
653 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530654 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530655 .sensor_pwd = 85,
656 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
657 .vcm_enable = 1,
658 .pdata = &msm_camera_device_data_rear,
659 .flash_data = &flash_s5k4e1,
660 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
661 .csi_if = 1
662};
663
664static struct platform_device msm_camera_sensor_s5k4e1 = {
665 .name = "msm_camera_s5k4e1",
666 .dev = {
667 .platform_data = &msm_camera_sensor_s5k4e1_data,
668 },
669};
670#endif
671
672#ifdef CONFIG_IMX072
673static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
674 .mount_angle = 90
675};
676
677static struct msm_camera_sensor_flash_data flash_imx072 = {
678 .flash_type = MSM_CAMERA_FLASH_LED,
679 .flash_src = &msm_flash_src
680};
681
682static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
683 .sensor_name = "imx072",
684 .sensor_reset_enable = 1,
685 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530686 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530687 .sensor_pwd = 85,
688 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
689 .vcm_enable = 1,
690 .pdata = &msm_camera_device_data_rear,
691 .flash_data = &flash_imx072,
692 .sensor_platform_info = &imx072_sensor_7627a_info,
693 .csi_if = 1
694};
695
696static struct platform_device msm_camera_sensor_imx072 = {
697 .name = "msm_camera_imx072",
698 .dev = {
699 .platform_data = &msm_camera_sensor_imx072_data,
700 },
701};
702#endif
703
704static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
705#ifdef CONFIG_WEBCAM_OV9726
706static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
707 .mount_angle = 90
708};
709
710static struct msm_camera_sensor_flash_data flash_ov9726 = {
711 .flash_type = MSM_CAMERA_FLASH_NONE,
712 .flash_src = &msm_flash_src
713};
714
715static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
716 .sensor_name = "ov9726",
717 .sensor_reset_enable = 0,
718 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530719 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530720 .sensor_pwd = 85,
721 .vcm_pwd = 1,
722 .vcm_enable = 0,
723 .pdata = &msm_camera_device_data_front,
724 .flash_data = &flash_ov9726,
725 .sensor_platform_info = &ov9726_sensor_7627a_info,
726 .csi_if = 1
727};
728
729static struct platform_device msm_camera_sensor_ov9726 = {
730 .name = "msm_camera_ov9726",
731 .dev = {
732 .platform_data = &msm_camera_sensor_ov9726_data,
733 },
734};
735#else
736static inline void msm_camera_vreg_init(void) { }
737#endif
738
739#ifdef CONFIG_MT9E013
740static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
741 .mount_angle = 90
742};
743
744static struct msm_camera_sensor_flash_data flash_mt9e013 = {
745 .flash_type = MSM_CAMERA_FLASH_LED,
746 .flash_src = &msm_flash_src
747};
748
749static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
750 .sensor_name = "mt9e013",
751 .sensor_reset = 0,
752 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530753 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530754 .sensor_pwd = 85,
755 .vcm_pwd = 1,
756 .vcm_enable = 0,
757 .pdata = &msm_camera_device_data_rear,
758 .flash_data = &flash_mt9e013,
759 .sensor_platform_info = &mt9e013_sensor_7627a_info,
760 .csi_if = 1
761};
762
763static struct platform_device msm_camera_sensor_mt9e013 = {
764 .name = "msm_camera_mt9e013",
765 .dev = {
766 .platform_data = &msm_camera_sensor_mt9e013_data,
767 },
768};
769#endif
770
771#ifdef CONFIG_OV5640
772static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
773 .mount_angle = 90
774};
775
776static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
777 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
778 ._fsrc.led_src.led_name = "flashlight",
779 ._fsrc.led_src.led_name_len = 10,
780};
781
782static struct msm_camera_sensor_flash_data flash_ov5640 = {
783 .flash_type = MSM_CAMERA_FLASH_LED,
784 .flash_src = &msm_flash_src_ov5640,
785};
786
787static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
788 .sensor_name = "ov5640",
789 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530790 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530791 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
792 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
793 .vcm_pwd = 0,
794 .vcm_enable = 0,
795 .pdata = &msm_camera_device_data_rear,
796 .flash_data = &flash_ov5640,
797 .sensor_platform_info = &ov5640_sensor_info,
798 .csi_if = 1,
799};
800
801static struct platform_device msm_camera_sensor_ov5640 = {
802 .name = "msm_camera_ov5640",
803 .dev = {
804 .platform_data = &msm_camera_sensor_ov5640_data,
805 },
806};
807#endif
808
809#ifdef CONFIG_WEBCAM_OV7692_QRD
810static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
811 .mount_angle = 90
812};
813
814static struct msm_camera_sensor_flash_data flash_ov7692 = {
815 .flash_type = MSM_CAMERA_FLASH_NONE,
816};
817
818static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
819 .sensor_name = "ov7692",
820 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530821 .pmic_gpio_enable = 1,
822 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
823 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530824 .vcm_pwd = 0,
825 .vcm_enable = 0,
826 .pdata = &msm_camera_device_data_front,
827 .flash_data = &flash_ov7692,
828 .sensor_platform_info = &ov7692_sensor_7627a_info,
829 .csi_if = 1,
830};
831
832static struct platform_device msm_camera_sensor_ov7692 = {
833 .name = "msm_camera_ov7692",
834 .dev = {
835 .platform_data = &msm_camera_sensor_ov7692_data,
836 },
837};
838#endif
839
Chintan Pandya40762702011-12-06 13:47:06 +0530840static struct i2c_board_info i2c_camera_devices[] = {
841 #ifdef CONFIG_S5K4E1
842 {
843 I2C_BOARD_INFO("s5k4e1", 0x36),
844 },
845 {
846 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
847 },
848 #endif
849 #ifdef CONFIG_WEBCAM_OV9726
850 {
851 I2C_BOARD_INFO("ov9726", 0x10),
852 },
853 #endif
854 #ifdef CONFIG_IMX072
855 {
856 I2C_BOARD_INFO("imx072", 0x34),
857 },
858 #endif
859 #ifdef CONFIG_MT9E013
860 {
861 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
862 },
863 #endif
864 {
865 I2C_BOARD_INFO("sc628a", 0x6E),
866 },
867};
868
869static struct i2c_board_info i2c_camera_devices_qrd[] = {
870 #ifdef CONFIG_OV5640
871 {
872 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
873 },
874 #endif
875 #ifdef CONFIG_WEBCAM_OV7692_QRD
876 {
877 I2C_BOARD_INFO("ov7692", 0x78),
878 },
879 #endif
880};
881
Su Liuaca04702012-02-14 02:27:32 +0530882static struct i2c_board_info i2c_camera_devices_evb[] = {
883 #ifdef CONFIG_OV5647
884 {
885 I2C_BOARD_INFO("ov5647", 0x36 << 1),
886 },
887 {
888 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
889 },
890 #endif
891 #ifdef CONFIG_WEBCAM_OV7692_QRD
892 {
893 I2C_BOARD_INFO("ov7692", 0x78),
894 },
895 #endif
896};
897
Chintan Pandya40762702011-12-06 13:47:06 +0530898static struct platform_device *camera_devices_msm[] __initdata = {
899#ifdef CONFIG_S5K4E1
900 &msm_camera_sensor_s5k4e1,
901#endif
902#ifdef CONFIG_IMX072
903 &msm_camera_sensor_imx072,
904#endif
905#ifdef CONFIG_WEBCAM_OV9726
906 &msm_camera_sensor_ov9726,
907#endif
908#ifdef CONFIG_MT9E013
909 &msm_camera_sensor_mt9e013,
910#endif
911};
912
913static struct platform_device *camera_devices_qrd[] __initdata = {
914#ifdef CONFIG_OV5640
915 &msm_camera_sensor_ov5640,
916#endif
917#ifdef CONFIG_WEBCAM_OV7692_QRD
918 &msm_camera_sensor_ov7692,
919#endif
920};
Su Liuaca04702012-02-14 02:27:32 +0530921
922static struct platform_device *camera_devices_evb[] __initdata = {
923#ifdef CONFIG_OV5647
924 &msm_camera_sensor_ov5647,
925#endif
926#ifdef CONFIG_WEBCAM_OV7692_QRD
927 &msm_camera_sensor_ov7692,
928#endif
929};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530930#endif
931
932enum {
933 SX150X_CAM,
934};
935
936static struct sx150x_platform_data sx150x_data[] __initdata = {
937 [SX150X_CAM] = {
938 .gpio_base = GPIO_CAM_EXPANDER_BASE,
939 .oscio_is_gpo = false,
940 .io_pullup_ena = 0,
941 .io_pulldn_ena = 0,
942 .io_open_drain_ena = 0x23,
943 .irq_summary = -1,
944 },
945};
946
947static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
948 {
949 I2C_BOARD_INFO("sx1508q", 0x22),
950 .platform_data = &sx150x_data[SX150X_CAM],
951 },
952};
Chintan Pandya40762702011-12-06 13:47:06 +0530953
954static void __init register_i2c_devices(void)
955{
956 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
957 cam_exp_i2c_info,
958 ARRAY_SIZE(cam_exp_i2c_info));
959}
960
Su Liuaca04702012-02-14 02:27:32 +0530961#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
962#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
963
964static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
965
966static void lcd_camera_power_init(void)
967{
968 int rc = 0;
969
970 pr_debug("lcd_camera_power_init\n");
971
972 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
973
974 /* LDO_EXT2V8 */
975 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
976 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
977 return;
978 }
979
980 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
981 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
982 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
983 if (rc < 0) {
984 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
985 goto fail_gpio2;
986 }
987
988 /* LDO_EVT1V8 */
989 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
990 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
991 goto fail_gpio2;
992 }
993
994 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
995 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
996 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
997 if (rc < 0) {
998 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
999 goto fail_gpio1;
1000 }
1001
1002 return;
1003
1004fail_gpio1:
1005 gpio_free(lcd_camera_ldo_1v8);
1006fail_gpio2:
1007 gpio_free(LCD_CAMERA_LDO_2V8);
1008
1009 return;
1010}
1011
1012static int lcd_camera_power_on_sku3(void)
1013{
1014 int rc = 0;
1015
1016 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1017 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1018
1019 pr_debug("turn on sku3 lcd_camera_ldo\n");
1020 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1021
1022 return rc;
1023}
1024
1025static int lcd_camera_power_off_sku3(void)
1026{
1027 int rc = 0;
1028
1029 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1030 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1031
1032 pr_debug("turn off sku3 lcd_camera_ldo\n");
1033 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1034
1035 gpio_free(lcd_camera_ldo_1v8);
1036 gpio_free(LCD_CAMERA_LDO_2V8);
1037
1038 return rc;
1039}
1040
1041int lcd_camera_power_onoff(int on)
1042{
1043 int rc = 0;
1044
1045 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1046
1047 if (on)
1048 rc = lcd_camera_power_on_sku3();
1049 else
1050 rc = lcd_camera_power_off_sku3();
1051
1052 return rc;
1053}
1054EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301055
Chintan Pandya40762702011-12-06 13:47:06 +05301056void __init msm7627a_camera_init(void)
1057{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301058
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301059#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301060 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301061#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301062
Su Liuaca04702012-02-14 02:27:32 +05301063 pr_debug("msm7627a_camera_init Entered\n");
1064 /* LCD and camera power (VREG & LDO) init */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301065 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
1066 evb_camera_gpio_cfg();
Su Liuaca04702012-02-14 02:27:32 +05301067 lcd_camera_power_init();
1068
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301069 }
1070
1071#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301072 if (machine_is_msm7627a_qrd1()) {
1073 qrd1_camera_gpio_cfg();
1074 platform_add_devices(camera_devices_qrd,
1075 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301076 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301077 platform_add_devices(camera_devices_evb,
1078 ARRAY_SIZE(camera_devices_evb));
1079 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301080 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301081 else
Chintan Pandya40762702011-12-06 13:47:06 +05301082 platform_add_devices(camera_devices_msm,
1083 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301084#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301085 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1086 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301087 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301088#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301089 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1090
1091 if (rc) {
1092 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1093 return;
1094 }
1095
1096 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1097
1098 if (rc) {
1099 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1100 return;
1101 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301102#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301103
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301104#if defined(CONFIG_MSM_CAMERA_V4L2)
1105 msm7x27a_init_cam();
1106#endif
1107#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301108 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301109 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1110 i2c_camera_devices_qrd,
1111 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301112 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301113 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1114 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1115 i2c_camera_devices_evb,
1116 ARRAY_SIZE(i2c_camera_devices_evb));
1117 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301118#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301119 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301120 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1121 i2c_camera_devices,
1122 ARRAY_SIZE(i2c_camera_devices));
1123}