blob: bd89e34f2561ed9a643d5131e354942882f6d902 [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
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530123struct msm_camera_device_platform_data msm_camera_device_data_csi1[] = {
124 {
125 .csid_core = 1,
126 .is_csic = 1,
127 .ioclk = {
128 .vfe_clk_rate = 192000000,
129 },
130 },
131 {
132 .csid_core = 1,
133 .is_csic = 1,
134 .ioclk = {
135 .vfe_clk_rate = 266667000,
136 },
137 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530138};
139
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530140struct msm_camera_device_platform_data msm_camera_device_data_csi0[] = {
141 {
142 .csid_core = 0,
143 .is_csic = 1,
144 .ioclk = {
145 .vfe_clk_rate = 192000000,
146 },
147 },
148 {
149 .csid_core = 0,
150 .is_csic = 1,
151 .ioclk = {
152 .vfe_clk_rate = 266667000,
153 },
154 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530155};
156
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800157static struct i2c_board_info msm_act_main_cam_i2c_info = {
158 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530159};
160
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800161static struct msm_actuator_info msm_act_main_cam_4_info = {
162 .board_info = &msm_act_main_cam_i2c_info,
163 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530164 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
165 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
166 .vcm_enable = 1,
167};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530168
169#ifdef CONFIG_S5K4E1
170static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
171 .flash_type = MSM_CAMERA_FLASH_LED,
172 .flash_src = &msm_flash_src
173};
174
175static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
176 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530177 .cam_vreg = msm_cam_vreg,
178 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
179 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530180};
181
182static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
183 .sensor_name = "s5k4e1",
184 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530185 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530186 .pdata = &msm_camera_device_data_csi1[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530187 .flash_data = &flash_s5k4e1,
188 .sensor_platform_info = &sensor_board_info_s5k4e1,
189 .csi_if = 1,
190 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530191 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800192 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530193};
194#endif
195
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530196#ifdef CONFIG_WEBCAM_OV7692_QRD
197static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
198 .mount_angle = 90,
199 .cam_vreg = msm_cam_vreg,
200 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
201 .gpio_conf = &gpio_conf_ov7692,
202};
203
204static struct msm_camera_sensor_flash_data flash_ov7692 = {
205 .flash_type = MSM_CAMERA_FLASH_NONE,
206};
207
208static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
209 .sensor_name = "ov7692",
210 .sensor_reset_enable = 0,
211 .pmic_gpio_enable = 1,
212 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
213 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530214 .pdata = &msm_camera_device_data_csi0[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530215 .flash_data = &flash_ov7692,
216 .sensor_platform_info = &sensor_board_info_ov7692,
217 .csi_if = 1,
218 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530219 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530220};
221#endif
222
223#ifdef CONFIG_OV5647
224
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800225static struct msm_actuator_info msm_act_main_cam_5_info = {
226 .board_info = &msm_act_main_cam_i2c_info,
227 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530228 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
229 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
230 .vcm_enable = 1,
231};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530232
233static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
234 .mount_angle = 90,
235 .cam_vreg = msm_cam_vreg,
236 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
237 .gpio_conf = &gpio_conf_ov5647,
238};
239
240static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530241 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
242 ._fsrc.ext_driver_src.led_en = 13,
243 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530244};
245
246static struct msm_camera_sensor_flash_data flash_ov5647 = {
247 .flash_type = MSM_CAMERA_FLASH_LED,
248 .flash_src = &msm_flash_src_ov5647,
249};
250
251static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
252 .sensor_name = "ov5647",
253 .sensor_reset_enable = 1,
254 .pmic_gpio_enable = 1,
255 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
256 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530257 .pdata = &msm_camera_device_data_csi1[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530258 .flash_data = &flash_ov5647,
259 .sensor_platform_info = &sensor_board_info_ov5647,
260 .csi_if = 1,
261 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530262 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800263 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530264};
265
266#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530267#ifdef CONFIG_MT9E013
268static struct msm_camera_sensor_flash_data flash_mt9e013 = {
269 .flash_type = MSM_CAMERA_FLASH_LED,
270 .flash_src = &msm_flash_src
271};
272
273static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
274 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530275 .cam_vreg = msm_cam_vreg,
276 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
277 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530278};
279
280static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
281 .sensor_name = "mt9e013",
282 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530283 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530284 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530285 .flash_data = &flash_mt9e013,
286 .sensor_platform_info = &sensor_board_info_mt9e013,
287 .csi_if = 1,
288 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530289 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530290};
291#endif
292
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530293#ifdef CONFIG_WEBCAM_OV9726
294static struct msm_camera_sensor_flash_data flash_ov9726 = {
295 .flash_type = MSM_CAMERA_FLASH_LED,
296 .flash_src = &msm_flash_src
297};
298
299static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
300 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530301 .cam_vreg = msm_cam_vreg,
302 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
303 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530304};
305
306static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
307 .sensor_name = "ov9726",
308 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530309 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530310 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530311 .flash_data = &flash_ov9726,
312 .sensor_platform_info = &sensor_board_info_ov9726,
313 .csi_if = 1,
314 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530315 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530316};
317#endif
318
Kevin Chan94b4c832012-03-02 21:27:16 -0800319static struct platform_device msm_camera_server = {
320 .name = "msm_cam_server",
321 .id = 0,
322};
323
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530324static void __init msm7x27a_init_cam(void)
325{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530326 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530327 || machine_is_msm7627a_qrd1()
328 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530329 sensor_board_info_s5k4e1.cam_vreg = NULL;
330 sensor_board_info_s5k4e1.num_vreg = 0;
331 sensor_board_info_mt9e013.cam_vreg = NULL;
332 sensor_board_info_mt9e013.num_vreg = 0;
333 sensor_board_info_ov9726.cam_vreg = NULL;
334 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530335 sensor_board_info_ov7692.cam_vreg = NULL;
336 sensor_board_info_ov7692.num_vreg = 0;
337 sensor_board_info_ov5647.cam_vreg = NULL;
338 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530339 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800340 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530341 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
342 || machine_is_msm8625_evt()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530343 platform_device_register(&msm8625_device_csic0);
344 platform_device_register(&msm8625_device_csic1);
345 } else {
346 platform_device_register(&msm7x27a_device_csic0);
347 platform_device_register(&msm7x27a_device_csic1);
348 }
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530349 if (machine_is_msm8625_evb() || machine_is_msm8625_evt())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530350 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530351 platform_device_register(&msm7x27a_device_clkctl);
352 platform_device_register(&msm7x27a_device_vfe);
353}
354
355static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530356 {
357 I2C_BOARD_INFO("s5k4e1", 0x36),
358 .platform_data = &msm_camera_sensor_s5k4e1_data,
359 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530360 {
361 I2C_BOARD_INFO("ov9726", 0x10),
362 .platform_data = &msm_camera_sensor_ov9726_data,
363 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530364 {
365 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
366 .platform_data = &msm_camera_sensor_mt9e013_data,
367 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530368 {
369 I2C_BOARD_INFO("ov7692", 0x78),
370 .platform_data = &msm_camera_sensor_ov7692_data,
371 },
372 {
373 I2C_BOARD_INFO("ov5647", 0x36 << 1),
374 .platform_data = &msm_camera_sensor_ov5647_data,
375 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530376 {
377 I2C_BOARD_INFO("sc628a", 0x6E),
378 },
379};
380#else
Chintan Pandya40762702011-12-06 13:47:06 +0530381static uint32_t camera_off_gpio_table[] = {
382 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
383};
384
385static uint32_t camera_on_gpio_table[] = {
386 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
387};
388
389#ifdef CONFIG_MSM_CAMERA_FLASH
390static struct msm_camera_sensor_flash_src msm_flash_src = {
391 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
392 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
393 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
394};
395#endif
396
397static struct regulator_bulk_data regs_camera[] = {
398 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
399 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
400 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
401};
402
403static void qrd1_camera_gpio_cfg(void)
404{
405
406 int rc = 0;
407
408 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
409 if (rc < 0)
410 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
411 __func__);
412
413
414 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
415 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
416 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
417 if (rc < 0) {
418 pr_err("%s: unable to enable Power Down gpio for main"
419 "camera!\n", __func__);
420 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
421 }
422
423
424 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
425 if (rc < 0) {
426 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
427 __func__);
428 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
429 }
430
431
432 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
433 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
434 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
435 if (rc < 0) {
436 pr_err("%s: unable to enable reset gpio for main camera!\n",
437 __func__);
438 gpio_free(QRD_GPIO_CAM_5MP_RESET);
439 }
440
441 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
442 if (rc < 0)
443 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
444 __func__);
445
446 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
447 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
448 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
449 if (rc < 0) {
450 pr_err("%s: unable to enable Power Down gpio for front"
451 "camera!\n", __func__);
452 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
453 }
454
455 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
456 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
457 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
458}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530459#endif
Su Liuaca04702012-02-14 02:27:32 +0530460
461static void evb_camera_gpio_cfg(void)
462{
463 int rc = 0;
464
465 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
466 if (rc < 0)
467 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
468 __func__);
469
470 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
471 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
472 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
473 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
474 if (rc < 0) {
475 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
476 __func__);
477 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
478 }
479
480 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
481
482 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
483 if (rc < 0)
484 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
485 __func__);
486
487 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
488 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
489 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
490 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
491 if (rc < 0) {
492 pr_err("%s: unable to enable reset gpio for main camera!\n",
493 __func__);
494 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
495 }
496
497 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
498
Su Liuaca04702012-02-14 02:27:32 +0530499}
500
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530501#ifndef CONFIG_MSM_CAMERA_V4L2
502
Chintan Pandya40762702011-12-06 13:47:06 +0530503static void msm_camera_vreg_config(int vreg_en)
504{
505 int rc = vreg_en ?
506 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
507 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
508
509 if (rc)
510 pr_err("%s: could not %sable regulators: %d\n",
511 __func__, vreg_en ? "en" : "dis", rc);
512}
513
514static int config_gpio_table(uint32_t *table, int len)
515{
516 int rc = 0, i = 0;
517
518 for (i = 0; i < len; i++) {
519 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
520 if (rc) {
521 pr_err("%s not able to get gpio\n", __func__);
522 for (i--; i >= 0; i--)
523 gpio_tlmm_config(camera_off_gpio_table[i],
524 GPIO_CFG_ENABLE);
525 break;
526 }
527 }
528 return rc;
529}
530
531static int config_camera_on_gpios_rear(void)
532{
533 int rc = 0;
534
535 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530536 || machine_is_msm7627a_qrd1()
537 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530538 msm_camera_vreg_config(1);
539
540 rc = config_gpio_table(camera_on_gpio_table,
541 ARRAY_SIZE(camera_on_gpio_table));
542 if (rc < 0) {
543 pr_err("%s: CAMSENSOR gpio table request"
544 "failed\n", __func__);
545 return rc;
546 }
547
548 return rc;
549}
550
551static void config_camera_off_gpios_rear(void)
552{
553 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530554 || machine_is_msm7627a_qrd1()
555 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530556 msm_camera_vreg_config(0);
557
558 config_gpio_table(camera_off_gpio_table,
559 ARRAY_SIZE(camera_off_gpio_table));
560}
561
562static int config_camera_on_gpios_front(void)
563{
564 int rc = 0;
565
566 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530567 || machine_is_msm7627a_qrd1()
568 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530569 msm_camera_vreg_config(1);
570
571 rc = config_gpio_table(camera_on_gpio_table,
572 ARRAY_SIZE(camera_on_gpio_table));
573 if (rc < 0) {
574 pr_err("%s: CAMSENSOR gpio table request"
575 "failed\n", __func__);
576 return rc;
577 }
578
579 return rc;
580}
581
582static void config_camera_off_gpios_front(void)
583{
584 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530585 || machine_is_msm7627a_qrd1()
586 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530587 msm_camera_vreg_config(0);
588
589 config_gpio_table(camera_off_gpio_table,
590 ARRAY_SIZE(camera_off_gpio_table));
591}
592
593struct msm_camera_device_platform_data msm_camera_device_data_rear = {
594 .camera_gpio_on = config_camera_on_gpios_rear,
595 .camera_gpio_off = config_camera_off_gpios_rear,
596 .ioext.csiphy = 0xA1000000,
597 .ioext.csisz = 0x00100000,
598 .ioext.csiirq = INT_CSI_IRQ_1,
599 .ioclk.mclk_clk_rate = 24000000,
600 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530601 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
602 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530603};
604
605struct msm_camera_device_platform_data msm_camera_device_data_front = {
606 .camera_gpio_on = config_camera_on_gpios_front,
607 .camera_gpio_off = config_camera_off_gpios_front,
608 .ioext.csiphy = 0xA0F00000,
609 .ioext.csisz = 0x00100000,
610 .ioext.csiirq = INT_CSI_IRQ_0,
611 .ioclk.mclk_clk_rate = 24000000,
612 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530613 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
614 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530615};
616
Su Liuaca04702012-02-14 02:27:32 +0530617#ifdef CONFIG_OV5647
618
619static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
620 .mount_angle = 90
621};
622
623static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
624 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
625 ._fsrc.led_src.led_name = "flashlight",
626 ._fsrc.led_src.led_name_len = 10,
627};
628
629static struct msm_camera_sensor_flash_data flash_ov5647 = {
630 .flash_type = MSM_CAMERA_FLASH_LED,
631 .flash_src = &msm_flash_src_ov5647,
632};
633
634static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
635 .sensor_name = "ov5647",
636 .sensor_reset_enable = 1,
637 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
638 .pmic_gpio_enable = 1,
639 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
640 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530641 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530642 .pdata = &msm_camera_device_data_rear,
643 .flash_data = &flash_ov5647,
644 .sensor_platform_info = &ov5647_sensor_7627a_info,
645 .csi_if = 1
646};
647
648static struct platform_device msm_camera_sensor_ov5647 = {
649 .name = "msm_camera_ov5647",
650 .dev = {
651 .platform_data = &msm_camera_sensor_ov5647_data,
652 },
653};
654#endif
655
Chintan Pandya40762702011-12-06 13:47:06 +0530656#ifdef CONFIG_S5K4E1
657static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
658 .mount_angle = 90
659};
660
661static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
662 .flash_type = MSM_CAMERA_FLASH_LED,
663 .flash_src = &msm_flash_src
664};
665
666static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
667 .sensor_name = "s5k4e1",
668 .sensor_reset_enable = 1,
669 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530670 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530671 .sensor_pwd = 85,
672 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
673 .vcm_enable = 1,
674 .pdata = &msm_camera_device_data_rear,
675 .flash_data = &flash_s5k4e1,
676 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
677 .csi_if = 1
678};
679
680static struct platform_device msm_camera_sensor_s5k4e1 = {
681 .name = "msm_camera_s5k4e1",
682 .dev = {
683 .platform_data = &msm_camera_sensor_s5k4e1_data,
684 },
685};
686#endif
687
688#ifdef CONFIG_IMX072
689static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
690 .mount_angle = 90
691};
692
693static struct msm_camera_sensor_flash_data flash_imx072 = {
694 .flash_type = MSM_CAMERA_FLASH_LED,
695 .flash_src = &msm_flash_src
696};
697
698static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
699 .sensor_name = "imx072",
700 .sensor_reset_enable = 1,
701 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530702 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530703 .sensor_pwd = 85,
704 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
705 .vcm_enable = 1,
706 .pdata = &msm_camera_device_data_rear,
707 .flash_data = &flash_imx072,
708 .sensor_platform_info = &imx072_sensor_7627a_info,
709 .csi_if = 1
710};
711
712static struct platform_device msm_camera_sensor_imx072 = {
713 .name = "msm_camera_imx072",
714 .dev = {
715 .platform_data = &msm_camera_sensor_imx072_data,
716 },
717};
718#endif
719
720static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
721#ifdef CONFIG_WEBCAM_OV9726
722static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
723 .mount_angle = 90
724};
725
726static struct msm_camera_sensor_flash_data flash_ov9726 = {
727 .flash_type = MSM_CAMERA_FLASH_NONE,
728 .flash_src = &msm_flash_src
729};
730
731static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
732 .sensor_name = "ov9726",
733 .sensor_reset_enable = 0,
734 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530735 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530736 .sensor_pwd = 85,
737 .vcm_pwd = 1,
738 .vcm_enable = 0,
739 .pdata = &msm_camera_device_data_front,
740 .flash_data = &flash_ov9726,
741 .sensor_platform_info = &ov9726_sensor_7627a_info,
742 .csi_if = 1
743};
744
745static struct platform_device msm_camera_sensor_ov9726 = {
746 .name = "msm_camera_ov9726",
747 .dev = {
748 .platform_data = &msm_camera_sensor_ov9726_data,
749 },
750};
751#else
752static inline void msm_camera_vreg_init(void) { }
753#endif
754
755#ifdef CONFIG_MT9E013
756static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
757 .mount_angle = 90
758};
759
760static struct msm_camera_sensor_flash_data flash_mt9e013 = {
761 .flash_type = MSM_CAMERA_FLASH_LED,
762 .flash_src = &msm_flash_src
763};
764
765static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
766 .sensor_name = "mt9e013",
767 .sensor_reset = 0,
768 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530769 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530770 .sensor_pwd = 85,
771 .vcm_pwd = 1,
772 .vcm_enable = 0,
773 .pdata = &msm_camera_device_data_rear,
774 .flash_data = &flash_mt9e013,
775 .sensor_platform_info = &mt9e013_sensor_7627a_info,
776 .csi_if = 1
777};
778
779static struct platform_device msm_camera_sensor_mt9e013 = {
780 .name = "msm_camera_mt9e013",
781 .dev = {
782 .platform_data = &msm_camera_sensor_mt9e013_data,
783 },
784};
785#endif
786
787#ifdef CONFIG_OV5640
788static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
789 .mount_angle = 90
790};
791
792static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
793 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
794 ._fsrc.led_src.led_name = "flashlight",
795 ._fsrc.led_src.led_name_len = 10,
796};
797
798static struct msm_camera_sensor_flash_data flash_ov5640 = {
799 .flash_type = MSM_CAMERA_FLASH_LED,
800 .flash_src = &msm_flash_src_ov5640,
801};
802
803static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
804 .sensor_name = "ov5640",
805 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530806 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530807 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
808 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
809 .vcm_pwd = 0,
810 .vcm_enable = 0,
811 .pdata = &msm_camera_device_data_rear,
812 .flash_data = &flash_ov5640,
813 .sensor_platform_info = &ov5640_sensor_info,
814 .csi_if = 1,
815};
816
817static struct platform_device msm_camera_sensor_ov5640 = {
818 .name = "msm_camera_ov5640",
819 .dev = {
820 .platform_data = &msm_camera_sensor_ov5640_data,
821 },
822};
823#endif
824
825#ifdef CONFIG_WEBCAM_OV7692_QRD
826static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
827 .mount_angle = 90
828};
829
830static struct msm_camera_sensor_flash_data flash_ov7692 = {
831 .flash_type = MSM_CAMERA_FLASH_NONE,
832};
833
834static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
835 .sensor_name = "ov7692",
836 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530837 .pmic_gpio_enable = 1,
838 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
839 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530840 .vcm_pwd = 0,
841 .vcm_enable = 0,
842 .pdata = &msm_camera_device_data_front,
843 .flash_data = &flash_ov7692,
844 .sensor_platform_info = &ov7692_sensor_7627a_info,
845 .csi_if = 1,
846};
847
848static struct platform_device msm_camera_sensor_ov7692 = {
849 .name = "msm_camera_ov7692",
850 .dev = {
851 .platform_data = &msm_camera_sensor_ov7692_data,
852 },
853};
854#endif
855
Chintan Pandya40762702011-12-06 13:47:06 +0530856static struct i2c_board_info i2c_camera_devices[] = {
857 #ifdef CONFIG_S5K4E1
858 {
859 I2C_BOARD_INFO("s5k4e1", 0x36),
860 },
861 {
862 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
863 },
864 #endif
865 #ifdef CONFIG_WEBCAM_OV9726
866 {
867 I2C_BOARD_INFO("ov9726", 0x10),
868 },
869 #endif
870 #ifdef CONFIG_IMX072
871 {
872 I2C_BOARD_INFO("imx072", 0x34),
873 },
874 #endif
875 #ifdef CONFIG_MT9E013
876 {
877 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
878 },
879 #endif
880 {
881 I2C_BOARD_INFO("sc628a", 0x6E),
882 },
883};
884
885static struct i2c_board_info i2c_camera_devices_qrd[] = {
886 #ifdef CONFIG_OV5640
887 {
888 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
889 },
890 #endif
891 #ifdef CONFIG_WEBCAM_OV7692_QRD
892 {
893 I2C_BOARD_INFO("ov7692", 0x78),
894 },
895 #endif
896};
897
Su Liuaca04702012-02-14 02:27:32 +0530898static struct i2c_board_info i2c_camera_devices_evb[] = {
899 #ifdef CONFIG_OV5647
900 {
901 I2C_BOARD_INFO("ov5647", 0x36 << 1),
902 },
903 {
904 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
905 },
906 #endif
907 #ifdef CONFIG_WEBCAM_OV7692_QRD
908 {
909 I2C_BOARD_INFO("ov7692", 0x78),
910 },
911 #endif
912};
913
Chintan Pandya40762702011-12-06 13:47:06 +0530914static struct platform_device *camera_devices_msm[] __initdata = {
915#ifdef CONFIG_S5K4E1
916 &msm_camera_sensor_s5k4e1,
917#endif
918#ifdef CONFIG_IMX072
919 &msm_camera_sensor_imx072,
920#endif
921#ifdef CONFIG_WEBCAM_OV9726
922 &msm_camera_sensor_ov9726,
923#endif
924#ifdef CONFIG_MT9E013
925 &msm_camera_sensor_mt9e013,
926#endif
927};
928
929static struct platform_device *camera_devices_qrd[] __initdata = {
930#ifdef CONFIG_OV5640
931 &msm_camera_sensor_ov5640,
932#endif
933#ifdef CONFIG_WEBCAM_OV7692_QRD
934 &msm_camera_sensor_ov7692,
935#endif
936};
Su Liuaca04702012-02-14 02:27:32 +0530937
938static struct platform_device *camera_devices_evb[] __initdata = {
939#ifdef CONFIG_OV5647
940 &msm_camera_sensor_ov5647,
941#endif
942#ifdef CONFIG_WEBCAM_OV7692_QRD
943 &msm_camera_sensor_ov7692,
944#endif
945};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530946#endif
947
948enum {
949 SX150X_CAM,
950};
951
952static struct sx150x_platform_data sx150x_data[] __initdata = {
953 [SX150X_CAM] = {
954 .gpio_base = GPIO_CAM_EXPANDER_BASE,
955 .oscio_is_gpo = false,
956 .io_pullup_ena = 0,
957 .io_pulldn_ena = 0,
958 .io_open_drain_ena = 0x23,
959 .irq_summary = -1,
960 },
961};
962
963static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
964 {
965 I2C_BOARD_INFO("sx1508q", 0x22),
966 .platform_data = &sx150x_data[SX150X_CAM],
967 },
968};
Chintan Pandya40762702011-12-06 13:47:06 +0530969
970static void __init register_i2c_devices(void)
971{
972 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
973 cam_exp_i2c_info,
974 ARRAY_SIZE(cam_exp_i2c_info));
975}
976
Su Liuaca04702012-02-14 02:27:32 +0530977#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
978#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
979
980static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
981
982static void lcd_camera_power_init(void)
983{
984 int rc = 0;
985
986 pr_debug("lcd_camera_power_init\n");
987
988 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
989
990 /* LDO_EXT2V8 */
991 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
992 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
993 return;
994 }
995
996 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
997 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
998 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
999 if (rc < 0) {
1000 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1001 goto fail_gpio2;
1002 }
1003
1004 /* LDO_EVT1V8 */
1005 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1006 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1007 goto fail_gpio2;
1008 }
1009
1010 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1011 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1012 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1013 if (rc < 0) {
1014 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1015 goto fail_gpio1;
1016 }
1017
1018 return;
1019
1020fail_gpio1:
1021 gpio_free(lcd_camera_ldo_1v8);
1022fail_gpio2:
1023 gpio_free(LCD_CAMERA_LDO_2V8);
1024
1025 return;
1026}
1027
1028static int lcd_camera_power_on_sku3(void)
1029{
1030 int rc = 0;
1031
1032 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1033 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1034
1035 pr_debug("turn on sku3 lcd_camera_ldo\n");
1036 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1037
1038 return rc;
1039}
1040
1041static int lcd_camera_power_off_sku3(void)
1042{
1043 int rc = 0;
1044
1045 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1046 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1047
1048 pr_debug("turn off sku3 lcd_camera_ldo\n");
1049 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1050
1051 gpio_free(lcd_camera_ldo_1v8);
1052 gpio_free(LCD_CAMERA_LDO_2V8);
1053
1054 return rc;
1055}
1056
1057int lcd_camera_power_onoff(int on)
1058{
1059 int rc = 0;
1060
1061 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1062
1063 if (on)
1064 rc = lcd_camera_power_on_sku3();
1065 else
1066 rc = lcd_camera_power_off_sku3();
1067
1068 return rc;
1069}
1070EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301071
Chintan Pandya40762702011-12-06 13:47:06 +05301072void __init msm7627a_camera_init(void)
1073{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301074
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301075#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301076 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301077#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301078
Su Liuaca04702012-02-14 02:27:32 +05301079 pr_debug("msm7627a_camera_init Entered\n");
1080 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301081 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1082 || machine_is_msm8625_evt()) {
Su Liuaca04702012-02-14 02:27:32 +05301083 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301084 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301085 }
1086
1087#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301088 if (machine_is_msm7627a_qrd1()) {
1089 qrd1_camera_gpio_cfg();
1090 platform_add_devices(camera_devices_qrd,
1091 ARRAY_SIZE(camera_devices_qrd));
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301092 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1093 || machine_is_msm8625_evt()) {
Su Liuaca04702012-02-14 02:27:32 +05301094 platform_add_devices(camera_devices_evb,
1095 ARRAY_SIZE(camera_devices_evb));
1096 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301097 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301098 else
Chintan Pandya40762702011-12-06 13:47:06 +05301099 platform_add_devices(camera_devices_msm,
1100 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301101#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301102 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301103 || !machine_is_msm8625_evb()
1104 || !machine_is_msm8625_evt())
Chintan Pandya40762702011-12-06 13:47:06 +05301105 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301106#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301107 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1108
1109 if (rc) {
1110 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1111 return;
1112 }
1113
1114 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1115
1116 if (rc) {
1117 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1118 return;
1119 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301120#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301121
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301122#if defined(CONFIG_MSM_CAMERA_V4L2)
1123 msm7x27a_init_cam();
1124#endif
1125#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301126 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301127 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1128 i2c_camera_devices_qrd,
1129 ARRAY_SIZE(i2c_camera_devices_qrd));
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301130 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
1131 || machine_is_msm8625_evt()) {
Su Liuaca04702012-02-14 02:27:32 +05301132 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1133 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1134 i2c_camera_devices_evb,
1135 ARRAY_SIZE(i2c_camera_devices_evb));
1136 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301137#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301138 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301139 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1140 i2c_camera_devices,
1141 ARRAY_SIZE(i2c_camera_devices));
1142}