blob: 251c97a05a2cae14e5b9d95236fdeb12512bd193 [file] [log] [blame]
Chintan Pandya40762702011-12-06 13:47:06 +05301/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/i2c.h>
14#include <linux/i2c/sx150x.h>
15#include <linux/gpio.h>
16#include <linux/regulator/consumer.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <asm/mach-types.h>
20#include <mach/msm_iomap.h>
21#include <mach/board.h>
22#include <mach/irqs-7xxx.h>
23#include "devices-msm7x2xa.h"
24#include "board-msm7627a.h"
Su Liuaca04702012-02-14 02:27:32 +053025#include <mach/vreg.h>
Chintan Pandya40762702011-12-06 13:47:06 +053026
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053027#define GPIO_SKU1_CAM_VGA_SHDN 18
28#define GPIO_SKU1_CAM_VGA_RESET_N 29
29#define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */
30#define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */
31#define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +053032#define GPIO_SKU7_CAM_VGA_SHDN 91
33#define GPIO_SKU7_CAM_5MP_SHDN_N 93 /* PWDN */
34#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 +053035
Suresh Vankadara87e195b2012-01-18 00:42:58 +053036#ifdef CONFIG_MSM_CAMERA_V4L2
37static uint32_t camera_off_gpio_table[] = {
38 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
39};
40
41static uint32_t camera_on_gpio_table[] = {
42 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
43};
44
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053045static struct gpio s5k4e1_cam_req_gpio[] = {
46 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_DIR_OUT, "CAM_RESET"},
47};
48
49static struct msm_gpio_set_tbl s5k4e1_cam_gpio_set_tbl[] = {
50 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_LOW, 1000},
51 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_HIGH, 4000},
52};
53
54static struct msm_camera_gpio_conf gpio_conf_s5k4e1 = {
55 .camera_off_table = camera_off_gpio_table,
56 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
57 .camera_on_table = camera_on_gpio_table,
58 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
59 .cam_gpio_req_tbl = s5k4e1_cam_req_gpio,
60 .cam_gpio_req_tbl_size = ARRAY_SIZE(s5k4e1_cam_req_gpio),
61 .cam_gpio_set_tbl = s5k4e1_cam_gpio_set_tbl,
62 .cam_gpio_set_tbl_size = ARRAY_SIZE(s5k4e1_cam_gpio_set_tbl),
63 .gpio_no_mux = 1,
64};
65
66static struct msm_camera_gpio_conf gpio_conf_mt9e013 = {
67 .camera_off_table = camera_off_gpio_table,
68 .camera_on_table = camera_on_gpio_table,
69 .gpio_no_mux = 1,
70};
71
72static struct msm_camera_gpio_conf gpio_conf_ov9726 = {
73 .camera_off_table = camera_off_gpio_table,
74 .camera_on_table = camera_on_gpio_table,
75 .gpio_no_mux = 1,
76};
77
Sreesudhan Ramakrish Ramkumarcfdfa0e2012-05-15 15:56:05 -070078#ifdef CONFIG_OV7692
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070079static struct gpio ov7692_cam_req_gpio[] = {
80 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_DIR_OUT, "CAM_VGA_SHDN"},
81 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_DIR_OUT, "CAM_VGA_RESET"},
82};
83
84static struct msm_gpio_set_tbl ov7692_cam_gpio_set_tbl[] = {
85 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_HIGH, 5000},
86 {GPIO_SKU1_CAM_VGA_SHDN, GPIOF_OUT_INIT_LOW, 5000},
87 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_HIGH, 5000},
88 {GPIO_SKU1_CAM_VGA_RESET_N, GPIOF_OUT_INIT_LOW, 5000},
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070089};
90
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053091static struct msm_camera_gpio_conf gpio_conf_ov7692 = {
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070092 .cam_gpio_req_tbl = ov7692_cam_req_gpio,
93 .cam_gpio_req_tbl_size = ARRAY_SIZE(ov7692_cam_req_gpio),
94 .cam_gpio_set_tbl = ov7692_cam_gpio_set_tbl,
95 .cam_gpio_set_tbl_size = ARRAY_SIZE(ov7692_cam_gpio_set_tbl),
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +053096 .gpio_no_mux = 1,
97};
98#endif
99
100#ifdef CONFIG_OV5647
101static struct msm_camera_gpio_conf gpio_conf_ov5647 = {
102 .camera_off_table = camera_off_gpio_table,
103 .camera_on_table = camera_on_gpio_table,
104 .gpio_no_mux = 1,
105};
106#endif
107
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530108#ifdef CONFIG_MSM_CAMERA_FLASH
109static struct msm_camera_sensor_flash_src msm_flash_src = {
110 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
111 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
112 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
113};
114#endif
115
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530116static struct camera_vreg_t msm_cam_vreg[] = {
117 {"msme1", REG_LDO, 1800000, 1800000, 0},
118 {"gp2", REG_LDO, 2850000, 2850000, 0},
119 {"usb2", REG_LDO, 1800000, 1800000, 0},
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530120};
121
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530122static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530123
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530124struct msm_camera_device_platform_data msm_camera_device_data_csi1[] = {
125 {
126 .csid_core = 1,
127 .is_csic = 1,
128 .ioclk = {
129 .vfe_clk_rate = 192000000,
130 },
131 },
132 {
133 .csid_core = 1,
134 .is_csic = 1,
135 .ioclk = {
136 .vfe_clk_rate = 266667000,
137 },
138 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530139};
140
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530141struct msm_camera_device_platform_data msm_camera_device_data_csi0[] = {
142 {
143 .csid_core = 0,
144 .is_csic = 1,
145 .ioclk = {
146 .vfe_clk_rate = 192000000,
147 },
148 },
149 {
150 .csid_core = 0,
151 .is_csic = 1,
152 .ioclk = {
153 .vfe_clk_rate = 266667000,
154 },
155 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530156};
157
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800158static struct i2c_board_info msm_act_main_cam_i2c_info = {
159 I2C_BOARD_INFO("msm_actuator", 0x11),
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530160};
161
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800162static struct msm_actuator_info msm_act_main_cam_4_info = {
163 .board_info = &msm_act_main_cam_i2c_info,
164 .cam_name = MSM_ACTUATOR_MAIN_CAM_4,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530165 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
166 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
167 .vcm_enable = 1,
168};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530169
170#ifdef CONFIG_S5K4E1
171static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
172 .flash_type = MSM_CAMERA_FLASH_LED,
173 .flash_src = &msm_flash_src
174};
175
176static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
177 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530178 .cam_vreg = msm_cam_vreg,
179 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
180 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530181};
182
183static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
184 .sensor_name = "s5k4e1",
185 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530186 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530187 .pdata = &msm_camera_device_data_csi1[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530188 .flash_data = &flash_s5k4e1,
189 .sensor_platform_info = &sensor_board_info_s5k4e1,
190 .csi_if = 1,
191 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530192 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800193 .actuator_info = &msm_act_main_cam_4_info,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530194};
195#endif
196
Sreesudhan Ramakrish Ramkumarcfdfa0e2012-05-15 15:56:05 -0700197#ifdef CONFIG_OV7692
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530198static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
199 .mount_angle = 90,
200 .cam_vreg = msm_cam_vreg,
201 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
202 .gpio_conf = &gpio_conf_ov7692,
203};
204
205static struct msm_camera_sensor_flash_data flash_ov7692 = {
206 .flash_type = MSM_CAMERA_FLASH_NONE,
207};
208
209static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
210 .sensor_name = "ov7692",
211 .sensor_reset_enable = 0,
212 .pmic_gpio_enable = 1,
Raju P.L.S.S.S.Nce5c5c22012-05-17 23:10:08 +0530213 .sensor_lcd_gpio_onoff = lcd_camera_power_onoff,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530214 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
215 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530216 .pdata = &msm_camera_device_data_csi0[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530217 .flash_data = &flash_ov7692,
218 .sensor_platform_info = &sensor_board_info_ov7692,
219 .csi_if = 1,
220 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530221 .sensor_type = YUV_SENSOR,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530222};
223#endif
224
225#ifdef CONFIG_OV5647
226
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800227static struct msm_actuator_info msm_act_main_cam_5_info = {
228 .board_info = &msm_act_main_cam_i2c_info,
229 .cam_name = MSM_ACTUATOR_MAIN_CAM_5,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530230 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
231 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
232 .vcm_enable = 1,
233};
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530234
235static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = {
236 .mount_angle = 90,
237 .cam_vreg = msm_cam_vreg,
238 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
239 .gpio_conf = &gpio_conf_ov5647,
240};
241
242static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
Raju P.L.S.S.S.Nbf3faff2012-04-05 14:33:36 +0530243 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED1,
244 ._fsrc.ext_driver_src.led_en = 13,
245 ._fsrc.ext_driver_src.led_flash_en = 32,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530246};
247
248static struct msm_camera_sensor_flash_data flash_ov5647 = {
249 .flash_type = MSM_CAMERA_FLASH_LED,
250 .flash_src = &msm_flash_src_ov5647,
251};
252
253static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
254 .sensor_name = "ov5647",
255 .sensor_reset_enable = 1,
256 .pmic_gpio_enable = 1,
Raju P.L.S.S.S.Nce5c5c22012-05-17 23:10:08 +0530257 .sensor_lcd_gpio_onoff = lcd_camera_power_onoff,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530258 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
259 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530260 .pdata = &msm_camera_device_data_csi1[0],
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530261 .flash_data = &flash_ov5647,
262 .sensor_platform_info = &sensor_board_info_ov5647,
263 .csi_if = 1,
264 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530265 .sensor_type = BAYER_SENSOR,
Rajakumar Govindaram6627b362012-01-29 19:00:30 -0800266 .actuator_info = &msm_act_main_cam_5_info,
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530267};
268
269#endif
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530270#ifdef CONFIG_MT9E013
271static struct msm_camera_sensor_flash_data flash_mt9e013 = {
272 .flash_type = MSM_CAMERA_FLASH_LED,
273 .flash_src = &msm_flash_src
274};
275
276static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
277 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530278 .cam_vreg = msm_cam_vreg,
279 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
280 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530281};
282
283static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
284 .sensor_name = "mt9e013",
285 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530286 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530287 .pdata = &msm_camera_device_data_csi1[1],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530288 .flash_data = &flash_mt9e013,
289 .sensor_platform_info = &sensor_board_info_mt9e013,
290 .csi_if = 1,
291 .camera_type = BACK_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530292 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530293};
294#endif
295
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530296#ifdef CONFIG_WEBCAM_OV9726
297static struct msm_camera_sensor_flash_data flash_ov9726 = {
298 .flash_type = MSM_CAMERA_FLASH_LED,
299 .flash_src = &msm_flash_src
300};
301
302static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
303 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530304 .cam_vreg = msm_cam_vreg,
305 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
306 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530307};
308
309static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
310 .sensor_name = "ov9726",
311 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530312 .pmic_gpio_enable = 0,
Raju P.L.S.S.S.Nabd2dc42012-05-07 21:28:45 +0530313 .pdata = &msm_camera_device_data_csi0[0],
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530314 .flash_data = &flash_ov9726,
315 .sensor_platform_info = &sensor_board_info_ov9726,
316 .csi_if = 1,
317 .camera_type = FRONT_CAMERA_2D,
Raju P.L.S.S.S.N3f4b3022012-03-29 10:09:01 +0530318 .sensor_type = BAYER_SENSOR,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530319};
320#endif
321
Kevin Chan94b4c832012-03-02 21:27:16 -0800322static struct platform_device msm_camera_server = {
323 .name = "msm_cam_server",
324 .id = 0,
325};
326
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530327static void __init msm7x27a_init_cam(void)
328{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530329 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530330 || machine_is_msm7627a_qrd1()
331 || machine_is_msm8625_ffa())) {
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530332 sensor_board_info_s5k4e1.cam_vreg = NULL;
333 sensor_board_info_s5k4e1.num_vreg = 0;
334 sensor_board_info_mt9e013.cam_vreg = NULL;
335 sensor_board_info_mt9e013.num_vreg = 0;
336 sensor_board_info_ov9726.cam_vreg = NULL;
337 sensor_board_info_ov9726.num_vreg = 0;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530338 sensor_board_info_ov7692.cam_vreg = NULL;
339 sensor_board_info_ov7692.num_vreg = 0;
340 sensor_board_info_ov5647.cam_vreg = NULL;
341 sensor_board_info_ov5647.num_vreg = 0;
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530342 }
Kevin Chan94b4c832012-03-02 21:27:16 -0800343 platform_device_register(&msm_camera_server);
Aparna Mallavarapu5a326242012-05-09 19:49:02 +0530344 if (machine_is_msm8625_surf() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530345 || machine_is_msm8625_evt()
346 || machine_is_msm8625_qrd7()) {
Raju P.L.S.S.S.N2b345012012-03-15 10:18:30 +0530347 platform_device_register(&msm8625_device_csic0);
348 platform_device_register(&msm8625_device_csic1);
349 } else {
350 platform_device_register(&msm7x27a_device_csic0);
351 platform_device_register(&msm7x27a_device_csic1);
352 }
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530353 if (machine_is_msm8625_evb()
354 || machine_is_msm8625_evt()
355 || machine_is_msm8625_qrd7())
Suresh Vankadara6050cef52012-04-16 21:44:59 +0530356 *(int *) msm7x27a_device_clkctl.dev.platform_data = 1;
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530357 platform_device_register(&msm7x27a_device_clkctl);
358 platform_device_register(&msm7x27a_device_vfe);
359}
360
361static struct i2c_board_info i2c_camera_devices[] = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530362 {
363 I2C_BOARD_INFO("s5k4e1", 0x36),
364 .platform_data = &msm_camera_sensor_s5k4e1_data,
365 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530366 {
367 I2C_BOARD_INFO("ov9726", 0x10),
368 .platform_data = &msm_camera_sensor_ov9726_data,
369 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530370 {
371 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
372 .platform_data = &msm_camera_sensor_mt9e013_data,
373 },
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530374 {
375 I2C_BOARD_INFO("ov7692", 0x78),
376 .platform_data = &msm_camera_sensor_ov7692_data,
377 },
378 {
379 I2C_BOARD_INFO("ov5647", 0x36 << 1),
380 .platform_data = &msm_camera_sensor_ov5647_data,
381 },
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530382 {
383 I2C_BOARD_INFO("sc628a", 0x6E),
384 },
385};
386#else
Chintan Pandya40762702011-12-06 13:47:06 +0530387static uint32_t camera_off_gpio_table[] = {
388 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
389};
390
391static uint32_t camera_on_gpio_table[] = {
392 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
393};
394
395#ifdef CONFIG_MSM_CAMERA_FLASH
396static struct msm_camera_sensor_flash_src msm_flash_src = {
397 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
398 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
399 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
400};
401#endif
402
403static struct regulator_bulk_data regs_camera[] = {
404 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
405 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
406 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
407};
408
409static void qrd1_camera_gpio_cfg(void)
410{
411
412 int rc = 0;
413
414 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
415 if (rc < 0)
416 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
417 __func__);
418
419
420 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
421 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
422 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
423 if (rc < 0) {
424 pr_err("%s: unable to enable Power Down gpio for main"
425 "camera!\n", __func__);
426 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
427 }
428
429
430 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
431 if (rc < 0) {
432 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
433 __func__);
434 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
435 }
436
437
438 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
439 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
440 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
441 if (rc < 0) {
442 pr_err("%s: unable to enable reset gpio for main camera!\n",
443 __func__);
444 gpio_free(QRD_GPIO_CAM_5MP_RESET);
445 }
446
447 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
448 if (rc < 0)
449 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
450 __func__);
451
452 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
453 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
454 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
455 if (rc < 0) {
456 pr_err("%s: unable to enable Power Down gpio for front"
457 "camera!\n", __func__);
458 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
459 }
460
461 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
462 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
463 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
464}
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530465#endif
Su Liuaca04702012-02-14 02:27:32 +0530466
467static void evb_camera_gpio_cfg(void)
468{
469 int rc = 0;
470
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530471 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_pwd, "ov5647");
Su Liuaca04702012-02-14 02:27:32 +0530472 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530473 pr_err("%s: gpio_request OV5647 sensor_pwd: %d failed!",
474 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530475
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530476 rc = gpio_tlmm_config(GPIO_CFG(msm_camera_sensor_ov5647_data.sensor_pwd,
477 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
478 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530479 if (rc < 0) {
480 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
481 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530482 gpio_free(msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530483 }
484
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530485 rc = gpio_direction_output(msm_camera_sensor_ov5647_data.sensor_pwd, 1);
Su Liuaca04702012-02-14 02:27:32 +0530486 if (rc < 0)
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530487 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
488 __func__, msm_camera_sensor_ov5647_data.sensor_pwd);
Su Liuaca04702012-02-14 02:27:32 +0530489
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530490 rc = gpio_request(msm_camera_sensor_ov5647_data.sensor_reset, "ov5647");
491 if (rc < 0)
492 pr_err("%s: gpio_request OV5647 sensor_reset: %d failed!",
493 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
494
495 rc = gpio_tlmm_config(GPIO_CFG(
496 msm_camera_sensor_ov5647_data.sensor_reset,
497 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
498 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
Su Liuaca04702012-02-14 02:27:32 +0530499 if (rc < 0) {
500 pr_err("%s: unable to enable reset gpio for main camera!\n",
501 __func__);
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530502 gpio_free(msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530503 }
504
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530505 rc = gpio_direction_output(
506 msm_camera_sensor_ov5647_data.sensor_reset, 1);
507 if (rc < 0)
508 pr_err("%s: unable to set gpio: %d direction for ov5647 camera\n",
509 __func__, msm_camera_sensor_ov5647_data.sensor_reset);
Su Liuaca04702012-02-14 02:27:32 +0530510
Su Liuaca04702012-02-14 02:27:32 +0530511}
512
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +0530513#ifndef CONFIG_MSM_CAMERA_V4L2
514
Chintan Pandya40762702011-12-06 13:47:06 +0530515static void msm_camera_vreg_config(int vreg_en)
516{
517 int rc = vreg_en ?
518 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
519 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
520
521 if (rc)
522 pr_err("%s: could not %sable regulators: %d\n",
523 __func__, vreg_en ? "en" : "dis", rc);
524}
525
526static int config_gpio_table(uint32_t *table, int len)
527{
528 int rc = 0, i = 0;
529
530 for (i = 0; i < len; i++) {
531 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
532 if (rc) {
533 pr_err("%s not able to get gpio\n", __func__);
534 for (i--; i >= 0; i--)
535 gpio_tlmm_config(camera_off_gpio_table[i],
536 GPIO_CFG_ENABLE);
537 break;
538 }
539 }
540 return rc;
541}
542
543static int config_camera_on_gpios_rear(void)
544{
545 int rc = 0;
546
547 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530548 || machine_is_msm7627a_qrd1()
549 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530550 msm_camera_vreg_config(1);
551
552 rc = config_gpio_table(camera_on_gpio_table,
553 ARRAY_SIZE(camera_on_gpio_table));
554 if (rc < 0) {
555 pr_err("%s: CAMSENSOR gpio table request"
556 "failed\n", __func__);
557 return rc;
558 }
559
560 return rc;
561}
562
563static void config_camera_off_gpios_rear(void)
564{
565 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530566 || machine_is_msm7627a_qrd1()
567 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530568 msm_camera_vreg_config(0);
569
570 config_gpio_table(camera_off_gpio_table,
571 ARRAY_SIZE(camera_off_gpio_table));
572}
573
574static int config_camera_on_gpios_front(void)
575{
576 int rc = 0;
577
578 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530579 || machine_is_msm7627a_qrd1()
580 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530581 msm_camera_vreg_config(1);
582
583 rc = config_gpio_table(camera_on_gpio_table,
584 ARRAY_SIZE(camera_on_gpio_table));
585 if (rc < 0) {
586 pr_err("%s: CAMSENSOR gpio table request"
587 "failed\n", __func__);
588 return rc;
589 }
590
591 return rc;
592}
593
594static void config_camera_off_gpios_front(void)
595{
596 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +0530597 || machine_is_msm7627a_qrd1()
598 || machine_is_msm8625_ffa())
Chintan Pandya40762702011-12-06 13:47:06 +0530599 msm_camera_vreg_config(0);
600
601 config_gpio_table(camera_off_gpio_table,
602 ARRAY_SIZE(camera_off_gpio_table));
603}
604
605struct msm_camera_device_platform_data msm_camera_device_data_rear = {
606 .camera_gpio_on = config_camera_on_gpios_rear,
607 .camera_gpio_off = config_camera_off_gpios_rear,
608 .ioext.csiphy = 0xA1000000,
609 .ioext.csisz = 0x00100000,
610 .ioext.csiirq = INT_CSI_IRQ_1,
611 .ioclk.mclk_clk_rate = 24000000,
612 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530613 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
614 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530615};
616
617struct msm_camera_device_platform_data msm_camera_device_data_front = {
618 .camera_gpio_on = config_camera_on_gpios_front,
619 .camera_gpio_off = config_camera_off_gpios_front,
620 .ioext.csiphy = 0xA0F00000,
621 .ioext.csisz = 0x00100000,
622 .ioext.csiirq = INT_CSI_IRQ_0,
623 .ioclk.mclk_clk_rate = 24000000,
624 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530625 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
626 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530627};
628
Su Liuaca04702012-02-14 02:27:32 +0530629#ifdef CONFIG_OV5647
630
631static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
632 .mount_angle = 90
633};
634
635static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
636 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
637 ._fsrc.led_src.led_name = "flashlight",
638 ._fsrc.led_src.led_name_len = 10,
639};
640
641static struct msm_camera_sensor_flash_data flash_ov5647 = {
642 .flash_type = MSM_CAMERA_FLASH_LED,
643 .flash_src = &msm_flash_src_ov5647,
644};
645
646static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
647 .sensor_name = "ov5647",
648 .sensor_reset_enable = 1,
649 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
650 .pmic_gpio_enable = 1,
651 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
652 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530653 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530654 .pdata = &msm_camera_device_data_rear,
655 .flash_data = &flash_ov5647,
656 .sensor_platform_info = &ov5647_sensor_7627a_info,
657 .csi_if = 1
658};
659
660static struct platform_device msm_camera_sensor_ov5647 = {
661 .name = "msm_camera_ov5647",
662 .dev = {
663 .platform_data = &msm_camera_sensor_ov5647_data,
664 },
665};
666#endif
667
Chintan Pandya40762702011-12-06 13:47:06 +0530668#ifdef CONFIG_S5K4E1
669static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
670 .mount_angle = 90
671};
672
673static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
674 .flash_type = MSM_CAMERA_FLASH_LED,
675 .flash_src = &msm_flash_src
676};
677
678static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
679 .sensor_name = "s5k4e1",
680 .sensor_reset_enable = 1,
681 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530682 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530683 .sensor_pwd = 85,
684 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
685 .vcm_enable = 1,
686 .pdata = &msm_camera_device_data_rear,
687 .flash_data = &flash_s5k4e1,
688 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
689 .csi_if = 1
690};
691
692static struct platform_device msm_camera_sensor_s5k4e1 = {
693 .name = "msm_camera_s5k4e1",
694 .dev = {
695 .platform_data = &msm_camera_sensor_s5k4e1_data,
696 },
697};
698#endif
699
700#ifdef CONFIG_IMX072
701static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
702 .mount_angle = 90
703};
704
705static struct msm_camera_sensor_flash_data flash_imx072 = {
706 .flash_type = MSM_CAMERA_FLASH_LED,
707 .flash_src = &msm_flash_src
708};
709
710static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
711 .sensor_name = "imx072",
712 .sensor_reset_enable = 1,
713 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530714 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530715 .sensor_pwd = 85,
716 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
717 .vcm_enable = 1,
718 .pdata = &msm_camera_device_data_rear,
719 .flash_data = &flash_imx072,
720 .sensor_platform_info = &imx072_sensor_7627a_info,
721 .csi_if = 1
722};
723
724static struct platform_device msm_camera_sensor_imx072 = {
725 .name = "msm_camera_imx072",
726 .dev = {
727 .platform_data = &msm_camera_sensor_imx072_data,
728 },
729};
730#endif
731
732static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
733#ifdef CONFIG_WEBCAM_OV9726
734static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
735 .mount_angle = 90
736};
737
738static struct msm_camera_sensor_flash_data flash_ov9726 = {
739 .flash_type = MSM_CAMERA_FLASH_NONE,
740 .flash_src = &msm_flash_src
741};
742
743static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
744 .sensor_name = "ov9726",
745 .sensor_reset_enable = 0,
746 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530747 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530748 .sensor_pwd = 85,
749 .vcm_pwd = 1,
750 .vcm_enable = 0,
751 .pdata = &msm_camera_device_data_front,
752 .flash_data = &flash_ov9726,
753 .sensor_platform_info = &ov9726_sensor_7627a_info,
754 .csi_if = 1
755};
756
757static struct platform_device msm_camera_sensor_ov9726 = {
758 .name = "msm_camera_ov9726",
759 .dev = {
760 .platform_data = &msm_camera_sensor_ov9726_data,
761 },
762};
763#else
764static inline void msm_camera_vreg_init(void) { }
765#endif
766
767#ifdef CONFIG_MT9E013
768static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
769 .mount_angle = 90
770};
771
772static struct msm_camera_sensor_flash_data flash_mt9e013 = {
773 .flash_type = MSM_CAMERA_FLASH_LED,
774 .flash_src = &msm_flash_src
775};
776
777static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
778 .sensor_name = "mt9e013",
779 .sensor_reset = 0,
780 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530781 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530782 .sensor_pwd = 85,
783 .vcm_pwd = 1,
784 .vcm_enable = 0,
785 .pdata = &msm_camera_device_data_rear,
786 .flash_data = &flash_mt9e013,
787 .sensor_platform_info = &mt9e013_sensor_7627a_info,
788 .csi_if = 1
789};
790
791static struct platform_device msm_camera_sensor_mt9e013 = {
792 .name = "msm_camera_mt9e013",
793 .dev = {
794 .platform_data = &msm_camera_sensor_mt9e013_data,
795 },
796};
797#endif
798
799#ifdef CONFIG_OV5640
800static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
801 .mount_angle = 90
802};
803
804static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
805 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
806 ._fsrc.led_src.led_name = "flashlight",
807 ._fsrc.led_src.led_name_len = 10,
808};
809
810static struct msm_camera_sensor_flash_data flash_ov5640 = {
811 .flash_type = MSM_CAMERA_FLASH_LED,
812 .flash_src = &msm_flash_src_ov5640,
813};
814
815static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
816 .sensor_name = "ov5640",
817 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530818 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530819 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
820 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
821 .vcm_pwd = 0,
822 .vcm_enable = 0,
823 .pdata = &msm_camera_device_data_rear,
824 .flash_data = &flash_ov5640,
825 .sensor_platform_info = &ov5640_sensor_info,
826 .csi_if = 1,
827};
828
829static struct platform_device msm_camera_sensor_ov5640 = {
830 .name = "msm_camera_ov5640",
831 .dev = {
832 .platform_data = &msm_camera_sensor_ov5640_data,
833 },
834};
835#endif
836
837#ifdef CONFIG_WEBCAM_OV7692_QRD
838static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
839 .mount_angle = 90
840};
841
842static struct msm_camera_sensor_flash_data flash_ov7692 = {
843 .flash_type = MSM_CAMERA_FLASH_NONE,
844};
845
846static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
847 .sensor_name = "ov7692",
848 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530849 .pmic_gpio_enable = 1,
850 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
851 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530852 .vcm_pwd = 0,
853 .vcm_enable = 0,
854 .pdata = &msm_camera_device_data_front,
855 .flash_data = &flash_ov7692,
856 .sensor_platform_info = &ov7692_sensor_7627a_info,
857 .csi_if = 1,
858};
859
860static struct platform_device msm_camera_sensor_ov7692 = {
861 .name = "msm_camera_ov7692",
862 .dev = {
863 .platform_data = &msm_camera_sensor_ov7692_data,
864 },
865};
866#endif
867
Chintan Pandya40762702011-12-06 13:47:06 +0530868static struct i2c_board_info i2c_camera_devices[] = {
869 #ifdef CONFIG_S5K4E1
870 {
871 I2C_BOARD_INFO("s5k4e1", 0x36),
872 },
873 {
874 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
875 },
876 #endif
877 #ifdef CONFIG_WEBCAM_OV9726
878 {
879 I2C_BOARD_INFO("ov9726", 0x10),
880 },
881 #endif
882 #ifdef CONFIG_IMX072
883 {
884 I2C_BOARD_INFO("imx072", 0x34),
885 },
886 #endif
887 #ifdef CONFIG_MT9E013
888 {
889 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
890 },
891 #endif
892 {
893 I2C_BOARD_INFO("sc628a", 0x6E),
894 },
895};
896
897static struct i2c_board_info i2c_camera_devices_qrd[] = {
898 #ifdef CONFIG_OV5640
899 {
900 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
901 },
902 #endif
903 #ifdef CONFIG_WEBCAM_OV7692_QRD
904 {
905 I2C_BOARD_INFO("ov7692", 0x78),
906 },
907 #endif
908};
909
Su Liuaca04702012-02-14 02:27:32 +0530910static struct i2c_board_info i2c_camera_devices_evb[] = {
911 #ifdef CONFIG_OV5647
912 {
913 I2C_BOARD_INFO("ov5647", 0x36 << 1),
914 },
915 {
916 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
917 },
918 #endif
919 #ifdef CONFIG_WEBCAM_OV7692_QRD
920 {
921 I2C_BOARD_INFO("ov7692", 0x78),
922 },
923 #endif
924};
925
Chintan Pandya40762702011-12-06 13:47:06 +0530926static struct platform_device *camera_devices_msm[] __initdata = {
927#ifdef CONFIG_S5K4E1
928 &msm_camera_sensor_s5k4e1,
929#endif
930#ifdef CONFIG_IMX072
931 &msm_camera_sensor_imx072,
932#endif
933#ifdef CONFIG_WEBCAM_OV9726
934 &msm_camera_sensor_ov9726,
935#endif
936#ifdef CONFIG_MT9E013
937 &msm_camera_sensor_mt9e013,
938#endif
939};
940
941static struct platform_device *camera_devices_qrd[] __initdata = {
942#ifdef CONFIG_OV5640
943 &msm_camera_sensor_ov5640,
944#endif
945#ifdef CONFIG_WEBCAM_OV7692_QRD
946 &msm_camera_sensor_ov7692,
947#endif
948};
Su Liuaca04702012-02-14 02:27:32 +0530949
950static struct platform_device *camera_devices_evb[] __initdata = {
951#ifdef CONFIG_OV5647
952 &msm_camera_sensor_ov5647,
953#endif
954#ifdef CONFIG_WEBCAM_OV7692_QRD
955 &msm_camera_sensor_ov7692,
956#endif
957};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530958#endif
959
960enum {
961 SX150X_CAM,
962};
963
964static struct sx150x_platform_data sx150x_data[] __initdata = {
965 [SX150X_CAM] = {
966 .gpio_base = GPIO_CAM_EXPANDER_BASE,
967 .oscio_is_gpo = false,
968 .io_pullup_ena = 0,
969 .io_pulldn_ena = 0,
970 .io_open_drain_ena = 0x23,
971 .irq_summary = -1,
972 },
973};
974
975static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
976 {
977 I2C_BOARD_INFO("sx1508q", 0x22),
978 .platform_data = &sx150x_data[SX150X_CAM],
979 },
980};
Chintan Pandya40762702011-12-06 13:47:06 +0530981
982static void __init register_i2c_devices(void)
983{
984 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
985 cam_exp_i2c_info,
986 ARRAY_SIZE(cam_exp_i2c_info));
987}
988
Su Liuaca04702012-02-14 02:27:32 +0530989#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
990#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +0530991#define SKU7_LCD_CAMERA_LDO_1V8 58 /* SKU7 1.8V LDO */
Su Liuaca04702012-02-14 02:27:32 +0530992
993static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
994
995static void lcd_camera_power_init(void)
996{
997 int rc = 0;
998
999 pr_debug("lcd_camera_power_init\n");
1000
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301001 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
1002 lcd_camera_ldo_1v8 = SKU7_LCD_CAMERA_LDO_1V8;
1003 else
1004 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
Su Liuaca04702012-02-14 02:27:32 +05301005
1006 /* LDO_EXT2V8 */
1007 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
1008 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
1009 return;
1010 }
1011
1012 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
1013 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1014 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1015 if (rc < 0) {
1016 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
1017 goto fail_gpio2;
1018 }
1019
1020 /* LDO_EVT1V8 */
1021 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
1022 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
1023 goto fail_gpio2;
1024 }
1025
1026 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
1027 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1028 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1029 if (rc < 0) {
1030 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
1031 goto fail_gpio1;
1032 }
1033
1034 return;
1035
1036fail_gpio1:
1037 gpio_free(lcd_camera_ldo_1v8);
1038fail_gpio2:
1039 gpio_free(LCD_CAMERA_LDO_2V8);
1040
1041 return;
1042}
1043
1044static int lcd_camera_power_on_sku3(void)
1045{
1046 int rc = 0;
1047
1048 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
1049 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
1050
1051 pr_debug("turn on sku3 lcd_camera_ldo\n");
1052 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1053
1054 return rc;
1055}
1056
1057static int lcd_camera_power_off_sku3(void)
1058{
1059 int rc = 0;
1060
1061 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1062 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1063
1064 pr_debug("turn off sku3 lcd_camera_ldo\n");
1065 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1066
1067 gpio_free(lcd_camera_ldo_1v8);
1068 gpio_free(LCD_CAMERA_LDO_2V8);
1069
1070 return rc;
1071}
1072
1073int lcd_camera_power_onoff(int on)
1074{
1075 int rc = 0;
1076
1077 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1078
1079 if (on)
1080 rc = lcd_camera_power_on_sku3();
1081 else
1082 rc = lcd_camera_power_off_sku3();
1083
1084 return rc;
1085}
1086EXPORT_SYMBOL(lcd_camera_power_onoff);
Su Liuaca04702012-02-14 02:27:32 +05301087
Chintan Pandya40762702011-12-06 13:47:06 +05301088void __init msm7627a_camera_init(void)
1089{
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301090
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301091#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301092 int rc;
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301093#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301094
Su Liuaca04702012-02-14 02:27:32 +05301095 pr_debug("msm7627a_camera_init Entered\n");
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301096
1097 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
1098 ov7692_cam_req_gpio[0].gpio =
1099 GPIO_SKU7_CAM_VGA_SHDN;
1100 ov7692_cam_gpio_set_tbl[0].gpio = GPIO_SKU7_CAM_VGA_SHDN;
1101 ov7692_cam_gpio_set_tbl[1].gpio = GPIO_SKU7_CAM_VGA_SHDN;
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301102
1103 msm_camera_sensor_ov5647_data.sensor_pwd =
1104 GPIO_SKU7_CAM_5MP_SHDN_N;
1105 msm_camera_sensor_ov5647_data.sensor_reset =
1106 GPIO_SKU7_CAM_5MP_CAMIF_RESET;
1107
1108 }
1109
Su Liuaca04702012-02-14 02:27:32 +05301110 /* LCD and camera power (VREG & LDO) init */
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301111 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301112 || machine_is_msm8625_evt()
1113 || machine_is_msm7627a_qrd3()
1114 || machine_is_msm8625_qrd7()) {
1115
Su Liuaca04702012-02-14 02:27:32 +05301116 lcd_camera_power_init();
Raju P.L.S.S.S.Ncea31512012-03-20 11:57:50 +05301117 evb_camera_gpio_cfg();
Raju P.L.S.S.S.Ncc400972012-03-13 10:09:59 +05301118 }
1119
1120#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301121 if (machine_is_msm7627a_qrd1()) {
1122 qrd1_camera_gpio_cfg();
1123 platform_add_devices(camera_devices_qrd,
1124 ARRAY_SIZE(camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301125 } else if (machine_is_msm7627a_evb()
1126 || machine_is_msm8625_evb()
1127 || machine_is_msm8625_evt()
1128 || machine_is_msm7627a_qrd3()
1129 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301130 platform_add_devices(camera_devices_evb,
1131 ARRAY_SIZE(camera_devices_evb));
1132 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301133 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301134 else
Chintan Pandya40762702011-12-06 13:47:06 +05301135 platform_add_devices(camera_devices_msm,
1136 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301137#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301138 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301139 || !machine_is_msm8625_evb()
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301140 || !machine_is_msm8625_evt()
1141 || !machine_is_msm7627a_qrd3()
1142 || !machine_is_msm8625_qrd7())
Chintan Pandya40762702011-12-06 13:47:06 +05301143 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301144#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301145 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1146
1147 if (rc) {
1148 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1149 return;
1150 }
1151
1152 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1153
1154 if (rc) {
1155 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1156 return;
1157 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301158#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301159
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301160#if defined(CONFIG_MSM_CAMERA_V4L2)
1161 msm7x27a_init_cam();
1162#endif
1163#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301164 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301165 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1166 i2c_camera_devices_qrd,
1167 ARRAY_SIZE(i2c_camera_devices_qrd));
Raju P.L.S.S.S.Nc71e1a82012-05-15 13:42:50 +05301168 } else if (machine_is_msm7627a_evb()
1169 || machine_is_msm8625_evb()
1170 || machine_is_msm8625_evt()
1171 || machine_is_msm7627a_qrd3()
1172 || machine_is_msm8625_qrd7()) {
Su Liuaca04702012-02-14 02:27:32 +05301173 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1174 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1175 i2c_camera_devices_evb,
1176 ARRAY_SIZE(i2c_camera_devices_evb));
1177 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301178#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301179 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301180 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1181 i2c_camera_devices,
1182 ARRAY_SIZE(i2c_camera_devices));
1183}