blob: e97fdad4a123f7b4fbed56598537ac5ee9086edc [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
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070076static struct gpio ov7692_cam_req_gpio[] = {
77 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_DIR_OUT, "CAM_VGA_SHDN"},
78 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_DIR_OUT, "CAM_VGA_RESET"},
79};
80
81static struct msm_gpio_set_tbl ov7692_cam_gpio_set_tbl[] = {
82 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_HIGH, 5000},
83 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_LOW, 5000},
84 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_HIGH, 5000},
85 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_LOW, 5000},
86 {40, GPIOF_OUT_INIT_HIGH, 5000},
87 {35, GPIOF_OUT_INIT_HIGH, 5000},
88};
89
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053090static struct msm_camera_gpio_conf gpio_conf_ov7692 = {
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070091 .cam_gpio_req_tbl = ov7692_cam_req_gpio,
92 .cam_gpio_req_tbl_size = ARRAY_SIZE(ov7692_cam_req_gpio),
93 .cam_gpio_set_tbl = ov7692_cam_gpio_set_tbl,
94 .cam_gpio_set_tbl_size = ARRAY_SIZE(ov7692_cam_gpio_set_tbl),
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053095 .gpio_no_mux = 1,
96};
97#endif
98
99#ifdef CONFIG_OV5647
100static struct msm_camera_gpio_conf gpio_conf_ov5647 = {
101 .camera_off_table = camera_off_gpio_table,
102 .camera_on_table = camera_on_gpio_table,
103 .gpio_no_mux = 1,
104};
105#endif
106
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530107#ifdef CONFIG_MSM_CAMERA_FLASH
108static struct msm_camera_sensor_flash_src msm_flash_src = {
109 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
110 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
111 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
112};
113#endif
114
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530115static struct camera_vreg_t msm_cam_vreg[] = {
116 {"msme1", REG_LDO, 1800000, 1800000, 0},
117 {"gp2", REG_LDO, 2850000, 2850000, 0},
118 {"usb2", REG_LDO, 1800000, 1800000, 0},
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530119};
120
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530121static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530122
123struct msm_camera_device_platform_data msm_camera_device_data_csi1 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530124 .csid_core = 1,
125 .is_csic = 1,
126};
127
128struct msm_camera_device_platform_data msm_camera_device_data_csi0 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530129 .csid_core = 0,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530130 .is_csic = 1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530131};
132
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800133static struct i2c_board_info msm_act_main_cam_i2c_info = {
134 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530135};
136
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800137static struct msm_actuator_info msm_act_main_cam_4_info = {
138 .board_info = &msm_act_main_cam_i2c_info,
139 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530140 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
141 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
142 .vcm_enable = 1,
143};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530144
145#ifdef CONFIG_S5K4E1
146static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
147 .flash_type = MSM_CAMERA_FLASH_LED,
148 .flash_src = &msm_flash_src
149};
150
151static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
152 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530153 .cam_vreg = msm_cam_vreg,
154 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
155 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530156};
157
158static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
159 .sensor_name = "s5k4e1",
160 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530161 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530162 .pdata = &msm_camera_device_data_csi1,
163 .flash_data = &flash_s5k4e1,
164 .sensor_platform_info = &sensor_board_info_s5k4e1,
165 .csi_if = 1,
166 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530167 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800168 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530169};
170#endif
171
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530172#ifdef CONFIG_WEBCAM_OV7692_QRD
173static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
174 .mount_angle = 90,
175 .cam_vreg = msm_cam_vreg,
176 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
177 .gpio_conf = &gpio_conf_ov7692,
178};
179
180static struct msm_camera_sensor_flash_data flash_ov7692 = {
181 .flash_type = MSM_CAMERA_FLASH_NONE,
182};
183
184static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
185 .sensor_name = "ov7692",
186 .sensor_reset_enable = 0,
187 .pmic_gpio_enable = 1,
188 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
189 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
190 .pdata = &msm_camera_device_data_csi0,
191 .flash_data = &flash_ov7692,
192 .sensor_platform_info = &sensor_board_info_ov7692,
193 .csi_if = 1,
194 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530195 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530196};
197#endif
198
199#ifdef CONFIG_OV5647
200
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800201static struct msm_actuator_info msm_act_main_cam_5_info = {
202 .board_info = &msm_act_main_cam_i2c_info,
203 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530204 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
205 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
206 .vcm_enable = 1,
207};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530208
209static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
210 .mount_angle = 90,
211 .cam_vreg = msm_cam_vreg,
212 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
213 .gpio_conf = &gpio_conf_ov5647,
214};
215
216static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530217 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
218 ._fsrc.ext_driver_src.led_en = 13,
219 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530220};
221
222static struct msm_camera_sensor_flash_data flash_ov5647 = {
223 .flash_type = MSM_CAMERA_FLASH_LED,
224 .flash_src = &msm_flash_src_ov5647,
225};
226
227static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
228 .sensor_name = "ov5647",
229 .sensor_reset_enable = 1,
230 .pmic_gpio_enable = 1,
231 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
232 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
233 .pdata = &msm_camera_device_data_csi1,
234 .flash_data = &flash_ov5647,
235 .sensor_platform_info = &sensor_board_info_ov5647,
236 .csi_if = 1,
237 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530238 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800239 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530240};
241
242#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530243#ifdef CONFIG_MT9E013
244static struct msm_camera_sensor_flash_data flash_mt9e013 = {
245 .flash_type = MSM_CAMERA_FLASH_LED,
246 .flash_src = &msm_flash_src
247};
248
249static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
250 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530251 .cam_vreg = msm_cam_vreg,
252 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
253 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530254};
255
256static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
257 .sensor_name = "mt9e013",
258 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530259 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530260 .pdata = &msm_camera_device_data_csi1,
261 .flash_data = &flash_mt9e013,
262 .sensor_platform_info = &sensor_board_info_mt9e013,
263 .csi_if = 1,
264 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530265 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530266};
267#endif
268
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530269#ifdef CONFIG_WEBCAM_OV9726
270static struct msm_camera_sensor_flash_data flash_ov9726 = {
271 .flash_type = MSM_CAMERA_FLASH_LED,
272 .flash_src = &msm_flash_src
273};
274
275static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
276 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530277 .cam_vreg = msm_cam_vreg,
278 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
279 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530280};
281
282static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
283 .sensor_name = "ov9726",
284 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530285 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530286 .pdata = &msm_camera_device_data_csi0,
287 .flash_data = &flash_ov9726,
288 .sensor_platform_info = &sensor_board_info_ov9726,
289 .csi_if = 1,
290 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530291 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530292};
293#endif
294
Kevin Chan94b4c832012-03-02 21:27:16 -0800295static struct platform_device msm_camera_server = {
296 .name = "msm_cam_server",
297 .id = 0,
298};
299
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530300static void __init msm7x27a_init_cam(void)
301{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530302 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530303 || machine_is_msm7627a_qrd1()
304 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530305 sensor_board_info_s5k4e1.cam_vreg = NULL;
306 sensor_board_info_s5k4e1.num_vreg = 0;
307 sensor_board_info_mt9e013.cam_vreg = NULL;
308 sensor_board_info_mt9e013.num_vreg = 0;
309 sensor_board_info_ov9726.cam_vreg = NULL;
310 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530311 sensor_board_info_ov7692.cam_vreg = NULL;
312 sensor_board_info_ov7692.num_vreg = 0;
313 sensor_board_info_ov5647.cam_vreg = NULL;
314 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530315 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800316 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530317 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
318 || machine_is_msm8625_evt()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530319 platform_device_register(&msm8625_device_csic0);
320 platform_device_register(&msm8625_device_csic1);
321 } else {
322 platform_device_register(&msm7x27a_device_csic0);
323 platform_device_register(&msm7x27a_device_csic1);
324 }
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530325 if (machine_is_msm8625_evb() || machine_is_msm8625_evt())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530326 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530327 platform_device_register(&msm7x27a_device_clkctl);
328 platform_device_register(&msm7x27a_device_vfe);
329}
330
331static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530332 {
333 I2C_BOARD_INFO("s5k4e1", 0x36),
334 .platform_data = &msm_camera_sensor_s5k4e1_data,
335 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530336 {
337 I2C_BOARD_INFO("ov9726", 0x10),
338 .platform_data = &msm_camera_sensor_ov9726_data,
339 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530340 {
341 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
342 .platform_data = &msm_camera_sensor_mt9e013_data,
343 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530344 {
345 I2C_BOARD_INFO("ov7692", 0x78),
346 .platform_data = &msm_camera_sensor_ov7692_data,
347 },
348 {
349 I2C_BOARD_INFO("ov5647", 0x36 << 1),
350 .platform_data = &msm_camera_sensor_ov5647_data,
351 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530352 {
353 I2C_BOARD_INFO("sc628a", 0x6E),
354 },
355};
356#else
Chintan Pandya40762702011-12-06 13:47:06 +0530357static uint32_t camera_off_gpio_table[] = {
358 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
359};
360
361static uint32_t camera_on_gpio_table[] = {
362 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
363};
364
365#ifdef CONFIG_MSM_CAMERA_FLASH
366static struct msm_camera_sensor_flash_src msm_flash_src = {
367 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
368 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
369 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
370};
371#endif
372
373static struct regulator_bulk_data regs_camera[] = {
374 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
375 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
376 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
377};
378
379static void qrd1_camera_gpio_cfg(void)
380{
381
382 int rc = 0;
383
384 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
385 if (rc < 0)
386 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
387 __func__);
388
389
390 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 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 Power Down gpio for main"
395 "camera!\n", __func__);
396 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
397 }
398
399
400 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
401 if (rc < 0) {
402 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
403 __func__);
404 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
405 }
406
407
408 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
409 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
410 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
411 if (rc < 0) {
412 pr_err("%s: unable to enable reset gpio for main camera!\n",
413 __func__);
414 gpio_free(QRD_GPIO_CAM_5MP_RESET);
415 }
416
417 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
418 if (rc < 0)
419 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
420 __func__);
421
422 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
423 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
424 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
425 if (rc < 0) {
426 pr_err("%s: unable to enable Power Down gpio for front"
427 "camera!\n", __func__);
428 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
429 }
430
431 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
432 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
433 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
434}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530435#endif
Su Liuaca04702012-02-14 02:27:32 +0530436
437static void evb_camera_gpio_cfg(void)
438{
439 int rc = 0;
440
441 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
442 if (rc < 0)
443 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
444 __func__);
445
446 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
447 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 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 Powr Dwn gpio for main camera!\n",
452 __func__);
453 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
454 }
455
456 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
457
458 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
459 if (rc < 0)
460 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
461 __func__);
462
463 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
464 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
465 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
466 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
467 if (rc < 0) {
468 pr_err("%s: unable to enable reset gpio for main camera!\n",
469 __func__);
470 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
471 }
472
473 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
474
Su Liuaca04702012-02-14 02:27:32 +0530475}
476
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530477#ifndef CONFIG_MSM_CAMERA_V4L2
478
Chintan Pandya40762702011-12-06 13:47:06 +0530479static void msm_camera_vreg_config(int vreg_en)
480{
481 int rc = vreg_en ?
482 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
483 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
484
485 if (rc)
486 pr_err("%s: could not %sable regulators: %d\n",
487 __func__, vreg_en ? "en" : "dis", rc);
488}
489
490static int config_gpio_table(uint32_t *table, int len)
491{
492 int rc = 0, i = 0;
493
494 for (i = 0; i < len; i++) {
495 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
496 if (rc) {
497 pr_err("%s not able to get gpio\n", __func__);
498 for (i--; i >= 0; i--)
499 gpio_tlmm_config(camera_off_gpio_table[i],
500 GPIO_CFG_ENABLE);
501 break;
502 }
503 }
504 return rc;
505}
506
507static int config_camera_on_gpios_rear(void)
508{
509 int rc = 0;
510
511 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530512 || machine_is_msm7627a_qrd1()
513 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530514 msm_camera_vreg_config(1);
515
516 rc = config_gpio_table(camera_on_gpio_table,
517 ARRAY_SIZE(camera_on_gpio_table));
518 if (rc < 0) {
519 pr_err("%s: CAMSENSOR gpio table request"
520 "failed\n", __func__);
521 return rc;
522 }
523
524 return rc;
525}
526
527static void config_camera_off_gpios_rear(void)
528{
529 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530530 || machine_is_msm7627a_qrd1()
531 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530532 msm_camera_vreg_config(0);
533
534 config_gpio_table(camera_off_gpio_table,
535 ARRAY_SIZE(camera_off_gpio_table));
536}
537
538static int config_camera_on_gpios_front(void)
539{
540 int rc = 0;
541
542 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530543 || machine_is_msm7627a_qrd1()
544 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530545 msm_camera_vreg_config(1);
546
547 rc = config_gpio_table(camera_on_gpio_table,
548 ARRAY_SIZE(camera_on_gpio_table));
549 if (rc < 0) {
550 pr_err("%s: CAMSENSOR gpio table request"
551 "failed\n", __func__);
552 return rc;
553 }
554
555 return rc;
556}
557
558static void config_camera_off_gpios_front(void)
559{
560 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530561 || machine_is_msm7627a_qrd1()
562 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530563 msm_camera_vreg_config(0);
564
565 config_gpio_table(camera_off_gpio_table,
566 ARRAY_SIZE(camera_off_gpio_table));
567}
568
569struct msm_camera_device_platform_data msm_camera_device_data_rear = {
570 .camera_gpio_on = config_camera_on_gpios_rear,
571 .camera_gpio_off = config_camera_off_gpios_rear,
572 .ioext.csiphy = 0xA1000000,
573 .ioext.csisz = 0x00100000,
574 .ioext.csiirq = INT_CSI_IRQ_1,
575 .ioclk.mclk_clk_rate = 24000000,
576 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530577 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
578 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530579};
580
581struct msm_camera_device_platform_data msm_camera_device_data_front = {
582 .camera_gpio_on = config_camera_on_gpios_front,
583 .camera_gpio_off = config_camera_off_gpios_front,
584 .ioext.csiphy = 0xA0F00000,
585 .ioext.csisz = 0x00100000,
586 .ioext.csiirq = INT_CSI_IRQ_0,
587 .ioclk.mclk_clk_rate = 24000000,
588 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530589 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
590 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530591};
592
Su Liuaca04702012-02-14 02:27:32 +0530593#ifdef CONFIG_OV5647
594
595static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
596 .mount_angle = 90
597};
598
599static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
600 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
601 ._fsrc.led_src.led_name = "flashlight",
602 ._fsrc.led_src.led_name_len = 10,
603};
604
605static struct msm_camera_sensor_flash_data flash_ov5647 = {
606 .flash_type = MSM_CAMERA_FLASH_LED,
607 .flash_src = &msm_flash_src_ov5647,
608};
609
610static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
611 .sensor_name = "ov5647",
612 .sensor_reset_enable = 1,
613 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
614 .pmic_gpio_enable = 1,
615 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
616 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530617 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530618 .pdata = &msm_camera_device_data_rear,
619 .flash_data = &flash_ov5647,
620 .sensor_platform_info = &ov5647_sensor_7627a_info,
621 .csi_if = 1
622};
623
624static struct platform_device msm_camera_sensor_ov5647 = {
625 .name = "msm_camera_ov5647",
626 .dev = {
627 .platform_data = &msm_camera_sensor_ov5647_data,
628 },
629};
630#endif
631
Chintan Pandya40762702011-12-06 13:47:06 +0530632#ifdef CONFIG_S5K4E1
633static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
634 .mount_angle = 90
635};
636
637static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
638 .flash_type = MSM_CAMERA_FLASH_LED,
639 .flash_src = &msm_flash_src
640};
641
642static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
643 .sensor_name = "s5k4e1",
644 .sensor_reset_enable = 1,
645 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530646 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530647 .sensor_pwd = 85,
648 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
649 .vcm_enable = 1,
650 .pdata = &msm_camera_device_data_rear,
651 .flash_data = &flash_s5k4e1,
652 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
653 .csi_if = 1
654};
655
656static struct platform_device msm_camera_sensor_s5k4e1 = {
657 .name = "msm_camera_s5k4e1",
658 .dev = {
659 .platform_data = &msm_camera_sensor_s5k4e1_data,
660 },
661};
662#endif
663
664#ifdef CONFIG_IMX072
665static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
666 .mount_angle = 90
667};
668
669static struct msm_camera_sensor_flash_data flash_imx072 = {
670 .flash_type = MSM_CAMERA_FLASH_LED,
671 .flash_src = &msm_flash_src
672};
673
674static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
675 .sensor_name = "imx072",
676 .sensor_reset_enable = 1,
677 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530678 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530679 .sensor_pwd = 85,
680 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
681 .vcm_enable = 1,
682 .pdata = &msm_camera_device_data_rear,
683 .flash_data = &flash_imx072,
684 .sensor_platform_info = &imx072_sensor_7627a_info,
685 .csi_if = 1
686};
687
688static struct platform_device msm_camera_sensor_imx072 = {
689 .name = "msm_camera_imx072",
690 .dev = {
691 .platform_data = &msm_camera_sensor_imx072_data,
692 },
693};
694#endif
695
696static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
697#ifdef CONFIG_WEBCAM_OV9726
698static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
699 .mount_angle = 90
700};
701
702static struct msm_camera_sensor_flash_data flash_ov9726 = {
703 .flash_type = MSM_CAMERA_FLASH_NONE,
704 .flash_src = &msm_flash_src
705};
706
707static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
708 .sensor_name = "ov9726",
709 .sensor_reset_enable = 0,
710 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530711 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530712 .sensor_pwd = 85,
713 .vcm_pwd = 1,
714 .vcm_enable = 0,
715 .pdata = &msm_camera_device_data_front,
716 .flash_data = &flash_ov9726,
717 .sensor_platform_info = &ov9726_sensor_7627a_info,
718 .csi_if = 1
719};
720
721static struct platform_device msm_camera_sensor_ov9726 = {
722 .name = "msm_camera_ov9726",
723 .dev = {
724 .platform_data = &msm_camera_sensor_ov9726_data,
725 },
726};
727#else
728static inline void msm_camera_vreg_init(void) { }
729#endif
730
731#ifdef CONFIG_MT9E013
732static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
733 .mount_angle = 90
734};
735
736static struct msm_camera_sensor_flash_data flash_mt9e013 = {
737 .flash_type = MSM_CAMERA_FLASH_LED,
738 .flash_src = &msm_flash_src
739};
740
741static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
742 .sensor_name = "mt9e013",
743 .sensor_reset = 0,
744 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530745 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530746 .sensor_pwd = 85,
747 .vcm_pwd = 1,
748 .vcm_enable = 0,
749 .pdata = &msm_camera_device_data_rear,
750 .flash_data = &flash_mt9e013,
751 .sensor_platform_info = &mt9e013_sensor_7627a_info,
752 .csi_if = 1
753};
754
755static struct platform_device msm_camera_sensor_mt9e013 = {
756 .name = "msm_camera_mt9e013",
757 .dev = {
758 .platform_data = &msm_camera_sensor_mt9e013_data,
759 },
760};
761#endif
762
763#ifdef CONFIG_OV5640
764static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
765 .mount_angle = 90
766};
767
768static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
769 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
770 ._fsrc.led_src.led_name = "flashlight",
771 ._fsrc.led_src.led_name_len = 10,
772};
773
774static struct msm_camera_sensor_flash_data flash_ov5640 = {
775 .flash_type = MSM_CAMERA_FLASH_LED,
776 .flash_src = &msm_flash_src_ov5640,
777};
778
779static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
780 .sensor_name = "ov5640",
781 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530782 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530783 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
784 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
785 .vcm_pwd = 0,
786 .vcm_enable = 0,
787 .pdata = &msm_camera_device_data_rear,
788 .flash_data = &flash_ov5640,
789 .sensor_platform_info = &ov5640_sensor_info,
790 .csi_if = 1,
791};
792
793static struct platform_device msm_camera_sensor_ov5640 = {
794 .name = "msm_camera_ov5640",
795 .dev = {
796 .platform_data = &msm_camera_sensor_ov5640_data,
797 },
798};
799#endif
800
801#ifdef CONFIG_WEBCAM_OV7692_QRD
802static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
803 .mount_angle = 90
804};
805
806static struct msm_camera_sensor_flash_data flash_ov7692 = {
807 .flash_type = MSM_CAMERA_FLASH_NONE,
808};
809
810static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
811 .sensor_name = "ov7692",
812 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530813 .pmic_gpio_enable = 1,
814 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
815 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530816 .vcm_pwd = 0,
817 .vcm_enable = 0,
818 .pdata = &msm_camera_device_data_front,
819 .flash_data = &flash_ov7692,
820 .sensor_platform_info = &ov7692_sensor_7627a_info,
821 .csi_if = 1,
822};
823
824static struct platform_device msm_camera_sensor_ov7692 = {
825 .name = "msm_camera_ov7692",
826 .dev = {
827 .platform_data = &msm_camera_sensor_ov7692_data,
828 },
829};
830#endif
831
Chintan Pandya40762702011-12-06 13:47:06 +0530832static struct i2c_board_info i2c_camera_devices[] = {
833 #ifdef CONFIG_S5K4E1
834 {
835 I2C_BOARD_INFO("s5k4e1", 0x36),
836 },
837 {
838 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
839 },
840 #endif
841 #ifdef CONFIG_WEBCAM_OV9726
842 {
843 I2C_BOARD_INFO("ov9726", 0x10),
844 },
845 #endif
846 #ifdef CONFIG_IMX072
847 {
848 I2C_BOARD_INFO("imx072", 0x34),
849 },
850 #endif
851 #ifdef CONFIG_MT9E013
852 {
853 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
854 },
855 #endif
856 {
857 I2C_BOARD_INFO("sc628a", 0x6E),
858 },
859};
860
861static struct i2c_board_info i2c_camera_devices_qrd[] = {
862 #ifdef CONFIG_OV5640
863 {
864 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
865 },
866 #endif
867 #ifdef CONFIG_WEBCAM_OV7692_QRD
868 {
869 I2C_BOARD_INFO("ov7692", 0x78),
870 },
871 #endif
872};
873
Su Liuaca04702012-02-14 02:27:32 +0530874static struct i2c_board_info i2c_camera_devices_evb[] = {
875 #ifdef CONFIG_OV5647
876 {
877 I2C_BOARD_INFO("ov5647", 0x36 << 1),
878 },
879 {
880 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
881 },
882 #endif
883 #ifdef CONFIG_WEBCAM_OV7692_QRD
884 {
885 I2C_BOARD_INFO("ov7692", 0x78),
886 },
887 #endif
888};
889
Chintan Pandya40762702011-12-06 13:47:06 +0530890static struct platform_device *camera_devices_msm[] __initdata = {
891#ifdef CONFIG_S5K4E1
892 &msm_camera_sensor_s5k4e1,
893#endif
894#ifdef CONFIG_IMX072
895 &msm_camera_sensor_imx072,
896#endif
897#ifdef CONFIG_WEBCAM_OV9726
898 &msm_camera_sensor_ov9726,
899#endif
900#ifdef CONFIG_MT9E013
901 &msm_camera_sensor_mt9e013,
902#endif
903};
904
905static struct platform_device *camera_devices_qrd[] __initdata = {
906#ifdef CONFIG_OV5640
907 &msm_camera_sensor_ov5640,
908#endif
909#ifdef CONFIG_WEBCAM_OV7692_QRD
910 &msm_camera_sensor_ov7692,
911#endif
912};
Su Liuaca04702012-02-14 02:27:32 +0530913
914static struct platform_device *camera_devices_evb[] __initdata = {
915#ifdef CONFIG_OV5647
916 &msm_camera_sensor_ov5647,
917#endif
918#ifdef CONFIG_WEBCAM_OV7692_QRD
919 &msm_camera_sensor_ov7692,
920#endif
921};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530922#endif
923
924enum {
925 SX150X_CAM,
926};
927
928static struct sx150x_platform_data sx150x_data[] __initdata = {
929 [SX150X_CAM] = {
930 .gpio_base = GPIO_CAM_EXPANDER_BASE,
931 .oscio_is_gpo = false,
932 .io_pullup_ena = 0,
933 .io_pulldn_ena = 0,
934 .io_open_drain_ena = 0x23,
935 .irq_summary = -1,
936 },
937};
938
939static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
940 {
941 I2C_BOARD_INFO("sx1508q", 0x22),
942 .platform_data = &sx150x_data[SX150X_CAM],
943 },
944};
Chintan Pandya40762702011-12-06 13:47:06 +0530945
946static void __init register_i2c_devices(void)
947{
948 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
949 cam_exp_i2c_info,
950 ARRAY_SIZE(cam_exp_i2c_info));
951}
952
Su Liuaca04702012-02-14 02:27:32 +0530953#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
954#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
955
956static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
957
958static void lcd_camera_power_init(void)
959{
960 int rc = 0;
961
962 pr_debug("lcd_camera_power_init\n");
963
964 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
965
966 /* LDO_EXT2V8 */
967 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
968 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
969 return;
970 }
971
972 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
973 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
974 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
975 if (rc < 0) {
976 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
977 goto fail_gpio2;
978 }
979
980 /* LDO_EVT1V8 */
981 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
982 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
983 goto fail_gpio2;
984 }
985
986 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
987 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
988 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
989 if (rc < 0) {
990 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
991 goto fail_gpio1;
992 }
993
994 return;
995
996fail_gpio1:
997 gpio_free(lcd_camera_ldo_1v8);
998fail_gpio2:
999 gpio_free(LCD_CAMERA_LDO_2V8);
1000
1001 return;
1002}
1003
1004static int lcd_camera_power_on_sku3(void)
1005{
1006 int rc = 0;
1007
1008 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1009 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1010
1011 pr_debug("turn on sku3 lcd_camera_ldo\n");
1012 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1013
1014 return rc;
1015}
1016
1017static int lcd_camera_power_off_sku3(void)
1018{
1019 int rc = 0;
1020
1021 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1022 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1023
1024 pr_debug("turn off sku3 lcd_camera_ldo\n");
1025 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1026
1027 gpio_free(lcd_camera_ldo_1v8);
1028 gpio_free(LCD_CAMERA_LDO_2V8);
1029
1030 return rc;
1031}
1032
1033int lcd_camera_power_onoff(int on)
1034{
1035 int rc = 0;
1036
1037 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1038
1039 if (on)
1040 rc = lcd_camera_power_on_sku3();
1041 else
1042 rc = lcd_camera_power_off_sku3();
1043
1044 return rc;
1045}
1046EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301047
Chintan Pandya40762702011-12-06 13:47:06 +05301048void __init msm7627a_camera_init(void)
1049{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301050
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301051#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301052 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301053#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301054
Su Liuaca04702012-02-14 02:27:32 +05301055 pr_debug("msm7627a_camera_init Entered\n");
1056 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301057 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1058 || machine_is_msm8625_evt()) {
Su Liuaca04702012-02-14 02:27:32 +05301059 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301060 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301061 }
1062
1063#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301064 if (machine_is_msm7627a_qrd1()) {
1065 qrd1_camera_gpio_cfg();
1066 platform_add_devices(camera_devices_qrd,
1067 ARRAY_SIZE(camera_devices_qrd));
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301068 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1069 || machine_is_msm8625_evt()) {
Su Liuaca04702012-02-14 02:27:32 +05301070 platform_add_devices(camera_devices_evb,
1071 ARRAY_SIZE(camera_devices_evb));
1072 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301073 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301074 else
Chintan Pandya40762702011-12-06 13:47:06 +05301075 platform_add_devices(camera_devices_msm,
1076 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301077#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301078 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301079 || !machine_is_msm8625_evb()
1080 || !machine_is_msm8625_evt())
Chintan Pandya40762702011-12-06 13:47:06 +05301081 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301082#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301083 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1084
1085 if (rc) {
1086 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1087 return;
1088 }
1089
1090 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1091
1092 if (rc) {
1093 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1094 return;
1095 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301096#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301097
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301098#if defined(CONFIG_MSM_CAMERA_V4L2)
1099 msm7x27a_init_cam();
1100#endif
1101#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301102 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301103 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1104 i2c_camera_devices_qrd,
1105 ARRAY_SIZE(i2c_camera_devices_qrd));
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301106 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1107 || machine_is_msm8625_evt()) {
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}