blob: d1d85fcd42ecb4a61128d4d8cfa2fc536dff1dd0 [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>
Jack Wangb88c8c22012-07-26 11:33:36 -070022#include <mach/camera.h>
Chintan Pandya40762702011-12-06 13:47:06 +053023#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
Lokesh Kumar Aakulu85da21e2012-07-18 12:02:23 +0530284static struct msm_camera_sensor_flash_src msm_flash_src_ov8825 = {
285 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
286 ._fsrc.ext_driver_src.led_en = 13,
287 ._fsrc.ext_driver_src.led_flash_en = 32,
288};
289
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530290static struct msm_camera_sensor_flash_data flash_ov8825 = {
Lokesh Kumar Aakulu85da21e2012-07-18 12:02:23 +0530291 .flash_type = MSM_CAMERA_FLASH_LED,
292 .flash_src = &msm_flash_src_ov8825,
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530293};
294
295static struct msm_camera_sensor_platform_info sensor_board_info_ov8825 = {
296 .mount_angle = 90,
297 .cam_vreg = msm_cam_vreg,
298 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
299 .gpio_conf = &gpio_conf_ov8825,
300};
301
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700302static struct msm_actuator_info msm_act_main_cam_3_info = {
303 .board_info = &msm_act_main_cam_i2c_info,
304 .cam_name = MSM_ACTUATOR_MAIN_CAM_3,
305 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
306 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
307 .vcm_enable = 0,
308};
309
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530310static struct msm_camera_sensor_info msm_camera_sensor_ov8825_data = {
311 .sensor_name = "ov8825",
312 .sensor_reset_enable = 1,
313 .pmic_gpio_enable = 1,
314 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
315 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
316 .pdata = &msm_camera_device_data_csi1[1],
317 .flash_data = &flash_ov8825,
318 .sensor_platform_info = &sensor_board_info_ov8825,
319 .csi_if = 1,
320 .camera_type = BACK_CAMERA_2D,
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700321 .sensor_type = BAYER_SENSOR,
322 .actuator_info = &msm_act_main_cam_3_info,
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530323};
324
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530325#ifdef CONFIG_MT9E013
326static struct msm_camera_sensor_flash_data flash_mt9e013 = {
327 .flash_type = MSM_CAMERA_FLASH_LED,
328 .flash_src = &msm_flash_src
329};
330
331static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
332 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530333 .cam_vreg = msm_cam_vreg,
334 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
335 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530336};
337
338static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
339 .sensor_name = "mt9e013",
340 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530341 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530342 .flash_data = &flash_mt9e013,
343 .sensor_platform_info = &sensor_board_info_mt9e013,
344 .csi_if = 1,
345 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530346 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530347};
348#endif
349
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530350#ifdef CONFIG_WEBCAM_OV9726
351static struct msm_camera_sensor_flash_data flash_ov9726 = {
352 .flash_type = MSM_CAMERA_FLASH_LED,
353 .flash_src = &msm_flash_src
354};
355
356static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
357 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530358 .cam_vreg = msm_cam_vreg,
359 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
360 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530361};
362
363static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
364 .sensor_name = "ov9726",
365 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530366 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530367 .flash_data = &flash_ov9726,
368 .sensor_platform_info = &sensor_board_info_ov9726,
369 .csi_if = 1,
370 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530371 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530372};
373#endif
374
Kevin Chan94b4c832012-03-02 21:27:16 -0800375static struct platform_device msm_camera_server = {
376 .name = "msm_cam_server",
377 .id = 0,
378};
379
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530380static void __init msm7x27a_init_cam(void)
381{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530382 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530383 || machine_is_msm7627a_qrd1()
384 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530385 sensor_board_info_s5k4e1.cam_vreg = NULL;
386 sensor_board_info_s5k4e1.num_vreg = 0;
387 sensor_board_info_mt9e013.cam_vreg = NULL;
388 sensor_board_info_mt9e013.num_vreg = 0;
389 sensor_board_info_ov9726.cam_vreg = NULL;
390 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530391 sensor_board_info_ov7692.cam_vreg = NULL;
392 sensor_board_info_ov7692.num_vreg = 0;
393 sensor_board_info_ov5647.cam_vreg = NULL;
394 sensor_board_info_ov5647.num_vreg = 0;
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530395 sensor_board_info_ov8825.cam_vreg = NULL;
396 sensor_board_info_ov8825.num_vreg = 0;
397
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530398 }
Lokesh Kumar Aakulu08781352012-07-13 18:20:23 +0530399 if (machine_is_msm8625_evb() || machine_is_msm7627a_evb()
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +0530400 || machine_is_msm8625_evt()) {
401 sensor_board_info_ov7692.cam_vreg =
402 ov7692_gpio_vreg;
403 sensor_board_info_ov7692.num_vreg =
404 ARRAY_SIZE(ov7692_gpio_vreg);
405 sensor_board_info_ov5647.cam_vreg =
406 ov5647_gpio_vreg;
407 sensor_board_info_ov5647.num_vreg =
408 ARRAY_SIZE(ov5647_gpio_vreg);
409 sensor_board_info_ov8825.cam_vreg =
410 ov8825_gpio_vreg;
411 sensor_board_info_ov8825.num_vreg =
412 ARRAY_SIZE(ov8825_gpio_vreg);
413 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800414 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530415 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530416 || machine_is_msm8625_evt()
417 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530418 platform_device_register(&msm8625_device_csic0);
419 platform_device_register(&msm8625_device_csic1);
420 } else {
421 platform_device_register(&msm7x27a_device_csic0);
422 platform_device_register(&msm7x27a_device_csic1);
423 }
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530424 if (machine_is_msm8625_evb()
425 || machine_is_msm8625_evt()
426 || machine_is_msm8625_qrd7())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530427 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530428 platform_device_register(&msm7x27a_device_clkctl);
429 platform_device_register(&msm7x27a_device_vfe);
430}
431
432static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530433 {
434 I2C_BOARD_INFO("s5k4e1", 0x36),
435 .platform_data = &msm_camera_sensor_s5k4e1_data,
436 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530437 {
438 I2C_BOARD_INFO("ov9726", 0x10),
439 .platform_data = &msm_camera_sensor_ov9726_data,
440 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530441 {
442 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
443 .platform_data = &msm_camera_sensor_mt9e013_data,
444 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530445 {
446 I2C_BOARD_INFO("ov7692", 0x78),
447 .platform_data = &msm_camera_sensor_ov7692_data,
448 },
449 {
450 I2C_BOARD_INFO("ov5647", 0x36 << 1),
451 .platform_data = &msm_camera_sensor_ov5647_data,
452 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530453 {
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530454 I2C_BOARD_INFO("ov8825", 0x6C >> 3),
455 .platform_data = &msm_camera_sensor_ov8825_data,
456 },
457 {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530458 I2C_BOARD_INFO("sc628a", 0x6E),
459 },
460};
461#else
Chintan Pandya40762702011-12-06 13:47:06 +0530462static uint32_t camera_off_gpio_table[] = {
463 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
464};
465
466static uint32_t camera_on_gpio_table[] = {
467 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
468};
469
470#ifdef CONFIG_MSM_CAMERA_FLASH
471static struct msm_camera_sensor_flash_src msm_flash_src = {
472 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
473 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
474 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
475};
476#endif
477
478static struct regulator_bulk_data regs_camera[] = {
479 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
480 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
481 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
482};
483
484static void qrd1_camera_gpio_cfg(void)
485{
486
487 int rc = 0;
488
489 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
490 if (rc < 0)
491 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
492 __func__);
493
494
495 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
496 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
497 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
498 if (rc < 0) {
499 pr_err("%s: unable to enable Power Down gpio for main"
500 "camera!\n", __func__);
501 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
502 }
503
504
505 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
506 if (rc < 0) {
507 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
508 __func__);
509 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
510 }
511
512
513 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
514 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
515 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
516 if (rc < 0) {
517 pr_err("%s: unable to enable reset gpio for main camera!\n",
518 __func__);
519 gpio_free(QRD_GPIO_CAM_5MP_RESET);
520 }
521
522 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
523 if (rc < 0)
524 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
525 __func__);
526
527 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
528 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
529 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
530 if (rc < 0) {
531 pr_err("%s: unable to enable Power Down gpio for front"
532 "camera!\n", __func__);
533 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
534 }
535
536 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
537 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
538 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
539}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530540#endif
Su Liuaca04702012-02-14 02:27:32 +0530541
542static void evb_camera_gpio_cfg(void)
543{
544 int rc = 0;
545
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530546 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_pwd, "ov5647");
Su Liuaca04702012-02-14 02:27:32 +0530547 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530548 pr_err("%s: gpio_request OV5647 sensor_pwd: %d failed!",
549 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530550
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530551 rc = gpio_tlmm_config(GPIO_CFG(msm_camera_sensor_ov5647_data.sensor_pwd,
552 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
553 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530554 if (rc < 0) {
555 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
556 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530557 gpio_free(msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530558 }
559
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530560 rc = gpio_direction_output(msm_camera_sensor_ov5647_data.sensor_pwd, 1);
Su Liuaca04702012-02-14 02:27:32 +0530561 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530562 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
563 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530564
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530565 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_reset, "ov5647");
566 if (rc < 0)
567 pr_err("%s: gpio_request OV5647 sensor_reset: %d failed!",
568 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
569
570 rc = gpio_tlmm_config(GPIO_CFG(
571 msm_camera_sensor_ov5647_data.sensor_reset,
572 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
573 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530574 if (rc < 0) {
575 pr_err("%s: unable to enable reset gpio for main camera!\n",
576 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530577 gpio_free(msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530578 }
579
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530580 rc = gpio_direction_output(
581 msm_camera_sensor_ov5647_data.sensor_reset, 1);
582 if (rc < 0)
583 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
584 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530585
Su Liuaca04702012-02-14 02:27:32 +0530586}
587
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530588#ifndef CONFIG_MSM_CAMERA_V4L2
589
Chintan Pandya40762702011-12-06 13:47:06 +0530590static void msm_camera_vreg_config(int vreg_en)
591{
592 int rc = vreg_en ?
593 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
594 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
595
596 if (rc)
597 pr_err("%s: could not %sable regulators: %d\n",
598 __func__, vreg_en ? "en" : "dis", rc);
599}
600
601static int config_gpio_table(uint32_t *table, int len)
602{
603 int rc = 0, i = 0;
604
605 for (i = 0; i < len; i++) {
606 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
607 if (rc) {
608 pr_err("%s not able to get gpio\n", __func__);
609 for (i--; i >= 0; i--)
610 gpio_tlmm_config(camera_off_gpio_table[i],
611 GPIO_CFG_ENABLE);
612 break;
613 }
614 }
615 return rc;
616}
617
618static int config_camera_on_gpios_rear(void)
619{
620 int rc = 0;
621
622 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530623 || machine_is_msm7627a_qrd1()
624 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530625 msm_camera_vreg_config(1);
626
627 rc = config_gpio_table(camera_on_gpio_table,
628 ARRAY_SIZE(camera_on_gpio_table));
629 if (rc < 0) {
630 pr_err("%s: CAMSENSOR gpio table request"
631 "failed\n", __func__);
632 return rc;
633 }
634
635 return rc;
636}
637
638static void config_camera_off_gpios_rear(void)
639{
640 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530641 || machine_is_msm7627a_qrd1()
642 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530643 msm_camera_vreg_config(0);
644
645 config_gpio_table(camera_off_gpio_table,
646 ARRAY_SIZE(camera_off_gpio_table));
647}
648
649static int config_camera_on_gpios_front(void)
650{
651 int rc = 0;
652
653 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530654 || machine_is_msm7627a_qrd1()
655 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530656 msm_camera_vreg_config(1);
657
658 rc = config_gpio_table(camera_on_gpio_table,
659 ARRAY_SIZE(camera_on_gpio_table));
660 if (rc < 0) {
661 pr_err("%s: CAMSENSOR gpio table request"
662 "failed\n", __func__);
663 return rc;
664 }
665
666 return rc;
667}
668
669static void config_camera_off_gpios_front(void)
670{
671 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530672 || machine_is_msm7627a_qrd1()
673 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530674 msm_camera_vreg_config(0);
675
676 config_gpio_table(camera_off_gpio_table,
677 ARRAY_SIZE(camera_off_gpio_table));
678}
679
680struct msm_camera_device_platform_data msm_camera_device_data_rear = {
681 .camera_gpio_on = config_camera_on_gpios_rear,
682 .camera_gpio_off = config_camera_off_gpios_rear,
683 .ioext.csiphy = 0xA1000000,
684 .ioext.csisz = 0x00100000,
685 .ioext.csiirq = INT_CSI_IRQ_1,
686 .ioclk.mclk_clk_rate = 24000000,
687 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530688 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
689 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530690};
691
692struct msm_camera_device_platform_data msm_camera_device_data_front = {
693 .camera_gpio_on = config_camera_on_gpios_front,
694 .camera_gpio_off = config_camera_off_gpios_front,
695 .ioext.csiphy = 0xA0F00000,
696 .ioext.csisz = 0x00100000,
697 .ioext.csiirq = INT_CSI_IRQ_0,
698 .ioclk.mclk_clk_rate = 24000000,
699 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530700 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
701 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530702};
703
Su Liuaca04702012-02-14 02:27:32 +0530704#ifdef CONFIG_OV5647
705
706static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
707 .mount_angle = 90
708};
709
710static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
711 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
712 ._fsrc.led_src.led_name = "flashlight",
713 ._fsrc.led_src.led_name_len = 10,
714};
715
716static struct msm_camera_sensor_flash_data flash_ov5647 = {
717 .flash_type = MSM_CAMERA_FLASH_LED,
718 .flash_src = &msm_flash_src_ov5647,
719};
720
721static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
722 .sensor_name = "ov5647",
723 .sensor_reset_enable = 1,
724 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
725 .pmic_gpio_enable = 1,
726 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
727 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530728 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530729 .pdata = &msm_camera_device_data_rear,
730 .flash_data = &flash_ov5647,
731 .sensor_platform_info = &ov5647_sensor_7627a_info,
732 .csi_if = 1
733};
734
735static struct platform_device msm_camera_sensor_ov5647 = {
736 .name = "msm_camera_ov5647",
737 .dev = {
738 .platform_data = &msm_camera_sensor_ov5647_data,
739 },
740};
741#endif
742
Chintan Pandya40762702011-12-06 13:47:06 +0530743#ifdef CONFIG_S5K4E1
744static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
745 .mount_angle = 90
746};
747
748static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
749 .flash_type = MSM_CAMERA_FLASH_LED,
750 .flash_src = &msm_flash_src
751};
752
753static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
754 .sensor_name = "s5k4e1",
755 .sensor_reset_enable = 1,
756 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530757 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530758 .sensor_pwd = 85,
759 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
760 .vcm_enable = 1,
761 .pdata = &msm_camera_device_data_rear,
762 .flash_data = &flash_s5k4e1,
763 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
764 .csi_if = 1
765};
766
767static struct platform_device msm_camera_sensor_s5k4e1 = {
768 .name = "msm_camera_s5k4e1",
769 .dev = {
770 .platform_data = &msm_camera_sensor_s5k4e1_data,
771 },
772};
773#endif
774
775#ifdef CONFIG_IMX072
776static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
777 .mount_angle = 90
778};
779
780static struct msm_camera_sensor_flash_data flash_imx072 = {
781 .flash_type = MSM_CAMERA_FLASH_LED,
782 .flash_src = &msm_flash_src
783};
784
785static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
786 .sensor_name = "imx072",
787 .sensor_reset_enable = 1,
788 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530789 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530790 .sensor_pwd = 85,
791 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
792 .vcm_enable = 1,
793 .pdata = &msm_camera_device_data_rear,
794 .flash_data = &flash_imx072,
795 .sensor_platform_info = &imx072_sensor_7627a_info,
796 .csi_if = 1
797};
798
799static struct platform_device msm_camera_sensor_imx072 = {
800 .name = "msm_camera_imx072",
801 .dev = {
802 .platform_data = &msm_camera_sensor_imx072_data,
803 },
804};
805#endif
806
Chintan Pandya40762702011-12-06 13:47:06 +0530807#ifdef CONFIG_WEBCAM_OV9726
Steve Mucklef132c6c2012-06-06 18:30:57 -0700808static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
Chintan Pandya40762702011-12-06 13:47:06 +0530809static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
810 .mount_angle = 90
811};
812
813static struct msm_camera_sensor_flash_data flash_ov9726 = {
814 .flash_type = MSM_CAMERA_FLASH_NONE,
815 .flash_src = &msm_flash_src
816};
817
818static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
819 .sensor_name = "ov9726",
820 .sensor_reset_enable = 0,
821 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530822 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530823 .sensor_pwd = 85,
824 .vcm_pwd = 1,
825 .vcm_enable = 0,
826 .pdata = &msm_camera_device_data_front,
827 .flash_data = &flash_ov9726,
828 .sensor_platform_info = &ov9726_sensor_7627a_info,
829 .csi_if = 1
830};
831
832static struct platform_device msm_camera_sensor_ov9726 = {
833 .name = "msm_camera_ov9726",
834 .dev = {
835 .platform_data = &msm_camera_sensor_ov9726_data,
836 },
837};
838#else
839static inline void msm_camera_vreg_init(void) { }
840#endif
841
842#ifdef CONFIG_MT9E013
843static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
844 .mount_angle = 90
845};
846
847static struct msm_camera_sensor_flash_data flash_mt9e013 = {
848 .flash_type = MSM_CAMERA_FLASH_LED,
849 .flash_src = &msm_flash_src
850};
851
852static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
853 .sensor_name = "mt9e013",
854 .sensor_reset = 0,
855 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530856 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530857 .sensor_pwd = 85,
858 .vcm_pwd = 1,
859 .vcm_enable = 0,
860 .pdata = &msm_camera_device_data_rear,
861 .flash_data = &flash_mt9e013,
862 .sensor_platform_info = &mt9e013_sensor_7627a_info,
863 .csi_if = 1
864};
865
866static struct platform_device msm_camera_sensor_mt9e013 = {
867 .name = "msm_camera_mt9e013",
868 .dev = {
869 .platform_data = &msm_camera_sensor_mt9e013_data,
870 },
871};
872#endif
873
874#ifdef CONFIG_OV5640
875static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
876 .mount_angle = 90
877};
878
879static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
880 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
881 ._fsrc.led_src.led_name = "flashlight",
882 ._fsrc.led_src.led_name_len = 10,
883};
884
885static struct msm_camera_sensor_flash_data flash_ov5640 = {
886 .flash_type = MSM_CAMERA_FLASH_LED,
887 .flash_src = &msm_flash_src_ov5640,
888};
889
890static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
891 .sensor_name = "ov5640",
892 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530893 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530894 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
895 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
896 .vcm_pwd = 0,
897 .vcm_enable = 0,
898 .pdata = &msm_camera_device_data_rear,
899 .flash_data = &flash_ov5640,
900 .sensor_platform_info = &ov5640_sensor_info,
901 .csi_if = 1,
902};
903
904static struct platform_device msm_camera_sensor_ov5640 = {
905 .name = "msm_camera_ov5640",
906 .dev = {
907 .platform_data = &msm_camera_sensor_ov5640_data,
908 },
909};
910#endif
911
912#ifdef CONFIG_WEBCAM_OV7692_QRD
913static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
914 .mount_angle = 90
915};
916
917static struct msm_camera_sensor_flash_data flash_ov7692 = {
918 .flash_type = MSM_CAMERA_FLASH_NONE,
919};
920
921static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
922 .sensor_name = "ov7692",
923 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530924 .pmic_gpio_enable = 1,
925 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
926 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530927 .vcm_pwd = 0,
928 .vcm_enable = 0,
929 .pdata = &msm_camera_device_data_front,
930 .flash_data = &flash_ov7692,
931 .sensor_platform_info = &ov7692_sensor_7627a_info,
932 .csi_if = 1,
933};
934
935static struct platform_device msm_camera_sensor_ov7692 = {
936 .name = "msm_camera_ov7692",
937 .dev = {
938 .platform_data = &msm_camera_sensor_ov7692_data,
939 },
940};
941#endif
942
Chintan Pandya40762702011-12-06 13:47:06 +0530943static struct i2c_board_info i2c_camera_devices[] = {
944 #ifdef CONFIG_S5K4E1
945 {
946 I2C_BOARD_INFO("s5k4e1", 0x36),
947 },
948 {
949 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
950 },
951 #endif
952 #ifdef CONFIG_WEBCAM_OV9726
953 {
954 I2C_BOARD_INFO("ov9726", 0x10),
955 },
956 #endif
957 #ifdef CONFIG_IMX072
958 {
959 I2C_BOARD_INFO("imx072", 0x34),
960 },
961 #endif
962 #ifdef CONFIG_MT9E013
963 {
964 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
965 },
966 #endif
967 {
968 I2C_BOARD_INFO("sc628a", 0x6E),
969 },
970};
971
972static struct i2c_board_info i2c_camera_devices_qrd[] = {
973 #ifdef CONFIG_OV5640
974 {
975 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
976 },
977 #endif
978 #ifdef CONFIG_WEBCAM_OV7692_QRD
979 {
980 I2C_BOARD_INFO("ov7692", 0x78),
981 },
982 #endif
983};
984
Su Liuaca04702012-02-14 02:27:32 +0530985static struct i2c_board_info i2c_camera_devices_evb[] = {
986 #ifdef CONFIG_OV5647
987 {
988 I2C_BOARD_INFO("ov5647", 0x36 << 1),
989 },
990 {
991 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
992 },
993 #endif
994 #ifdef CONFIG_WEBCAM_OV7692_QRD
995 {
996 I2C_BOARD_INFO("ov7692", 0x78),
997 },
998 #endif
999};
1000
Chintan Pandya40762702011-12-06 13:47:06 +05301001static struct platform_device *camera_devices_msm[] __initdata = {
1002#ifdef CONFIG_S5K4E1
1003 &msm_camera_sensor_s5k4e1,
1004#endif
1005#ifdef CONFIG_IMX072
1006 &msm_camera_sensor_imx072,
1007#endif
1008#ifdef CONFIG_WEBCAM_OV9726
1009 &msm_camera_sensor_ov9726,
1010#endif
1011#ifdef CONFIG_MT9E013
1012 &msm_camera_sensor_mt9e013,
1013#endif
1014};
1015
1016static struct platform_device *camera_devices_qrd[] __initdata = {
1017#ifdef CONFIG_OV5640
1018 &msm_camera_sensor_ov5640,
1019#endif
1020#ifdef CONFIG_WEBCAM_OV7692_QRD
1021 &msm_camera_sensor_ov7692,
1022#endif
1023};
Su Liuaca04702012-02-14 02:27:32 +05301024
1025static struct platform_device *camera_devices_evb[] __initdata = {
1026#ifdef CONFIG_OV5647
1027 &msm_camera_sensor_ov5647,
1028#endif
1029#ifdef CONFIG_WEBCAM_OV7692_QRD
1030 &msm_camera_sensor_ov7692,
1031#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +05301032 &msm_camera_sensor_ov8825,
Su Liuaca04702012-02-14 02:27:32 +05301033};
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301034#endif
1035
1036enum {
1037 SX150X_CAM,
1038};
1039
1040static struct sx150x_platform_data sx150x_data[] __initdata = {
1041 [SX150X_CAM] = {
1042 .gpio_base = GPIO_CAM_EXPANDER_BASE,
1043 .oscio_is_gpo = false,
1044 .io_pullup_ena = 0,
1045 .io_pulldn_ena = 0,
1046 .io_open_drain_ena = 0x23,
1047 .irq_summary = -1,
1048 },
1049};
1050
1051static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
1052 {
1053 I2C_BOARD_INFO("sx1508q", 0x22),
1054 .platform_data = &sx150x_data[SX150X_CAM],
1055 },
1056};
Chintan Pandya40762702011-12-06 13:47:06 +05301057
1058static void __init register_i2c_devices(void)
1059{
1060 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1061 cam_exp_i2c_info,
1062 ARRAY_SIZE(cam_exp_i2c_info));
1063}
1064
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301065#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301066#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
1067#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301068#define SKU7_LCD_CAMERA_LDO_1V8 58 /* SKU7 1.8V LDO */
Su Liuaca04702012-02-14 02:27:32 +05301069
1070static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
1071
1072static void lcd_camera_power_init(void)
1073{
1074 int rc = 0;
1075
1076 pr_debug("lcd_camera_power_init\n");
1077
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301078 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
1079 lcd_camera_ldo_1v8 = SKU7_LCD_CAMERA_LDO_1V8;
1080 else
1081 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
Su Liuaca04702012-02-14 02:27:32 +05301082
1083 /* LDO_EXT2V8 */
1084 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
1085 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
1086 return;
1087 }
1088
1089 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
1090 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1091 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1092 if (rc < 0) {
1093 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1094 goto fail_gpio2;
1095 }
1096
1097 /* LDO_EVT1V8 */
1098 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1099 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1100 goto fail_gpio2;
1101 }
1102
1103 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1104 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1105 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1106 if (rc < 0) {
1107 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1108 goto fail_gpio1;
1109 }
1110
1111 return;
1112
1113fail_gpio1:
1114 gpio_free(lcd_camera_ldo_1v8);
1115fail_gpio2:
1116 gpio_free(LCD_CAMERA_LDO_2V8);
1117
1118 return;
1119}
1120
1121static int lcd_camera_power_on_sku3(void)
1122{
1123 int rc = 0;
1124
1125 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1126 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1127
1128 pr_debug("turn on sku3 lcd_camera_ldo\n");
1129 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1130
1131 return rc;
1132}
1133
1134static int lcd_camera_power_off_sku3(void)
1135{
1136 int rc = 0;
1137
1138 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1139 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1140
1141 pr_debug("turn off sku3 lcd_camera_ldo\n");
1142 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1143
1144 gpio_free(lcd_camera_ldo_1v8);
1145 gpio_free(LCD_CAMERA_LDO_2V8);
1146
1147 return rc;
1148}
1149
1150int lcd_camera_power_onoff(int on)
1151{
1152 int rc = 0;
1153
1154 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1155
1156 if (on)
1157 rc = lcd_camera_power_on_sku3();
1158 else
1159 rc = lcd_camera_power_off_sku3();
1160
1161 return rc;
1162}
1163EXPORT_SYMBOL(lcd_camera_power_onoff);
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301164#endif
Su Liuaca04702012-02-14 02:27:32 +05301165
Chintan Pandya40762702011-12-06 13:47:06 +05301166void __init msm7627a_camera_init(void)
1167{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301168
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301169#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301170 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301171#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301172
Su Liuaca04702012-02-14 02:27:32 +05301173 pr_debug("msm7627a_camera_init Entered\n");
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301174
1175 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
1176 ov7692_cam_req_gpio[0].gpio =
1177 GPIO_SKU7_CAM_VGA_SHDN;
1178 ov7692_cam_gpio_set_tbl[0].gpio = GPIO_SKU7_CAM_VGA_SHDN;
1179 ov7692_cam_gpio_set_tbl[1].gpio = GPIO_SKU7_CAM_VGA_SHDN;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301180
1181 msm_camera_sensor_ov5647_data.sensor_pwd =
1182 GPIO_SKU7_CAM_5MP_SHDN_N;
1183 msm_camera_sensor_ov5647_data.sensor_reset =
1184 GPIO_SKU7_CAM_5MP_CAMIF_RESET;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301185 }
1186
Su Liuaca04702012-02-14 02:27:32 +05301187 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301188 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301189 || machine_is_msm8625_evt()
1190 || machine_is_msm7627a_qrd3()
1191 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301192#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301193 lcd_camera_power_init();
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301194#endif
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301195 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301196 }
1197
1198#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301199 if (machine_is_msm7627a_qrd1()) {
1200 qrd1_camera_gpio_cfg();
1201 platform_add_devices(camera_devices_qrd,
1202 ARRAY_SIZE(camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301203 } else if (machine_is_msm7627a_evb()
1204 || machine_is_msm8625_evb()
1205 || machine_is_msm8625_evt()
1206 || machine_is_msm7627a_qrd3()
1207 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301208 platform_add_devices(camera_devices_evb,
1209 ARRAY_SIZE(camera_devices_evb));
1210 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301211 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301212 else
Chintan Pandya40762702011-12-06 13:47:06 +05301213 platform_add_devices(camera_devices_msm,
1214 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301215#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301216 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301217 || !machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301218 || !machine_is_msm8625_evt()
1219 || !machine_is_msm7627a_qrd3()
1220 || !machine_is_msm8625_qrd7())
Chintan Pandya40762702011-12-06 13:47:06 +05301221 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301222#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301223 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1224
1225 if (rc) {
1226 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1227 return;
1228 }
1229
1230 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1231
1232 if (rc) {
1233 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1234 return;
1235 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301236#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301237
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301238#if defined(CONFIG_MSM_CAMERA_V4L2)
1239 msm7x27a_init_cam();
1240#endif
1241#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301242 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301243 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1244 i2c_camera_devices_qrd,
1245 ARRAY_SIZE(i2c_camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301246 } else if (machine_is_msm7627a_evb()
1247 || machine_is_msm8625_evb()
1248 || machine_is_msm8625_evt()
1249 || machine_is_msm7627a_qrd3()
1250 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301251 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1252 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1253 i2c_camera_devices_evb,
1254 ARRAY_SIZE(i2c_camera_devices_evb));
1255 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301256#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301257 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301258 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1259 i2c_camera_devices,
1260 ARRAY_SIZE(i2c_camera_devices));
1261}