blob: 9d01d90357a8afa1476b2b254985ac0460bc7f77 [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
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800117static struct i2c_board_info msm_act_main_cam_i2c_info = {
118 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530119};
120
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800121static struct msm_actuator_info msm_act_main_cam_4_info = {
122 .board_info = &msm_act_main_cam_i2c_info,
123 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530124 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
125 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
126 .vcm_enable = 1,
127};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530128
129#ifdef CONFIG_S5K4E1
130static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
131 .flash_type = MSM_CAMERA_FLASH_LED,
132 .flash_src = &msm_flash_src
133};
134
135static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
136 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530137 .cam_vreg = msm_cam_vreg,
138 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
139 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530140};
141
142static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
143 .sensor_name = "s5k4e1",
144 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530145 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530146 .pdata = &msm_camera_device_data_csi1,
147 .flash_data = &flash_s5k4e1,
148 .sensor_platform_info = &sensor_board_info_s5k4e1,
149 .csi_if = 1,
150 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530151 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800152 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530153};
154#endif
155
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530156#ifdef CONFIG_WEBCAM_OV7692_QRD
157static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
158 .mount_angle = 90,
159 .cam_vreg = msm_cam_vreg,
160 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
161 .gpio_conf = &gpio_conf_ov7692,
162};
163
164static struct msm_camera_sensor_flash_data flash_ov7692 = {
165 .flash_type = MSM_CAMERA_FLASH_NONE,
166};
167
168static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
169 .sensor_name = "ov7692",
170 .sensor_reset_enable = 0,
171 .pmic_gpio_enable = 1,
172 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
173 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
174 .pdata = &msm_camera_device_data_csi0,
175 .flash_data = &flash_ov7692,
176 .sensor_platform_info = &sensor_board_info_ov7692,
177 .csi_if = 1,
178 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530179 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530180};
181#endif
182
183#ifdef CONFIG_OV5647
184
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800185static struct msm_actuator_info msm_act_main_cam_5_info = {
186 .board_info = &msm_act_main_cam_i2c_info,
187 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530188 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
189 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
190 .vcm_enable = 1,
191};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530192
193static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
194 .mount_angle = 90,
195 .cam_vreg = msm_cam_vreg,
196 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
197 .gpio_conf = &gpio_conf_ov5647,
198};
199
200static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530201 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
202 ._fsrc.ext_driver_src.led_en = 13,
203 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530204};
205
206static struct msm_camera_sensor_flash_data flash_ov5647 = {
207 .flash_type = MSM_CAMERA_FLASH_LED,
208 .flash_src = &msm_flash_src_ov5647,
209};
210
211static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
212 .sensor_name = "ov5647",
213 .sensor_reset_enable = 1,
214 .pmic_gpio_enable = 1,
215 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
216 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
217 .pdata = &msm_camera_device_data_csi1,
218 .flash_data = &flash_ov5647,
219 .sensor_platform_info = &sensor_board_info_ov5647,
220 .csi_if = 1,
221 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530222 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800223 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530224};
225
226#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530227#ifdef CONFIG_MT9E013
228static struct msm_camera_sensor_flash_data flash_mt9e013 = {
229 .flash_type = MSM_CAMERA_FLASH_LED,
230 .flash_src = &msm_flash_src
231};
232
233static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
234 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530235 .cam_vreg = msm_cam_vreg,
236 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
237 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530238};
239
240static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
241 .sensor_name = "mt9e013",
242 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530243 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530244 .pdata = &msm_camera_device_data_csi1,
245 .flash_data = &flash_mt9e013,
246 .sensor_platform_info = &sensor_board_info_mt9e013,
247 .csi_if = 1,
248 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530249 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530250};
251#endif
252
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530253#ifdef CONFIG_WEBCAM_OV9726
254static struct msm_camera_sensor_flash_data flash_ov9726 = {
255 .flash_type = MSM_CAMERA_FLASH_LED,
256 .flash_src = &msm_flash_src
257};
258
259static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
260 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530261 .cam_vreg = msm_cam_vreg,
262 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
263 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530264};
265
266static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
267 .sensor_name = "ov9726",
268 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530269 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530270 .pdata = &msm_camera_device_data_csi0,
271 .flash_data = &flash_ov9726,
272 .sensor_platform_info = &sensor_board_info_ov9726,
273 .csi_if = 1,
274 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530275 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530276};
277#endif
278
Kevin Chan94b4c832012-03-02 21:27:16 -0800279static struct platform_device msm_camera_server = {
280 .name = "msm_cam_server",
281 .id = 0,
282};
283
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530284static void __init msm7x27a_init_cam(void)
285{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530286 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
287 || machine_is_msm7627a_qrd1())) {
288 sensor_board_info_s5k4e1.cam_vreg = NULL;
289 sensor_board_info_s5k4e1.num_vreg = 0;
290 sensor_board_info_mt9e013.cam_vreg = NULL;
291 sensor_board_info_mt9e013.num_vreg = 0;
292 sensor_board_info_ov9726.cam_vreg = NULL;
293 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530294 sensor_board_info_ov7692.cam_vreg = NULL;
295 sensor_board_info_ov7692.num_vreg = 0;
296 sensor_board_info_ov5647.cam_vreg = NULL;
297 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530298 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800299 platform_device_register(&msm_camera_server);
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 Vankadara6050cef52012-04-16 21:44:59 +0530307 if (machine_is_msm8625_evb())
308 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530309 platform_device_register(&msm7x27a_device_clkctl);
310 platform_device_register(&msm7x27a_device_vfe);
311}
312
313static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530314 {
315 I2C_BOARD_INFO("s5k4e1", 0x36),
316 .platform_data = &msm_camera_sensor_s5k4e1_data,
317 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530318 {
319 I2C_BOARD_INFO("ov9726", 0x10),
320 .platform_data = &msm_camera_sensor_ov9726_data,
321 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530322 {
323 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
324 .platform_data = &msm_camera_sensor_mt9e013_data,
325 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530326 {
327 I2C_BOARD_INFO("ov7692", 0x78),
328 .platform_data = &msm_camera_sensor_ov7692_data,
329 },
330 {
331 I2C_BOARD_INFO("ov5647", 0x36 << 1),
332 .platform_data = &msm_camera_sensor_ov5647_data,
333 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530334 {
335 I2C_BOARD_INFO("sc628a", 0x6E),
336 },
337};
338#else
Chintan Pandya40762702011-12-06 13:47:06 +0530339static uint32_t camera_off_gpio_table[] = {
340 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
341};
342
343static uint32_t camera_on_gpio_table[] = {
344 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
345};
346
347#ifdef CONFIG_MSM_CAMERA_FLASH
348static struct msm_camera_sensor_flash_src msm_flash_src = {
349 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
350 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
351 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
352};
353#endif
354
355static struct regulator_bulk_data regs_camera[] = {
356 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
357 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
358 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
359};
360
361static void qrd1_camera_gpio_cfg(void)
362{
363
364 int rc = 0;
365
366 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
367 if (rc < 0)
368 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
369 __func__);
370
371
372 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
373 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
374 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
375 if (rc < 0) {
376 pr_err("%s: unable to enable Power Down gpio for main"
377 "camera!\n", __func__);
378 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
379 }
380
381
382 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
383 if (rc < 0) {
384 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
385 __func__);
386 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
387 }
388
389
390 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
391 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
392 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
393 if (rc < 0) {
394 pr_err("%s: unable to enable reset gpio for main camera!\n",
395 __func__);
396 gpio_free(QRD_GPIO_CAM_5MP_RESET);
397 }
398
399 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
400 if (rc < 0)
401 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
402 __func__);
403
404 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
405 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
406 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
407 if (rc < 0) {
408 pr_err("%s: unable to enable Power Down gpio for front"
409 "camera!\n", __func__);
410 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
411 }
412
413 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
414 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
415 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
416}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530417#endif
Su Liuaca04702012-02-14 02:27:32 +0530418
419static void evb_camera_gpio_cfg(void)
420{
421 int rc = 0;
422
423 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
424 if (rc < 0)
425 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
426 __func__);
427
428 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
429 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
430 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
431 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
432 if (rc < 0) {
433 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
434 __func__);
435 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
436 }
437
438 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
439
440 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
441 if (rc < 0)
442 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
443 __func__);
444
445 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
446 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
447 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
448 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
449 if (rc < 0) {
450 pr_err("%s: unable to enable reset gpio for main camera!\n",
451 __func__);
452 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
453 }
454
455 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
456
457 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
458 if (rc < 0)
459 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
460 __func__);
461
462 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
463 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
464 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
465 if (rc < 0) {
466 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
467 __func__);
468 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
469 }
470
471 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
472
473 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
474 if (rc < 0)
475 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
476 __func__);
477
478 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
479 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
480 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
481
482 if (rc < 0) {
483 pr_err("%s: unable to enable reset gpio for front camera!\n",
484 __func__);
485 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
486 }
487 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
488
489}
490
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530491#ifndef CONFIG_MSM_CAMERA_V4L2
492
Chintan Pandya40762702011-12-06 13:47:06 +0530493static void msm_camera_vreg_config(int vreg_en)
494{
495 int rc = vreg_en ?
496 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
497 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
498
499 if (rc)
500 pr_err("%s: could not %sable regulators: %d\n",
501 __func__, vreg_en ? "en" : "dis", rc);
502}
503
504static int config_gpio_table(uint32_t *table, int len)
505{
506 int rc = 0, i = 0;
507
508 for (i = 0; i < len; i++) {
509 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
510 if (rc) {
511 pr_err("%s not able to get gpio\n", __func__);
512 for (i--; i >= 0; i--)
513 gpio_tlmm_config(camera_off_gpio_table[i],
514 GPIO_CFG_ENABLE);
515 break;
516 }
517 }
518 return rc;
519}
520
521static int config_camera_on_gpios_rear(void)
522{
523 int rc = 0;
524
525 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
526 || machine_is_msm7627a_qrd1())
527 msm_camera_vreg_config(1);
528
529 rc = config_gpio_table(camera_on_gpio_table,
530 ARRAY_SIZE(camera_on_gpio_table));
531 if (rc < 0) {
532 pr_err("%s: CAMSENSOR gpio table request"
533 "failed\n", __func__);
534 return rc;
535 }
536
537 return rc;
538}
539
540static void config_camera_off_gpios_rear(void)
541{
542 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
543 || machine_is_msm7627a_qrd1())
544 msm_camera_vreg_config(0);
545
546 config_gpio_table(camera_off_gpio_table,
547 ARRAY_SIZE(camera_off_gpio_table));
548}
549
550static int config_camera_on_gpios_front(void)
551{
552 int rc = 0;
553
554 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
555 || machine_is_msm7627a_qrd1())
556 msm_camera_vreg_config(1);
557
558 rc = config_gpio_table(camera_on_gpio_table,
559 ARRAY_SIZE(camera_on_gpio_table));
560 if (rc < 0) {
561 pr_err("%s: CAMSENSOR gpio table request"
562 "failed\n", __func__);
563 return rc;
564 }
565
566 return rc;
567}
568
569static void config_camera_off_gpios_front(void)
570{
571 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
572 || machine_is_msm7627a_qrd1())
573 msm_camera_vreg_config(0);
574
575 config_gpio_table(camera_off_gpio_table,
576 ARRAY_SIZE(camera_off_gpio_table));
577}
578
579struct msm_camera_device_platform_data msm_camera_device_data_rear = {
580 .camera_gpio_on = config_camera_on_gpios_rear,
581 .camera_gpio_off = config_camera_off_gpios_rear,
582 .ioext.csiphy = 0xA1000000,
583 .ioext.csisz = 0x00100000,
584 .ioext.csiirq = INT_CSI_IRQ_1,
585 .ioclk.mclk_clk_rate = 24000000,
586 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530587 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
588 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530589};
590
591struct msm_camera_device_platform_data msm_camera_device_data_front = {
592 .camera_gpio_on = config_camera_on_gpios_front,
593 .camera_gpio_off = config_camera_off_gpios_front,
594 .ioext.csiphy = 0xA0F00000,
595 .ioext.csisz = 0x00100000,
596 .ioext.csiirq = INT_CSI_IRQ_0,
597 .ioclk.mclk_clk_rate = 24000000,
598 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530599 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
600 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530601};
602
Su Liuaca04702012-02-14 02:27:32 +0530603#ifdef CONFIG_OV5647
604
605static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
606 .mount_angle = 90
607};
608
609static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
610 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
611 ._fsrc.led_src.led_name = "flashlight",
612 ._fsrc.led_src.led_name_len = 10,
613};
614
615static struct msm_camera_sensor_flash_data flash_ov5647 = {
616 .flash_type = MSM_CAMERA_FLASH_LED,
617 .flash_src = &msm_flash_src_ov5647,
618};
619
620static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
621 .sensor_name = "ov5647",
622 .sensor_reset_enable = 1,
623 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
624 .pmic_gpio_enable = 1,
625 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
626 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530627 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530628 .pdata = &msm_camera_device_data_rear,
629 .flash_data = &flash_ov5647,
630 .sensor_platform_info = &ov5647_sensor_7627a_info,
631 .csi_if = 1
632};
633
634static struct platform_device msm_camera_sensor_ov5647 = {
635 .name = "msm_camera_ov5647",
636 .dev = {
637 .platform_data = &msm_camera_sensor_ov5647_data,
638 },
639};
640#endif
641
Chintan Pandya40762702011-12-06 13:47:06 +0530642#ifdef CONFIG_S5K4E1
643static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
644 .mount_angle = 90
645};
646
647static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
648 .flash_type = MSM_CAMERA_FLASH_LED,
649 .flash_src = &msm_flash_src
650};
651
652static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
653 .sensor_name = "s5k4e1",
654 .sensor_reset_enable = 1,
655 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530656 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530657 .sensor_pwd = 85,
658 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
659 .vcm_enable = 1,
660 .pdata = &msm_camera_device_data_rear,
661 .flash_data = &flash_s5k4e1,
662 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
663 .csi_if = 1
664};
665
666static struct platform_device msm_camera_sensor_s5k4e1 = {
667 .name = "msm_camera_s5k4e1",
668 .dev = {
669 .platform_data = &msm_camera_sensor_s5k4e1_data,
670 },
671};
672#endif
673
674#ifdef CONFIG_IMX072
675static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
676 .mount_angle = 90
677};
678
679static struct msm_camera_sensor_flash_data flash_imx072 = {
680 .flash_type = MSM_CAMERA_FLASH_LED,
681 .flash_src = &msm_flash_src
682};
683
684static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
685 .sensor_name = "imx072",
686 .sensor_reset_enable = 1,
687 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530688 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530689 .sensor_pwd = 85,
690 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
691 .vcm_enable = 1,
692 .pdata = &msm_camera_device_data_rear,
693 .flash_data = &flash_imx072,
694 .sensor_platform_info = &imx072_sensor_7627a_info,
695 .csi_if = 1
696};
697
698static struct platform_device msm_camera_sensor_imx072 = {
699 .name = "msm_camera_imx072",
700 .dev = {
701 .platform_data = &msm_camera_sensor_imx072_data,
702 },
703};
704#endif
705
706static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
707#ifdef CONFIG_WEBCAM_OV9726
708static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
709 .mount_angle = 90
710};
711
712static struct msm_camera_sensor_flash_data flash_ov9726 = {
713 .flash_type = MSM_CAMERA_FLASH_NONE,
714 .flash_src = &msm_flash_src
715};
716
717static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
718 .sensor_name = "ov9726",
719 .sensor_reset_enable = 0,
720 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530721 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530722 .sensor_pwd = 85,
723 .vcm_pwd = 1,
724 .vcm_enable = 0,
725 .pdata = &msm_camera_device_data_front,
726 .flash_data = &flash_ov9726,
727 .sensor_platform_info = &ov9726_sensor_7627a_info,
728 .csi_if = 1
729};
730
731static struct platform_device msm_camera_sensor_ov9726 = {
732 .name = "msm_camera_ov9726",
733 .dev = {
734 .platform_data = &msm_camera_sensor_ov9726_data,
735 },
736};
737#else
738static inline void msm_camera_vreg_init(void) { }
739#endif
740
741#ifdef CONFIG_MT9E013
742static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
743 .mount_angle = 90
744};
745
746static struct msm_camera_sensor_flash_data flash_mt9e013 = {
747 .flash_type = MSM_CAMERA_FLASH_LED,
748 .flash_src = &msm_flash_src
749};
750
751static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
752 .sensor_name = "mt9e013",
753 .sensor_reset = 0,
754 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530755 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530756 .sensor_pwd = 85,
757 .vcm_pwd = 1,
758 .vcm_enable = 0,
759 .pdata = &msm_camera_device_data_rear,
760 .flash_data = &flash_mt9e013,
761 .sensor_platform_info = &mt9e013_sensor_7627a_info,
762 .csi_if = 1
763};
764
765static struct platform_device msm_camera_sensor_mt9e013 = {
766 .name = "msm_camera_mt9e013",
767 .dev = {
768 .platform_data = &msm_camera_sensor_mt9e013_data,
769 },
770};
771#endif
772
773#ifdef CONFIG_OV5640
774static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
775 .mount_angle = 90
776};
777
778static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
779 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
780 ._fsrc.led_src.led_name = "flashlight",
781 ._fsrc.led_src.led_name_len = 10,
782};
783
784static struct msm_camera_sensor_flash_data flash_ov5640 = {
785 .flash_type = MSM_CAMERA_FLASH_LED,
786 .flash_src = &msm_flash_src_ov5640,
787};
788
789static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
790 .sensor_name = "ov5640",
791 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530792 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530793 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
794 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
795 .vcm_pwd = 0,
796 .vcm_enable = 0,
797 .pdata = &msm_camera_device_data_rear,
798 .flash_data = &flash_ov5640,
799 .sensor_platform_info = &ov5640_sensor_info,
800 .csi_if = 1,
801};
802
803static struct platform_device msm_camera_sensor_ov5640 = {
804 .name = "msm_camera_ov5640",
805 .dev = {
806 .platform_data = &msm_camera_sensor_ov5640_data,
807 },
808};
809#endif
810
811#ifdef CONFIG_WEBCAM_OV7692_QRD
812static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
813 .mount_angle = 90
814};
815
816static struct msm_camera_sensor_flash_data flash_ov7692 = {
817 .flash_type = MSM_CAMERA_FLASH_NONE,
818};
819
820static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
821 .sensor_name = "ov7692",
822 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530823 .pmic_gpio_enable = 1,
824 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
825 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530826 .vcm_pwd = 0,
827 .vcm_enable = 0,
828 .pdata = &msm_camera_device_data_front,
829 .flash_data = &flash_ov7692,
830 .sensor_platform_info = &ov7692_sensor_7627a_info,
831 .csi_if = 1,
832};
833
834static struct platform_device msm_camera_sensor_ov7692 = {
835 .name = "msm_camera_ov7692",
836 .dev = {
837 .platform_data = &msm_camera_sensor_ov7692_data,
838 },
839};
840#endif
841
Chintan Pandya40762702011-12-06 13:47:06 +0530842static struct i2c_board_info i2c_camera_devices[] = {
843 #ifdef CONFIG_S5K4E1
844 {
845 I2C_BOARD_INFO("s5k4e1", 0x36),
846 },
847 {
848 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
849 },
850 #endif
851 #ifdef CONFIG_WEBCAM_OV9726
852 {
853 I2C_BOARD_INFO("ov9726", 0x10),
854 },
855 #endif
856 #ifdef CONFIG_IMX072
857 {
858 I2C_BOARD_INFO("imx072", 0x34),
859 },
860 #endif
861 #ifdef CONFIG_MT9E013
862 {
863 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
864 },
865 #endif
866 {
867 I2C_BOARD_INFO("sc628a", 0x6E),
868 },
869};
870
871static struct i2c_board_info i2c_camera_devices_qrd[] = {
872 #ifdef CONFIG_OV5640
873 {
874 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
875 },
876 #endif
877 #ifdef CONFIG_WEBCAM_OV7692_QRD
878 {
879 I2C_BOARD_INFO("ov7692", 0x78),
880 },
881 #endif
882};
883
Su Liuaca04702012-02-14 02:27:32 +0530884static struct i2c_board_info i2c_camera_devices_evb[] = {
885 #ifdef CONFIG_OV5647
886 {
887 I2C_BOARD_INFO("ov5647", 0x36 << 1),
888 },
889 {
890 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
891 },
892 #endif
893 #ifdef CONFIG_WEBCAM_OV7692_QRD
894 {
895 I2C_BOARD_INFO("ov7692", 0x78),
896 },
897 #endif
898};
899
Chintan Pandya40762702011-12-06 13:47:06 +0530900static struct platform_device *camera_devices_msm[] __initdata = {
901#ifdef CONFIG_S5K4E1
902 &msm_camera_sensor_s5k4e1,
903#endif
904#ifdef CONFIG_IMX072
905 &msm_camera_sensor_imx072,
906#endif
907#ifdef CONFIG_WEBCAM_OV9726
908 &msm_camera_sensor_ov9726,
909#endif
910#ifdef CONFIG_MT9E013
911 &msm_camera_sensor_mt9e013,
912#endif
913};
914
915static struct platform_device *camera_devices_qrd[] __initdata = {
916#ifdef CONFIG_OV5640
917 &msm_camera_sensor_ov5640,
918#endif
919#ifdef CONFIG_WEBCAM_OV7692_QRD
920 &msm_camera_sensor_ov7692,
921#endif
922};
Su Liuaca04702012-02-14 02:27:32 +0530923
924static struct platform_device *camera_devices_evb[] __initdata = {
925#ifdef CONFIG_OV5647
926 &msm_camera_sensor_ov5647,
927#endif
928#ifdef CONFIG_WEBCAM_OV7692_QRD
929 &msm_camera_sensor_ov7692,
930#endif
931};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530932#endif
933
934enum {
935 SX150X_CAM,
936};
937
938static struct sx150x_platform_data sx150x_data[] __initdata = {
939 [SX150X_CAM] = {
940 .gpio_base = GPIO_CAM_EXPANDER_BASE,
941 .oscio_is_gpo = false,
942 .io_pullup_ena = 0,
943 .io_pulldn_ena = 0,
944 .io_open_drain_ena = 0x23,
945 .irq_summary = -1,
946 },
947};
948
949static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
950 {
951 I2C_BOARD_INFO("sx1508q", 0x22),
952 .platform_data = &sx150x_data[SX150X_CAM],
953 },
954};
Chintan Pandya40762702011-12-06 13:47:06 +0530955
956static void __init register_i2c_devices(void)
957{
958 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
959 cam_exp_i2c_info,
960 ARRAY_SIZE(cam_exp_i2c_info));
961}
962
Su Liuaca04702012-02-14 02:27:32 +0530963#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
964#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
965
966static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
967
968static void lcd_camera_power_init(void)
969{
970 int rc = 0;
971
972 pr_debug("lcd_camera_power_init\n");
973
974 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
975
976 /* LDO_EXT2V8 */
977 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
978 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
979 return;
980 }
981
982 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
983 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
984 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
985 if (rc < 0) {
986 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
987 goto fail_gpio2;
988 }
989
990 /* LDO_EVT1V8 */
991 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
992 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
993 goto fail_gpio2;
994 }
995
996 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
997 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
998 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
999 if (rc < 0) {
1000 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1001 goto fail_gpio1;
1002 }
1003
1004 return;
1005
1006fail_gpio1:
1007 gpio_free(lcd_camera_ldo_1v8);
1008fail_gpio2:
1009 gpio_free(LCD_CAMERA_LDO_2V8);
1010
1011 return;
1012}
1013
1014static int lcd_camera_power_on_sku3(void)
1015{
1016 int rc = 0;
1017
1018 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1019 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1020
1021 pr_debug("turn on sku3 lcd_camera_ldo\n");
1022 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1023
1024 return rc;
1025}
1026
1027static int lcd_camera_power_off_sku3(void)
1028{
1029 int rc = 0;
1030
1031 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1032 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1033
1034 pr_debug("turn off sku3 lcd_camera_ldo\n");
1035 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1036
1037 gpio_free(lcd_camera_ldo_1v8);
1038 gpio_free(LCD_CAMERA_LDO_2V8);
1039
1040 return rc;
1041}
1042
1043int lcd_camera_power_onoff(int on)
1044{
1045 int rc = 0;
1046
1047 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1048
1049 if (on)
1050 rc = lcd_camera_power_on_sku3();
1051 else
1052 rc = lcd_camera_power_off_sku3();
1053
1054 return rc;
1055}
1056EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301057
Chintan Pandya40762702011-12-06 13:47:06 +05301058void __init msm7627a_camera_init(void)
1059{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301060
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301061#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301062 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301063#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301064
Su Liuaca04702012-02-14 02:27:32 +05301065 pr_debug("msm7627a_camera_init Entered\n");
1066 /* LCD and camera power (VREG & LDO) init */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301067 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301068 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301069 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301070 }
1071
1072#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301073 if (machine_is_msm7627a_qrd1()) {
1074 qrd1_camera_gpio_cfg();
1075 platform_add_devices(camera_devices_qrd,
1076 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301077 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301078 platform_add_devices(camera_devices_evb,
1079 ARRAY_SIZE(camera_devices_evb));
1080 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301081 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301082 else
Chintan Pandya40762702011-12-06 13:47:06 +05301083 platform_add_devices(camera_devices_msm,
1084 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301085#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301086 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1087 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301088 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301089#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301090 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1091
1092 if (rc) {
1093 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1094 return;
1095 }
1096
1097 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1098
1099 if (rc) {
1100 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1101 return;
1102 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301103#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301104
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301105#if defined(CONFIG_MSM_CAMERA_V4L2)
1106 msm7x27a_init_cam();
1107#endif
1108#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301109 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301110 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1111 i2c_camera_devices_qrd,
1112 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301113 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301114 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1115 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1116 i2c_camera_devices_evb,
1117 ARRAY_SIZE(i2c_camera_devices_evb));
1118 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301119#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301120 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301121 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1122 i2c_camera_devices,
1123 ARRAY_SIZE(i2c_camera_devices));
1124}