blob: 79ad996ebe246e718faaeccd10c29c660d03f019 [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 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700142 .csiphy_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530143 .csid_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530144 .ioclk = {
145 .vfe_clk_rate = 192000000,
146 },
147 },
148 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700149 .csiphy_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530150 .csid_core = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530151 .ioclk = {
152 .vfe_clk_rate = 266667000,
153 },
154 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530155};
156
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530157struct msm_camera_device_platform_data msm_camera_device_data_csi0[] = {
158 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700159 .csiphy_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530160 .csid_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530161 .ioclk = {
162 .vfe_clk_rate = 192000000,
163 },
164 },
165 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700166 .csiphy_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530167 .csid_core = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530168 .ioclk = {
169 .vfe_clk_rate = 266667000,
170 },
171 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530172};
173
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800174static struct i2c_board_info msm_act_main_cam_i2c_info = {
175 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530176};
177
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800178static struct msm_actuator_info msm_act_main_cam_4_info = {
179 .board_info = &msm_act_main_cam_i2c_info,
180 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530181 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
182 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
183 .vcm_enable = 1,
184};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530185
186#ifdef CONFIG_S5K4E1
187static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
188 .flash_type = MSM_CAMERA_FLASH_LED,
189 .flash_src = &msm_flash_src
190};
191
192static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
193 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530194 .cam_vreg = msm_cam_vreg,
195 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
196 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530197};
198
199static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
200 .sensor_name = "s5k4e1",
201 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530202 .pdata = &msm_camera_device_data_csi1[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530203 .flash_data = &flash_s5k4e1,
204 .sensor_platform_info = &sensor_board_info_s5k4e1,
205 .csi_if = 1,
206 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530207 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800208 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530209};
210#endif
211
Sreesudhan Ramakrish Ramkumarcfdfa0e2012-05-15 15:56:05 -0700212#ifdef CONFIG_OV7692
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530213static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
214 .mount_angle = 90,
215 .cam_vreg = msm_cam_vreg,
216 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
217 .gpio_conf = &gpio_conf_ov7692,
218};
219
220static struct msm_camera_sensor_flash_data flash_ov7692 = {
221 .flash_type = MSM_CAMERA_FLASH_NONE,
222};
223
224static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
225 .sensor_name = "ov7692",
226 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530227 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
228 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530229 .pdata = &msm_camera_device_data_csi0[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530230 .flash_data = &flash_ov7692,
231 .sensor_platform_info = &sensor_board_info_ov7692,
232 .csi_if = 1,
233 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530234 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530235};
236#endif
237
238#ifdef CONFIG_OV5647
239
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800240static struct msm_actuator_info msm_act_main_cam_5_info = {
241 .board_info = &msm_act_main_cam_i2c_info,
242 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530243 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
244 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
245 .vcm_enable = 1,
246};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530247
248static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
249 .mount_angle = 90,
250 .cam_vreg = msm_cam_vreg,
251 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
252 .gpio_conf = &gpio_conf_ov5647,
253};
254
255static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530256 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
257 ._fsrc.ext_driver_src.led_en = 13,
258 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530259};
260
261static struct msm_camera_sensor_flash_data flash_ov5647 = {
262 .flash_type = MSM_CAMERA_FLASH_LED,
263 .flash_src = &msm_flash_src_ov5647,
264};
265
266static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
267 .sensor_name = "ov5647",
268 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530269 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
270 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530271 .pdata = &msm_camera_device_data_csi1[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530272 .flash_data = &flash_ov5647,
273 .sensor_platform_info = &sensor_board_info_ov5647,
274 .csi_if = 1,
275 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530276 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800277 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530278};
279
280#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530281
282static struct msm_camera_gpio_conf gpio_conf_ov8825 = {
283 .camera_off_table = camera_off_gpio_table,
284 .camera_on_table = camera_on_gpio_table,
285 .gpio_no_mux = 1,
286};
287
Lokesh Kumar Aakulu85da21e2012-07-18 12:02:23 +0530288static struct msm_camera_sensor_flash_src msm_flash_src_ov8825 = {
289 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
290 ._fsrc.ext_driver_src.led_en = 13,
291 ._fsrc.ext_driver_src.led_flash_en = 32,
292};
293
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530294static struct msm_camera_sensor_flash_data flash_ov8825 = {
Lokesh Kumar Aakulu85da21e2012-07-18 12:02:23 +0530295 .flash_type = MSM_CAMERA_FLASH_LED,
296 .flash_src = &msm_flash_src_ov8825,
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530297};
298
299static struct msm_camera_sensor_platform_info sensor_board_info_ov8825 = {
300 .mount_angle = 90,
301 .cam_vreg = msm_cam_vreg,
302 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
303 .gpio_conf = &gpio_conf_ov8825,
304};
305
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700306static struct msm_actuator_info msm_act_main_cam_3_info = {
307 .board_info = &msm_act_main_cam_i2c_info,
308 .cam_name = MSM_ACTUATOR_MAIN_CAM_3,
309 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
310 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
311 .vcm_enable = 0,
312};
313
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530314static struct msm_camera_sensor_info msm_camera_sensor_ov8825_data = {
315 .sensor_name = "ov8825",
316 .sensor_reset_enable = 1,
317 .pmic_gpio_enable = 1,
318 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
319 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
320 .pdata = &msm_camera_device_data_csi1[1],
321 .flash_data = &flash_ov8825,
322 .sensor_platform_info = &sensor_board_info_ov8825,
323 .csi_if = 1,
324 .camera_type = BACK_CAMERA_2D,
Rajakumar Govindaramef37a642012-06-27 19:05:09 -0700325 .sensor_type = BAYER_SENSOR,
326 .actuator_info = &msm_act_main_cam_3_info,
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530327};
328
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530329#ifdef CONFIG_MT9E013
330static struct msm_camera_sensor_flash_data flash_mt9e013 = {
331 .flash_type = MSM_CAMERA_FLASH_LED,
332 .flash_src = &msm_flash_src
333};
334
335static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
336 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530337 .cam_vreg = msm_cam_vreg,
338 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
339 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530340};
341
342static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
343 .sensor_name = "mt9e013",
344 .sensor_reset_enable = 1,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530345 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530346 .flash_data = &flash_mt9e013,
347 .sensor_platform_info = &sensor_board_info_mt9e013,
348 .csi_if = 1,
349 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530350 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530351};
352#endif
353
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530354#ifdef CONFIG_WEBCAM_OV9726
355static struct msm_camera_sensor_flash_data flash_ov9726 = {
356 .flash_type = MSM_CAMERA_FLASH_LED,
357 .flash_src = &msm_flash_src
358};
359
360static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
361 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530362 .cam_vreg = msm_cam_vreg,
363 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
364 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530365};
366
367static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
368 .sensor_name = "ov9726",
369 .sensor_reset_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530370 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530371 .flash_data = &flash_ov9726,
372 .sensor_platform_info = &sensor_board_info_ov9726,
373 .csi_if = 1,
374 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530375 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530376};
377#endif
378
Kevin Chan94b4c832012-03-02 21:27:16 -0800379static struct platform_device msm_camera_server = {
380 .name = "msm_cam_server",
381 .id = 0,
382};
383
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530384static void __init msm7x27a_init_cam(void)
385{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530386 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530387 || machine_is_msm7627a_qrd1()
388 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530389 sensor_board_info_s5k4e1.cam_vreg = NULL;
390 sensor_board_info_s5k4e1.num_vreg = 0;
391 sensor_board_info_mt9e013.cam_vreg = NULL;
392 sensor_board_info_mt9e013.num_vreg = 0;
393 sensor_board_info_ov9726.cam_vreg = NULL;
394 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530395 sensor_board_info_ov7692.cam_vreg = NULL;
396 sensor_board_info_ov7692.num_vreg = 0;
397 sensor_board_info_ov5647.cam_vreg = NULL;
398 sensor_board_info_ov5647.num_vreg = 0;
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530399 sensor_board_info_ov8825.cam_vreg = NULL;
400 sensor_board_info_ov8825.num_vreg = 0;
401
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530402 }
Lokesh Kumar Aakulu08781352012-07-13 18:20:23 +0530403 if (machine_is_msm8625_evb() || machine_is_msm7627a_evb()
Praveen Aca64fad42012-08-01 15:49:10 +0530404 || machine_is_msm8625_evt()
405 || machine_is_msm7627a_qrd3()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +0530406 || machine_is_msm8625_qrd7()
407 || machine_is_qrd_skud_prime()) {
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +0530408 sensor_board_info_ov7692.cam_vreg =
409 ov7692_gpio_vreg;
410 sensor_board_info_ov7692.num_vreg =
411 ARRAY_SIZE(ov7692_gpio_vreg);
412 sensor_board_info_ov5647.cam_vreg =
413 ov5647_gpio_vreg;
414 sensor_board_info_ov5647.num_vreg =
415 ARRAY_SIZE(ov5647_gpio_vreg);
416 sensor_board_info_ov8825.cam_vreg =
417 ov8825_gpio_vreg;
418 sensor_board_info_ov8825.num_vreg =
419 ARRAY_SIZE(ov8825_gpio_vreg);
420 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800421 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530422 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530423 || machine_is_msm8625_evt()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +0530424 || machine_is_msm8625_qrd7()
425 || machine_is_qrd_skud_prime()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530426 platform_device_register(&msm8625_device_csic0);
427 platform_device_register(&msm8625_device_csic1);
428 } else {
429 platform_device_register(&msm7x27a_device_csic0);
430 platform_device_register(&msm7x27a_device_csic1);
431 }
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530432 if (machine_is_msm8625_evb()
433 || machine_is_msm8625_evt()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +0530434 || machine_is_msm8625_qrd7()
435 || machine_is_qrd_skud_prime())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530436 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530437 platform_device_register(&msm7x27a_device_clkctl);
438 platform_device_register(&msm7x27a_device_vfe);
439}
440
441static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530442 {
443 I2C_BOARD_INFO("s5k4e1", 0x36),
444 .platform_data = &msm_camera_sensor_s5k4e1_data,
445 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530446 {
447 I2C_BOARD_INFO("ov9726", 0x10),
448 .platform_data = &msm_camera_sensor_ov9726_data,
449 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530450 {
451 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
452 .platform_data = &msm_camera_sensor_mt9e013_data,
453 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530454 {
455 I2C_BOARD_INFO("ov7692", 0x78),
456 .platform_data = &msm_camera_sensor_ov7692_data,
457 },
458 {
459 I2C_BOARD_INFO("ov5647", 0x36 << 1),
460 .platform_data = &msm_camera_sensor_ov5647_data,
461 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530462 {
Katta Santhisindhu16746f62012-06-08 13:35:07 +0530463 I2C_BOARD_INFO("ov8825", 0x6C >> 3),
464 .platform_data = &msm_camera_sensor_ov8825_data,
465 },
466 {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530467 I2C_BOARD_INFO("sc628a", 0x6E),
468 },
469};
470#else
Chintan Pandya40762702011-12-06 13:47:06 +0530471static uint32_t camera_off_gpio_table[] = {
472 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
473};
474
475static uint32_t camera_on_gpio_table[] = {
476 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
477};
478
479#ifdef CONFIG_MSM_CAMERA_FLASH
480static struct msm_camera_sensor_flash_src msm_flash_src = {
481 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
482 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
483 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
484};
485#endif
486
487static struct regulator_bulk_data regs_camera[] = {
488 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
489 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
490 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
491};
492
493static void qrd1_camera_gpio_cfg(void)
494{
495
496 int rc = 0;
497
498 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
499 if (rc < 0)
500 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
501 __func__);
502
503
504 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
505 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
506 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
507 if (rc < 0) {
508 pr_err("%s: unable to enable Power Down gpio for main"
509 "camera!\n", __func__);
510 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
511 }
512
513
514 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
515 if (rc < 0) {
516 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
517 __func__);
518 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
519 }
520
521
522 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
523 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
524 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
525 if (rc < 0) {
526 pr_err("%s: unable to enable reset gpio for main camera!\n",
527 __func__);
528 gpio_free(QRD_GPIO_CAM_5MP_RESET);
529 }
530
531 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
532 if (rc < 0)
533 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
534 __func__);
535
536 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
537 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
538 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
539 if (rc < 0) {
540 pr_err("%s: unable to enable Power Down gpio for front"
541 "camera!\n", __func__);
542 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
543 }
544
545 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
546 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
547 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
548}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530549#endif
Su Liuaca04702012-02-14 02:27:32 +0530550
551static void evb_camera_gpio_cfg(void)
552{
553 int rc = 0;
554
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530555 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_pwd, "ov5647");
Su Liuaca04702012-02-14 02:27:32 +0530556 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530557 pr_err("%s: gpio_request OV5647 sensor_pwd: %d failed!",
558 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530559
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530560 rc = gpio_tlmm_config(GPIO_CFG(msm_camera_sensor_ov5647_data.sensor_pwd,
561 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
562 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530563 if (rc < 0) {
564 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
565 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530566 gpio_free(msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530567 }
568
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530569 rc = gpio_direction_output(msm_camera_sensor_ov5647_data.sensor_pwd, 1);
Su Liuaca04702012-02-14 02:27:32 +0530570 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530571 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
572 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530573
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530574 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_reset, "ov5647");
575 if (rc < 0)
576 pr_err("%s: gpio_request OV5647 sensor_reset: %d failed!",
577 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
578
579 rc = gpio_tlmm_config(GPIO_CFG(
580 msm_camera_sensor_ov5647_data.sensor_reset,
581 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
582 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530583 if (rc < 0) {
584 pr_err("%s: unable to enable reset gpio for main camera!\n",
585 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530586 gpio_free(msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530587 }
588
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530589 rc = gpio_direction_output(
590 msm_camera_sensor_ov5647_data.sensor_reset, 1);
591 if (rc < 0)
592 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
593 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530594
Su Liuaca04702012-02-14 02:27:32 +0530595}
596
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530597#ifndef CONFIG_MSM_CAMERA_V4L2
598
Chintan Pandya40762702011-12-06 13:47:06 +0530599static void msm_camera_vreg_config(int vreg_en)
600{
601 int rc = vreg_en ?
602 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
603 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
604
605 if (rc)
606 pr_err("%s: could not %sable regulators: %d\n",
607 __func__, vreg_en ? "en" : "dis", rc);
608}
609
610static int config_gpio_table(uint32_t *table, int len)
611{
612 int rc = 0, i = 0;
613
614 for (i = 0; i < len; i++) {
615 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
616 if (rc) {
617 pr_err("%s not able to get gpio\n", __func__);
618 for (i--; i >= 0; i--)
619 gpio_tlmm_config(camera_off_gpio_table[i],
620 GPIO_CFG_ENABLE);
621 break;
622 }
623 }
624 return rc;
625}
626
627static int config_camera_on_gpios_rear(void)
628{
629 int rc = 0;
630
631 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530632 || machine_is_msm7627a_qrd1()
633 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530634 msm_camera_vreg_config(1);
635
636 rc = config_gpio_table(camera_on_gpio_table,
637 ARRAY_SIZE(camera_on_gpio_table));
638 if (rc < 0) {
639 pr_err("%s: CAMSENSOR gpio table request"
640 "failed\n", __func__);
641 return rc;
642 }
643
644 return rc;
645}
646
647static void config_camera_off_gpios_rear(void)
648{
649 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530650 || machine_is_msm7627a_qrd1()
651 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530652 msm_camera_vreg_config(0);
653
654 config_gpio_table(camera_off_gpio_table,
655 ARRAY_SIZE(camera_off_gpio_table));
656}
657
658static int config_camera_on_gpios_front(void)
659{
660 int rc = 0;
661
662 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530663 || machine_is_msm7627a_qrd1()
664 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530665 msm_camera_vreg_config(1);
666
667 rc = config_gpio_table(camera_on_gpio_table,
668 ARRAY_SIZE(camera_on_gpio_table));
669 if (rc < 0) {
670 pr_err("%s: CAMSENSOR gpio table request"
671 "failed\n", __func__);
672 return rc;
673 }
674
675 return rc;
676}
677
678static void config_camera_off_gpios_front(void)
679{
680 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530681 || machine_is_msm7627a_qrd1()
682 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530683 msm_camera_vreg_config(0);
684
685 config_gpio_table(camera_off_gpio_table,
686 ARRAY_SIZE(camera_off_gpio_table));
687}
688
689struct msm_camera_device_platform_data msm_camera_device_data_rear = {
690 .camera_gpio_on = config_camera_on_gpios_rear,
691 .camera_gpio_off = config_camera_off_gpios_rear,
692 .ioext.csiphy = 0xA1000000,
693 .ioext.csisz = 0x00100000,
694 .ioext.csiirq = INT_CSI_IRQ_1,
695 .ioclk.mclk_clk_rate = 24000000,
696 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530697 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
698 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530699};
700
701struct msm_camera_device_platform_data msm_camera_device_data_front = {
702 .camera_gpio_on = config_camera_on_gpios_front,
703 .camera_gpio_off = config_camera_off_gpios_front,
704 .ioext.csiphy = 0xA0F00000,
705 .ioext.csisz = 0x00100000,
706 .ioext.csiirq = INT_CSI_IRQ_0,
707 .ioclk.mclk_clk_rate = 24000000,
708 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530709 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
710 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530711};
712
Su Liuaca04702012-02-14 02:27:32 +0530713#ifdef CONFIG_OV5647
714
715static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
716 .mount_angle = 90
717};
718
719static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
720 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
721 ._fsrc.led_src.led_name = "flashlight",
722 ._fsrc.led_src.led_name_len = 10,
723};
724
725static struct msm_camera_sensor_flash_data flash_ov5647 = {
726 .flash_type = MSM_CAMERA_FLASH_LED,
727 .flash_src = &msm_flash_src_ov5647,
728};
729
730static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
731 .sensor_name = "ov5647",
732 .sensor_reset_enable = 1,
733 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
734 .pmic_gpio_enable = 1,
735 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
736 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530737 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530738 .pdata = &msm_camera_device_data_rear,
739 .flash_data = &flash_ov5647,
740 .sensor_platform_info = &ov5647_sensor_7627a_info,
741 .csi_if = 1
742};
743
744static struct platform_device msm_camera_sensor_ov5647 = {
745 .name = "msm_camera_ov5647",
746 .dev = {
747 .platform_data = &msm_camera_sensor_ov5647_data,
748 },
749};
750#endif
751
Chintan Pandya40762702011-12-06 13:47:06 +0530752#ifdef CONFIG_S5K4E1
753static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
754 .mount_angle = 90
755};
756
757static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
758 .flash_type = MSM_CAMERA_FLASH_LED,
759 .flash_src = &msm_flash_src
760};
761
762static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
763 .sensor_name = "s5k4e1",
764 .sensor_reset_enable = 1,
765 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530766 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530767 .sensor_pwd = 85,
768 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
769 .vcm_enable = 1,
770 .pdata = &msm_camera_device_data_rear,
771 .flash_data = &flash_s5k4e1,
772 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
773 .csi_if = 1
774};
775
776static struct platform_device msm_camera_sensor_s5k4e1 = {
777 .name = "msm_camera_s5k4e1",
778 .dev = {
779 .platform_data = &msm_camera_sensor_s5k4e1_data,
780 },
781};
782#endif
783
784#ifdef CONFIG_IMX072
785static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
786 .mount_angle = 90
787};
788
789static struct msm_camera_sensor_flash_data flash_imx072 = {
790 .flash_type = MSM_CAMERA_FLASH_LED,
791 .flash_src = &msm_flash_src
792};
793
794static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
795 .sensor_name = "imx072",
796 .sensor_reset_enable = 1,
797 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530798 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530799 .sensor_pwd = 85,
800 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
801 .vcm_enable = 1,
802 .pdata = &msm_camera_device_data_rear,
803 .flash_data = &flash_imx072,
804 .sensor_platform_info = &imx072_sensor_7627a_info,
805 .csi_if = 1
806};
807
808static struct platform_device msm_camera_sensor_imx072 = {
809 .name = "msm_camera_imx072",
810 .dev = {
811 .platform_data = &msm_camera_sensor_imx072_data,
812 },
813};
814#endif
815
Chintan Pandya40762702011-12-06 13:47:06 +0530816#ifdef CONFIG_WEBCAM_OV9726
Steve Mucklef132c6c2012-06-06 18:30:57 -0700817static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
Chintan Pandya40762702011-12-06 13:47:06 +0530818static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
819 .mount_angle = 90
820};
821
822static struct msm_camera_sensor_flash_data flash_ov9726 = {
823 .flash_type = MSM_CAMERA_FLASH_NONE,
824 .flash_src = &msm_flash_src
825};
826
827static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
828 .sensor_name = "ov9726",
829 .sensor_reset_enable = 0,
830 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530831 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530832 .sensor_pwd = 85,
833 .vcm_pwd = 1,
834 .vcm_enable = 0,
835 .pdata = &msm_camera_device_data_front,
836 .flash_data = &flash_ov9726,
837 .sensor_platform_info = &ov9726_sensor_7627a_info,
838 .csi_if = 1
839};
840
841static struct platform_device msm_camera_sensor_ov9726 = {
842 .name = "msm_camera_ov9726",
843 .dev = {
844 .platform_data = &msm_camera_sensor_ov9726_data,
845 },
846};
847#else
848static inline void msm_camera_vreg_init(void) { }
849#endif
850
851#ifdef CONFIG_MT9E013
852static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
853 .mount_angle = 90
854};
855
856static struct msm_camera_sensor_flash_data flash_mt9e013 = {
857 .flash_type = MSM_CAMERA_FLASH_LED,
858 .flash_src = &msm_flash_src
859};
860
861static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
862 .sensor_name = "mt9e013",
863 .sensor_reset = 0,
864 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530865 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530866 .sensor_pwd = 85,
867 .vcm_pwd = 1,
868 .vcm_enable = 0,
869 .pdata = &msm_camera_device_data_rear,
870 .flash_data = &flash_mt9e013,
871 .sensor_platform_info = &mt9e013_sensor_7627a_info,
872 .csi_if = 1
873};
874
875static struct platform_device msm_camera_sensor_mt9e013 = {
876 .name = "msm_camera_mt9e013",
877 .dev = {
878 .platform_data = &msm_camera_sensor_mt9e013_data,
879 },
880};
881#endif
882
883#ifdef CONFIG_OV5640
884static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
885 .mount_angle = 90
886};
887
888static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
889 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
890 ._fsrc.led_src.led_name = "flashlight",
891 ._fsrc.led_src.led_name_len = 10,
892};
893
894static struct msm_camera_sensor_flash_data flash_ov5640 = {
895 .flash_type = MSM_CAMERA_FLASH_LED,
896 .flash_src = &msm_flash_src_ov5640,
897};
898
899static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
900 .sensor_name = "ov5640",
901 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530902 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530903 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
904 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
905 .vcm_pwd = 0,
906 .vcm_enable = 0,
907 .pdata = &msm_camera_device_data_rear,
908 .flash_data = &flash_ov5640,
909 .sensor_platform_info = &ov5640_sensor_info,
910 .csi_if = 1,
911};
912
913static struct platform_device msm_camera_sensor_ov5640 = {
914 .name = "msm_camera_ov5640",
915 .dev = {
916 .platform_data = &msm_camera_sensor_ov5640_data,
917 },
918};
919#endif
920
921#ifdef CONFIG_WEBCAM_OV7692_QRD
922static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
923 .mount_angle = 90
924};
925
926static struct msm_camera_sensor_flash_data flash_ov7692 = {
927 .flash_type = MSM_CAMERA_FLASH_NONE,
928};
929
930static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
931 .sensor_name = "ov7692",
932 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530933 .pmic_gpio_enable = 1,
934 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
935 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530936 .vcm_pwd = 0,
937 .vcm_enable = 0,
938 .pdata = &msm_camera_device_data_front,
939 .flash_data = &flash_ov7692,
940 .sensor_platform_info = &ov7692_sensor_7627a_info,
941 .csi_if = 1,
942};
943
944static struct platform_device msm_camera_sensor_ov7692 = {
945 .name = "msm_camera_ov7692",
946 .dev = {
947 .platform_data = &msm_camera_sensor_ov7692_data,
948 },
949};
950#endif
951
Chintan Pandya40762702011-12-06 13:47:06 +0530952static struct i2c_board_info i2c_camera_devices[] = {
953 #ifdef CONFIG_S5K4E1
954 {
955 I2C_BOARD_INFO("s5k4e1", 0x36),
956 },
957 {
958 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
959 },
960 #endif
961 #ifdef CONFIG_WEBCAM_OV9726
962 {
963 I2C_BOARD_INFO("ov9726", 0x10),
964 },
965 #endif
966 #ifdef CONFIG_IMX072
967 {
968 I2C_BOARD_INFO("imx072", 0x34),
969 },
970 #endif
971 #ifdef CONFIG_MT9E013
972 {
973 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
974 },
975 #endif
976 {
977 I2C_BOARD_INFO("sc628a", 0x6E),
978 },
979};
980
981static struct i2c_board_info i2c_camera_devices_qrd[] = {
982 #ifdef CONFIG_OV5640
983 {
984 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
985 },
986 #endif
987 #ifdef CONFIG_WEBCAM_OV7692_QRD
988 {
989 I2C_BOARD_INFO("ov7692", 0x78),
990 },
991 #endif
992};
993
Su Liuaca04702012-02-14 02:27:32 +0530994static struct i2c_board_info i2c_camera_devices_evb[] = {
995 #ifdef CONFIG_OV5647
996 {
997 I2C_BOARD_INFO("ov5647", 0x36 << 1),
998 },
999 {
1000 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
1001 },
1002 #endif
1003 #ifdef CONFIG_WEBCAM_OV7692_QRD
1004 {
1005 I2C_BOARD_INFO("ov7692", 0x78),
1006 },
1007 #endif
1008};
1009
Chintan Pandya40762702011-12-06 13:47:06 +05301010static struct platform_device *camera_devices_msm[] __initdata = {
1011#ifdef CONFIG_S5K4E1
1012 &msm_camera_sensor_s5k4e1,
1013#endif
1014#ifdef CONFIG_IMX072
1015 &msm_camera_sensor_imx072,
1016#endif
1017#ifdef CONFIG_WEBCAM_OV9726
1018 &msm_camera_sensor_ov9726,
1019#endif
1020#ifdef CONFIG_MT9E013
1021 &msm_camera_sensor_mt9e013,
1022#endif
1023};
1024
1025static struct platform_device *camera_devices_qrd[] __initdata = {
1026#ifdef CONFIG_OV5640
1027 &msm_camera_sensor_ov5640,
1028#endif
1029#ifdef CONFIG_WEBCAM_OV7692_QRD
1030 &msm_camera_sensor_ov7692,
1031#endif
1032};
Su Liuaca04702012-02-14 02:27:32 +05301033
1034static struct platform_device *camera_devices_evb[] __initdata = {
1035#ifdef CONFIG_OV5647
1036 &msm_camera_sensor_ov5647,
1037#endif
1038#ifdef CONFIG_WEBCAM_OV7692_QRD
1039 &msm_camera_sensor_ov7692,
1040#endif
Katta Santhisindhu16746f62012-06-08 13:35:07 +05301041 &msm_camera_sensor_ov8825,
Su Liuaca04702012-02-14 02:27:32 +05301042};
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301043#endif
1044
1045enum {
1046 SX150X_CAM,
1047};
1048
1049static struct sx150x_platform_data sx150x_data[] __initdata = {
1050 [SX150X_CAM] = {
1051 .gpio_base = GPIO_CAM_EXPANDER_BASE,
1052 .oscio_is_gpo = false,
1053 .io_pullup_ena = 0,
1054 .io_pulldn_ena = 0,
1055 .io_open_drain_ena = 0x23,
1056 .irq_summary = -1,
1057 },
1058};
1059
1060static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
1061 {
1062 I2C_BOARD_INFO("sx1508q", 0x22),
1063 .platform_data = &sx150x_data[SX150X_CAM],
1064 },
1065};
Chintan Pandya40762702011-12-06 13:47:06 +05301066
1067static void __init register_i2c_devices(void)
1068{
1069 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1070 cam_exp_i2c_info,
1071 ARRAY_SIZE(cam_exp_i2c_info));
1072}
1073
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301074#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301075#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
1076#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301077#define SKU7_LCD_CAMERA_LDO_1V8 58 /* SKU7 1.8V LDO */
Su Liuaca04702012-02-14 02:27:32 +05301078
1079static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
1080
1081static void lcd_camera_power_init(void)
1082{
1083 int rc = 0;
1084
1085 pr_debug("lcd_camera_power_init\n");
1086
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301087 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
1088 lcd_camera_ldo_1v8 = SKU7_LCD_CAMERA_LDO_1V8;
1089 else
1090 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
Su Liuaca04702012-02-14 02:27:32 +05301091
1092 /* LDO_EXT2V8 */
1093 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
1094 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
1095 return;
1096 }
1097
1098 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
1099 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1100 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1101 if (rc < 0) {
1102 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1103 goto fail_gpio2;
1104 }
1105
1106 /* LDO_EVT1V8 */
1107 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1108 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1109 goto fail_gpio2;
1110 }
1111
1112 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1113 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1114 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1115 if (rc < 0) {
1116 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1117 goto fail_gpio1;
1118 }
1119
1120 return;
1121
1122fail_gpio1:
1123 gpio_free(lcd_camera_ldo_1v8);
1124fail_gpio2:
1125 gpio_free(LCD_CAMERA_LDO_2V8);
1126
1127 return;
1128}
1129
1130static int lcd_camera_power_on_sku3(void)
1131{
1132 int rc = 0;
1133
1134 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1135 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1136
1137 pr_debug("turn on sku3 lcd_camera_ldo\n");
1138 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1139
1140 return rc;
1141}
1142
1143static int lcd_camera_power_off_sku3(void)
1144{
1145 int rc = 0;
1146
1147 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1148 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1149
1150 pr_debug("turn off sku3 lcd_camera_ldo\n");
1151 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1152
1153 gpio_free(lcd_camera_ldo_1v8);
1154 gpio_free(LCD_CAMERA_LDO_2V8);
1155
1156 return rc;
1157}
1158
1159int lcd_camera_power_onoff(int on)
1160{
1161 int rc = 0;
1162
1163 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1164
1165 if (on)
1166 rc = lcd_camera_power_on_sku3();
1167 else
1168 rc = lcd_camera_power_off_sku3();
1169
1170 return rc;
1171}
1172EXPORT_SYMBOL(lcd_camera_power_onoff);
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301173#endif
Su Liuaca04702012-02-14 02:27:32 +05301174
Chintan Pandya40762702011-12-06 13:47:06 +05301175void __init msm7627a_camera_init(void)
1176{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301177
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301178#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301179 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301180#endif
Su Liuaca04702012-02-14 02:27:32 +05301181 pr_debug("msm7627a_camera_init Entered\n");
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301182
1183 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
1184 ov7692_cam_req_gpio[0].gpio =
1185 GPIO_SKU7_CAM_VGA_SHDN;
1186 ov7692_cam_gpio_set_tbl[0].gpio = GPIO_SKU7_CAM_VGA_SHDN;
1187 ov7692_cam_gpio_set_tbl[1].gpio = GPIO_SKU7_CAM_VGA_SHDN;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301188
1189 msm_camera_sensor_ov5647_data.sensor_pwd =
1190 GPIO_SKU7_CAM_5MP_SHDN_N;
1191 msm_camera_sensor_ov5647_data.sensor_reset =
1192 GPIO_SKU7_CAM_5MP_CAMIF_RESET;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301193 }
1194
Su Liuaca04702012-02-14 02:27:32 +05301195 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301196 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301197 || machine_is_msm8625_evt()
1198 || machine_is_msm7627a_qrd3()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +05301199 || machine_is_msm8625_qrd7()
1200 || machine_is_qrd_skud_prime()) {
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301201#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301202 lcd_camera_power_init();
Raju P.L.S.S.S.Naf7e5142012-06-17 20:30:16 +05301203#endif
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301204 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301205 }
1206
1207#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301208 if (machine_is_msm7627a_qrd1()) {
1209 qrd1_camera_gpio_cfg();
1210 platform_add_devices(camera_devices_qrd,
1211 ARRAY_SIZE(camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301212 } else if (machine_is_msm7627a_evb()
1213 || machine_is_msm8625_evb()
1214 || machine_is_msm8625_evt()
1215 || machine_is_msm7627a_qrd3()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +05301216 || machine_is_msm8625_qrd7()
1217 || machine_is_qrd_skud_prime()) {
Su Liuaca04702012-02-14 02:27:32 +05301218 platform_add_devices(camera_devices_evb,
1219 ARRAY_SIZE(camera_devices_evb));
1220 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301221 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301222 else
Chintan Pandya40762702011-12-06 13:47:06 +05301223 platform_add_devices(camera_devices_msm,
1224 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301225#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301226 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301227 || !machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301228 || !machine_is_msm8625_evt()
1229 || !machine_is_msm7627a_qrd3()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +05301230 || !machine_is_msm8625_qrd7()
1231 || !machine_is_qrd_skud_prime())
Chintan Pandya40762702011-12-06 13:47:06 +05301232 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301233#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301234 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1235
1236 if (rc) {
1237 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1238 return;
1239 }
1240
1241 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1242
1243 if (rc) {
1244 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1245 return;
1246 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301247#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301248
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301249#if defined(CONFIG_MSM_CAMERA_V4L2)
1250 msm7x27a_init_cam();
1251#endif
1252#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301253 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301254 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1255 i2c_camera_devices_qrd,
1256 ARRAY_SIZE(i2c_camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301257 } else if (machine_is_msm7627a_evb()
1258 || machine_is_msm8625_evb()
1259 || machine_is_msm8625_evt()
1260 || machine_is_msm7627a_qrd3()
Channagoud Kadabi2bd65c82012-10-12 15:14:23 +05301261 || machine_is_msm8625_qrd7()
1262 || machine_is_qrd_skud_prime()) {
Su Liuaca04702012-02-14 02:27:32 +05301263 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1264 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1265 i2c_camera_devices_evb,
1266 ARRAY_SIZE(i2c_camera_devices_evb));
1267 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301268#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301269 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301270 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1271 i2c_camera_devices,
1272 ARRAY_SIZE(i2c_camera_devices));
1273}