blob: ea3a36d097fa09ad582b6ee9085e8b9b05a3e1a6 [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
Suresh Vankadara87e195b2012-01-18 00:42:58 +053027#ifdef CONFIG_MSM_CAMERA_V4L2
28static uint32_t camera_off_gpio_table[] = {
29 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
30};
31
32static uint32_t camera_on_gpio_table[] = {
33 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
34};
35
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053036static struct gpio s5k4e1_cam_req_gpio[] = {
37 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_DIR_OUT, "CAM_RESET"},
38};
39
40static struct msm_gpio_set_tbl s5k4e1_cam_gpio_set_tbl[] = {
41 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_LOW, 1000},
42 {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_HIGH, 4000},
43};
44
45static struct msm_camera_gpio_conf gpio_conf_s5k4e1 = {
46 .camera_off_table = camera_off_gpio_table,
47 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
48 .camera_on_table = camera_on_gpio_table,
49 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
50 .cam_gpio_req_tbl = s5k4e1_cam_req_gpio,
51 .cam_gpio_req_tbl_size = ARRAY_SIZE(s5k4e1_cam_req_gpio),
52 .cam_gpio_set_tbl = s5k4e1_cam_gpio_set_tbl,
53 .cam_gpio_set_tbl_size = ARRAY_SIZE(s5k4e1_cam_gpio_set_tbl),
54 .gpio_no_mux = 1,
55};
56
57static struct msm_camera_gpio_conf gpio_conf_mt9e013 = {
58 .camera_off_table = camera_off_gpio_table,
59 .camera_on_table = camera_on_gpio_table,
60 .gpio_no_mux = 1,
61};
62
63static struct msm_camera_gpio_conf gpio_conf_ov9726 = {
64 .camera_off_table = camera_off_gpio_table,
65 .camera_on_table = camera_on_gpio_table,
66 .gpio_no_mux = 1,
67};
68
Suresh Vankadara87e195b2012-01-18 00:42:58 +053069#ifdef CONFIG_MSM_CAMERA_FLASH
70static struct msm_camera_sensor_flash_src msm_flash_src = {
71 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
72 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
73 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
74};
75#endif
76
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053077static struct camera_vreg_t msm_cam_vreg[] = {
78 {"msme1", REG_LDO, 1800000, 1800000, 0},
79 {"gp2", REG_LDO, 2850000, 2850000, 0},
80 {"usb2", REG_LDO, 1800000, 1800000, 0},
Suresh Vankadara87e195b2012-01-18 00:42:58 +053081};
82
Suresh Vankadara87e195b2012-01-18 00:42:58 +053083static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
Suresh Vankadara87e195b2012-01-18 00:42:58 +053084
85struct msm_camera_device_platform_data msm_camera_device_data_csi1 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +053086 .csid_core = 1,
87 .is_csic = 1,
88};
89
90struct msm_camera_device_platform_data msm_camera_device_data_csi0 = {
Suresh Vankadara87e195b2012-01-18 00:42:58 +053091 .csid_core = 0,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +053092 .is_csic = 1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +053093};
94
95#ifdef CONFIG_DW9712_ACT
96static struct i2c_board_info s5k4e1_actuator_i2c_info = {
97 I2C_BOARD_INFO("dw9712_act", 0x8C >> 1),
98};
99
100static struct msm_actuator_info s5k4e1_actuator_info = {
101 .board_info = &s5k4e1_actuator_i2c_info,
102 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
103 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
104 .vcm_enable = 1,
105};
106#endif
107
108#ifdef CONFIG_S5K4E1
109static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
110 .flash_type = MSM_CAMERA_FLASH_LED,
111 .flash_src = &msm_flash_src
112};
113
114static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
115 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530116 .cam_vreg = msm_cam_vreg,
117 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
118 .gpio_conf = &gpio_conf_s5k4e1,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530119};
120
121static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
122 .sensor_name = "s5k4e1",
123 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530124 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530125 .pdata = &msm_camera_device_data_csi1,
126 .flash_data = &flash_s5k4e1,
127 .sensor_platform_info = &sensor_board_info_s5k4e1,
128 .csi_if = 1,
129 .camera_type = BACK_CAMERA_2D,
130#ifdef CONFIG_DW9712_ACT
131 .actuator_info = &s5k4e1_actuator_info
132#endif
133};
134#endif
135
136#ifdef CONFIG_MT9E013
137static struct msm_camera_sensor_flash_data flash_mt9e013 = {
138 .flash_type = MSM_CAMERA_FLASH_LED,
139 .flash_src = &msm_flash_src
140};
141
142static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
143 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530144 .cam_vreg = msm_cam_vreg,
145 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
146 .gpio_conf = &gpio_conf_mt9e013,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530147};
148
149static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
150 .sensor_name = "mt9e013",
151 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530152 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530153 .pdata = &msm_camera_device_data_csi1,
154 .flash_data = &flash_mt9e013,
155 .sensor_platform_info = &sensor_board_info_mt9e013,
156 .csi_if = 1,
157 .camera_type = BACK_CAMERA_2D,
158};
159#endif
160
161#ifdef CONFIG_IMX072
162static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
163 .mount_angle = 90
164};
165
166static struct msm_camera_sensor_flash_data flash_imx072 = {
167 .flash_type = MSM_CAMERA_FLASH_LED,
168 .flash_src = &msm_flash_src
169};
170
171static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
172 .sensor_name = "imx072",
173 .sensor_reset_enable = 1,
174 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530175 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530176 .sensor_pwd = 85,
177 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
178 .vcm_enable = 1,
179 .pdata = &msm_camera_device_data_csi1,
180 .flash_data = &flash_imx072,
181 .sensor_platform_info = &imx072_sensor_7627a_info,
182 .csi_if = 1
183};
184
185static struct platform_device msm_camera_sensor_imx072 = {
186 .name = "msm_camera_imx072",
187 .dev = {
188 .platform_data = &msm_camera_sensor_imx072_data,
189 },
190};
191#endif
192
193#ifdef CONFIG_WEBCAM_OV9726
194static struct msm_camera_sensor_flash_data flash_ov9726 = {
195 .flash_type = MSM_CAMERA_FLASH_LED,
196 .flash_src = &msm_flash_src
197};
198
199static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
200 .mount_angle = 90,
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530201 .cam_vreg = msm_cam_vreg,
202 .num_vreg = ARRAY_SIZE(msm_cam_vreg),
203 .gpio_conf = &gpio_conf_ov9726,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530204};
205
206static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
207 .sensor_name = "ov9726",
208 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530209 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530210 .pdata = &msm_camera_device_data_csi0,
211 .flash_data = &flash_ov9726,
212 .sensor_platform_info = &sensor_board_info_ov9726,
213 .csi_if = 1,
214 .camera_type = FRONT_CAMERA_2D,
215};
216#endif
217
218static void __init msm7x27a_init_cam(void)
219{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530220 if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
221 || machine_is_msm7627a_qrd1())) {
222 sensor_board_info_s5k4e1.cam_vreg = NULL;
223 sensor_board_info_s5k4e1.num_vreg = 0;
224 sensor_board_info_mt9e013.cam_vreg = NULL;
225 sensor_board_info_mt9e013.num_vreg = 0;
226 sensor_board_info_ov9726.cam_vreg = NULL;
227 sensor_board_info_ov9726.num_vreg = 0;
228 }
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530229 platform_device_register(&msm7x27a_device_csic0);
230 platform_device_register(&msm7x27a_device_csic1);
231 platform_device_register(&msm7x27a_device_clkctl);
232 platform_device_register(&msm7x27a_device_vfe);
233}
234
235static struct i2c_board_info i2c_camera_devices[] = {
236 #ifdef CONFIG_S5K4E1
237 {
238 I2C_BOARD_INFO("s5k4e1", 0x36),
239 .platform_data = &msm_camera_sensor_s5k4e1_data,
240 },
241 #endif
242 #ifdef CONFIG_WEBCAM_OV9726
243 {
244 I2C_BOARD_INFO("ov9726", 0x10),
245 .platform_data = &msm_camera_sensor_ov9726_data,
246 },
247 #endif
248 #ifdef CONFIG_IMX072
249 {
250 I2C_BOARD_INFO("imx072", 0x34),
251 },
252 #endif
253 #ifdef CONFIG_MT9E013
254 {
255 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
256 .platform_data = &msm_camera_sensor_mt9e013_data,
257 },
258 #endif
259 {
260 I2C_BOARD_INFO("sc628a", 0x6E),
261 },
262};
263#else
Chintan Pandya40762702011-12-06 13:47:06 +0530264static uint32_t camera_off_gpio_table[] = {
265 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
266};
267
268static uint32_t camera_on_gpio_table[] = {
269 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
270};
271
272#ifdef CONFIG_MSM_CAMERA_FLASH
273static struct msm_camera_sensor_flash_src msm_flash_src = {
274 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
275 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
276 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
277};
278#endif
279
280static struct regulator_bulk_data regs_camera[] = {
281 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
282 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
283 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
284};
285
286static void qrd1_camera_gpio_cfg(void)
287{
288
289 int rc = 0;
290
291 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
292 if (rc < 0)
293 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
294 __func__);
295
296
297 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
298 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
299 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
300 if (rc < 0) {
301 pr_err("%s: unable to enable Power Down gpio for main"
302 "camera!\n", __func__);
303 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
304 }
305
306
307 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
308 if (rc < 0) {
309 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
310 __func__);
311 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
312 }
313
314
315 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
316 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
317 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
318 if (rc < 0) {
319 pr_err("%s: unable to enable reset gpio for main camera!\n",
320 __func__);
321 gpio_free(QRD_GPIO_CAM_5MP_RESET);
322 }
323
324 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
325 if (rc < 0)
326 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
327 __func__);
328
329 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
330 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
331 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
332 if (rc < 0) {
333 pr_err("%s: unable to enable Power Down gpio for front"
334 "camera!\n", __func__);
335 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
336 }
337
338 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
339 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
340 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
341}
342
Su Liuaca04702012-02-14 02:27:32 +0530343#define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */
344#define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */
345#define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30
346
347#define GPIO_SKU1_CAM_VGA_SHDN 18
348#define GPIO_SKU1_CAM_VGA_RESET_N 29
349
350static void evb_camera_gpio_cfg(void)
351{
352 int rc = 0;
353
354 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
355 if (rc < 0)
356 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
357 __func__);
358
359 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
360 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
361 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
362 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
363 if (rc < 0) {
364 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
365 __func__);
366 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
367 }
368
369 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
370
371 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
372 if (rc < 0)
373 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
374 __func__);
375
376 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
377 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
378 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
379 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
380 if (rc < 0) {
381 pr_err("%s: unable to enable reset gpio for main camera!\n",
382 __func__);
383 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
384 }
385
386 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
387
388 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
389 if (rc < 0)
390 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
391 __func__);
392
393 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
394 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
395 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
396 if (rc < 0) {
397 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
398 __func__);
399 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
400 }
401
402 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
403
404 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
405 if (rc < 0)
406 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
407 __func__);
408
409 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
410 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
411 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
412
413 if (rc < 0) {
414 pr_err("%s: unable to enable reset gpio for front camera!\n",
415 __func__);
416 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
417 }
418 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
419
420}
421
Chintan Pandya40762702011-12-06 13:47:06 +0530422static void msm_camera_vreg_config(int vreg_en)
423{
424 int rc = vreg_en ?
425 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
426 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
427
428 if (rc)
429 pr_err("%s: could not %sable regulators: %d\n",
430 __func__, vreg_en ? "en" : "dis", rc);
431}
432
433static int config_gpio_table(uint32_t *table, int len)
434{
435 int rc = 0, i = 0;
436
437 for (i = 0; i < len; i++) {
438 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
439 if (rc) {
440 pr_err("%s not able to get gpio\n", __func__);
441 for (i--; i >= 0; i--)
442 gpio_tlmm_config(camera_off_gpio_table[i],
443 GPIO_CFG_ENABLE);
444 break;
445 }
446 }
447 return rc;
448}
449
450static int config_camera_on_gpios_rear(void)
451{
452 int rc = 0;
453
454 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
455 || machine_is_msm7627a_qrd1())
456 msm_camera_vreg_config(1);
457
458 rc = config_gpio_table(camera_on_gpio_table,
459 ARRAY_SIZE(camera_on_gpio_table));
460 if (rc < 0) {
461 pr_err("%s: CAMSENSOR gpio table request"
462 "failed\n", __func__);
463 return rc;
464 }
465
466 return rc;
467}
468
469static void config_camera_off_gpios_rear(void)
470{
471 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
472 || machine_is_msm7627a_qrd1())
473 msm_camera_vreg_config(0);
474
475 config_gpio_table(camera_off_gpio_table,
476 ARRAY_SIZE(camera_off_gpio_table));
477}
478
479static int config_camera_on_gpios_front(void)
480{
481 int rc = 0;
482
483 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
484 || machine_is_msm7627a_qrd1())
485 msm_camera_vreg_config(1);
486
487 rc = config_gpio_table(camera_on_gpio_table,
488 ARRAY_SIZE(camera_on_gpio_table));
489 if (rc < 0) {
490 pr_err("%s: CAMSENSOR gpio table request"
491 "failed\n", __func__);
492 return rc;
493 }
494
495 return rc;
496}
497
498static void config_camera_off_gpios_front(void)
499{
500 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
501 || machine_is_msm7627a_qrd1())
502 msm_camera_vreg_config(0);
503
504 config_gpio_table(camera_off_gpio_table,
505 ARRAY_SIZE(camera_off_gpio_table));
506}
507
508struct msm_camera_device_platform_data msm_camera_device_data_rear = {
509 .camera_gpio_on = config_camera_on_gpios_rear,
510 .camera_gpio_off = config_camera_off_gpios_rear,
511 .ioext.csiphy = 0xA1000000,
512 .ioext.csisz = 0x00100000,
513 .ioext.csiirq = INT_CSI_IRQ_1,
514 .ioclk.mclk_clk_rate = 24000000,
515 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530516 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
517 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530518};
519
520struct msm_camera_device_platform_data msm_camera_device_data_front = {
521 .camera_gpio_on = config_camera_on_gpios_front,
522 .camera_gpio_off = config_camera_off_gpios_front,
523 .ioext.csiphy = 0xA0F00000,
524 .ioext.csisz = 0x00100000,
525 .ioext.csiirq = INT_CSI_IRQ_0,
526 .ioclk.mclk_clk_rate = 24000000,
527 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530528 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
529 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530530};
531
Su Liuaca04702012-02-14 02:27:32 +0530532#ifdef CONFIG_OV5647
533
534static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
535 .mount_angle = 90
536};
537
538static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
539 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
540 ._fsrc.led_src.led_name = "flashlight",
541 ._fsrc.led_src.led_name_len = 10,
542};
543
544static struct msm_camera_sensor_flash_data flash_ov5647 = {
545 .flash_type = MSM_CAMERA_FLASH_LED,
546 .flash_src = &msm_flash_src_ov5647,
547};
548
549static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
550 .sensor_name = "ov5647",
551 .sensor_reset_enable = 1,
552 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
553 .pmic_gpio_enable = 1,
554 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
555 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
Lokesh Kumar Aakulufe9c3ec2012-02-22 19:26:29 +0530556 .vcm_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530557 .pdata = &msm_camera_device_data_rear,
558 .flash_data = &flash_ov5647,
559 .sensor_platform_info = &ov5647_sensor_7627a_info,
560 .csi_if = 1
561};
562
563static struct platform_device msm_camera_sensor_ov5647 = {
564 .name = "msm_camera_ov5647",
565 .dev = {
566 .platform_data = &msm_camera_sensor_ov5647_data,
567 },
568};
569#endif
570
Chintan Pandya40762702011-12-06 13:47:06 +0530571#ifdef CONFIG_S5K4E1
572static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
573 .mount_angle = 90
574};
575
576static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
577 .flash_type = MSM_CAMERA_FLASH_LED,
578 .flash_src = &msm_flash_src
579};
580
581static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
582 .sensor_name = "s5k4e1",
583 .sensor_reset_enable = 1,
584 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530585 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530586 .sensor_pwd = 85,
587 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
588 .vcm_enable = 1,
589 .pdata = &msm_camera_device_data_rear,
590 .flash_data = &flash_s5k4e1,
591 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
592 .csi_if = 1
593};
594
595static struct platform_device msm_camera_sensor_s5k4e1 = {
596 .name = "msm_camera_s5k4e1",
597 .dev = {
598 .platform_data = &msm_camera_sensor_s5k4e1_data,
599 },
600};
601#endif
602
603#ifdef CONFIG_IMX072
604static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
605 .mount_angle = 90
606};
607
608static struct msm_camera_sensor_flash_data flash_imx072 = {
609 .flash_type = MSM_CAMERA_FLASH_LED,
610 .flash_src = &msm_flash_src
611};
612
613static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
614 .sensor_name = "imx072",
615 .sensor_reset_enable = 1,
616 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530617 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530618 .sensor_pwd = 85,
619 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
620 .vcm_enable = 1,
621 .pdata = &msm_camera_device_data_rear,
622 .flash_data = &flash_imx072,
623 .sensor_platform_info = &imx072_sensor_7627a_info,
624 .csi_if = 1
625};
626
627static struct platform_device msm_camera_sensor_imx072 = {
628 .name = "msm_camera_imx072",
629 .dev = {
630 .platform_data = &msm_camera_sensor_imx072_data,
631 },
632};
633#endif
634
635static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
636#ifdef CONFIG_WEBCAM_OV9726
637static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
638 .mount_angle = 90
639};
640
641static struct msm_camera_sensor_flash_data flash_ov9726 = {
642 .flash_type = MSM_CAMERA_FLASH_NONE,
643 .flash_src = &msm_flash_src
644};
645
646static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
647 .sensor_name = "ov9726",
648 .sensor_reset_enable = 0,
649 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530650 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530651 .sensor_pwd = 85,
652 .vcm_pwd = 1,
653 .vcm_enable = 0,
654 .pdata = &msm_camera_device_data_front,
655 .flash_data = &flash_ov9726,
656 .sensor_platform_info = &ov9726_sensor_7627a_info,
657 .csi_if = 1
658};
659
660static struct platform_device msm_camera_sensor_ov9726 = {
661 .name = "msm_camera_ov9726",
662 .dev = {
663 .platform_data = &msm_camera_sensor_ov9726_data,
664 },
665};
666#else
667static inline void msm_camera_vreg_init(void) { }
668#endif
669
670#ifdef CONFIG_MT9E013
671static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
672 .mount_angle = 90
673};
674
675static struct msm_camera_sensor_flash_data flash_mt9e013 = {
676 .flash_type = MSM_CAMERA_FLASH_LED,
677 .flash_src = &msm_flash_src
678};
679
680static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
681 .sensor_name = "mt9e013",
682 .sensor_reset = 0,
683 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530684 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530685 .sensor_pwd = 85,
686 .vcm_pwd = 1,
687 .vcm_enable = 0,
688 .pdata = &msm_camera_device_data_rear,
689 .flash_data = &flash_mt9e013,
690 .sensor_platform_info = &mt9e013_sensor_7627a_info,
691 .csi_if = 1
692};
693
694static struct platform_device msm_camera_sensor_mt9e013 = {
695 .name = "msm_camera_mt9e013",
696 .dev = {
697 .platform_data = &msm_camera_sensor_mt9e013_data,
698 },
699};
700#endif
701
702#ifdef CONFIG_OV5640
703static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
704 .mount_angle = 90
705};
706
707static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
708 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
709 ._fsrc.led_src.led_name = "flashlight",
710 ._fsrc.led_src.led_name_len = 10,
711};
712
713static struct msm_camera_sensor_flash_data flash_ov5640 = {
714 .flash_type = MSM_CAMERA_FLASH_LED,
715 .flash_src = &msm_flash_src_ov5640,
716};
717
718static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
719 .sensor_name = "ov5640",
720 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530721 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530722 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
723 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
724 .vcm_pwd = 0,
725 .vcm_enable = 0,
726 .pdata = &msm_camera_device_data_rear,
727 .flash_data = &flash_ov5640,
728 .sensor_platform_info = &ov5640_sensor_info,
729 .csi_if = 1,
730};
731
732static struct platform_device msm_camera_sensor_ov5640 = {
733 .name = "msm_camera_ov5640",
734 .dev = {
735 .platform_data = &msm_camera_sensor_ov5640_data,
736 },
737};
738#endif
739
740#ifdef CONFIG_WEBCAM_OV7692_QRD
741static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
742 .mount_angle = 90
743};
744
745static struct msm_camera_sensor_flash_data flash_ov7692 = {
746 .flash_type = MSM_CAMERA_FLASH_NONE,
747};
748
749static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
750 .sensor_name = "ov7692",
751 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530752 .pmic_gpio_enable = 1,
753 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
754 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530755 .vcm_pwd = 0,
756 .vcm_enable = 0,
757 .pdata = &msm_camera_device_data_front,
758 .flash_data = &flash_ov7692,
759 .sensor_platform_info = &ov7692_sensor_7627a_info,
760 .csi_if = 1,
761};
762
763static struct platform_device msm_camera_sensor_ov7692 = {
764 .name = "msm_camera_ov7692",
765 .dev = {
766 .platform_data = &msm_camera_sensor_ov7692_data,
767 },
768};
769#endif
770
Chintan Pandya40762702011-12-06 13:47:06 +0530771static struct i2c_board_info i2c_camera_devices[] = {
772 #ifdef CONFIG_S5K4E1
773 {
774 I2C_BOARD_INFO("s5k4e1", 0x36),
775 },
776 {
777 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
778 },
779 #endif
780 #ifdef CONFIG_WEBCAM_OV9726
781 {
782 I2C_BOARD_INFO("ov9726", 0x10),
783 },
784 #endif
785 #ifdef CONFIG_IMX072
786 {
787 I2C_BOARD_INFO("imx072", 0x34),
788 },
789 #endif
790 #ifdef CONFIG_MT9E013
791 {
792 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
793 },
794 #endif
795 {
796 I2C_BOARD_INFO("sc628a", 0x6E),
797 },
798};
799
800static struct i2c_board_info i2c_camera_devices_qrd[] = {
801 #ifdef CONFIG_OV5640
802 {
803 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
804 },
805 #endif
806 #ifdef CONFIG_WEBCAM_OV7692_QRD
807 {
808 I2C_BOARD_INFO("ov7692", 0x78),
809 },
810 #endif
811};
812
Su Liuaca04702012-02-14 02:27:32 +0530813static struct i2c_board_info i2c_camera_devices_evb[] = {
814 #ifdef CONFIG_OV5647
815 {
816 I2C_BOARD_INFO("ov5647", 0x36 << 1),
817 },
818 {
819 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
820 },
821 #endif
822 #ifdef CONFIG_WEBCAM_OV7692_QRD
823 {
824 I2C_BOARD_INFO("ov7692", 0x78),
825 },
826 #endif
827};
828
Chintan Pandya40762702011-12-06 13:47:06 +0530829static struct platform_device *camera_devices_msm[] __initdata = {
830#ifdef CONFIG_S5K4E1
831 &msm_camera_sensor_s5k4e1,
832#endif
833#ifdef CONFIG_IMX072
834 &msm_camera_sensor_imx072,
835#endif
836#ifdef CONFIG_WEBCAM_OV9726
837 &msm_camera_sensor_ov9726,
838#endif
839#ifdef CONFIG_MT9E013
840 &msm_camera_sensor_mt9e013,
841#endif
842};
843
844static struct platform_device *camera_devices_qrd[] __initdata = {
845#ifdef CONFIG_OV5640
846 &msm_camera_sensor_ov5640,
847#endif
848#ifdef CONFIG_WEBCAM_OV7692_QRD
849 &msm_camera_sensor_ov7692,
850#endif
851};
Su Liuaca04702012-02-14 02:27:32 +0530852
853static struct platform_device *camera_devices_evb[] __initdata = {
854#ifdef CONFIG_OV5647
855 &msm_camera_sensor_ov5647,
856#endif
857#ifdef CONFIG_WEBCAM_OV7692_QRD
858 &msm_camera_sensor_ov7692,
859#endif
860};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530861#endif
862
863enum {
864 SX150X_CAM,
865};
866
867static struct sx150x_platform_data sx150x_data[] __initdata = {
868 [SX150X_CAM] = {
869 .gpio_base = GPIO_CAM_EXPANDER_BASE,
870 .oscio_is_gpo = false,
871 .io_pullup_ena = 0,
872 .io_pulldn_ena = 0,
873 .io_open_drain_ena = 0x23,
874 .irq_summary = -1,
875 },
876};
877
878static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
879 {
880 I2C_BOARD_INFO("sx1508q", 0x22),
881 .platform_data = &sx150x_data[SX150X_CAM],
882 },
883};
Chintan Pandya40762702011-12-06 13:47:06 +0530884
885static void __init register_i2c_devices(void)
886{
887 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
888 cam_exp_i2c_info,
889 ARRAY_SIZE(cam_exp_i2c_info));
890}
891
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530892#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +0530893#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
894#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
895
896static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
897
898static void lcd_camera_power_init(void)
899{
900 int rc = 0;
901
902 pr_debug("lcd_camera_power_init\n");
903
904 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
905
906 /* LDO_EXT2V8 */
907 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
908 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
909 return;
910 }
911
912 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
913 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
914 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
915 if (rc < 0) {
916 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
917 goto fail_gpio2;
918 }
919
920 /* LDO_EVT1V8 */
921 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
922 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
923 goto fail_gpio2;
924 }
925
926 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
927 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
928 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
929 if (rc < 0) {
930 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
931 goto fail_gpio1;
932 }
933
934 return;
935
936fail_gpio1:
937 gpio_free(lcd_camera_ldo_1v8);
938fail_gpio2:
939 gpio_free(LCD_CAMERA_LDO_2V8);
940
941 return;
942}
943
944static int lcd_camera_power_on_sku3(void)
945{
946 int rc = 0;
947
948 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
949 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
950
951 pr_debug("turn on sku3 lcd_camera_ldo\n");
952 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
953
954 return rc;
955}
956
957static int lcd_camera_power_off_sku3(void)
958{
959 int rc = 0;
960
961 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
962 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
963
964 pr_debug("turn off sku3 lcd_camera_ldo\n");
965 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
966
967 gpio_free(lcd_camera_ldo_1v8);
968 gpio_free(LCD_CAMERA_LDO_2V8);
969
970 return rc;
971}
972
973int lcd_camera_power_onoff(int on)
974{
975 int rc = 0;
976
977 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
978
979 if (on)
980 rc = lcd_camera_power_on_sku3();
981 else
982 rc = lcd_camera_power_off_sku3();
983
984 return rc;
985}
986EXPORT_SYMBOL(lcd_camera_power_onoff);
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530987#endif
Su Liuaca04702012-02-14 02:27:32 +0530988
Chintan Pandya40762702011-12-06 13:47:06 +0530989void __init msm7627a_camera_init(void)
990{
Sandeep Kodimelac6f78672012-03-07 10:44:04 +0530991#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +0530992 int rc;
993
Su Liuaca04702012-02-14 02:27:32 +0530994 pr_debug("msm7627a_camera_init Entered\n");
995 /* LCD and camera power (VREG & LDO) init */
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530996 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Su Liuaca04702012-02-14 02:27:32 +0530997 lcd_camera_power_init();
998
Chintan Pandya40762702011-12-06 13:47:06 +0530999 if (machine_is_msm7627a_qrd1()) {
1000 qrd1_camera_gpio_cfg();
1001 platform_add_devices(camera_devices_qrd,
1002 ARRAY_SIZE(camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301003 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301004 evb_camera_gpio_cfg();
1005 platform_add_devices(camera_devices_evb,
1006 ARRAY_SIZE(camera_devices_evb));
1007 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301008 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301009 else
Chintan Pandya40762702011-12-06 13:47:06 +05301010 platform_add_devices(camera_devices_msm,
1011 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301012#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301013 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb()
1014 || !machine_is_msm8625_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301015 register_i2c_devices();
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301016#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301017 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1018
1019 if (rc) {
1020 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1021 return;
1022 }
1023
1024 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1025
1026 if (rc) {
1027 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1028 return;
1029 }
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301030#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301031
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301032#if defined(CONFIG_MSM_CAMERA_V4L2)
1033 msm7x27a_init_cam();
1034#endif
1035#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301036 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301037 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1038 i2c_camera_devices_qrd,
1039 ARRAY_SIZE(i2c_camera_devices_qrd));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301040 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Su Liuaca04702012-02-14 02:27:32 +05301041 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1042 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1043 i2c_camera_devices_evb,
1044 ARRAY_SIZE(i2c_camera_devices_evb));
1045 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301046#endif
Sandeep Kodimelac6f78672012-03-07 10:44:04 +05301047 pr_debug("i2c_register_board_info\n");
Chintan Pandya40762702011-12-06 13:47:06 +05301048 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1049 i2c_camera_devices,
1050 ARRAY_SIZE(i2c_camera_devices));
1051}