blob: 3ab5ba00e76eeaf94744423967acb45563699ccb [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
295static struct msm_camera_sensor_info msm_camera_sensor_ov8825_data = {
296 .sensor_name = "ov8825",
297 .sensor_reset_enable = 1,
298 .pmic_gpio_enable = 1,
299 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
300 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
301 .pdata = &msm_camera_device_data_csi1[1],
302 .flash_data = &flash_ov8825,
303 .sensor_platform_info = &sensor_board_info_ov8825,
304 .csi_if = 1,
305 .camera_type = BACK_CAMERA_2D,
306};
307
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530308#ifdef CONFIG_MT9E013
309static struct msm_camera_sensor_flash_data flash_mt9e013 = {
310 .flash_type = MSM_CAMERA_FLASH_LED,
311 .flash_src = &msm_flash_src
312};
313
314static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
315 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530316 .cam_vreg = msm_cam_vreg,
317 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
318 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530319};
320
321static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
322 .sensor_name = "mt9e013",
323 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530324 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530325 .flash_data = &flash_mt9e013,
326 .sensor_platform_info = &sensor_board_info_mt9e013,
327 .csi_if = 1,
328 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530329 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530330};
331#endif
332
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530333#ifdef CONFIG_WEBCAM_OV9726
334static struct msm_camera_sensor_flash_data flash_ov9726 = {
335 .flash_type = MSM_CAMERA_FLASH_LED,
336 .flash_src = &msm_flash_src
337};
338
339static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
340 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530341 .cam_vreg = msm_cam_vreg,
342 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
343 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530344};
345
346static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
347 .sensor_name = "ov9726",
348 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530349 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530350 .flash_data = &flash_ov9726,
351 .sensor_platform_info = &sensor_board_info_ov9726,
352 .csi_if = 1,
353 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530354 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530355};
356#endif
357
Kevin Chan94b4c832012-03-02 21:27:16 -0800358static struct platform_device msm_camera_server = {
359 .name = "msm_cam_server",
360 .id = 0,
361};
362
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530363static void __init msm7x27a_init_cam(void)
364{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530365 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530366 || machine_is_msm7627a_qrd1()
367 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530368 sensor_board_info_s5k4e1.cam_vreg = NULL;
369 sensor_board_info_s5k4e1.num_vreg = 0;
370 sensor_board_info_mt9e013.cam_vreg = NULL;
371 sensor_board_info_mt9e013.num_vreg = 0;
372 sensor_board_info_ov9726.cam_vreg = NULL;
373 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530374 sensor_board_info_ov7692.cam_vreg = NULL;
375 sensor_board_info_ov7692.num_vreg = 0;
376 sensor_board_info_ov5647.cam_vreg = NULL;
377 sensor_board_info_ov5647.num_vreg = 0;
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530378 sensor_board_info_ov8825.cam_vreg = NULL;
379 sensor_board_info_ov8825.num_vreg = 0;
380
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530381 }
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +0530382 if (machine_is_msm8625_evb()
383 || machine_is_msm8625_evt()) {
384 sensor_board_info_ov7692.cam_vreg =
385 ov7692_gpio_vreg;
386 sensor_board_info_ov7692.num_vreg =
387 ARRAY_SIZE(ov7692_gpio_vreg);
388 sensor_board_info_ov5647.cam_vreg =
389 ov5647_gpio_vreg;
390 sensor_board_info_ov5647.num_vreg =
391 ARRAY_SIZE(ov5647_gpio_vreg);
392 sensor_board_info_ov8825.cam_vreg =
393 ov8825_gpio_vreg;
394 sensor_board_info_ov8825.num_vreg =
395 ARRAY_SIZE(ov8825_gpio_vreg);
396 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800397 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530398 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530399 || machine_is_msm8625_evt()
400 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530401 platform_device_register(&msm8625_device_csic0);
402 platform_device_register(&msm8625_device_csic1);
403 } else {
404 platform_device_register(&msm7x27a_device_csic0);
405 platform_device_register(&msm7x27a_device_csic1);
406 }
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530407 if (machine_is_msm8625_evb()
408 || machine_is_msm8625_evt()
409 || machine_is_msm8625_qrd7())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530410 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530411 platform_device_register(&msm7x27a_device_clkctl);
412 platform_device_register(&msm7x27a_device_vfe);
413}
414
415static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530416 {
417 I2C_BOARD_INFO("s5k4e1", 0x36),
418 .platform_data = &msm_camera_sensor_s5k4e1_data,
419 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530420 {
421 I2C_BOARD_INFO("ov9726", 0x10),
422 .platform_data = &msm_camera_sensor_ov9726_data,
423 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530424 {
425 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
426 .platform_data = &msm_camera_sensor_mt9e013_data,
427 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530428 {
429 I2C_BOARD_INFO("ov7692", 0x78),
430 .platform_data = &msm_camera_sensor_ov7692_data,
431 },
432 {
433 I2C_BOARD_INFO("ov5647", 0x36 << 1),
434 .platform_data = &msm_camera_sensor_ov5647_data,
435 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530436 {
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530437 I2C_BOARD_INFO("ov8825", 0x6C >> 3),
438 .platform_data = &msm_camera_sensor_ov8825_data,
439 },
440 {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530441 I2C_BOARD_INFO("sc628a", 0x6E),
442 },
443};
444#else
Chintan Pandya40762702011-12-06 13:47:06 +0530445static uint32_t camera_off_gpio_table[] = {
446 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
447};
448
449static uint32_t camera_on_gpio_table[] = {
450 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
451};
452
453#ifdef CONFIG_MSM_CAMERA_FLASH
454static struct msm_camera_sensor_flash_src msm_flash_src = {
455 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
456 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
457 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
458};
459#endif
460
461static struct regulator_bulk_data regs_camera[] = {
462 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
463 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
464 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
465};
466
467static void qrd1_camera_gpio_cfg(void)
468{
469
470 int rc = 0;
471
472 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
473 if (rc < 0)
474 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
475 __func__);
476
477
478 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
479 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
480 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
481 if (rc < 0) {
482 pr_err("%s: unable to enable Power Down gpio for main"
483 "camera!\n", __func__);
484 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
485 }
486
487
488 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
489 if (rc < 0) {
490 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
491 __func__);
492 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
493 }
494
495
496 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
497 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
498 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
499 if (rc < 0) {
500 pr_err("%s: unable to enable reset gpio for main camera!\n",
501 __func__);
502 gpio_free(QRD_GPIO_CAM_5MP_RESET);
503 }
504
505 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
506 if (rc < 0)
507 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
508 __func__);
509
510 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
511 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
512 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
513 if (rc < 0) {
514 pr_err("%s: unable to enable Power Down gpio for front"
515 "camera!\n", __func__);
516 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
517 }
518
519 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
520 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
521 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
522}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530523#endif
Su Liuaca04702012-02-14 02:27:32 +0530524
525static void evb_camera_gpio_cfg(void)
526{
527 int rc = 0;
528
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530529 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_pwd, "ov5647");
Su Liuaca04702012-02-14 02:27:32 +0530530 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530531 pr_err("%s: gpio_request OV5647 sensor_pwd: %d failed!",
532 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530533
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530534 rc = gpio_tlmm_config(GPIO_CFG(msm_camera_sensor_ov5647_data.sensor_pwd,
535 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
536 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530537 if (rc < 0) {
538 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
539 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530540 gpio_free(msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530541 }
542
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530543 rc = gpio_direction_output(msm_camera_sensor_ov5647_data.sensor_pwd, 1);
Su Liuaca04702012-02-14 02:27:32 +0530544 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530545 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
546 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530547
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530548 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_reset, "ov5647");
549 if (rc < 0)
550 pr_err("%s: gpio_request OV5647 sensor_reset: %d failed!",
551 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
552
553 rc = gpio_tlmm_config(GPIO_CFG(
554 msm_camera_sensor_ov5647_data.sensor_reset,
555 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
556 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530557 if (rc < 0) {
558 pr_err("%s: unable to enable reset gpio for main camera!\n",
559 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530560 gpio_free(msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530561 }
562
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530563 rc = gpio_direction_output(
564 msm_camera_sensor_ov5647_data.sensor_reset, 1);
565 if (rc < 0)
566 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
567 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530568
Su Liuaca04702012-02-14 02:27:32 +0530569}
570
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530571#ifndef CONFIG_MSM_CAMERA_V4L2
572
Chintan Pandya40762702011-12-06 13:47:06 +0530573static void msm_camera_vreg_config(int vreg_en)
574{
575 int rc = vreg_en ?
576 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
577 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
578
579 if (rc)
580 pr_err("%s: could not %sable regulators: %d\n",
581 __func__, vreg_en ? "en" : "dis", rc);
582}
583
584static int config_gpio_table(uint32_t *table, int len)
585{
586 int rc = 0, i = 0;
587
588 for (i = 0; i < len; i++) {
589 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
590 if (rc) {
591 pr_err("%s not able to get gpio\n", __func__);
592 for (i--; i >= 0; i--)
593 gpio_tlmm_config(camera_off_gpio_table[i],
594 GPIO_CFG_ENABLE);
595 break;
596 }
597 }
598 return rc;
599}
600
601static int config_camera_on_gpios_rear(void)
602{
603 int rc = 0;
604
605 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530606 || machine_is_msm7627a_qrd1()
607 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530608 msm_camera_vreg_config(1);
609
610 rc = config_gpio_table(camera_on_gpio_table,
611 ARRAY_SIZE(camera_on_gpio_table));
612 if (rc < 0) {
613 pr_err("%s: CAMSENSOR gpio table request"
614 "failed\n", __func__);
615 return rc;
616 }
617
618 return rc;
619}
620
621static void config_camera_off_gpios_rear(void)
622{
623 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530624 || machine_is_msm7627a_qrd1()
625 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530626 msm_camera_vreg_config(0);
627
628 config_gpio_table(camera_off_gpio_table,
629 ARRAY_SIZE(camera_off_gpio_table));
630}
631
632static int config_camera_on_gpios_front(void)
633{
634 int rc = 0;
635
636 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530637 || machine_is_msm7627a_qrd1()
638 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530639 msm_camera_vreg_config(1);
640
641 rc = config_gpio_table(camera_on_gpio_table,
642 ARRAY_SIZE(camera_on_gpio_table));
643 if (rc < 0) {
644 pr_err("%s: CAMSENSOR gpio table request"
645 "failed\n", __func__);
646 return rc;
647 }
648
649 return rc;
650}
651
652static void config_camera_off_gpios_front(void)
653{
654 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530655 || machine_is_msm7627a_qrd1()
656 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530657 msm_camera_vreg_config(0);
658
659 config_gpio_table(camera_off_gpio_table,
660 ARRAY_SIZE(camera_off_gpio_table));
661}
662
663struct msm_camera_device_platform_data msm_camera_device_data_rear = {
664 .camera_gpio_on = config_camera_on_gpios_rear,
665 .camera_gpio_off = config_camera_off_gpios_rear,
666 .ioext.csiphy = 0xA1000000,
667 .ioext.csisz = 0x00100000,
668 .ioext.csiirq = INT_CSI_IRQ_1,
669 .ioclk.mclk_clk_rate = 24000000,
670 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530671 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
672 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530673};
674
675struct msm_camera_device_platform_data msm_camera_device_data_front = {
676 .camera_gpio_on = config_camera_on_gpios_front,
677 .camera_gpio_off = config_camera_off_gpios_front,
678 .ioext.csiphy = 0xA0F00000,
679 .ioext.csisz = 0x00100000,
680 .ioext.csiirq = INT_CSI_IRQ_0,
681 .ioclk.mclk_clk_rate = 24000000,
682 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530683 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
684 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530685};
686
Su Liuaca04702012-02-14 02:27:32 +0530687#ifdef CONFIG_OV5647
688
689static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
690 .mount_angle = 90
691};
692
693static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
694 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
695 ._fsrc.led_src.led_name = "flashlight",
696 ._fsrc.led_src.led_name_len = 10,
697};
698
699static struct msm_camera_sensor_flash_data flash_ov5647 = {
700 .flash_type = MSM_CAMERA_FLASH_LED,
701 .flash_src = &msm_flash_src_ov5647,
702};
703
704static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
705 .sensor_name = "ov5647",
706 .sensor_reset_enable = 1,
707 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
708 .pmic_gpio_enable = 1,
709 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
710 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530711 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530712 .pdata = &msm_camera_device_data_rear,
713 .flash_data = &flash_ov5647,
714 .sensor_platform_info = &ov5647_sensor_7627a_info,
715 .csi_if = 1
716};
717
718static struct platform_device msm_camera_sensor_ov5647 = {
719 .name = "msm_camera_ov5647",
720 .dev = {
721 .platform_data = &msm_camera_sensor_ov5647_data,
722 },
723};
724#endif
725
Chintan Pandya40762702011-12-06 13:47:06 +0530726#ifdef CONFIG_S5K4E1
727static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
728 .mount_angle = 90
729};
730
731static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
732 .flash_type = MSM_CAMERA_FLASH_LED,
733 .flash_src = &msm_flash_src
734};
735
736static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
737 .sensor_name = "s5k4e1",
738 .sensor_reset_enable = 1,
739 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530740 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530741 .sensor_pwd = 85,
742 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
743 .vcm_enable = 1,
744 .pdata = &msm_camera_device_data_rear,
745 .flash_data = &flash_s5k4e1,
746 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
747 .csi_if = 1
748};
749
750static struct platform_device msm_camera_sensor_s5k4e1 = {
751 .name = "msm_camera_s5k4e1",
752 .dev = {
753 .platform_data = &msm_camera_sensor_s5k4e1_data,
754 },
755};
756#endif
757
758#ifdef CONFIG_IMX072
759static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
760 .mount_angle = 90
761};
762
763static struct msm_camera_sensor_flash_data flash_imx072 = {
764 .flash_type = MSM_CAMERA_FLASH_LED,
765 .flash_src = &msm_flash_src
766};
767
768static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
769 .sensor_name = "imx072",
770 .sensor_reset_enable = 1,
771 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530772 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530773 .sensor_pwd = 85,
774 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
775 .vcm_enable = 1,
776 .pdata = &msm_camera_device_data_rear,
777 .flash_data = &flash_imx072,
778 .sensor_platform_info = &imx072_sensor_7627a_info,
779 .csi_if = 1
780};
781
782static struct platform_device msm_camera_sensor_imx072 = {
783 .name = "msm_camera_imx072",
784 .dev = {
785 .platform_data = &msm_camera_sensor_imx072_data,
786 },
787};
788#endif
789
Chintan Pandya40762702011-12-06 13:47:06 +0530790#ifdef CONFIG_WEBCAM_OV9726
Steve Mucklef132c6c2012-06-06 18:30:57 -0700791static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
Chintan Pandya40762702011-12-06 13:47:06 +0530792static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
793 .mount_angle = 90
794};
795
796static struct msm_camera_sensor_flash_data flash_ov9726 = {
797 .flash_type = MSM_CAMERA_FLASH_NONE,
798 .flash_src = &msm_flash_src
799};
800
801static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
802 .sensor_name = "ov9726",
803 .sensor_reset_enable = 0,
804 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530805 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530806 .sensor_pwd = 85,
807 .vcm_pwd = 1,
808 .vcm_enable = 0,
809 .pdata = &msm_camera_device_data_front,
810 .flash_data = &flash_ov9726,
811 .sensor_platform_info = &ov9726_sensor_7627a_info,
812 .csi_if = 1
813};
814
815static struct platform_device msm_camera_sensor_ov9726 = {
816 .name = "msm_camera_ov9726",
817 .dev = {
818 .platform_data = &msm_camera_sensor_ov9726_data,
819 },
820};
821#else
822static inline void msm_camera_vreg_init(void) { }
823#endif
824
825#ifdef CONFIG_MT9E013
826static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
827 .mount_angle = 90
828};
829
830static struct msm_camera_sensor_flash_data flash_mt9e013 = {
831 .flash_type = MSM_CAMERA_FLASH_LED,
832 .flash_src = &msm_flash_src
833};
834
835static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
836 .sensor_name = "mt9e013",
837 .sensor_reset = 0,
838 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530839 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530840 .sensor_pwd = 85,
841 .vcm_pwd = 1,
842 .vcm_enable = 0,
843 .pdata = &msm_camera_device_data_rear,
844 .flash_data = &flash_mt9e013,
845 .sensor_platform_info = &mt9e013_sensor_7627a_info,
846 .csi_if = 1
847};
848
849static struct platform_device msm_camera_sensor_mt9e013 = {
850 .name = "msm_camera_mt9e013",
851 .dev = {
852 .platform_data = &msm_camera_sensor_mt9e013_data,
853 },
854};
855#endif
856
857#ifdef CONFIG_OV5640
858static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
859 .mount_angle = 90
860};
861
862static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
863 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
864 ._fsrc.led_src.led_name = "flashlight",
865 ._fsrc.led_src.led_name_len = 10,
866};
867
868static struct msm_camera_sensor_flash_data flash_ov5640 = {
869 .flash_type = MSM_CAMERA_FLASH_LED,
870 .flash_src = &msm_flash_src_ov5640,
871};
872
873static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
874 .sensor_name = "ov5640",
875 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530876 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530877 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
878 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
879 .vcm_pwd = 0,
880 .vcm_enable = 0,
881 .pdata = &msm_camera_device_data_rear,
882 .flash_data = &flash_ov5640,
883 .sensor_platform_info = &ov5640_sensor_info,
884 .csi_if = 1,
885};
886
887static struct platform_device msm_camera_sensor_ov5640 = {
888 .name = "msm_camera_ov5640",
889 .dev = {
890 .platform_data = &msm_camera_sensor_ov5640_data,
891 },
892};
893#endif
894
895#ifdef CONFIG_WEBCAM_OV7692_QRD
896static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
897 .mount_angle = 90
898};
899
900static struct msm_camera_sensor_flash_data flash_ov7692 = {
901 .flash_type = MSM_CAMERA_FLASH_NONE,
902};
903
904static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
905 .sensor_name = "ov7692",
906 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530907 .pmic_gpio_enable = 1,
908 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
909 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530910 .vcm_pwd = 0,
911 .vcm_enable = 0,
912 .pdata = &msm_camera_device_data_front,
913 .flash_data = &flash_ov7692,
914 .sensor_platform_info = &ov7692_sensor_7627a_info,
915 .csi_if = 1,
916};
917
918static struct platform_device msm_camera_sensor_ov7692 = {
919 .name = "msm_camera_ov7692",
920 .dev = {
921 .platform_data = &msm_camera_sensor_ov7692_data,
922 },
923};
924#endif
925
Chintan Pandya40762702011-12-06 13:47:06 +0530926static struct i2c_board_info i2c_camera_devices[] = {
927 #ifdef CONFIG_S5K4E1
928 {
929 I2C_BOARD_INFO("s5k4e1", 0x36),
930 },
931 {
932 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
933 },
934 #endif
935 #ifdef CONFIG_WEBCAM_OV9726
936 {
937 I2C_BOARD_INFO("ov9726", 0x10),
938 },
939 #endif
940 #ifdef CONFIG_IMX072
941 {
942 I2C_BOARD_INFO("imx072", 0x34),
943 },
944 #endif
945 #ifdef CONFIG_MT9E013
946 {
947 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
948 },
949 #endif
950 {
951 I2C_BOARD_INFO("sc628a", 0x6E),
952 },
953};
954
955static struct i2c_board_info i2c_camera_devices_qrd[] = {
956 #ifdef CONFIG_OV5640
957 {
958 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
959 },
960 #endif
961 #ifdef CONFIG_WEBCAM_OV7692_QRD
962 {
963 I2C_BOARD_INFO("ov7692", 0x78),
964 },
965 #endif
966};
967
Su Liuaca04702012-02-14 02:27:32 +0530968static struct i2c_board_info i2c_camera_devices_evb[] = {
969 #ifdef CONFIG_OV5647
970 {
971 I2C_BOARD_INFO("ov5647", 0x36 << 1),
972 },
973 {
974 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
975 },
976 #endif
977 #ifdef CONFIG_WEBCAM_OV7692_QRD
978 {
979 I2C_BOARD_INFO("ov7692", 0x78),
980 },
981 #endif
982};
983
Chintan Pandya40762702011-12-06 13:47:06 +0530984static struct platform_device *camera_devices_msm[] __initdata = {
985#ifdef CONFIG_S5K4E1
986 &msm_camera_sensor_s5k4e1,
987#endif
988#ifdef CONFIG_IMX072
989 &msm_camera_sensor_imx072,
990#endif
991#ifdef CONFIG_WEBCAM_OV9726
992 &msm_camera_sensor_ov9726,
993#endif
994#ifdef CONFIG_MT9E013
995 &msm_camera_sensor_mt9e013,
996#endif
997};
998
999static struct platform_device *camera_devices_qrd[] __initdata = {
1000#ifdef CONFIG_OV5640
1001 &msm_camera_sensor_ov5640,
1002#endif
1003#ifdef CONFIG_WEBCAM_OV7692_QRD
1004 &msm_camera_sensor_ov7692,
1005#endif
1006};
Su Liuaca04702012-02-14 02:27:32 +05301007
1008static struct platform_device *camera_devices_evb[] __initdata = {
1009#ifdef CONFIG_OV5647
1010 &msm_camera_sensor_ov5647,
1011#endif
1012#ifdef CONFIG_WEBCAM_OV7692_QRD
1013 &msm_camera_sensor_ov7692,
1014#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +05301015 &msm_camera_sensor_ov8825,
Su Liuaca04702012-02-14 02:27:32 +05301016};
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301017#endif
1018
1019enum {
1020 SX150X_CAM,
1021};
1022
1023static struct sx150x_platform_data sx150x_data[] __initdata = {
1024 [SX150X_CAM] = {
1025 .gpio_base = GPIO_CAM_EXPANDER_BASE,
1026 .oscio_is_gpo = false,
1027 .io_pullup_ena = 0,
1028 .io_pulldn_ena = 0,
1029 .io_open_drain_ena = 0x23,
1030 .irq_summary = -1,
1031 },
1032};
1033
1034static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
1035 {
1036 I2C_BOARD_INFO("sx1508q", 0x22),
1037 .platform_data = &sx150x_data[SX150X_CAM],
1038 },
1039};
Chintan Pandya40762702011-12-06 13:47:06 +05301040
1041static void __init register_i2c_devices(void)
1042{
1043 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1044 cam_exp_i2c_info,
1045 ARRAY_SIZE(cam_exp_i2c_info));
1046}
1047
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301048#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301049#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
1050#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301051#define SKU7_LCD_CAMERA_LDO_1V8 58 /* SKU7 1.8V LDO */
Su Liuaca04702012-02-14 02:27:32 +05301052
1053static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
1054
1055static void lcd_camera_power_init(void)
1056{
1057 int rc = 0;
1058
1059 pr_debug("lcd_camera_power_init\n");
1060
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301061 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
1062 lcd_camera_ldo_1v8 = SKU7_LCD_CAMERA_LDO_1V8;
1063 else
1064 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
Su Liuaca04702012-02-14 02:27:32 +05301065
1066 /* LDO_EXT2V8 */
1067 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
1068 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
1069 return;
1070 }
1071
1072 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
1073 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1074 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1075 if (rc < 0) {
1076 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1077 goto fail_gpio2;
1078 }
1079
1080 /* LDO_EVT1V8 */
1081 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1082 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1083 goto fail_gpio2;
1084 }
1085
1086 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1087 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1088 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1089 if (rc < 0) {
1090 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1091 goto fail_gpio1;
1092 }
1093
1094 return;
1095
1096fail_gpio1:
1097 gpio_free(lcd_camera_ldo_1v8);
1098fail_gpio2:
1099 gpio_free(LCD_CAMERA_LDO_2V8);
1100
1101 return;
1102}
1103
1104static int lcd_camera_power_on_sku3(void)
1105{
1106 int rc = 0;
1107
1108 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1109 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1110
1111 pr_debug("turn on sku3 lcd_camera_ldo\n");
1112 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1113
1114 return rc;
1115}
1116
1117static int lcd_camera_power_off_sku3(void)
1118{
1119 int rc = 0;
1120
1121 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1122 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1123
1124 pr_debug("turn off sku3 lcd_camera_ldo\n");
1125 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1126
1127 gpio_free(lcd_camera_ldo_1v8);
1128 gpio_free(LCD_CAMERA_LDO_2V8);
1129
1130 return rc;
1131}
1132
1133int lcd_camera_power_onoff(int on)
1134{
1135 int rc = 0;
1136
1137 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1138
1139 if (on)
1140 rc = lcd_camera_power_on_sku3();
1141 else
1142 rc = lcd_camera_power_off_sku3();
1143
1144 return rc;
1145}
1146EXPORT_SYMBOL(lcd_camera_power_onoff);
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301147#endif
Su Liuaca04702012-02-14 02:27:32 +05301148
Chintan Pandya40762702011-12-06 13:47:06 +05301149void __init msm7627a_camera_init(void)
1150{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301151
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301152#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301153 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301154#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301155
Su Liuaca04702012-02-14 02:27:32 +05301156 pr_debug("msm7627a_camera_init Entered\n");
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301157
1158 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
1159 ov7692_cam_req_gpio[0].gpio =
1160 GPIO_SKU7_CAM_VGA_SHDN;
1161 ov7692_cam_gpio_set_tbl[0].gpio = GPIO_SKU7_CAM_VGA_SHDN;
1162 ov7692_cam_gpio_set_tbl[1].gpio = GPIO_SKU7_CAM_VGA_SHDN;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301163
1164 msm_camera_sensor_ov5647_data.sensor_pwd =
1165 GPIO_SKU7_CAM_5MP_SHDN_N;
1166 msm_camera_sensor_ov5647_data.sensor_reset =
1167 GPIO_SKU7_CAM_5MP_CAMIF_RESET;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301168 }
1169
Su Liuaca04702012-02-14 02:27:32 +05301170 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301171 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301172 || machine_is_msm8625_evt()
1173 || machine_is_msm7627a_qrd3()
1174 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301175#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301176 lcd_camera_power_init();
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301177#endif
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301178 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301179 }
1180
1181#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301182 if (machine_is_msm7627a_qrd1()) {
1183 qrd1_camera_gpio_cfg();
1184 platform_add_devices(camera_devices_qrd,
1185 ARRAY_SIZE(camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301186 } else if (machine_is_msm7627a_evb()
1187 || machine_is_msm8625_evb()
1188 || machine_is_msm8625_evt()
1189 || machine_is_msm7627a_qrd3()
1190 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301191 platform_add_devices(camera_devices_evb,
1192 ARRAY_SIZE(camera_devices_evb));
1193 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301194 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301195 else
Chintan Pandya40762702011-12-06 13:47:06 +05301196 platform_add_devices(camera_devices_msm,
1197 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301198#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301199 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301200 || !machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301201 || !machine_is_msm8625_evt()
1202 || !machine_is_msm7627a_qrd3()
1203 || !machine_is_msm8625_qrd7())
Chintan Pandya40762702011-12-06 13:47:06 +05301204 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301205#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301206 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1207
1208 if (rc) {
1209 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1210 return;
1211 }
1212
1213 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1214
1215 if (rc) {
1216 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1217 return;
1218 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301219#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301220
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301221#if defined(CONFIG_MSM_CAMERA_V4L2)
1222 msm7x27a_init_cam();
1223#endif
1224#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301225 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301226 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1227 i2c_camera_devices_qrd,
1228 ARRAY_SIZE(i2c_camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301229 } else if (machine_is_msm7627a_evb()
1230 || machine_is_msm8625_evb()
1231 || machine_is_msm8625_evt()
1232 || machine_is_msm7627a_qrd3()
1233 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301234 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1235 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1236 i2c_camera_devices_evb,
1237 ARRAY_SIZE(i2c_camera_devices_evb));
1238 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301239#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301240 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301241 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1242 i2c_camera_devices,
1243 ARRAY_SIZE(i2c_camera_devices));
1244}