blob: 22690733180b8fe556ff99fe78bdaee956537e71 [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
117#ifdef CONFIG_DW9712_ACT
118static struct i2c_board_info s5k4e1_actuator_i2c_info = {
119 I2C_BOARD_INFO("dw9712_act", 0x8C >> 1),
120};
121
122static struct msm_actuator_info s5k4e1_actuator_info = {
123 .board_info = &s5k4e1_actuator_i2c_info,
124 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
125 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
126 .vcm_enable = 1,
127};
128#endif
129
130#ifdef CONFIG_S5K4E1
131static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
132 .flash_type = MSM_CAMERA_FLASH_LED,
133 .flash_src = &msm_flash_src
134};
135
136static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
137 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530138 .cam_vreg = msm_cam_vreg,
139 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
140 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530141};
142
143static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
144 .sensor_name = "s5k4e1",
145 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530146 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530147 .pdata = &msm_camera_device_data_csi1,
148 .flash_data = &flash_s5k4e1,
149 .sensor_platform_info = &sensor_board_info_s5k4e1,
150 .csi_if = 1,
151 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530152 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530153#ifdef CONFIG_DW9712_ACT
154 .actuator_info = &s5k4e1_actuator_info
155#endif
156};
157#endif
158
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530159#ifdef CONFIG_WEBCAM_OV7692_QRD
160static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
161 .mount_angle = 90,
162 .cam_vreg = msm_cam_vreg,
163 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
164 .gpio_conf = &gpio_conf_ov7692,
165};
166
167static struct msm_camera_sensor_flash_data flash_ov7692 = {
168 .flash_type = MSM_CAMERA_FLASH_NONE,
169};
170
171static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
172 .sensor_name = "ov7692",
173 .sensor_reset_enable = 0,
174 .pmic_gpio_enable = 1,
175 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
176 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
177 .pdata = &msm_camera_device_data_csi0,
178 .flash_data = &flash_ov7692,
179 .sensor_platform_info = &sensor_board_info_ov7692,
180 .csi_if = 1,
181 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530182 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530183};
184#endif
185
186#ifdef CONFIG_OV5647
187
188#ifdef CONFIG_AD5046_ACT
189static struct i2c_board_info ad5046_actuator_i2c_info = {
190 I2C_BOARD_INFO("ad5046_act", 0x18 >> 1),
191};
192
193static struct msm_actuator_info ad5046_actuator_info = {
194 .board_info = &ad5046_actuator_i2c_info,
195 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
196 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
197 .vcm_enable = 1,
198};
199#endif
200
201static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
202 .mount_angle = 90,
203 .cam_vreg = msm_cam_vreg,
204 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
205 .gpio_conf = &gpio_conf_ov5647,
206};
207
208static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
209 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
210 ._fsrc.led_src.led_name = "flashlight",
211 ._fsrc.led_src.led_name_len = 10,
212};
213
214static struct msm_camera_sensor_flash_data flash_ov5647 = {
215 .flash_type = MSM_CAMERA_FLASH_LED,
216 .flash_src = &msm_flash_src_ov5647,
217};
218
219static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
220 .sensor_name = "ov5647",
221 .sensor_reset_enable = 1,
222 .pmic_gpio_enable = 1,
223 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
224 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
225 .pdata = &msm_camera_device_data_csi1,
226 .flash_data = &flash_ov5647,
227 .sensor_platform_info = &sensor_board_info_ov5647,
228 .csi_if = 1,
229 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530230 .sensor_type = BAYER_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530231
232#ifdef CONFIG_AD5046_ACT
233 .actuator_info = &ad5046_actuator_info
234#endif
235};
236
237#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530238#ifdef CONFIG_MT9E013
239static struct msm_camera_sensor_flash_data flash_mt9e013 = {
240 .flash_type = MSM_CAMERA_FLASH_LED,
241 .flash_src = &msm_flash_src
242};
243
244static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
245 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530246 .cam_vreg = msm_cam_vreg,
247 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
248 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530249};
250
251static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
252 .sensor_name = "mt9e013",
253 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530254 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530255 .pdata = &msm_camera_device_data_csi1,
256 .flash_data = &flash_mt9e013,
257 .sensor_platform_info = &sensor_board_info_mt9e013,
258 .csi_if = 1,
259 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530260 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530261};
262#endif
263
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530264#ifdef CONFIG_WEBCAM_OV9726
265static struct msm_camera_sensor_flash_data flash_ov9726 = {
266 .flash_type = MSM_CAMERA_FLASH_LED,
267 .flash_src = &msm_flash_src
268};
269
270static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
271 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530272 .cam_vreg = msm_cam_vreg,
273 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
274 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530275};
276
277static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
278 .sensor_name = "ov9726",
279 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530280 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530281 .pdata = &msm_camera_device_data_csi0,
282 .flash_data = &flash_ov9726,
283 .sensor_platform_info = &sensor_board_info_ov9726,
284 .csi_if = 1,
285 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530286 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530287};
288#endif
289
290static void __init msm7x27a_init_cam(void)
291{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530292 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
293 || machine_is_msm7627a_qrd1())) {
294 sensor_board_info_s5k4e1.cam_vreg = NULL;
295 sensor_board_info_s5k4e1.num_vreg = 0;
296 sensor_board_info_mt9e013.cam_vreg = NULL;
297 sensor_board_info_mt9e013.num_vreg = 0;
298 sensor_board_info_ov9726.cam_vreg = NULL;
299 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530300 sensor_board_info_ov7692.cam_vreg = NULL;
301 sensor_board_info_ov7692.num_vreg = 0;
302 sensor_board_info_ov5647.cam_vreg = NULL;
303 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530304 }
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530305 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()) {
306 platform_device_register(&msm8625_device_csic0);
307 platform_device_register(&msm8625_device_csic1);
308 } else {
309 platform_device_register(&msm7x27a_device_csic0);
310 platform_device_register(&msm7x27a_device_csic1);
311 }
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530312 platform_device_register(&msm7x27a_device_clkctl);
313 platform_device_register(&msm7x27a_device_vfe);
314}
315
316static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530317 {
318 I2C_BOARD_INFO("s5k4e1", 0x36),
319 .platform_data = &msm_camera_sensor_s5k4e1_data,
320 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530321 {
322 I2C_BOARD_INFO("ov9726", 0x10),
323 .platform_data = &msm_camera_sensor_ov9726_data,
324 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530325 {
326 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
327 .platform_data = &msm_camera_sensor_mt9e013_data,
328 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530329 {
330 I2C_BOARD_INFO("ov7692", 0x78),
331 .platform_data = &msm_camera_sensor_ov7692_data,
332 },
333 {
334 I2C_BOARD_INFO("ov5647", 0x36 << 1),
335 .platform_data = &msm_camera_sensor_ov5647_data,
336 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530337 {
338 I2C_BOARD_INFO("sc628a", 0x6E),
339 },
340};
341#else
Chintan Pandya40762702011-12-06 13:47:06 +0530342static uint32_t camera_off_gpio_table[] = {
343 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
344};
345
346static uint32_t camera_on_gpio_table[] = {
347 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
348};
349
350#ifdef CONFIG_MSM_CAMERA_FLASH
351static struct msm_camera_sensor_flash_src msm_flash_src = {
352 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
353 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
354 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
355};
356#endif
357
358static struct regulator_bulk_data regs_camera[] = {
359 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
360 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
361 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
362};
363
364static void qrd1_camera_gpio_cfg(void)
365{
366
367 int rc = 0;
368
369 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
370 if (rc < 0)
371 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
372 __func__);
373
374
375 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
376 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
377 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
378 if (rc < 0) {
379 pr_err("%s: unable to enable Power Down gpio for main"
380 "camera!\n", __func__);
381 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
382 }
383
384
385 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
386 if (rc < 0) {
387 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
388 __func__);
389 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
390 }
391
392
393 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
394 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
395 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
396 if (rc < 0) {
397 pr_err("%s: unable to enable reset gpio for main camera!\n",
398 __func__);
399 gpio_free(QRD_GPIO_CAM_5MP_RESET);
400 }
401
402 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
403 if (rc < 0)
404 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
405 __func__);
406
407 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 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 Power Down gpio for front"
412 "camera!\n", __func__);
413 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
414 }
415
416 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
417 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
418 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
419}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530420#endif
Su Liuaca04702012-02-14 02:27:32 +0530421
422static void evb_camera_gpio_cfg(void)
423{
424 int rc = 0;
425
426 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
427 if (rc < 0)
428 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
429 __func__);
430
431 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
432 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
433 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
434 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
435 if (rc < 0) {
436 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
437 __func__);
438 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
439 }
440
441 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
442
443 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
444 if (rc < 0)
445 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
446 __func__);
447
448 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
449 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
450 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
451 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
452 if (rc < 0) {
453 pr_err("%s: unable to enable reset gpio for main camera!\n",
454 __func__);
455 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
456 }
457
458 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
459
460 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
461 if (rc < 0)
462 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
463 __func__);
464
465 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
466 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
467 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
468 if (rc < 0) {
469 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
470 __func__);
471 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
472 }
473
474 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
475
476 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
477 if (rc < 0)
478 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
479 __func__);
480
481 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
482 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
483 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
484
485 if (rc < 0) {
486 pr_err("%s: unable to enable reset gpio for front camera!\n",
487 __func__);
488 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
489 }
490 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
491
492}
493
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530494#ifndef CONFIG_MSM_CAMERA_V4L2
495
Chintan Pandya40762702011-12-06 13:47:06 +0530496static void msm_camera_vreg_config(int vreg_en)
497{
498 int rc = vreg_en ?
499 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
500 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
501
502 if (rc)
503 pr_err("%s: could not %sable regulators: %d\n",
504 __func__, vreg_en ? "en" : "dis", rc);
505}
506
507static int config_gpio_table(uint32_t *table, int len)
508{
509 int rc = 0, i = 0;
510
511 for (i = 0; i < len; i++) {
512 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
513 if (rc) {
514 pr_err("%s not able to get gpio\n", __func__);
515 for (i--; i >= 0; i--)
516 gpio_tlmm_config(camera_off_gpio_table[i],
517 GPIO_CFG_ENABLE);
518 break;
519 }
520 }
521 return rc;
522}
523
524static int config_camera_on_gpios_rear(void)
525{
526 int rc = 0;
527
528 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
529 || machine_is_msm7627a_qrd1())
530 msm_camera_vreg_config(1);
531
532 rc = config_gpio_table(camera_on_gpio_table,
533 ARRAY_SIZE(camera_on_gpio_table));
534 if (rc < 0) {
535 pr_err("%s: CAMSENSOR gpio table request"
536 "failed\n", __func__);
537 return rc;
538 }
539
540 return rc;
541}
542
543static void config_camera_off_gpios_rear(void)
544{
545 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
546 || machine_is_msm7627a_qrd1())
547 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()
558 || machine_is_msm7627a_qrd1())
559 msm_camera_vreg_config(1);
560
561 rc = config_gpio_table(camera_on_gpio_table,
562 ARRAY_SIZE(camera_on_gpio_table));
563 if (rc < 0) {
564 pr_err("%s: CAMSENSOR gpio table request"
565 "failed\n", __func__);
566 return rc;
567 }
568
569 return rc;
570}
571
572static void config_camera_off_gpios_front(void)
573{
574 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
575 || machine_is_msm7627a_qrd1())
576 msm_camera_vreg_config(0);
577
578 config_gpio_table(camera_off_gpio_table,
579 ARRAY_SIZE(camera_off_gpio_table));
580}
581
582struct msm_camera_device_platform_data msm_camera_device_data_rear = {
583 .camera_gpio_on = config_camera_on_gpios_rear,
584 .camera_gpio_off = config_camera_off_gpios_rear,
585 .ioext.csiphy = 0xA1000000,
586 .ioext.csisz = 0x00100000,
587 .ioext.csiirq = INT_CSI_IRQ_1,
588 .ioclk.mclk_clk_rate = 24000000,
589 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530590 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
591 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530592};
593
594struct msm_camera_device_platform_data msm_camera_device_data_front = {
595 .camera_gpio_on = config_camera_on_gpios_front,
596 .camera_gpio_off = config_camera_off_gpios_front,
597 .ioext.csiphy = 0xA0F00000,
598 .ioext.csisz = 0x00100000,
599 .ioext.csiirq = INT_CSI_IRQ_0,
600 .ioclk.mclk_clk_rate = 24000000,
601 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530602 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
603 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530604};
605
Su Liuaca04702012-02-14 02:27:32 +0530606#ifdef CONFIG_OV5647
607
608static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
609 .mount_angle = 90
610};
611
612static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
613 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
614 ._fsrc.led_src.led_name = "flashlight",
615 ._fsrc.led_src.led_name_len = 10,
616};
617
618static struct msm_camera_sensor_flash_data flash_ov5647 = {
619 .flash_type = MSM_CAMERA_FLASH_LED,
620 .flash_src = &msm_flash_src_ov5647,
621};
622
623static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
624 .sensor_name = "ov5647",
625 .sensor_reset_enable = 1,
626 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
627 .pmic_gpio_enable = 1,
628 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
629 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530630 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530631 .pdata = &msm_camera_device_data_rear,
632 .flash_data = &flash_ov5647,
633 .sensor_platform_info = &ov5647_sensor_7627a_info,
634 .csi_if = 1
635};
636
637static struct platform_device msm_camera_sensor_ov5647 = {
638 .name = "msm_camera_ov5647",
639 .dev = {
640 .platform_data = &msm_camera_sensor_ov5647_data,
641 },
642};
643#endif
644
Chintan Pandya40762702011-12-06 13:47:06 +0530645#ifdef CONFIG_S5K4E1
646static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
647 .mount_angle = 90
648};
649
650static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
651 .flash_type = MSM_CAMERA_FLASH_LED,
652 .flash_src = &msm_flash_src
653};
654
655static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
656 .sensor_name = "s5k4e1",
657 .sensor_reset_enable = 1,
658 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530659 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530660 .sensor_pwd = 85,
661 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
662 .vcm_enable = 1,
663 .pdata = &msm_camera_device_data_rear,
664 .flash_data = &flash_s5k4e1,
665 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
666 .csi_if = 1
667};
668
669static struct platform_device msm_camera_sensor_s5k4e1 = {
670 .name = "msm_camera_s5k4e1",
671 .dev = {
672 .platform_data = &msm_camera_sensor_s5k4e1_data,
673 },
674};
675#endif
676
677#ifdef CONFIG_IMX072
678static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
679 .mount_angle = 90
680};
681
682static struct msm_camera_sensor_flash_data flash_imx072 = {
683 .flash_type = MSM_CAMERA_FLASH_LED,
684 .flash_src = &msm_flash_src
685};
686
687static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
688 .sensor_name = "imx072",
689 .sensor_reset_enable = 1,
690 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530691 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530692 .sensor_pwd = 85,
693 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
694 .vcm_enable = 1,
695 .pdata = &msm_camera_device_data_rear,
696 .flash_data = &flash_imx072,
697 .sensor_platform_info = &imx072_sensor_7627a_info,
698 .csi_if = 1
699};
700
701static struct platform_device msm_camera_sensor_imx072 = {
702 .name = "msm_camera_imx072",
703 .dev = {
704 .platform_data = &msm_camera_sensor_imx072_data,
705 },
706};
707#endif
708
709static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
710#ifdef CONFIG_WEBCAM_OV9726
711static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
712 .mount_angle = 90
713};
714
715static struct msm_camera_sensor_flash_data flash_ov9726 = {
716 .flash_type = MSM_CAMERA_FLASH_NONE,
717 .flash_src = &msm_flash_src
718};
719
720static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
721 .sensor_name = "ov9726",
722 .sensor_reset_enable = 0,
723 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530724 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530725 .sensor_pwd = 85,
726 .vcm_pwd = 1,
727 .vcm_enable = 0,
728 .pdata = &msm_camera_device_data_front,
729 .flash_data = &flash_ov9726,
730 .sensor_platform_info = &ov9726_sensor_7627a_info,
731 .csi_if = 1
732};
733
734static struct platform_device msm_camera_sensor_ov9726 = {
735 .name = "msm_camera_ov9726",
736 .dev = {
737 .platform_data = &msm_camera_sensor_ov9726_data,
738 },
739};
740#else
741static inline void msm_camera_vreg_init(void) { }
742#endif
743
744#ifdef CONFIG_MT9E013
745static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
746 .mount_angle = 90
747};
748
749static struct msm_camera_sensor_flash_data flash_mt9e013 = {
750 .flash_type = MSM_CAMERA_FLASH_LED,
751 .flash_src = &msm_flash_src
752};
753
754static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
755 .sensor_name = "mt9e013",
756 .sensor_reset = 0,
757 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530758 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530759 .sensor_pwd = 85,
760 .vcm_pwd = 1,
761 .vcm_enable = 0,
762 .pdata = &msm_camera_device_data_rear,
763 .flash_data = &flash_mt9e013,
764 .sensor_platform_info = &mt9e013_sensor_7627a_info,
765 .csi_if = 1
766};
767
768static struct platform_device msm_camera_sensor_mt9e013 = {
769 .name = "msm_camera_mt9e013",
770 .dev = {
771 .platform_data = &msm_camera_sensor_mt9e013_data,
772 },
773};
774#endif
775
776#ifdef CONFIG_OV5640
777static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
778 .mount_angle = 90
779};
780
781static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
782 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
783 ._fsrc.led_src.led_name = "flashlight",
784 ._fsrc.led_src.led_name_len = 10,
785};
786
787static struct msm_camera_sensor_flash_data flash_ov5640 = {
788 .flash_type = MSM_CAMERA_FLASH_LED,
789 .flash_src = &msm_flash_src_ov5640,
790};
791
792static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
793 .sensor_name = "ov5640",
794 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530795 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530796 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
797 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
798 .vcm_pwd = 0,
799 .vcm_enable = 0,
800 .pdata = &msm_camera_device_data_rear,
801 .flash_data = &flash_ov5640,
802 .sensor_platform_info = &ov5640_sensor_info,
803 .csi_if = 1,
804};
805
806static struct platform_device msm_camera_sensor_ov5640 = {
807 .name = "msm_camera_ov5640",
808 .dev = {
809 .platform_data = &msm_camera_sensor_ov5640_data,
810 },
811};
812#endif
813
814#ifdef CONFIG_WEBCAM_OV7692_QRD
815static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
816 .mount_angle = 90
817};
818
819static struct msm_camera_sensor_flash_data flash_ov7692 = {
820 .flash_type = MSM_CAMERA_FLASH_NONE,
821};
822
823static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
824 .sensor_name = "ov7692",
825 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530826 .pmic_gpio_enable = 1,
827 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
828 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530829 .vcm_pwd = 0,
830 .vcm_enable = 0,
831 .pdata = &msm_camera_device_data_front,
832 .flash_data = &flash_ov7692,
833 .sensor_platform_info = &ov7692_sensor_7627a_info,
834 .csi_if = 1,
835};
836
837static struct platform_device msm_camera_sensor_ov7692 = {
838 .name = "msm_camera_ov7692",
839 .dev = {
840 .platform_data = &msm_camera_sensor_ov7692_data,
841 },
842};
843#endif
844
Chintan Pandya40762702011-12-06 13:47:06 +0530845static struct i2c_board_info i2c_camera_devices[] = {
846 #ifdef CONFIG_S5K4E1
847 {
848 I2C_BOARD_INFO("s5k4e1", 0x36),
849 },
850 {
851 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
852 },
853 #endif
854 #ifdef CONFIG_WEBCAM_OV9726
855 {
856 I2C_BOARD_INFO("ov9726", 0x10),
857 },
858 #endif
859 #ifdef CONFIG_IMX072
860 {
861 I2C_BOARD_INFO("imx072", 0x34),
862 },
863 #endif
864 #ifdef CONFIG_MT9E013
865 {
866 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
867 },
868 #endif
869 {
870 I2C_BOARD_INFO("sc628a", 0x6E),
871 },
872};
873
874static struct i2c_board_info i2c_camera_devices_qrd[] = {
875 #ifdef CONFIG_OV5640
876 {
877 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
878 },
879 #endif
880 #ifdef CONFIG_WEBCAM_OV7692_QRD
881 {
882 I2C_BOARD_INFO("ov7692", 0x78),
883 },
884 #endif
885};
886
Su Liuaca04702012-02-14 02:27:32 +0530887static struct i2c_board_info i2c_camera_devices_evb[] = {
888 #ifdef CONFIG_OV5647
889 {
890 I2C_BOARD_INFO("ov5647", 0x36 << 1),
891 },
892 {
893 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
894 },
895 #endif
896 #ifdef CONFIG_WEBCAM_OV7692_QRD
897 {
898 I2C_BOARD_INFO("ov7692", 0x78),
899 },
900 #endif
901};
902
Chintan Pandya40762702011-12-06 13:47:06 +0530903static struct platform_device *camera_devices_msm[] __initdata = {
904#ifdef CONFIG_S5K4E1
905 &msm_camera_sensor_s5k4e1,
906#endif
907#ifdef CONFIG_IMX072
908 &msm_camera_sensor_imx072,
909#endif
910#ifdef CONFIG_WEBCAM_OV9726
911 &msm_camera_sensor_ov9726,
912#endif
913#ifdef CONFIG_MT9E013
914 &msm_camera_sensor_mt9e013,
915#endif
916};
917
918static struct platform_device *camera_devices_qrd[] __initdata = {
919#ifdef CONFIG_OV5640
920 &msm_camera_sensor_ov5640,
921#endif
922#ifdef CONFIG_WEBCAM_OV7692_QRD
923 &msm_camera_sensor_ov7692,
924#endif
925};
Su Liuaca04702012-02-14 02:27:32 +0530926
927static struct platform_device *camera_devices_evb[] __initdata = {
928#ifdef CONFIG_OV5647
929 &msm_camera_sensor_ov5647,
930#endif
931#ifdef CONFIG_WEBCAM_OV7692_QRD
932 &msm_camera_sensor_ov7692,
933#endif
934};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530935#endif
936
937enum {
938 SX150X_CAM,
939};
940
941static struct sx150x_platform_data sx150x_data[] __initdata = {
942 [SX150X_CAM] = {
943 .gpio_base = GPIO_CAM_EXPANDER_BASE,
944 .oscio_is_gpo = false,
945 .io_pullup_ena = 0,
946 .io_pulldn_ena = 0,
947 .io_open_drain_ena = 0x23,
948 .irq_summary = -1,
949 },
950};
951
952static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
953 {
954 I2C_BOARD_INFO("sx1508q", 0x22),
955 .platform_data = &sx150x_data[SX150X_CAM],
956 },
957};
Chintan Pandya40762702011-12-06 13:47:06 +0530958
959static void __init register_i2c_devices(void)
960{
961 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
962 cam_exp_i2c_info,
963 ARRAY_SIZE(cam_exp_i2c_info));
964}
965
Su Liuaca04702012-02-14 02:27:32 +0530966#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
967#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
968
969static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
970
971static void lcd_camera_power_init(void)
972{
973 int rc = 0;
974
975 pr_debug("lcd_camera_power_init\n");
976
977 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
978
979 /* LDO_EXT2V8 */
980 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
981 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
982 return;
983 }
984
985 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 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_2v8!\n", __func__);
990 goto fail_gpio2;
991 }
992
993 /* LDO_EVT1V8 */
994 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
995 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
996 goto fail_gpio2;
997 }
998
999 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1000 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1001 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1002 if (rc < 0) {
1003 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1004 goto fail_gpio1;
1005 }
1006
1007 return;
1008
1009fail_gpio1:
1010 gpio_free(lcd_camera_ldo_1v8);
1011fail_gpio2:
1012 gpio_free(LCD_CAMERA_LDO_2V8);
1013
1014 return;
1015}
1016
1017static int lcd_camera_power_on_sku3(void)
1018{
1019 int rc = 0;
1020
1021 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1022 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1023
1024 pr_debug("turn on sku3 lcd_camera_ldo\n");
1025 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1026
1027 return rc;
1028}
1029
1030static int lcd_camera_power_off_sku3(void)
1031{
1032 int rc = 0;
1033
1034 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1035 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1036
1037 pr_debug("turn off sku3 lcd_camera_ldo\n");
1038 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1039
1040 gpio_free(lcd_camera_ldo_1v8);
1041 gpio_free(LCD_CAMERA_LDO_2V8);
1042
1043 return rc;
1044}
1045
1046int lcd_camera_power_onoff(int on)
1047{
1048 int rc = 0;
1049
1050 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1051
1052 if (on)
1053 rc = lcd_camera_power_on_sku3();
1054 else
1055 rc = lcd_camera_power_off_sku3();
1056
1057 return rc;
1058}
1059EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301060
Chintan Pandya40762702011-12-06 13:47:06 +05301061void __init msm7627a_camera_init(void)
1062{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301063
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301064#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301065 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301066#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301067
Su Liuaca04702012-02-14 02:27:32 +05301068 pr_debug("msm7627a_camera_init Entered\n");
1069 /* LCD and camera power (VREG & LDO) init */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301070 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301071 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301072 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301073 }
1074
1075#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301076 if (machine_is_msm7627a_qrd1()) {
1077 qrd1_camera_gpio_cfg();
1078 platform_add_devices(camera_devices_qrd,
1079 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301080 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301081 platform_add_devices(camera_devices_evb,
1082 ARRAY_SIZE(camera_devices_evb));
1083 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301084 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301085 else
Chintan Pandya40762702011-12-06 13:47:06 +05301086 platform_add_devices(camera_devices_msm,
1087 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301088#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301089 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1090 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301091 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301092#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301093 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1094
1095 if (rc) {
1096 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1097 return;
1098 }
1099
1100 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1101
1102 if (rc) {
1103 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1104 return;
1105 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301106#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301107
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301108#if defined(CONFIG_MSM_CAMERA_V4L2)
1109 msm7x27a_init_cam();
1110#endif
1111#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301112 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301113 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1114 i2c_camera_devices_qrd,
1115 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301116 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301117 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1118 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1119 i2c_camera_devices_evb,
1120 ARRAY_SIZE(i2c_camera_devices_evb));
1121 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301122#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301123 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301124 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1125 i2c_camera_devices,
1126 ARRAY_SIZE(i2c_camera_devices));
1127}