blob: 8e64a43ab37045b11d079fdc474aafca5286bd99 [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()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530287 || machine_is_msm7627a_qrd1()
288 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530289 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 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800300 platform_device_register(&msm_camera_server);
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530301 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()) {
302 platform_device_register(&msm8625_device_csic0);
303 platform_device_register(&msm8625_device_csic1);
304 } else {
305 platform_device_register(&msm7x27a_device_csic0);
306 platform_device_register(&msm7x27a_device_csic1);
307 }
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530308 if (machine_is_msm8625_evb())
309 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530310 platform_device_register(&msm7x27a_device_clkctl);
311 platform_device_register(&msm7x27a_device_vfe);
312}
313
314static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530315 {
316 I2C_BOARD_INFO("s5k4e1", 0x36),
317 .platform_data = &msm_camera_sensor_s5k4e1_data,
318 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530319 {
320 I2C_BOARD_INFO("ov9726", 0x10),
321 .platform_data = &msm_camera_sensor_ov9726_data,
322 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530323 {
324 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
325 .platform_data = &msm_camera_sensor_mt9e013_data,
326 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530327 {
328 I2C_BOARD_INFO("ov7692", 0x78),
329 .platform_data = &msm_camera_sensor_ov7692_data,
330 },
331 {
332 I2C_BOARD_INFO("ov5647", 0x36 << 1),
333 .platform_data = &msm_camera_sensor_ov5647_data,
334 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530335 {
336 I2C_BOARD_INFO("sc628a", 0x6E),
337 },
338};
339#else
Chintan Pandya40762702011-12-06 13:47:06 +0530340static uint32_t camera_off_gpio_table[] = {
341 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
342};
343
344static uint32_t camera_on_gpio_table[] = {
345 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
346};
347
348#ifdef CONFIG_MSM_CAMERA_FLASH
349static struct msm_camera_sensor_flash_src msm_flash_src = {
350 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
351 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
352 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
353};
354#endif
355
356static struct regulator_bulk_data regs_camera[] = {
357 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
358 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
359 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
360};
361
362static void qrd1_camera_gpio_cfg(void)
363{
364
365 int rc = 0;
366
367 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
368 if (rc < 0)
369 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
370 __func__);
371
372
373 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
374 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
375 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
376 if (rc < 0) {
377 pr_err("%s: unable to enable Power Down gpio for main"
378 "camera!\n", __func__);
379 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
380 }
381
382
383 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
384 if (rc < 0) {
385 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
386 __func__);
387 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
388 }
389
390
391 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
392 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
393 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
394 if (rc < 0) {
395 pr_err("%s: unable to enable reset gpio for main camera!\n",
396 __func__);
397 gpio_free(QRD_GPIO_CAM_5MP_RESET);
398 }
399
400 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
401 if (rc < 0)
402 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
403 __func__);
404
405 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
406 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
407 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
408 if (rc < 0) {
409 pr_err("%s: unable to enable Power Down gpio for front"
410 "camera!\n", __func__);
411 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
412 }
413
414 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
415 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
416 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
417}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530418#endif
Su Liuaca04702012-02-14 02:27:32 +0530419
420static void evb_camera_gpio_cfg(void)
421{
422 int rc = 0;
423
424 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
425 if (rc < 0)
426 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
427 __func__);
428
429 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
430 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
431 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
432 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
433 if (rc < 0) {
434 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
435 __func__);
436 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
437 }
438
439 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
440
441 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
442 if (rc < 0)
443 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
444 __func__);
445
446 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
447 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
448 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
449 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
450 if (rc < 0) {
451 pr_err("%s: unable to enable reset gpio for main camera!\n",
452 __func__);
453 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
454 }
455
456 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
457
458 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
459 if (rc < 0)
460 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
461 __func__);
462
463 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
464 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
465 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
466 if (rc < 0) {
467 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
468 __func__);
469 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
470 }
471
472 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
473
474 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
475 if (rc < 0)
476 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
477 __func__);
478
479 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
480 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
481 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
482
483 if (rc < 0) {
484 pr_err("%s: unable to enable reset gpio for front camera!\n",
485 __func__);
486 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
487 }
488 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
489
490}
491
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530492#ifndef CONFIG_MSM_CAMERA_V4L2
493
Chintan Pandya40762702011-12-06 13:47:06 +0530494static void msm_camera_vreg_config(int vreg_en)
495{
496 int rc = vreg_en ?
497 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
498 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
499
500 if (rc)
501 pr_err("%s: could not %sable regulators: %d\n",
502 __func__, vreg_en ? "en" : "dis", rc);
503}
504
505static int config_gpio_table(uint32_t *table, int len)
506{
507 int rc = 0, i = 0;
508
509 for (i = 0; i < len; i++) {
510 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
511 if (rc) {
512 pr_err("%s not able to get gpio\n", __func__);
513 for (i--; i >= 0; i--)
514 gpio_tlmm_config(camera_off_gpio_table[i],
515 GPIO_CFG_ENABLE);
516 break;
517 }
518 }
519 return rc;
520}
521
522static int config_camera_on_gpios_rear(void)
523{
524 int rc = 0;
525
526 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530527 || machine_is_msm7627a_qrd1()
528 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530529 msm_camera_vreg_config(1);
530
531 rc = config_gpio_table(camera_on_gpio_table,
532 ARRAY_SIZE(camera_on_gpio_table));
533 if (rc < 0) {
534 pr_err("%s: CAMSENSOR gpio table request"
535 "failed\n", __func__);
536 return rc;
537 }
538
539 return rc;
540}
541
542static void config_camera_off_gpios_rear(void)
543{
544 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530545 || machine_is_msm7627a_qrd1()
546 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530547 msm_camera_vreg_config(0);
548
549 config_gpio_table(camera_off_gpio_table,
550 ARRAY_SIZE(camera_off_gpio_table));
551}
552
553static int config_camera_on_gpios_front(void)
554{
555 int rc = 0;
556
557 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530558 || machine_is_msm7627a_qrd1()
559 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530560 msm_camera_vreg_config(1);
561
562 rc = config_gpio_table(camera_on_gpio_table,
563 ARRAY_SIZE(camera_on_gpio_table));
564 if (rc < 0) {
565 pr_err("%s: CAMSENSOR gpio table request"
566 "failed\n", __func__);
567 return rc;
568 }
569
570 return rc;
571}
572
573static void config_camera_off_gpios_front(void)
574{
575 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530576 || machine_is_msm7627a_qrd1()
577 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530578 msm_camera_vreg_config(0);
579
580 config_gpio_table(camera_off_gpio_table,
581 ARRAY_SIZE(camera_off_gpio_table));
582}
583
584struct msm_camera_device_platform_data msm_camera_device_data_rear = {
585 .camera_gpio_on = config_camera_on_gpios_rear,
586 .camera_gpio_off = config_camera_off_gpios_rear,
587 .ioext.csiphy = 0xA1000000,
588 .ioext.csisz = 0x00100000,
589 .ioext.csiirq = INT_CSI_IRQ_1,
590 .ioclk.mclk_clk_rate = 24000000,
591 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530592 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
593 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530594};
595
596struct msm_camera_device_platform_data msm_camera_device_data_front = {
597 .camera_gpio_on = config_camera_on_gpios_front,
598 .camera_gpio_off = config_camera_off_gpios_front,
599 .ioext.csiphy = 0xA0F00000,
600 .ioext.csisz = 0x00100000,
601 .ioext.csiirq = INT_CSI_IRQ_0,
602 .ioclk.mclk_clk_rate = 24000000,
603 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530604 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
605 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530606};
607
Su Liuaca04702012-02-14 02:27:32 +0530608#ifdef CONFIG_OV5647
609
610static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
611 .mount_angle = 90
612};
613
614static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
615 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
616 ._fsrc.led_src.led_name = "flashlight",
617 ._fsrc.led_src.led_name_len = 10,
618};
619
620static struct msm_camera_sensor_flash_data flash_ov5647 = {
621 .flash_type = MSM_CAMERA_FLASH_LED,
622 .flash_src = &msm_flash_src_ov5647,
623};
624
625static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
626 .sensor_name = "ov5647",
627 .sensor_reset_enable = 1,
628 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
629 .pmic_gpio_enable = 1,
630 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
631 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530632 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530633 .pdata = &msm_camera_device_data_rear,
634 .flash_data = &flash_ov5647,
635 .sensor_platform_info = &ov5647_sensor_7627a_info,
636 .csi_if = 1
637};
638
639static struct platform_device msm_camera_sensor_ov5647 = {
640 .name = "msm_camera_ov5647",
641 .dev = {
642 .platform_data = &msm_camera_sensor_ov5647_data,
643 },
644};
645#endif
646
Chintan Pandya40762702011-12-06 13:47:06 +0530647#ifdef CONFIG_S5K4E1
648static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
649 .mount_angle = 90
650};
651
652static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
653 .flash_type = MSM_CAMERA_FLASH_LED,
654 .flash_src = &msm_flash_src
655};
656
657static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
658 .sensor_name = "s5k4e1",
659 .sensor_reset_enable = 1,
660 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530661 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530662 .sensor_pwd = 85,
663 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
664 .vcm_enable = 1,
665 .pdata = &msm_camera_device_data_rear,
666 .flash_data = &flash_s5k4e1,
667 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
668 .csi_if = 1
669};
670
671static struct platform_device msm_camera_sensor_s5k4e1 = {
672 .name = "msm_camera_s5k4e1",
673 .dev = {
674 .platform_data = &msm_camera_sensor_s5k4e1_data,
675 },
676};
677#endif
678
679#ifdef CONFIG_IMX072
680static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
681 .mount_angle = 90
682};
683
684static struct msm_camera_sensor_flash_data flash_imx072 = {
685 .flash_type = MSM_CAMERA_FLASH_LED,
686 .flash_src = &msm_flash_src
687};
688
689static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
690 .sensor_name = "imx072",
691 .sensor_reset_enable = 1,
692 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530693 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530694 .sensor_pwd = 85,
695 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
696 .vcm_enable = 1,
697 .pdata = &msm_camera_device_data_rear,
698 .flash_data = &flash_imx072,
699 .sensor_platform_info = &imx072_sensor_7627a_info,
700 .csi_if = 1
701};
702
703static struct platform_device msm_camera_sensor_imx072 = {
704 .name = "msm_camera_imx072",
705 .dev = {
706 .platform_data = &msm_camera_sensor_imx072_data,
707 },
708};
709#endif
710
711static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
712#ifdef CONFIG_WEBCAM_OV9726
713static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
714 .mount_angle = 90
715};
716
717static struct msm_camera_sensor_flash_data flash_ov9726 = {
718 .flash_type = MSM_CAMERA_FLASH_NONE,
719 .flash_src = &msm_flash_src
720};
721
722static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
723 .sensor_name = "ov9726",
724 .sensor_reset_enable = 0,
725 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530726 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530727 .sensor_pwd = 85,
728 .vcm_pwd = 1,
729 .vcm_enable = 0,
730 .pdata = &msm_camera_device_data_front,
731 .flash_data = &flash_ov9726,
732 .sensor_platform_info = &ov9726_sensor_7627a_info,
733 .csi_if = 1
734};
735
736static struct platform_device msm_camera_sensor_ov9726 = {
737 .name = "msm_camera_ov9726",
738 .dev = {
739 .platform_data = &msm_camera_sensor_ov9726_data,
740 },
741};
742#else
743static inline void msm_camera_vreg_init(void) { }
744#endif
745
746#ifdef CONFIG_MT9E013
747static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
748 .mount_angle = 90
749};
750
751static struct msm_camera_sensor_flash_data flash_mt9e013 = {
752 .flash_type = MSM_CAMERA_FLASH_LED,
753 .flash_src = &msm_flash_src
754};
755
756static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
757 .sensor_name = "mt9e013",
758 .sensor_reset = 0,
759 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530760 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530761 .sensor_pwd = 85,
762 .vcm_pwd = 1,
763 .vcm_enable = 0,
764 .pdata = &msm_camera_device_data_rear,
765 .flash_data = &flash_mt9e013,
766 .sensor_platform_info = &mt9e013_sensor_7627a_info,
767 .csi_if = 1
768};
769
770static struct platform_device msm_camera_sensor_mt9e013 = {
771 .name = "msm_camera_mt9e013",
772 .dev = {
773 .platform_data = &msm_camera_sensor_mt9e013_data,
774 },
775};
776#endif
777
778#ifdef CONFIG_OV5640
779static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
780 .mount_angle = 90
781};
782
783static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
784 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
785 ._fsrc.led_src.led_name = "flashlight",
786 ._fsrc.led_src.led_name_len = 10,
787};
788
789static struct msm_camera_sensor_flash_data flash_ov5640 = {
790 .flash_type = MSM_CAMERA_FLASH_LED,
791 .flash_src = &msm_flash_src_ov5640,
792};
793
794static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
795 .sensor_name = "ov5640",
796 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530797 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530798 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
799 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
800 .vcm_pwd = 0,
801 .vcm_enable = 0,
802 .pdata = &msm_camera_device_data_rear,
803 .flash_data = &flash_ov5640,
804 .sensor_platform_info = &ov5640_sensor_info,
805 .csi_if = 1,
806};
807
808static struct platform_device msm_camera_sensor_ov5640 = {
809 .name = "msm_camera_ov5640",
810 .dev = {
811 .platform_data = &msm_camera_sensor_ov5640_data,
812 },
813};
814#endif
815
816#ifdef CONFIG_WEBCAM_OV7692_QRD
817static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
818 .mount_angle = 90
819};
820
821static struct msm_camera_sensor_flash_data flash_ov7692 = {
822 .flash_type = MSM_CAMERA_FLASH_NONE,
823};
824
825static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
826 .sensor_name = "ov7692",
827 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530828 .pmic_gpio_enable = 1,
829 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
830 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530831 .vcm_pwd = 0,
832 .vcm_enable = 0,
833 .pdata = &msm_camera_device_data_front,
834 .flash_data = &flash_ov7692,
835 .sensor_platform_info = &ov7692_sensor_7627a_info,
836 .csi_if = 1,
837};
838
839static struct platform_device msm_camera_sensor_ov7692 = {
840 .name = "msm_camera_ov7692",
841 .dev = {
842 .platform_data = &msm_camera_sensor_ov7692_data,
843 },
844};
845#endif
846
Chintan Pandya40762702011-12-06 13:47:06 +0530847static struct i2c_board_info i2c_camera_devices[] = {
848 #ifdef CONFIG_S5K4E1
849 {
850 I2C_BOARD_INFO("s5k4e1", 0x36),
851 },
852 {
853 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
854 },
855 #endif
856 #ifdef CONFIG_WEBCAM_OV9726
857 {
858 I2C_BOARD_INFO("ov9726", 0x10),
859 },
860 #endif
861 #ifdef CONFIG_IMX072
862 {
863 I2C_BOARD_INFO("imx072", 0x34),
864 },
865 #endif
866 #ifdef CONFIG_MT9E013
867 {
868 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
869 },
870 #endif
871 {
872 I2C_BOARD_INFO("sc628a", 0x6E),
873 },
874};
875
876static struct i2c_board_info i2c_camera_devices_qrd[] = {
877 #ifdef CONFIG_OV5640
878 {
879 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
880 },
881 #endif
882 #ifdef CONFIG_WEBCAM_OV7692_QRD
883 {
884 I2C_BOARD_INFO("ov7692", 0x78),
885 },
886 #endif
887};
888
Su Liuaca04702012-02-14 02:27:32 +0530889static struct i2c_board_info i2c_camera_devices_evb[] = {
890 #ifdef CONFIG_OV5647
891 {
892 I2C_BOARD_INFO("ov5647", 0x36 << 1),
893 },
894 {
895 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
896 },
897 #endif
898 #ifdef CONFIG_WEBCAM_OV7692_QRD
899 {
900 I2C_BOARD_INFO("ov7692", 0x78),
901 },
902 #endif
903};
904
Chintan Pandya40762702011-12-06 13:47:06 +0530905static struct platform_device *camera_devices_msm[] __initdata = {
906#ifdef CONFIG_S5K4E1
907 &msm_camera_sensor_s5k4e1,
908#endif
909#ifdef CONFIG_IMX072
910 &msm_camera_sensor_imx072,
911#endif
912#ifdef CONFIG_WEBCAM_OV9726
913 &msm_camera_sensor_ov9726,
914#endif
915#ifdef CONFIG_MT9E013
916 &msm_camera_sensor_mt9e013,
917#endif
918};
919
920static struct platform_device *camera_devices_qrd[] __initdata = {
921#ifdef CONFIG_OV5640
922 &msm_camera_sensor_ov5640,
923#endif
924#ifdef CONFIG_WEBCAM_OV7692_QRD
925 &msm_camera_sensor_ov7692,
926#endif
927};
Su Liuaca04702012-02-14 02:27:32 +0530928
929static struct platform_device *camera_devices_evb[] __initdata = {
930#ifdef CONFIG_OV5647
931 &msm_camera_sensor_ov5647,
932#endif
933#ifdef CONFIG_WEBCAM_OV7692_QRD
934 &msm_camera_sensor_ov7692,
935#endif
936};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530937#endif
938
939enum {
940 SX150X_CAM,
941};
942
943static struct sx150x_platform_data sx150x_data[] __initdata = {
944 [SX150X_CAM] = {
945 .gpio_base = GPIO_CAM_EXPANDER_BASE,
946 .oscio_is_gpo = false,
947 .io_pullup_ena = 0,
948 .io_pulldn_ena = 0,
949 .io_open_drain_ena = 0x23,
950 .irq_summary = -1,
951 },
952};
953
954static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
955 {
956 I2C_BOARD_INFO("sx1508q", 0x22),
957 .platform_data = &sx150x_data[SX150X_CAM],
958 },
959};
Chintan Pandya40762702011-12-06 13:47:06 +0530960
961static void __init register_i2c_devices(void)
962{
963 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
964 cam_exp_i2c_info,
965 ARRAY_SIZE(cam_exp_i2c_info));
966}
967
Su Liuaca04702012-02-14 02:27:32 +0530968#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
969#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
970
971static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
972
973static void lcd_camera_power_init(void)
974{
975 int rc = 0;
976
977 pr_debug("lcd_camera_power_init\n");
978
979 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
980
981 /* LDO_EXT2V8 */
982 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
983 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
984 return;
985 }
986
987 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
988 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
989 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
990 if (rc < 0) {
991 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
992 goto fail_gpio2;
993 }
994
995 /* LDO_EVT1V8 */
996 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
997 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
998 goto fail_gpio2;
999 }
1000
1001 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1002 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1003 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1004 if (rc < 0) {
1005 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1006 goto fail_gpio1;
1007 }
1008
1009 return;
1010
1011fail_gpio1:
1012 gpio_free(lcd_camera_ldo_1v8);
1013fail_gpio2:
1014 gpio_free(LCD_CAMERA_LDO_2V8);
1015
1016 return;
1017}
1018
1019static int lcd_camera_power_on_sku3(void)
1020{
1021 int rc = 0;
1022
1023 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1024 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1025
1026 pr_debug("turn on sku3 lcd_camera_ldo\n");
1027 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1028
1029 return rc;
1030}
1031
1032static int lcd_camera_power_off_sku3(void)
1033{
1034 int rc = 0;
1035
1036 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1037 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1038
1039 pr_debug("turn off sku3 lcd_camera_ldo\n");
1040 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1041
1042 gpio_free(lcd_camera_ldo_1v8);
1043 gpio_free(LCD_CAMERA_LDO_2V8);
1044
1045 return rc;
1046}
1047
1048int lcd_camera_power_onoff(int on)
1049{
1050 int rc = 0;
1051
1052 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1053
1054 if (on)
1055 rc = lcd_camera_power_on_sku3();
1056 else
1057 rc = lcd_camera_power_off_sku3();
1058
1059 return rc;
1060}
1061EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301062
Chintan Pandya40762702011-12-06 13:47:06 +05301063void __init msm7627a_camera_init(void)
1064{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301065
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301066#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301067 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301068#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301069
Su Liuaca04702012-02-14 02:27:32 +05301070 pr_debug("msm7627a_camera_init Entered\n");
1071 /* LCD and camera power (VREG & LDO) init */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301072 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301073 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301074 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301075 }
1076
1077#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301078 if (machine_is_msm7627a_qrd1()) {
1079 qrd1_camera_gpio_cfg();
1080 platform_add_devices(camera_devices_qrd,
1081 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301082 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301083 platform_add_devices(camera_devices_evb,
1084 ARRAY_SIZE(camera_devices_evb));
1085 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301086 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301087 else
Chintan Pandya40762702011-12-06 13:47:06 +05301088 platform_add_devices(camera_devices_msm,
1089 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301090#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301091 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1092 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301093 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301094#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301095 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1096
1097 if (rc) {
1098 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1099 return;
1100 }
1101
1102 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1103
1104 if (rc) {
1105 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1106 return;
1107 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301108#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301109
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301110#if defined(CONFIG_MSM_CAMERA_V4L2)
1111 msm7x27a_init_cam();
1112#endif
1113#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301114 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301115 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1116 i2c_camera_devices_qrd,
1117 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301118 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301119 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1120 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1121 i2c_camera_devices_evb,
1122 ARRAY_SIZE(i2c_camera_devices_evb));
1123 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301124#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301125 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301126 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1127 i2c_camera_devices,
1128 ARRAY_SIZE(i2c_camera_devices));
1129}