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