blob: 57684f9cbd129f530a189953dc9942e954f235b4 [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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070019#include <linux/module.h>
Chintan Pandya40762702011-12-06 13:47:06 +053020#include <asm/mach-types.h>
21#include <mach/msm_iomap.h>
22#include <mach/board.h>
23#include <mach/irqs-7xxx.h>
24#include "devices-msm7x2xa.h"
25#include "board-msm7627a.h"
Su Liuaca04702012-02-14 02:27:32 +053026#include <mach/vreg.h>
Chintan Pandya40762702011-12-06 13:47:06 +053027
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053028#define GPIO_SKU1_CAM_VGA_SHDN 18
29#define GPIO_SKU1_CAM_VGA_RESET_N 29
30#define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */
31#define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */
32#define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +053033#define GPIO_SKU7_CAM_VGA_SHDN 91
34#define GPIO_SKU7_CAM_5MP_SHDN_N 93 /* PWDN */
35#define GPIO_SKU7_CAM_5MP_CAMIF_RESET 23 /* (board_is(EVT))?123:121 RESET */
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053036
Suresh Vankadara87e195b2012-01-18 00:42:58 +053037#ifdef CONFIG_MSM_CAMERA_V4L2
38static uint32_t camera_off_gpio_table[] = {
39 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
40};
41
42static uint32_t camera_on_gpio_table[] = {
43 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
44};
45
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053046static struct gpio s5k4e1_cam_req_gpio[] = {
47 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_DIR_OUT, "CAM_RESET"},
48};
49
50static struct msm_gpio_set_tbl s5k4e1_cam_gpio_set_tbl[] = {
51 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_LOW, 1000},
52 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_HIGH, 4000},
53};
54
55static struct msm_camera_gpio_conf gpio_conf_s5k4e1 = {
56 .camera_off_table = camera_off_gpio_table,
57 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
58 .camera_on_table = camera_on_gpio_table,
59 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
60 .cam_gpio_req_tbl = s5k4e1_cam_req_gpio,
61 .cam_gpio_req_tbl_size = ARRAY_SIZE(s5k4e1_cam_req_gpio),
62 .cam_gpio_set_tbl = s5k4e1_cam_gpio_set_tbl,
63 .cam_gpio_set_tbl_size = ARRAY_SIZE(s5k4e1_cam_gpio_set_tbl),
64 .gpio_no_mux = 1,
65};
66
67static struct msm_camera_gpio_conf gpio_conf_mt9e013 = {
68 .camera_off_table = camera_off_gpio_table,
69 .camera_on_table = camera_on_gpio_table,
70 .gpio_no_mux = 1,
71};
72
73static struct msm_camera_gpio_conf gpio_conf_ov9726 = {
74 .camera_off_table = camera_off_gpio_table,
75 .camera_on_table = camera_on_gpio_table,
76 .gpio_no_mux = 1,
77};
78
Sreesudhan Ramakrish Ramkumarcfdfa0e2012-05-15 15:56:05 -070079#ifdef CONFIG_OV7692
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070080static struct gpio ov7692_cam_req_gpio[] = {
81 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_DIR_OUT, "CAM_VGA_SHDN"},
82 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_DIR_OUT, "CAM_VGA_RESET"},
83};
84
85static struct msm_gpio_set_tbl ov7692_cam_gpio_set_tbl[] = {
86 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_HIGH, 5000},
87 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_LOW, 5000},
88 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_HIGH, 5000},
89 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_LOW, 5000},
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070090};
91
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053092static struct msm_camera_gpio_conf gpio_conf_ov7692 = {
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070093 .cam_gpio_req_tbl = ov7692_cam_req_gpio,
94 .cam_gpio_req_tbl_size = ARRAY_SIZE(ov7692_cam_req_gpio),
95 .cam_gpio_set_tbl = ov7692_cam_gpio_set_tbl,
96 .cam_gpio_set_tbl_size = ARRAY_SIZE(ov7692_cam_gpio_set_tbl),
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053097 .gpio_no_mux = 1,
98};
99#endif
100
101#ifdef CONFIG_OV5647
102static struct msm_camera_gpio_conf gpio_conf_ov5647 = {
103 .camera_off_table = camera_off_gpio_table,
104 .camera_on_table = camera_on_gpio_table,
105 .gpio_no_mux = 1,
106};
107#endif
108
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530109#ifdef CONFIG_MSM_CAMERA_FLASH
110static struct msm_camera_sensor_flash_src msm_flash_src = {
111 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
112 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
113 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
114};
115#endif
116
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530117static struct camera_vreg_t msm_cam_vreg[] = {
118 {"msme1", REG_LDO, 1800000, 1800000, 0},
119 {"gp2", REG_LDO, 2850000, 2850000, 0},
120 {"usb2", REG_LDO, 1800000, 1800000, 0},
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530121};
122
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +0530123static struct camera_vreg_t ov5647_gpio_vreg[] = {
124 {"cam_ov5647_avdd", REG_GPIO, 0, 0, 0},
125 {"cam_ov5647_vdd", REG_GPIO, 0, 0, 0},
126};
127
128static struct camera_vreg_t ov8825_gpio_vreg[] = {
129 {"cam_ov8825_avdd", REG_GPIO, 0, 0, 0},
130 {"cam_ov8825_vdd", REG_GPIO, 0, 0, 0},
131};
132
133static struct camera_vreg_t ov7692_gpio_vreg[] = {
134 {"cam_ov7692_avdd", REG_GPIO, 0, 0, 0},
135 {"cam_ov7692_vdd", REG_GPIO, 0, 0, 0},
136};
137
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530138static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530139
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530140struct msm_camera_device_platform_data msm_camera_device_data_csi1[] = {
141 {
142 .csid_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530143 .ioclk = {
144 .vfe_clk_rate = 192000000,
145 },
146 },
147 {
148 .csid_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530149 .ioclk = {
150 .vfe_clk_rate = 266667000,
151 },
152 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530153};
154
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530155struct msm_camera_device_platform_data msm_camera_device_data_csi0[] = {
156 {
157 .csid_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530158 .ioclk = {
159 .vfe_clk_rate = 192000000,
160 },
161 },
162 {
163 .csid_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530164 .ioclk = {
165 .vfe_clk_rate = 266667000,
166 },
167 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530168};
169
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800170static struct i2c_board_info msm_act_main_cam_i2c_info = {
171 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530172};
173
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800174static struct msm_actuator_info msm_act_main_cam_4_info = {
175 .board_info = &msm_act_main_cam_i2c_info,
176 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530177 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
178 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
179 .vcm_enable = 1,
180};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530181
182#ifdef CONFIG_S5K4E1
183static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
184 .flash_type = MSM_CAMERA_FLASH_LED,
185 .flash_src = &msm_flash_src
186};
187
188static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
189 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530190 .cam_vreg = msm_cam_vreg,
191 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
192 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530193};
194
195static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
196 .sensor_name = "s5k4e1",
197 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530198 .pdata = &msm_camera_device_data_csi1[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530199 .flash_data = &flash_s5k4e1,
200 .sensor_platform_info = &sensor_board_info_s5k4e1,
201 .csi_if = 1,
202 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530203 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800204 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530205};
206#endif
207
Sreesudhan Ramakrish Ramkumarcfdfa0e2012-05-15 15:56:05 -0700208#ifdef CONFIG_OV7692
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530209static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
210 .mount_angle = 90,
211 .cam_vreg = msm_cam_vreg,
212 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
213 .gpio_conf = &gpio_conf_ov7692,
214};
215
216static struct msm_camera_sensor_flash_data flash_ov7692 = {
217 .flash_type = MSM_CAMERA_FLASH_NONE,
218};
219
220static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
221 .sensor_name = "ov7692",
222 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530223 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
224 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530225 .pdata = &msm_camera_device_data_csi0[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530226 .flash_data = &flash_ov7692,
227 .sensor_platform_info = &sensor_board_info_ov7692,
228 .csi_if = 1,
229 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530230 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530231};
232#endif
233
234#ifdef CONFIG_OV5647
235
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800236static struct msm_actuator_info msm_act_main_cam_5_info = {
237 .board_info = &msm_act_main_cam_i2c_info,
238 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530239 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
240 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
241 .vcm_enable = 1,
242};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530243
244static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
245 .mount_angle = 90,
246 .cam_vreg = msm_cam_vreg,
247 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
248 .gpio_conf = &gpio_conf_ov5647,
249};
250
251static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530252 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
253 ._fsrc.ext_driver_src.led_en = 13,
254 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530255};
256
257static struct msm_camera_sensor_flash_data flash_ov5647 = {
258 .flash_type = MSM_CAMERA_FLASH_LED,
259 .flash_src = &msm_flash_src_ov5647,
260};
261
262static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
263 .sensor_name = "ov5647",
264 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530265 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
266 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530267 .pdata = &msm_camera_device_data_csi1[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530268 .flash_data = &flash_ov5647,
269 .sensor_platform_info = &sensor_board_info_ov5647,
270 .csi_if = 1,
271 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530272 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800273 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530274};
275
276#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530277
278static struct msm_camera_gpio_conf gpio_conf_ov8825 = {
279 .camera_off_table = camera_off_gpio_table,
280 .camera_on_table = camera_on_gpio_table,
281 .gpio_no_mux = 1,
282};
283
284static struct msm_camera_sensor_flash_data flash_ov8825 = {
285 .flash_type = MSM_CAMERA_FLASH_NONE,
286};
287
288static struct msm_camera_sensor_platform_info sensor_board_info_ov8825 = {
289 .mount_angle = 90,
290 .cam_vreg = msm_cam_vreg,
291 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
292 .gpio_conf = &gpio_conf_ov8825,
293};
294
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700295static struct msm_actuator_info msm_act_main_cam_3_info = {
296 .board_info = &msm_act_main_cam_i2c_info,
297 .cam_name = MSM_ACTUATOR_MAIN_CAM_3,
298 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
299 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
300 .vcm_enable = 0,
301};
302
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530303static struct msm_camera_sensor_info msm_camera_sensor_ov8825_data = {
304 .sensor_name = "ov8825",
305 .sensor_reset_enable = 1,
306 .pmic_gpio_enable = 1,
307 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
308 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
309 .pdata = &msm_camera_device_data_csi1[1],
310 .flash_data = &flash_ov8825,
311 .sensor_platform_info = &sensor_board_info_ov8825,
312 .csi_if = 1,
313 .camera_type = BACK_CAMERA_2D,
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700314 .sensor_type = BAYER_SENSOR,
315 .actuator_info = &msm_act_main_cam_3_info,
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530316};
317
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530318#ifdef CONFIG_MT9E013
319static struct msm_camera_sensor_flash_data flash_mt9e013 = {
320 .flash_type = MSM_CAMERA_FLASH_LED,
321 .flash_src = &msm_flash_src
322};
323
324static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
325 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530326 .cam_vreg = msm_cam_vreg,
327 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
328 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530329};
330
331static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
332 .sensor_name = "mt9e013",
333 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530334 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530335 .flash_data = &flash_mt9e013,
336 .sensor_platform_info = &sensor_board_info_mt9e013,
337 .csi_if = 1,
338 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530339 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530340};
341#endif
342
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530343#ifdef CONFIG_WEBCAM_OV9726
344static struct msm_camera_sensor_flash_data flash_ov9726 = {
345 .flash_type = MSM_CAMERA_FLASH_LED,
346 .flash_src = &msm_flash_src
347};
348
349static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
350 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530351 .cam_vreg = msm_cam_vreg,
352 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
353 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530354};
355
356static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
357 .sensor_name = "ov9726",
358 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530359 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530360 .flash_data = &flash_ov9726,
361 .sensor_platform_info = &sensor_board_info_ov9726,
362 .csi_if = 1,
363 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530364 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530365};
366#endif
367
Kevin Chan94b4c832012-03-02 21:27:16 -0800368static struct platform_device msm_camera_server = {
369 .name = "msm_cam_server",
370 .id = 0,
371};
372
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530373static void __init msm7x27a_init_cam(void)
374{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530375 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530376 || machine_is_msm7627a_qrd1()
377 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530378 sensor_board_info_s5k4e1.cam_vreg = NULL;
379 sensor_board_info_s5k4e1.num_vreg = 0;
380 sensor_board_info_mt9e013.cam_vreg = NULL;
381 sensor_board_info_mt9e013.num_vreg = 0;
382 sensor_board_info_ov9726.cam_vreg = NULL;
383 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530384 sensor_board_info_ov7692.cam_vreg = NULL;
385 sensor_board_info_ov7692.num_vreg = 0;
386 sensor_board_info_ov5647.cam_vreg = NULL;
387 sensor_board_info_ov5647.num_vreg = 0;
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530388 sensor_board_info_ov8825.cam_vreg = NULL;
389 sensor_board_info_ov8825.num_vreg = 0;
390
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530391 }
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +0530392 if (machine_is_msm8625_evb()
393 || machine_is_msm8625_evt()) {
394 sensor_board_info_ov7692.cam_vreg =
395 ov7692_gpio_vreg;
396 sensor_board_info_ov7692.num_vreg =
397 ARRAY_SIZE(ov7692_gpio_vreg);
398 sensor_board_info_ov5647.cam_vreg =
399 ov5647_gpio_vreg;
400 sensor_board_info_ov5647.num_vreg =
401 ARRAY_SIZE(ov5647_gpio_vreg);
402 sensor_board_info_ov8825.cam_vreg =
403 ov8825_gpio_vreg;
404 sensor_board_info_ov8825.num_vreg =
405 ARRAY_SIZE(ov8825_gpio_vreg);
406 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800407 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530408 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530409 || machine_is_msm8625_evt()
410 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530411 platform_device_register(&msm8625_device_csic0);
412 platform_device_register(&msm8625_device_csic1);
413 } else {
414 platform_device_register(&msm7x27a_device_csic0);
415 platform_device_register(&msm7x27a_device_csic1);
416 }
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530417 if (machine_is_msm8625_evb()
418 || machine_is_msm8625_evt()
419 || machine_is_msm8625_qrd7())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530420 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530421 platform_device_register(&msm7x27a_device_clkctl);
422 platform_device_register(&msm7x27a_device_vfe);
423}
424
425static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530426 {
427 I2C_BOARD_INFO("s5k4e1", 0x36),
428 .platform_data = &msm_camera_sensor_s5k4e1_data,
429 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530430 {
431 I2C_BOARD_INFO("ov9726", 0x10),
432 .platform_data = &msm_camera_sensor_ov9726_data,
433 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530434 {
435 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
436 .platform_data = &msm_camera_sensor_mt9e013_data,
437 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530438 {
439 I2C_BOARD_INFO("ov7692", 0x78),
440 .platform_data = &msm_camera_sensor_ov7692_data,
441 },
442 {
443 I2C_BOARD_INFO("ov5647", 0x36 << 1),
444 .platform_data = &msm_camera_sensor_ov5647_data,
445 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530446 {
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530447 I2C_BOARD_INFO("ov8825", 0x6C >> 3),
448 .platform_data = &msm_camera_sensor_ov8825_data,
449 },
450 {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530451 I2C_BOARD_INFO("sc628a", 0x6E),
452 },
453};
454#else
Chintan Pandya40762702011-12-06 13:47:06 +0530455static uint32_t camera_off_gpio_table[] = {
456 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
457};
458
459static uint32_t camera_on_gpio_table[] = {
460 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
461};
462
463#ifdef CONFIG_MSM_CAMERA_FLASH
464static struct msm_camera_sensor_flash_src msm_flash_src = {
465 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
466 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
467 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
468};
469#endif
470
471static struct regulator_bulk_data regs_camera[] = {
472 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
473 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
474 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
475};
476
477static void qrd1_camera_gpio_cfg(void)
478{
479
480 int rc = 0;
481
482 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
483 if (rc < 0)
484 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
485 __func__);
486
487
488 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
489 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
490 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
491 if (rc < 0) {
492 pr_err("%s: unable to enable Power Down gpio for main"
493 "camera!\n", __func__);
494 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
495 }
496
497
498 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
499 if (rc < 0) {
500 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
501 __func__);
502 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
503 }
504
505
506 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
507 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
508 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
509 if (rc < 0) {
510 pr_err("%s: unable to enable reset gpio for main camera!\n",
511 __func__);
512 gpio_free(QRD_GPIO_CAM_5MP_RESET);
513 }
514
515 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
516 if (rc < 0)
517 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
518 __func__);
519
520 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
521 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
522 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
523 if (rc < 0) {
524 pr_err("%s: unable to enable Power Down gpio for front"
525 "camera!\n", __func__);
526 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
527 }
528
529 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
530 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
531 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
532}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530533#endif
Su Liuaca04702012-02-14 02:27:32 +0530534
535static void evb_camera_gpio_cfg(void)
536{
537 int rc = 0;
538
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530539 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_pwd, "ov5647");
Su Liuaca04702012-02-14 02:27:32 +0530540 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530541 pr_err("%s: gpio_request OV5647 sensor_pwd: %d failed!",
542 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530543
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530544 rc = gpio_tlmm_config(GPIO_CFG(msm_camera_sensor_ov5647_data.sensor_pwd,
545 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
546 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530547 if (rc < 0) {
548 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
549 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530550 gpio_free(msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530551 }
552
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530553 rc = gpio_direction_output(msm_camera_sensor_ov5647_data.sensor_pwd, 1);
Su Liuaca04702012-02-14 02:27:32 +0530554 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530555 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
556 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530557
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530558 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_reset, "ov5647");
559 if (rc < 0)
560 pr_err("%s: gpio_request OV5647 sensor_reset: %d failed!",
561 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
562
563 rc = gpio_tlmm_config(GPIO_CFG(
564 msm_camera_sensor_ov5647_data.sensor_reset,
565 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
566 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530567 if (rc < 0) {
568 pr_err("%s: unable to enable reset gpio for main camera!\n",
569 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530570 gpio_free(msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530571 }
572
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530573 rc = gpio_direction_output(
574 msm_camera_sensor_ov5647_data.sensor_reset, 1);
575 if (rc < 0)
576 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
577 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530578
Su Liuaca04702012-02-14 02:27:32 +0530579}
580
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530581#ifndef CONFIG_MSM_CAMERA_V4L2
582
Chintan Pandya40762702011-12-06 13:47:06 +0530583static void msm_camera_vreg_config(int vreg_en)
584{
585 int rc = vreg_en ?
586 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
587 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
588
589 if (rc)
590 pr_err("%s: could not %sable regulators: %d\n",
591 __func__, vreg_en ? "en" : "dis", rc);
592}
593
594static int config_gpio_table(uint32_t *table, int len)
595{
596 int rc = 0, i = 0;
597
598 for (i = 0; i < len; i++) {
599 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
600 if (rc) {
601 pr_err("%s not able to get gpio\n", __func__);
602 for (i--; i >= 0; i--)
603 gpio_tlmm_config(camera_off_gpio_table[i],
604 GPIO_CFG_ENABLE);
605 break;
606 }
607 }
608 return rc;
609}
610
611static int config_camera_on_gpios_rear(void)
612{
613 int rc = 0;
614
615 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530616 || machine_is_msm7627a_qrd1()
617 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530618 msm_camera_vreg_config(1);
619
620 rc = config_gpio_table(camera_on_gpio_table,
621 ARRAY_SIZE(camera_on_gpio_table));
622 if (rc < 0) {
623 pr_err("%s: CAMSENSOR gpio table request"
624 "failed\n", __func__);
625 return rc;
626 }
627
628 return rc;
629}
630
631static void config_camera_off_gpios_rear(void)
632{
633 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530634 || machine_is_msm7627a_qrd1()
635 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530636 msm_camera_vreg_config(0);
637
638 config_gpio_table(camera_off_gpio_table,
639 ARRAY_SIZE(camera_off_gpio_table));
640}
641
642static int config_camera_on_gpios_front(void)
643{
644 int rc = 0;
645
646 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530647 || machine_is_msm7627a_qrd1()
648 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530649 msm_camera_vreg_config(1);
650
651 rc = config_gpio_table(camera_on_gpio_table,
652 ARRAY_SIZE(camera_on_gpio_table));
653 if (rc < 0) {
654 pr_err("%s: CAMSENSOR gpio table request"
655 "failed\n", __func__);
656 return rc;
657 }
658
659 return rc;
660}
661
662static void config_camera_off_gpios_front(void)
663{
664 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530665 || machine_is_msm7627a_qrd1()
666 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530667 msm_camera_vreg_config(0);
668
669 config_gpio_table(camera_off_gpio_table,
670 ARRAY_SIZE(camera_off_gpio_table));
671}
672
673struct msm_camera_device_platform_data msm_camera_device_data_rear = {
674 .camera_gpio_on = config_camera_on_gpios_rear,
675 .camera_gpio_off = config_camera_off_gpios_rear,
676 .ioext.csiphy = 0xA1000000,
677 .ioext.csisz = 0x00100000,
678 .ioext.csiirq = INT_CSI_IRQ_1,
679 .ioclk.mclk_clk_rate = 24000000,
680 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530681 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
682 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530683};
684
685struct msm_camera_device_platform_data msm_camera_device_data_front = {
686 .camera_gpio_on = config_camera_on_gpios_front,
687 .camera_gpio_off = config_camera_off_gpios_front,
688 .ioext.csiphy = 0xA0F00000,
689 .ioext.csisz = 0x00100000,
690 .ioext.csiirq = INT_CSI_IRQ_0,
691 .ioclk.mclk_clk_rate = 24000000,
692 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530693 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
694 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530695};
696
Su Liuaca04702012-02-14 02:27:32 +0530697#ifdef CONFIG_OV5647
698
699static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
700 .mount_angle = 90
701};
702
703static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
704 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
705 ._fsrc.led_src.led_name = "flashlight",
706 ._fsrc.led_src.led_name_len = 10,
707};
708
709static struct msm_camera_sensor_flash_data flash_ov5647 = {
710 .flash_type = MSM_CAMERA_FLASH_LED,
711 .flash_src = &msm_flash_src_ov5647,
712};
713
714static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
715 .sensor_name = "ov5647",
716 .sensor_reset_enable = 1,
717 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
718 .pmic_gpio_enable = 1,
719 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
720 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530721 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530722 .pdata = &msm_camera_device_data_rear,
723 .flash_data = &flash_ov5647,
724 .sensor_platform_info = &ov5647_sensor_7627a_info,
725 .csi_if = 1
726};
727
728static struct platform_device msm_camera_sensor_ov5647 = {
729 .name = "msm_camera_ov5647",
730 .dev = {
731 .platform_data = &msm_camera_sensor_ov5647_data,
732 },
733};
734#endif
735
Chintan Pandya40762702011-12-06 13:47:06 +0530736#ifdef CONFIG_S5K4E1
737static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
738 .mount_angle = 90
739};
740
741static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
742 .flash_type = MSM_CAMERA_FLASH_LED,
743 .flash_src = &msm_flash_src
744};
745
746static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
747 .sensor_name = "s5k4e1",
748 .sensor_reset_enable = 1,
749 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530750 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530751 .sensor_pwd = 85,
752 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
753 .vcm_enable = 1,
754 .pdata = &msm_camera_device_data_rear,
755 .flash_data = &flash_s5k4e1,
756 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
757 .csi_if = 1
758};
759
760static struct platform_device msm_camera_sensor_s5k4e1 = {
761 .name = "msm_camera_s5k4e1",
762 .dev = {
763 .platform_data = &msm_camera_sensor_s5k4e1_data,
764 },
765};
766#endif
767
768#ifdef CONFIG_IMX072
769static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
770 .mount_angle = 90
771};
772
773static struct msm_camera_sensor_flash_data flash_imx072 = {
774 .flash_type = MSM_CAMERA_FLASH_LED,
775 .flash_src = &msm_flash_src
776};
777
778static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
779 .sensor_name = "imx072",
780 .sensor_reset_enable = 1,
781 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530782 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530783 .sensor_pwd = 85,
784 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
785 .vcm_enable = 1,
786 .pdata = &msm_camera_device_data_rear,
787 .flash_data = &flash_imx072,
788 .sensor_platform_info = &imx072_sensor_7627a_info,
789 .csi_if = 1
790};
791
792static struct platform_device msm_camera_sensor_imx072 = {
793 .name = "msm_camera_imx072",
794 .dev = {
795 .platform_data = &msm_camera_sensor_imx072_data,
796 },
797};
798#endif
799
Chintan Pandya40762702011-12-06 13:47:06 +0530800#ifdef CONFIG_WEBCAM_OV9726
Steve Mucklef132c6c2012-06-06 18:30:57 -0700801static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
Chintan Pandya40762702011-12-06 13:47:06 +0530802static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
803 .mount_angle = 90
804};
805
806static struct msm_camera_sensor_flash_data flash_ov9726 = {
807 .flash_type = MSM_CAMERA_FLASH_NONE,
808 .flash_src = &msm_flash_src
809};
810
811static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
812 .sensor_name = "ov9726",
813 .sensor_reset_enable = 0,
814 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530815 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530816 .sensor_pwd = 85,
817 .vcm_pwd = 1,
818 .vcm_enable = 0,
819 .pdata = &msm_camera_device_data_front,
820 .flash_data = &flash_ov9726,
821 .sensor_platform_info = &ov9726_sensor_7627a_info,
822 .csi_if = 1
823};
824
825static struct platform_device msm_camera_sensor_ov9726 = {
826 .name = "msm_camera_ov9726",
827 .dev = {
828 .platform_data = &msm_camera_sensor_ov9726_data,
829 },
830};
831#else
832static inline void msm_camera_vreg_init(void) { }
833#endif
834
835#ifdef CONFIG_MT9E013
836static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
837 .mount_angle = 90
838};
839
840static struct msm_camera_sensor_flash_data flash_mt9e013 = {
841 .flash_type = MSM_CAMERA_FLASH_LED,
842 .flash_src = &msm_flash_src
843};
844
845static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
846 .sensor_name = "mt9e013",
847 .sensor_reset = 0,
848 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530849 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530850 .sensor_pwd = 85,
851 .vcm_pwd = 1,
852 .vcm_enable = 0,
853 .pdata = &msm_camera_device_data_rear,
854 .flash_data = &flash_mt9e013,
855 .sensor_platform_info = &mt9e013_sensor_7627a_info,
856 .csi_if = 1
857};
858
859static struct platform_device msm_camera_sensor_mt9e013 = {
860 .name = "msm_camera_mt9e013",
861 .dev = {
862 .platform_data = &msm_camera_sensor_mt9e013_data,
863 },
864};
865#endif
866
867#ifdef CONFIG_OV5640
868static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
869 .mount_angle = 90
870};
871
872static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
873 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
874 ._fsrc.led_src.led_name = "flashlight",
875 ._fsrc.led_src.led_name_len = 10,
876};
877
878static struct msm_camera_sensor_flash_data flash_ov5640 = {
879 .flash_type = MSM_CAMERA_FLASH_LED,
880 .flash_src = &msm_flash_src_ov5640,
881};
882
883static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
884 .sensor_name = "ov5640",
885 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530886 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530887 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
888 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
889 .vcm_pwd = 0,
890 .vcm_enable = 0,
891 .pdata = &msm_camera_device_data_rear,
892 .flash_data = &flash_ov5640,
893 .sensor_platform_info = &ov5640_sensor_info,
894 .csi_if = 1,
895};
896
897static struct platform_device msm_camera_sensor_ov5640 = {
898 .name = "msm_camera_ov5640",
899 .dev = {
900 .platform_data = &msm_camera_sensor_ov5640_data,
901 },
902};
903#endif
904
905#ifdef CONFIG_WEBCAM_OV7692_QRD
906static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
907 .mount_angle = 90
908};
909
910static struct msm_camera_sensor_flash_data flash_ov7692 = {
911 .flash_type = MSM_CAMERA_FLASH_NONE,
912};
913
914static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
915 .sensor_name = "ov7692",
916 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530917 .pmic_gpio_enable = 1,
918 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
919 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530920 .vcm_pwd = 0,
921 .vcm_enable = 0,
922 .pdata = &msm_camera_device_data_front,
923 .flash_data = &flash_ov7692,
924 .sensor_platform_info = &ov7692_sensor_7627a_info,
925 .csi_if = 1,
926};
927
928static struct platform_device msm_camera_sensor_ov7692 = {
929 .name = "msm_camera_ov7692",
930 .dev = {
931 .platform_data = &msm_camera_sensor_ov7692_data,
932 },
933};
934#endif
935
Chintan Pandya40762702011-12-06 13:47:06 +0530936static struct i2c_board_info i2c_camera_devices[] = {
937 #ifdef CONFIG_S5K4E1
938 {
939 I2C_BOARD_INFO("s5k4e1", 0x36),
940 },
941 {
942 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
943 },
944 #endif
945 #ifdef CONFIG_WEBCAM_OV9726
946 {
947 I2C_BOARD_INFO("ov9726", 0x10),
948 },
949 #endif
950 #ifdef CONFIG_IMX072
951 {
952 I2C_BOARD_INFO("imx072", 0x34),
953 },
954 #endif
955 #ifdef CONFIG_MT9E013
956 {
957 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
958 },
959 #endif
960 {
961 I2C_BOARD_INFO("sc628a", 0x6E),
962 },
963};
964
965static struct i2c_board_info i2c_camera_devices_qrd[] = {
966 #ifdef CONFIG_OV5640
967 {
968 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
969 },
970 #endif
971 #ifdef CONFIG_WEBCAM_OV7692_QRD
972 {
973 I2C_BOARD_INFO("ov7692", 0x78),
974 },
975 #endif
976};
977
Su Liuaca04702012-02-14 02:27:32 +0530978static struct i2c_board_info i2c_camera_devices_evb[] = {
979 #ifdef CONFIG_OV5647
980 {
981 I2C_BOARD_INFO("ov5647", 0x36 << 1),
982 },
983 {
984 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
985 },
986 #endif
987 #ifdef CONFIG_WEBCAM_OV7692_QRD
988 {
989 I2C_BOARD_INFO("ov7692", 0x78),
990 },
991 #endif
992};
993
Chintan Pandya40762702011-12-06 13:47:06 +0530994static struct platform_device *camera_devices_msm[] __initdata = {
995#ifdef CONFIG_S5K4E1
996 &msm_camera_sensor_s5k4e1,
997#endif
998#ifdef CONFIG_IMX072
999 &msm_camera_sensor_imx072,
1000#endif
1001#ifdef CONFIG_WEBCAM_OV9726
1002 &msm_camera_sensor_ov9726,
1003#endif
1004#ifdef CONFIG_MT9E013
1005 &msm_camera_sensor_mt9e013,
1006#endif
1007};
1008
1009static struct platform_device *camera_devices_qrd[] __initdata = {
1010#ifdef CONFIG_OV5640
1011 &msm_camera_sensor_ov5640,
1012#endif
1013#ifdef CONFIG_WEBCAM_OV7692_QRD
1014 &msm_camera_sensor_ov7692,
1015#endif
1016};
Su Liuaca04702012-02-14 02:27:32 +05301017
1018static struct platform_device *camera_devices_evb[] __initdata = {
1019#ifdef CONFIG_OV5647
1020 &msm_camera_sensor_ov5647,
1021#endif
1022#ifdef CONFIG_WEBCAM_OV7692_QRD
1023 &msm_camera_sensor_ov7692,
1024#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +05301025 &msm_camera_sensor_ov8825,
Su Liuaca04702012-02-14 02:27:32 +05301026};
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301027#endif
1028
1029enum {
1030 SX150X_CAM,
1031};
1032
1033static struct sx150x_platform_data sx150x_data[] __initdata = {
1034 [SX150X_CAM] = {
1035 .gpio_base = GPIO_CAM_EXPANDER_BASE,
1036 .oscio_is_gpo = false,
1037 .io_pullup_ena = 0,
1038 .io_pulldn_ena = 0,
1039 .io_open_drain_ena = 0x23,
1040 .irq_summary = -1,
1041 },
1042};
1043
1044static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
1045 {
1046 I2C_BOARD_INFO("sx1508q", 0x22),
1047 .platform_data = &sx150x_data[SX150X_CAM],
1048 },
1049};
Chintan Pandya40762702011-12-06 13:47:06 +05301050
1051static void __init register_i2c_devices(void)
1052{
1053 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1054 cam_exp_i2c_info,
1055 ARRAY_SIZE(cam_exp_i2c_info));
1056}
1057
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301058#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301059#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
1060#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301061#define SKU7_LCD_CAMERA_LDO_1V8 58 /* SKU7 1.8V LDO */
Su Liuaca04702012-02-14 02:27:32 +05301062
1063static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
1064
1065static void lcd_camera_power_init(void)
1066{
1067 int rc = 0;
1068
1069 pr_debug("lcd_camera_power_init\n");
1070
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301071 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
1072 lcd_camera_ldo_1v8 = SKU7_LCD_CAMERA_LDO_1V8;
1073 else
1074 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
Su Liuaca04702012-02-14 02:27:32 +05301075
1076 /* LDO_EXT2V8 */
1077 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
1078 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
1079 return;
1080 }
1081
1082 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
1083 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1084 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1085 if (rc < 0) {
1086 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1087 goto fail_gpio2;
1088 }
1089
1090 /* LDO_EVT1V8 */
1091 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1092 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1093 goto fail_gpio2;
1094 }
1095
1096 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1097 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1098 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1099 if (rc < 0) {
1100 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1101 goto fail_gpio1;
1102 }
1103
1104 return;
1105
1106fail_gpio1:
1107 gpio_free(lcd_camera_ldo_1v8);
1108fail_gpio2:
1109 gpio_free(LCD_CAMERA_LDO_2V8);
1110
1111 return;
1112}
1113
1114static int lcd_camera_power_on_sku3(void)
1115{
1116 int rc = 0;
1117
1118 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1119 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1120
1121 pr_debug("turn on sku3 lcd_camera_ldo\n");
1122 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1123
1124 return rc;
1125}
1126
1127static int lcd_camera_power_off_sku3(void)
1128{
1129 int rc = 0;
1130
1131 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1132 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1133
1134 pr_debug("turn off sku3 lcd_camera_ldo\n");
1135 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1136
1137 gpio_free(lcd_camera_ldo_1v8);
1138 gpio_free(LCD_CAMERA_LDO_2V8);
1139
1140 return rc;
1141}
1142
1143int lcd_camera_power_onoff(int on)
1144{
1145 int rc = 0;
1146
1147 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1148
1149 if (on)
1150 rc = lcd_camera_power_on_sku3();
1151 else
1152 rc = lcd_camera_power_off_sku3();
1153
1154 return rc;
1155}
1156EXPORT_SYMBOL(lcd_camera_power_onoff);
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301157#endif
Su Liuaca04702012-02-14 02:27:32 +05301158
Chintan Pandya40762702011-12-06 13:47:06 +05301159void __init msm7627a_camera_init(void)
1160{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301161
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301162#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301163 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301164#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301165
Su Liuaca04702012-02-14 02:27:32 +05301166 pr_debug("msm7627a_camera_init Entered\n");
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301167
1168 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
1169 ov7692_cam_req_gpio[0].gpio =
1170 GPIO_SKU7_CAM_VGA_SHDN;
1171 ov7692_cam_gpio_set_tbl[0].gpio = GPIO_SKU7_CAM_VGA_SHDN;
1172 ov7692_cam_gpio_set_tbl[1].gpio = GPIO_SKU7_CAM_VGA_SHDN;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301173
1174 msm_camera_sensor_ov5647_data.sensor_pwd =
1175 GPIO_SKU7_CAM_5MP_SHDN_N;
1176 msm_camera_sensor_ov5647_data.sensor_reset =
1177 GPIO_SKU7_CAM_5MP_CAMIF_RESET;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301178 }
1179
Su Liuaca04702012-02-14 02:27:32 +05301180 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301181 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301182 || machine_is_msm8625_evt()
1183 || machine_is_msm7627a_qrd3()
1184 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301185#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301186 lcd_camera_power_init();
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301187#endif
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301188 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301189 }
1190
1191#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301192 if (machine_is_msm7627a_qrd1()) {
1193 qrd1_camera_gpio_cfg();
1194 platform_add_devices(camera_devices_qrd,
1195 ARRAY_SIZE(camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301196 } else if (machine_is_msm7627a_evb()
1197 || machine_is_msm8625_evb()
1198 || machine_is_msm8625_evt()
1199 || machine_is_msm7627a_qrd3()
1200 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301201 platform_add_devices(camera_devices_evb,
1202 ARRAY_SIZE(camera_devices_evb));
1203 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301204 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301205 else
Chintan Pandya40762702011-12-06 13:47:06 +05301206 platform_add_devices(camera_devices_msm,
1207 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301208#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301209 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301210 || !machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301211 || !machine_is_msm8625_evt()
1212 || !machine_is_msm7627a_qrd3()
1213 || !machine_is_msm8625_qrd7())
Chintan Pandya40762702011-12-06 13:47:06 +05301214 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301215#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301216 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1217
1218 if (rc) {
1219 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1220 return;
1221 }
1222
1223 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1224
1225 if (rc) {
1226 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1227 return;
1228 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301229#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301230
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301231#if defined(CONFIG_MSM_CAMERA_V4L2)
1232 msm7x27a_init_cam();
1233#endif
1234#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301235 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301236 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1237 i2c_camera_devices_qrd,
1238 ARRAY_SIZE(i2c_camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301239 } else if (machine_is_msm7627a_evb()
1240 || machine_is_msm8625_evb()
1241 || machine_is_msm8625_evt()
1242 || machine_is_msm7627a_qrd3()
1243 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301244 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1245 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1246 i2c_camera_devices_evb,
1247 ARRAY_SIZE(i2c_camera_devices_evb));
1248 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301249#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301250 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301251 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1252 i2c_camera_devices,
1253 ARRAY_SIZE(i2c_camera_devices));
1254}