blob: f7333b947ae30155101ce7bebbf1b2ed015ed31b [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
279static void __init msm7x27a_init_cam(void)
280{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530281 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
282 || machine_is_msm7627a_qrd1())) {
283 sensor_board_info_s5k4e1.cam_vreg = NULL;
284 sensor_board_info_s5k4e1.num_vreg = 0;
285 sensor_board_info_mt9e013.cam_vreg = NULL;
286 sensor_board_info_mt9e013.num_vreg = 0;
287 sensor_board_info_ov9726.cam_vreg = NULL;
288 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530289 sensor_board_info_ov7692.cam_vreg = NULL;
290 sensor_board_info_ov7692.num_vreg = 0;
291 sensor_board_info_ov5647.cam_vreg = NULL;
292 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530293 }
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530294 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()) {
295 platform_device_register(&msm8625_device_csic0);
296 platform_device_register(&msm8625_device_csic1);
297 } else {
298 platform_device_register(&msm7x27a_device_csic0);
299 platform_device_register(&msm7x27a_device_csic1);
300 }
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530301 if (machine_is_msm8625_evb())
302 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530303 platform_device_register(&msm7x27a_device_clkctl);
304 platform_device_register(&msm7x27a_device_vfe);
305}
306
307static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530308 {
309 I2C_BOARD_INFO("s5k4e1", 0x36),
310 .platform_data = &msm_camera_sensor_s5k4e1_data,
311 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530312 {
313 I2C_BOARD_INFO("ov9726", 0x10),
314 .platform_data = &msm_camera_sensor_ov9726_data,
315 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530316 {
317 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
318 .platform_data = &msm_camera_sensor_mt9e013_data,
319 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530320 {
321 I2C_BOARD_INFO("ov7692", 0x78),
322 .platform_data = &msm_camera_sensor_ov7692_data,
323 },
324 {
325 I2C_BOARD_INFO("ov5647", 0x36 << 1),
326 .platform_data = &msm_camera_sensor_ov5647_data,
327 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530328 {
329 I2C_BOARD_INFO("sc628a", 0x6E),
330 },
331};
332#else
Chintan Pandya40762702011-12-06 13:47:06 +0530333static uint32_t camera_off_gpio_table[] = {
334 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
335};
336
337static uint32_t camera_on_gpio_table[] = {
338 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
339};
340
341#ifdef CONFIG_MSM_CAMERA_FLASH
342static struct msm_camera_sensor_flash_src msm_flash_src = {
343 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
344 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
345 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
346};
347#endif
348
349static struct regulator_bulk_data regs_camera[] = {
350 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
351 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
352 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
353};
354
355static void qrd1_camera_gpio_cfg(void)
356{
357
358 int rc = 0;
359
360 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
361 if (rc < 0)
362 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
363 __func__);
364
365
366 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
367 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
368 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
369 if (rc < 0) {
370 pr_err("%s: unable to enable Power Down gpio for main"
371 "camera!\n", __func__);
372 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
373 }
374
375
376 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
377 if (rc < 0) {
378 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
379 __func__);
380 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
381 }
382
383
384 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
385 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
386 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
387 if (rc < 0) {
388 pr_err("%s: unable to enable reset gpio for main camera!\n",
389 __func__);
390 gpio_free(QRD_GPIO_CAM_5MP_RESET);
391 }
392
393 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
394 if (rc < 0)
395 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
396 __func__);
397
398 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
399 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
400 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
401 if (rc < 0) {
402 pr_err("%s: unable to enable Power Down gpio for front"
403 "camera!\n", __func__);
404 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
405 }
406
407 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
408 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
409 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
410}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530411#endif
Su Liuaca04702012-02-14 02:27:32 +0530412
413static void evb_camera_gpio_cfg(void)
414{
415 int rc = 0;
416
417 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
418 if (rc < 0)
419 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
420 __func__);
421
422 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
423 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
424 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
425 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
426 if (rc < 0) {
427 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
428 __func__);
429 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
430 }
431
432 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
433
434 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
435 if (rc < 0)
436 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
437 __func__);
438
439 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
440 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
441 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
442 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
443 if (rc < 0) {
444 pr_err("%s: unable to enable reset gpio for main camera!\n",
445 __func__);
446 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
447 }
448
449 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
450
451 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
452 if (rc < 0)
453 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
454 __func__);
455
456 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
457 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
458 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
459 if (rc < 0) {
460 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
461 __func__);
462 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
463 }
464
465 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
466
467 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
468 if (rc < 0)
469 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
470 __func__);
471
472 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
473 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
474 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
475
476 if (rc < 0) {
477 pr_err("%s: unable to enable reset gpio for front camera!\n",
478 __func__);
479 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
480 }
481 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
482
483}
484
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530485#ifndef CONFIG_MSM_CAMERA_V4L2
486
Chintan Pandya40762702011-12-06 13:47:06 +0530487static void msm_camera_vreg_config(int vreg_en)
488{
489 int rc = vreg_en ?
490 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
491 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
492
493 if (rc)
494 pr_err("%s: could not %sable regulators: %d\n",
495 __func__, vreg_en ? "en" : "dis", rc);
496}
497
498static int config_gpio_table(uint32_t *table, int len)
499{
500 int rc = 0, i = 0;
501
502 for (i = 0; i < len; i++) {
503 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
504 if (rc) {
505 pr_err("%s not able to get gpio\n", __func__);
506 for (i--; i >= 0; i--)
507 gpio_tlmm_config(camera_off_gpio_table[i],
508 GPIO_CFG_ENABLE);
509 break;
510 }
511 }
512 return rc;
513}
514
515static int config_camera_on_gpios_rear(void)
516{
517 int rc = 0;
518
519 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
520 || machine_is_msm7627a_qrd1())
521 msm_camera_vreg_config(1);
522
523 rc = config_gpio_table(camera_on_gpio_table,
524 ARRAY_SIZE(camera_on_gpio_table));
525 if (rc < 0) {
526 pr_err("%s: CAMSENSOR gpio table request"
527 "failed\n", __func__);
528 return rc;
529 }
530
531 return rc;
532}
533
534static void config_camera_off_gpios_rear(void)
535{
536 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
537 || machine_is_msm7627a_qrd1())
538 msm_camera_vreg_config(0);
539
540 config_gpio_table(camera_off_gpio_table,
541 ARRAY_SIZE(camera_off_gpio_table));
542}
543
544static int config_camera_on_gpios_front(void)
545{
546 int rc = 0;
547
548 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
549 || machine_is_msm7627a_qrd1())
550 msm_camera_vreg_config(1);
551
552 rc = config_gpio_table(camera_on_gpio_table,
553 ARRAY_SIZE(camera_on_gpio_table));
554 if (rc < 0) {
555 pr_err("%s: CAMSENSOR gpio table request"
556 "failed\n", __func__);
557 return rc;
558 }
559
560 return rc;
561}
562
563static void config_camera_off_gpios_front(void)
564{
565 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
566 || machine_is_msm7627a_qrd1())
567 msm_camera_vreg_config(0);
568
569 config_gpio_table(camera_off_gpio_table,
570 ARRAY_SIZE(camera_off_gpio_table));
571}
572
573struct msm_camera_device_platform_data msm_camera_device_data_rear = {
574 .camera_gpio_on = config_camera_on_gpios_rear,
575 .camera_gpio_off = config_camera_off_gpios_rear,
576 .ioext.csiphy = 0xA1000000,
577 .ioext.csisz = 0x00100000,
578 .ioext.csiirq = INT_CSI_IRQ_1,
579 .ioclk.mclk_clk_rate = 24000000,
580 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530581 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
582 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530583};
584
585struct msm_camera_device_platform_data msm_camera_device_data_front = {
586 .camera_gpio_on = config_camera_on_gpios_front,
587 .camera_gpio_off = config_camera_off_gpios_front,
588 .ioext.csiphy = 0xA0F00000,
589 .ioext.csisz = 0x00100000,
590 .ioext.csiirq = INT_CSI_IRQ_0,
591 .ioclk.mclk_clk_rate = 24000000,
592 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530593 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
594 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530595};
596
Su Liuaca04702012-02-14 02:27:32 +0530597#ifdef CONFIG_OV5647
598
599static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
600 .mount_angle = 90
601};
602
603static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
604 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
605 ._fsrc.led_src.led_name = "flashlight",
606 ._fsrc.led_src.led_name_len = 10,
607};
608
609static struct msm_camera_sensor_flash_data flash_ov5647 = {
610 .flash_type = MSM_CAMERA_FLASH_LED,
611 .flash_src = &msm_flash_src_ov5647,
612};
613
614static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
615 .sensor_name = "ov5647",
616 .sensor_reset_enable = 1,
617 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
618 .pmic_gpio_enable = 1,
619 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
620 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530621 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530622 .pdata = &msm_camera_device_data_rear,
623 .flash_data = &flash_ov5647,
624 .sensor_platform_info = &ov5647_sensor_7627a_info,
625 .csi_if = 1
626};
627
628static struct platform_device msm_camera_sensor_ov5647 = {
629 .name = "msm_camera_ov5647",
630 .dev = {
631 .platform_data = &msm_camera_sensor_ov5647_data,
632 },
633};
634#endif
635
Chintan Pandya40762702011-12-06 13:47:06 +0530636#ifdef CONFIG_S5K4E1
637static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
638 .mount_angle = 90
639};
640
641static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
642 .flash_type = MSM_CAMERA_FLASH_LED,
643 .flash_src = &msm_flash_src
644};
645
646static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
647 .sensor_name = "s5k4e1",
648 .sensor_reset_enable = 1,
649 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530650 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530651 .sensor_pwd = 85,
652 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
653 .vcm_enable = 1,
654 .pdata = &msm_camera_device_data_rear,
655 .flash_data = &flash_s5k4e1,
656 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
657 .csi_if = 1
658};
659
660static struct platform_device msm_camera_sensor_s5k4e1 = {
661 .name = "msm_camera_s5k4e1",
662 .dev = {
663 .platform_data = &msm_camera_sensor_s5k4e1_data,
664 },
665};
666#endif
667
668#ifdef CONFIG_IMX072
669static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
670 .mount_angle = 90
671};
672
673static struct msm_camera_sensor_flash_data flash_imx072 = {
674 .flash_type = MSM_CAMERA_FLASH_LED,
675 .flash_src = &msm_flash_src
676};
677
678static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
679 .sensor_name = "imx072",
680 .sensor_reset_enable = 1,
681 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530682 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530683 .sensor_pwd = 85,
684 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
685 .vcm_enable = 1,
686 .pdata = &msm_camera_device_data_rear,
687 .flash_data = &flash_imx072,
688 .sensor_platform_info = &imx072_sensor_7627a_info,
689 .csi_if = 1
690};
691
692static struct platform_device msm_camera_sensor_imx072 = {
693 .name = "msm_camera_imx072",
694 .dev = {
695 .platform_data = &msm_camera_sensor_imx072_data,
696 },
697};
698#endif
699
700static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
701#ifdef CONFIG_WEBCAM_OV9726
702static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
703 .mount_angle = 90
704};
705
706static struct msm_camera_sensor_flash_data flash_ov9726 = {
707 .flash_type = MSM_CAMERA_FLASH_NONE,
708 .flash_src = &msm_flash_src
709};
710
711static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
712 .sensor_name = "ov9726",
713 .sensor_reset_enable = 0,
714 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530715 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530716 .sensor_pwd = 85,
717 .vcm_pwd = 1,
718 .vcm_enable = 0,
719 .pdata = &msm_camera_device_data_front,
720 .flash_data = &flash_ov9726,
721 .sensor_platform_info = &ov9726_sensor_7627a_info,
722 .csi_if = 1
723};
724
725static struct platform_device msm_camera_sensor_ov9726 = {
726 .name = "msm_camera_ov9726",
727 .dev = {
728 .platform_data = &msm_camera_sensor_ov9726_data,
729 },
730};
731#else
732static inline void msm_camera_vreg_init(void) { }
733#endif
734
735#ifdef CONFIG_MT9E013
736static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
737 .mount_angle = 90
738};
739
740static struct msm_camera_sensor_flash_data flash_mt9e013 = {
741 .flash_type = MSM_CAMERA_FLASH_LED,
742 .flash_src = &msm_flash_src
743};
744
745static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
746 .sensor_name = "mt9e013",
747 .sensor_reset = 0,
748 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530749 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530750 .sensor_pwd = 85,
751 .vcm_pwd = 1,
752 .vcm_enable = 0,
753 .pdata = &msm_camera_device_data_rear,
754 .flash_data = &flash_mt9e013,
755 .sensor_platform_info = &mt9e013_sensor_7627a_info,
756 .csi_if = 1
757};
758
759static struct platform_device msm_camera_sensor_mt9e013 = {
760 .name = "msm_camera_mt9e013",
761 .dev = {
762 .platform_data = &msm_camera_sensor_mt9e013_data,
763 },
764};
765#endif
766
767#ifdef CONFIG_OV5640
768static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
769 .mount_angle = 90
770};
771
772static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
773 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
774 ._fsrc.led_src.led_name = "flashlight",
775 ._fsrc.led_src.led_name_len = 10,
776};
777
778static struct msm_camera_sensor_flash_data flash_ov5640 = {
779 .flash_type = MSM_CAMERA_FLASH_LED,
780 .flash_src = &msm_flash_src_ov5640,
781};
782
783static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
784 .sensor_name = "ov5640",
785 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530786 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530787 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
788 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
789 .vcm_pwd = 0,
790 .vcm_enable = 0,
791 .pdata = &msm_camera_device_data_rear,
792 .flash_data = &flash_ov5640,
793 .sensor_platform_info = &ov5640_sensor_info,
794 .csi_if = 1,
795};
796
797static struct platform_device msm_camera_sensor_ov5640 = {
798 .name = "msm_camera_ov5640",
799 .dev = {
800 .platform_data = &msm_camera_sensor_ov5640_data,
801 },
802};
803#endif
804
805#ifdef CONFIG_WEBCAM_OV7692_QRD
806static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
807 .mount_angle = 90
808};
809
810static struct msm_camera_sensor_flash_data flash_ov7692 = {
811 .flash_type = MSM_CAMERA_FLASH_NONE,
812};
813
814static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
815 .sensor_name = "ov7692",
816 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530817 .pmic_gpio_enable = 1,
818 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
819 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530820 .vcm_pwd = 0,
821 .vcm_enable = 0,
822 .pdata = &msm_camera_device_data_front,
823 .flash_data = &flash_ov7692,
824 .sensor_platform_info = &ov7692_sensor_7627a_info,
825 .csi_if = 1,
826};
827
828static struct platform_device msm_camera_sensor_ov7692 = {
829 .name = "msm_camera_ov7692",
830 .dev = {
831 .platform_data = &msm_camera_sensor_ov7692_data,
832 },
833};
834#endif
835
Chintan Pandya40762702011-12-06 13:47:06 +0530836static struct i2c_board_info i2c_camera_devices[] = {
837 #ifdef CONFIG_S5K4E1
838 {
839 I2C_BOARD_INFO("s5k4e1", 0x36),
840 },
841 {
842 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
843 },
844 #endif
845 #ifdef CONFIG_WEBCAM_OV9726
846 {
847 I2C_BOARD_INFO("ov9726", 0x10),
848 },
849 #endif
850 #ifdef CONFIG_IMX072
851 {
852 I2C_BOARD_INFO("imx072", 0x34),
853 },
854 #endif
855 #ifdef CONFIG_MT9E013
856 {
857 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
858 },
859 #endif
860 {
861 I2C_BOARD_INFO("sc628a", 0x6E),
862 },
863};
864
865static struct i2c_board_info i2c_camera_devices_qrd[] = {
866 #ifdef CONFIG_OV5640
867 {
868 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
869 },
870 #endif
871 #ifdef CONFIG_WEBCAM_OV7692_QRD
872 {
873 I2C_BOARD_INFO("ov7692", 0x78),
874 },
875 #endif
876};
877
Su Liuaca04702012-02-14 02:27:32 +0530878static struct i2c_board_info i2c_camera_devices_evb[] = {
879 #ifdef CONFIG_OV5647
880 {
881 I2C_BOARD_INFO("ov5647", 0x36 << 1),
882 },
883 {
884 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
885 },
886 #endif
887 #ifdef CONFIG_WEBCAM_OV7692_QRD
888 {
889 I2C_BOARD_INFO("ov7692", 0x78),
890 },
891 #endif
892};
893
Chintan Pandya40762702011-12-06 13:47:06 +0530894static struct platform_device *camera_devices_msm[] __initdata = {
895#ifdef CONFIG_S5K4E1
896 &msm_camera_sensor_s5k4e1,
897#endif
898#ifdef CONFIG_IMX072
899 &msm_camera_sensor_imx072,
900#endif
901#ifdef CONFIG_WEBCAM_OV9726
902 &msm_camera_sensor_ov9726,
903#endif
904#ifdef CONFIG_MT9E013
905 &msm_camera_sensor_mt9e013,
906#endif
907};
908
909static struct platform_device *camera_devices_qrd[] __initdata = {
910#ifdef CONFIG_OV5640
911 &msm_camera_sensor_ov5640,
912#endif
913#ifdef CONFIG_WEBCAM_OV7692_QRD
914 &msm_camera_sensor_ov7692,
915#endif
916};
Su Liuaca04702012-02-14 02:27:32 +0530917
918static struct platform_device *camera_devices_evb[] __initdata = {
919#ifdef CONFIG_OV5647
920 &msm_camera_sensor_ov5647,
921#endif
922#ifdef CONFIG_WEBCAM_OV7692_QRD
923 &msm_camera_sensor_ov7692,
924#endif
925};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530926#endif
927
928enum {
929 SX150X_CAM,
930};
931
932static struct sx150x_platform_data sx150x_data[] __initdata = {
933 [SX150X_CAM] = {
934 .gpio_base = GPIO_CAM_EXPANDER_BASE,
935 .oscio_is_gpo = false,
936 .io_pullup_ena = 0,
937 .io_pulldn_ena = 0,
938 .io_open_drain_ena = 0x23,
939 .irq_summary = -1,
940 },
941};
942
943static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
944 {
945 I2C_BOARD_INFO("sx1508q", 0x22),
946 .platform_data = &sx150x_data[SX150X_CAM],
947 },
948};
Chintan Pandya40762702011-12-06 13:47:06 +0530949
950static void __init register_i2c_devices(void)
951{
952 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
953 cam_exp_i2c_info,
954 ARRAY_SIZE(cam_exp_i2c_info));
955}
956
Su Liuaca04702012-02-14 02:27:32 +0530957#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
958#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
959
960static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
961
962static void lcd_camera_power_init(void)
963{
964 int rc = 0;
965
966 pr_debug("lcd_camera_power_init\n");
967
968 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
969
970 /* LDO_EXT2V8 */
971 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
972 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
973 return;
974 }
975
976 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
977 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
978 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
979 if (rc < 0) {
980 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
981 goto fail_gpio2;
982 }
983
984 /* LDO_EVT1V8 */
985 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
986 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
987 goto fail_gpio2;
988 }
989
990 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
991 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
992 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
993 if (rc < 0) {
994 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
995 goto fail_gpio1;
996 }
997
998 return;
999
1000fail_gpio1:
1001 gpio_free(lcd_camera_ldo_1v8);
1002fail_gpio2:
1003 gpio_free(LCD_CAMERA_LDO_2V8);
1004
1005 return;
1006}
1007
1008static int lcd_camera_power_on_sku3(void)
1009{
1010 int rc = 0;
1011
1012 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1013 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1014
1015 pr_debug("turn on sku3 lcd_camera_ldo\n");
1016 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1017
1018 return rc;
1019}
1020
1021static int lcd_camera_power_off_sku3(void)
1022{
1023 int rc = 0;
1024
1025 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1026 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1027
1028 pr_debug("turn off sku3 lcd_camera_ldo\n");
1029 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1030
1031 gpio_free(lcd_camera_ldo_1v8);
1032 gpio_free(LCD_CAMERA_LDO_2V8);
1033
1034 return rc;
1035}
1036
1037int lcd_camera_power_onoff(int on)
1038{
1039 int rc = 0;
1040
1041 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1042
1043 if (on)
1044 rc = lcd_camera_power_on_sku3();
1045 else
1046 rc = lcd_camera_power_off_sku3();
1047
1048 return rc;
1049}
1050EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301051
Chintan Pandya40762702011-12-06 13:47:06 +05301052void __init msm7627a_camera_init(void)
1053{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301054
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301055#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301056 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301057#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301058
Su Liuaca04702012-02-14 02:27:32 +05301059 pr_debug("msm7627a_camera_init Entered\n");
1060 /* LCD and camera power (VREG & LDO) init */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301061 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301062 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301063 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301064 }
1065
1066#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301067 if (machine_is_msm7627a_qrd1()) {
1068 qrd1_camera_gpio_cfg();
1069 platform_add_devices(camera_devices_qrd,
1070 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301071 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301072 platform_add_devices(camera_devices_evb,
1073 ARRAY_SIZE(camera_devices_evb));
1074 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301075 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301076 else
Chintan Pandya40762702011-12-06 13:47:06 +05301077 platform_add_devices(camera_devices_msm,
1078 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301079#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301080 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1081 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301082 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301083#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301084 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1085
1086 if (rc) {
1087 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1088 return;
1089 }
1090
1091 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1092
1093 if (rc) {
1094 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1095 return;
1096 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301097#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301098
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301099#if defined(CONFIG_MSM_CAMERA_V4L2)
1100 msm7x27a_init_cam();
1101#endif
1102#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301103 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301104 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1105 i2c_camera_devices_qrd,
1106 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301107 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301108 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1109 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1110 i2c_camera_devices_evb,
1111 ARRAY_SIZE(i2c_camera_devices_evb));
1112 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301113#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301114 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301115 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1116 i2c_camera_devices,
1117 ARRAY_SIZE(i2c_camera_devices));
1118}