blob: 77af5e2ea865bcac874fb20250adb7f7116ef869 [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
36#ifdef CONFIG_MSM_CAMERA_FLASH
37static struct msm_camera_sensor_flash_src msm_flash_src = {
38 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
39 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
40 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
41};
42#endif
43
44static struct regulator_bulk_data regs_camera[] = {
45 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
46 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
47 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
48};
49
50static void msm_camera_vreg_config(int vreg_en)
51{
52 int rc = vreg_en ?
53 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
54 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
55
56 if (rc)
57 pr_err("%s: could not %sable regulators: %d\n",
58 __func__, vreg_en ? "en" : "dis", rc);
59}
60
61static int config_gpio_table(uint32_t *table, int len)
62{
63 int rc = 0, i = 0;
64
65 for (i = 0; i < len; i++) {
66 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
67 if (rc) {
68 pr_err("%s not able to get gpio\n", __func__);
69 for (i--; i >= 0; i--)
70 gpio_tlmm_config(camera_off_gpio_table[i],
71 GPIO_CFG_ENABLE);
72 break;
73 }
74 }
75 return rc;
76}
77
78static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data;
79/* TODO: static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data; */
80static int config_camera_on_gpios_rear(void)
81{
82 int rc = 0;
83
84 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
85 msm_camera_vreg_config(1);
86
87 rc = config_gpio_table(camera_on_gpio_table,
88 ARRAY_SIZE(camera_on_gpio_table));
89 if (rc < 0) {
90 pr_err("%s: CAMSENSOR gpio table request"
91 "failed\n", __func__);
92 return rc;
93 }
94
95 return rc;
96}
97
98static void config_camera_off_gpios_rear(void)
99{
100 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
101 msm_camera_vreg_config(0);
102
103 config_gpio_table(camera_off_gpio_table,
104 ARRAY_SIZE(camera_off_gpio_table));
105}
106
107static int config_camera_on_gpios_front(void)
108{
109 int rc = 0;
110
111 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
112 msm_camera_vreg_config(1);
113
114 rc = config_gpio_table(camera_on_gpio_table,
115 ARRAY_SIZE(camera_on_gpio_table));
116 if (rc < 0) {
117 pr_err("%s: CAMSENSOR gpio table request"
118 "failed\n", __func__);
119 return rc;
120 }
121
122 return rc;
123}
124
125static void config_camera_off_gpios_front(void)
126{
127 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
128 msm_camera_vreg_config(0);
129
130 config_gpio_table(camera_off_gpio_table,
131 ARRAY_SIZE(camera_off_gpio_table));
132}
133
134struct msm_camera_device_platform_data msm_camera_device_data_csi1 = {
135 .camera_gpio_on = config_camera_on_gpios_rear,
136 .camera_gpio_off = config_camera_off_gpios_rear,
137 .ioclk.mclk_clk_rate = 24000000,
138 .ioclk.vfe_clk_rate = 192000000,
139 .csid_core = 1,
140 .is_csic = 1,
141};
142
143struct msm_camera_device_platform_data msm_camera_device_data_csi0 = {
144 .camera_gpio_on = config_camera_on_gpios_front,
145 .camera_gpio_off = config_camera_off_gpios_front,
146 .ioclk.mclk_clk_rate = 24000000,
147 .ioclk.vfe_clk_rate = 192000000,
148 .csid_core = 0,
149};
150
151#ifdef CONFIG_DW9712_ACT
152static struct i2c_board_info s5k4e1_actuator_i2c_info = {
153 I2C_BOARD_INFO("dw9712_act", 0x8C >> 1),
154};
155
156static struct msm_actuator_info s5k4e1_actuator_info = {
157 .board_info = &s5k4e1_actuator_i2c_info,
158 .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID,
159 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
160 .vcm_enable = 1,
161};
162#endif
163
164#ifdef CONFIG_S5K4E1
165static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
166 .flash_type = MSM_CAMERA_FLASH_LED,
167 .flash_src = &msm_flash_src
168};
169
170static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = {
171 .mount_angle = 90,
172 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
173 .sensor_pwd = 85,
174 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
175 .vcm_enable = 1,
176};
177
178static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
179 .sensor_name = "s5k4e1",
180 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530181 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530182 .pdata = &msm_camera_device_data_csi1,
183 .flash_data = &flash_s5k4e1,
184 .sensor_platform_info = &sensor_board_info_s5k4e1,
185 .csi_if = 1,
186 .camera_type = BACK_CAMERA_2D,
187#ifdef CONFIG_DW9712_ACT
188 .actuator_info = &s5k4e1_actuator_info
189#endif
190};
191#endif
192
193#ifdef CONFIG_MT9E013
194static struct msm_camera_sensor_flash_data flash_mt9e013 = {
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_mt9e013 = {
200 .mount_angle = 90,
201 .sensor_reset = 0,
202 .sensor_pwd = 85,
203 .vcm_pwd = 1,
204 .vcm_enable = 0,
205};
206
207static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
208 .sensor_name = "mt9e013",
209 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530210 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530211 .pdata = &msm_camera_device_data_csi1,
212 .flash_data = &flash_mt9e013,
213 .sensor_platform_info = &sensor_board_info_mt9e013,
214 .csi_if = 1,
215 .camera_type = BACK_CAMERA_2D,
216};
217#endif
218
219#ifdef CONFIG_IMX072
220static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
221 .mount_angle = 90
222};
223
224static struct msm_camera_sensor_flash_data flash_imx072 = {
225 .flash_type = MSM_CAMERA_FLASH_LED,
226 .flash_src = &msm_flash_src
227};
228
229static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
230 .sensor_name = "imx072",
231 .sensor_reset_enable = 1,
232 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530233 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530234 .sensor_pwd = 85,
235 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
236 .vcm_enable = 1,
237 .pdata = &msm_camera_device_data_csi1,
238 .flash_data = &flash_imx072,
239 .sensor_platform_info = &imx072_sensor_7627a_info,
240 .csi_if = 1
241};
242
243static struct platform_device msm_camera_sensor_imx072 = {
244 .name = "msm_camera_imx072",
245 .dev = {
246 .platform_data = &msm_camera_sensor_imx072_data,
247 },
248};
249#endif
250
251#ifdef CONFIG_WEBCAM_OV9726
252static struct msm_camera_sensor_flash_data flash_ov9726 = {
253 .flash_type = MSM_CAMERA_FLASH_LED,
254 .flash_src = &msm_flash_src
255};
256
257static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = {
258 .mount_angle = 90,
259 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
260 .sensor_pwd = 85,
261 .vcm_pwd = 1,
262 .vcm_enable = 0,
263};
264
265static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
266 .sensor_name = "ov9726",
267 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530268 .pmic_gpio_enable = 0,
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530269 .pdata = &msm_camera_device_data_csi0,
270 .flash_data = &flash_ov9726,
271 .sensor_platform_info = &sensor_board_info_ov9726,
272 .csi_if = 1,
273 .camera_type = FRONT_CAMERA_2D,
274};
275#endif
276
277static void __init msm7x27a_init_cam(void)
278{
279 platform_device_register(&msm7x27a_device_csic0);
280 platform_device_register(&msm7x27a_device_csic1);
281 platform_device_register(&msm7x27a_device_clkctl);
282 platform_device_register(&msm7x27a_device_vfe);
283}
284
285static struct i2c_board_info i2c_camera_devices[] = {
286 #ifdef CONFIG_S5K4E1
287 {
288 I2C_BOARD_INFO("s5k4e1", 0x36),
289 .platform_data = &msm_camera_sensor_s5k4e1_data,
290 },
291 #endif
292 #ifdef CONFIG_WEBCAM_OV9726
293 {
294 I2C_BOARD_INFO("ov9726", 0x10),
295 .platform_data = &msm_camera_sensor_ov9726_data,
296 },
297 #endif
298 #ifdef CONFIG_IMX072
299 {
300 I2C_BOARD_INFO("imx072", 0x34),
301 },
302 #endif
303 #ifdef CONFIG_MT9E013
304 {
305 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
306 .platform_data = &msm_camera_sensor_mt9e013_data,
307 },
308 #endif
309 {
310 I2C_BOARD_INFO("sc628a", 0x6E),
311 },
312};
313#else
Chintan Pandya40762702011-12-06 13:47:06 +0530314static uint32_t camera_off_gpio_table[] = {
315 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
316};
317
318static uint32_t camera_on_gpio_table[] = {
319 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
320};
321
322#ifdef CONFIG_MSM_CAMERA_FLASH
323static struct msm_camera_sensor_flash_src msm_flash_src = {
324 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
325 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
326 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
327};
328#endif
329
330static struct regulator_bulk_data regs_camera[] = {
331 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
332 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
333 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
334};
335
336static void qrd1_camera_gpio_cfg(void)
337{
338
339 int rc = 0;
340
341 rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640");
342 if (rc < 0)
343 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
344 __func__);
345
346
347 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0,
348 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
349 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
350 if (rc < 0) {
351 pr_err("%s: unable to enable Power Down gpio for main"
352 "camera!\n", __func__);
353 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
354 }
355
356
357 rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640");
358 if (rc < 0) {
359 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
360 __func__);
361 gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN);
362 }
363
364
365 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0,
366 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
367 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
368 if (rc < 0) {
369 pr_err("%s: unable to enable reset gpio for main camera!\n",
370 __func__);
371 gpio_free(QRD_GPIO_CAM_5MP_RESET);
372 }
373
374 rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692");
375 if (rc < 0)
376 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
377 __func__);
378
379 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0,
380 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
381 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
382 if (rc < 0) {
383 pr_err("%s: unable to enable Power Down gpio for front"
384 "camera!\n", __func__);
385 gpio_free(QRD_GPIO_CAM_3MP_PWDN);
386 }
387
388 gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1);
389 gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1);
390 gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1);
391}
392
Su Liuaca04702012-02-14 02:27:32 +0530393#define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */
394#define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */
395#define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30
396
397#define GPIO_SKU1_CAM_VGA_SHDN 18
398#define GPIO_SKU1_CAM_VGA_RESET_N 29
399
400static void evb_camera_gpio_cfg(void)
401{
402 int rc = 0;
403
404 rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647");
405 if (rc < 0)
406 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!",
407 __func__);
408
409 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N);
410 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0,
411 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
412 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
413 if (rc < 0) {
414 pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n",
415 __func__);
416 gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N);
417 }
418
419 gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1);
420
421 rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647");
422 if (rc < 0)
423 pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!",
424 __func__);
425
426 pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET);
427 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0,
428 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
429 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
430 if (rc < 0) {
431 pr_err("%s: unable to enable reset gpio for main camera!\n",
432 __func__);
433 gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET);
434 }
435
436 gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1);
437
438 rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692");
439 if (rc < 0)
440 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!",
441 __func__);
442
443 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0,
444 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
445 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
446 if (rc < 0) {
447 pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n",
448 __func__);
449 gpio_free(GPIO_SKU1_CAM_VGA_SHDN);
450 }
451
452 gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1);
453
454 rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692");
455 if (rc < 0)
456 pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!",
457 __func__);
458
459 rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0,
460 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
461 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
462
463 if (rc < 0) {
464 pr_err("%s: unable to enable reset gpio for front camera!\n",
465 __func__);
466 gpio_free(GPIO_SKU1_CAM_VGA_RESET_N);
467 }
468 gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1);
469
470}
471
Chintan Pandya40762702011-12-06 13:47:06 +0530472static void msm_camera_vreg_config(int vreg_en)
473{
474 int rc = vreg_en ?
475 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
476 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
477
478 if (rc)
479 pr_err("%s: could not %sable regulators: %d\n",
480 __func__, vreg_en ? "en" : "dis", rc);
481}
482
483static int config_gpio_table(uint32_t *table, int len)
484{
485 int rc = 0, i = 0;
486
487 for (i = 0; i < len; i++) {
488 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
489 if (rc) {
490 pr_err("%s not able to get gpio\n", __func__);
491 for (i--; i >= 0; i--)
492 gpio_tlmm_config(camera_off_gpio_table[i],
493 GPIO_CFG_ENABLE);
494 break;
495 }
496 }
497 return rc;
498}
499
500static int config_camera_on_gpios_rear(void)
501{
502 int rc = 0;
503
504 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
505 || machine_is_msm7627a_qrd1())
506 msm_camera_vreg_config(1);
507
508 rc = config_gpio_table(camera_on_gpio_table,
509 ARRAY_SIZE(camera_on_gpio_table));
510 if (rc < 0) {
511 pr_err("%s: CAMSENSOR gpio table request"
512 "failed\n", __func__);
513 return rc;
514 }
515
516 return rc;
517}
518
519static void config_camera_off_gpios_rear(void)
520{
521 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
522 || machine_is_msm7627a_qrd1())
523 msm_camera_vreg_config(0);
524
525 config_gpio_table(camera_off_gpio_table,
526 ARRAY_SIZE(camera_off_gpio_table));
527}
528
529static int config_camera_on_gpios_front(void)
530{
531 int rc = 0;
532
533 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
534 || machine_is_msm7627a_qrd1())
535 msm_camera_vreg_config(1);
536
537 rc = config_gpio_table(camera_on_gpio_table,
538 ARRAY_SIZE(camera_on_gpio_table));
539 if (rc < 0) {
540 pr_err("%s: CAMSENSOR gpio table request"
541 "failed\n", __func__);
542 return rc;
543 }
544
545 return rc;
546}
547
548static void config_camera_off_gpios_front(void)
549{
550 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
551 || machine_is_msm7627a_qrd1())
552 msm_camera_vreg_config(0);
553
554 config_gpio_table(camera_off_gpio_table,
555 ARRAY_SIZE(camera_off_gpio_table));
556}
557
558struct msm_camera_device_platform_data msm_camera_device_data_rear = {
559 .camera_gpio_on = config_camera_on_gpios_rear,
560 .camera_gpio_off = config_camera_off_gpios_rear,
561 .ioext.csiphy = 0xA1000000,
562 .ioext.csisz = 0x00100000,
563 .ioext.csiirq = INT_CSI_IRQ_1,
564 .ioclk.mclk_clk_rate = 24000000,
565 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530566 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
567 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530568};
569
570struct msm_camera_device_platform_data msm_camera_device_data_front = {
571 .camera_gpio_on = config_camera_on_gpios_front,
572 .camera_gpio_off = config_camera_off_gpios_front,
573 .ioext.csiphy = 0xA0F00000,
574 .ioext.csisz = 0x00100000,
575 .ioext.csiirq = INT_CSI_IRQ_0,
576 .ioclk.mclk_clk_rate = 24000000,
577 .ioclk.vfe_clk_rate = 192000000,
Taniya Das13b811a2011-12-09 18:33:45 +0530578 .ioext.appphy = MSM7XXX_CLK_CTL_PHYS,
579 .ioext.appsz = MSM7XXX_CLK_CTL_SIZE,
Chintan Pandya40762702011-12-06 13:47:06 +0530580};
581
Su Liuaca04702012-02-14 02:27:32 +0530582#ifdef CONFIG_OV5647
583
584static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = {
585 .mount_angle = 90
586};
587
588static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = {
589 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
590 ._fsrc.led_src.led_name = "flashlight",
591 ._fsrc.led_src.led_name_len = 10,
592};
593
594static struct msm_camera_sensor_flash_data flash_ov5647 = {
595 .flash_type = MSM_CAMERA_FLASH_LED,
596 .flash_src = &msm_flash_src_ov5647,
597};
598
599static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = {
600 .sensor_name = "ov5647",
601 .sensor_reset_enable = 1,
602 .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET,
603 .pmic_gpio_enable = 1,
604 .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N,
605 .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN,
606 .vcm_enable = 0,
607 .pdata = &msm_camera_device_data_rear,
608 .flash_data = &flash_ov5647,
609 .sensor_platform_info = &ov5647_sensor_7627a_info,
610 .csi_if = 1
611};
612
613static struct platform_device msm_camera_sensor_ov5647 = {
614 .name = "msm_camera_ov5647",
615 .dev = {
616 .platform_data = &msm_camera_sensor_ov5647_data,
617 },
618};
619#endif
620
Chintan Pandya40762702011-12-06 13:47:06 +0530621#ifdef CONFIG_S5K4E1
622static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = {
623 .mount_angle = 90
624};
625
626static struct msm_camera_sensor_flash_data flash_s5k4e1 = {
627 .flash_type = MSM_CAMERA_FLASH_LED,
628 .flash_src = &msm_flash_src
629};
630
631static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = {
632 .sensor_name = "s5k4e1",
633 .sensor_reset_enable = 1,
634 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N,
Su Liuaca04702012-02-14 02:27:32 +0530635 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530636 .sensor_pwd = 85,
637 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
638 .vcm_enable = 1,
639 .pdata = &msm_camera_device_data_rear,
640 .flash_data = &flash_s5k4e1,
641 .sensor_platform_info = &s5k4e1_sensor_7627a_info,
642 .csi_if = 1
643};
644
645static struct platform_device msm_camera_sensor_s5k4e1 = {
646 .name = "msm_camera_s5k4e1",
647 .dev = {
648 .platform_data = &msm_camera_sensor_s5k4e1_data,
649 },
650};
651#endif
652
653#ifdef CONFIG_IMX072
654static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = {
655 .mount_angle = 90
656};
657
658static struct msm_camera_sensor_flash_data flash_imx072 = {
659 .flash_type = MSM_CAMERA_FLASH_LED,
660 .flash_src = &msm_flash_src
661};
662
663static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = {
664 .sensor_name = "imx072",
665 .sensor_reset_enable = 1,
666 .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/
Su Liuaca04702012-02-14 02:27:32 +0530667 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530668 .sensor_pwd = 85,
669 .vcm_pwd = GPIO_CAM_GP_CAM_PWDN,
670 .vcm_enable = 1,
671 .pdata = &msm_camera_device_data_rear,
672 .flash_data = &flash_imx072,
673 .sensor_platform_info = &imx072_sensor_7627a_info,
674 .csi_if = 1
675};
676
677static struct platform_device msm_camera_sensor_imx072 = {
678 .name = "msm_camera_imx072",
679 .dev = {
680 .platform_data = &msm_camera_sensor_imx072_data,
681 },
682};
683#endif
684
685static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data;
686#ifdef CONFIG_WEBCAM_OV9726
687static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = {
688 .mount_angle = 90
689};
690
691static struct msm_camera_sensor_flash_data flash_ov9726 = {
692 .flash_type = MSM_CAMERA_FLASH_NONE,
693 .flash_src = &msm_flash_src
694};
695
696static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
697 .sensor_name = "ov9726",
698 .sensor_reset_enable = 0,
699 .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR,
Su Liuaca04702012-02-14 02:27:32 +0530700 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530701 .sensor_pwd = 85,
702 .vcm_pwd = 1,
703 .vcm_enable = 0,
704 .pdata = &msm_camera_device_data_front,
705 .flash_data = &flash_ov9726,
706 .sensor_platform_info = &ov9726_sensor_7627a_info,
707 .csi_if = 1
708};
709
710static struct platform_device msm_camera_sensor_ov9726 = {
711 .name = "msm_camera_ov9726",
712 .dev = {
713 .platform_data = &msm_camera_sensor_ov9726_data,
714 },
715};
716#else
717static inline void msm_camera_vreg_init(void) { }
718#endif
719
720#ifdef CONFIG_MT9E013
721static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = {
722 .mount_angle = 90
723};
724
725static struct msm_camera_sensor_flash_data flash_mt9e013 = {
726 .flash_type = MSM_CAMERA_FLASH_LED,
727 .flash_src = &msm_flash_src
728};
729
730static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
731 .sensor_name = "mt9e013",
732 .sensor_reset = 0,
733 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530734 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530735 .sensor_pwd = 85,
736 .vcm_pwd = 1,
737 .vcm_enable = 0,
738 .pdata = &msm_camera_device_data_rear,
739 .flash_data = &flash_mt9e013,
740 .sensor_platform_info = &mt9e013_sensor_7627a_info,
741 .csi_if = 1
742};
743
744static struct platform_device msm_camera_sensor_mt9e013 = {
745 .name = "msm_camera_mt9e013",
746 .dev = {
747 .platform_data = &msm_camera_sensor_mt9e013_data,
748 },
749};
750#endif
751
752#ifdef CONFIG_OV5640
753static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
754 .mount_angle = 90
755};
756
757static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
758 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
759 ._fsrc.led_src.led_name = "flashlight",
760 ._fsrc.led_src.led_name_len = 10,
761};
762
763static struct msm_camera_sensor_flash_data flash_ov5640 = {
764 .flash_type = MSM_CAMERA_FLASH_LED,
765 .flash_src = &msm_flash_src_ov5640,
766};
767
768static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
769 .sensor_name = "ov5640",
770 .sensor_reset_enable = 1,
Su Liuaca04702012-02-14 02:27:32 +0530771 .pmic_gpio_enable = 0,
Chintan Pandya40762702011-12-06 13:47:06 +0530772 .sensor_reset = QRD_GPIO_CAM_5MP_RESET,
773 .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN,
774 .vcm_pwd = 0,
775 .vcm_enable = 0,
776 .pdata = &msm_camera_device_data_rear,
777 .flash_data = &flash_ov5640,
778 .sensor_platform_info = &ov5640_sensor_info,
779 .csi_if = 1,
780};
781
782static struct platform_device msm_camera_sensor_ov5640 = {
783 .name = "msm_camera_ov5640",
784 .dev = {
785 .platform_data = &msm_camera_sensor_ov5640_data,
786 },
787};
788#endif
789
790#ifdef CONFIG_WEBCAM_OV7692_QRD
791static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
792 .mount_angle = 90
793};
794
795static struct msm_camera_sensor_flash_data flash_ov7692 = {
796 .flash_type = MSM_CAMERA_FLASH_NONE,
797};
798
799static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
800 .sensor_name = "ov7692",
801 .sensor_reset_enable = 0,
Su Liuaca04702012-02-14 02:27:32 +0530802 .pmic_gpio_enable = 1,
803 .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N,
804 .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN,
Chintan Pandya40762702011-12-06 13:47:06 +0530805 .vcm_pwd = 0,
806 .vcm_enable = 0,
807 .pdata = &msm_camera_device_data_front,
808 .flash_data = &flash_ov7692,
809 .sensor_platform_info = &ov7692_sensor_7627a_info,
810 .csi_if = 1,
811};
812
813static struct platform_device msm_camera_sensor_ov7692 = {
814 .name = "msm_camera_ov7692",
815 .dev = {
816 .platform_data = &msm_camera_sensor_ov7692_data,
817 },
818};
819#endif
820
Chintan Pandya40762702011-12-06 13:47:06 +0530821static struct i2c_board_info i2c_camera_devices[] = {
822 #ifdef CONFIG_S5K4E1
823 {
824 I2C_BOARD_INFO("s5k4e1", 0x36),
825 },
826 {
827 I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1),
828 },
829 #endif
830 #ifdef CONFIG_WEBCAM_OV9726
831 {
832 I2C_BOARD_INFO("ov9726", 0x10),
833 },
834 #endif
835 #ifdef CONFIG_IMX072
836 {
837 I2C_BOARD_INFO("imx072", 0x34),
838 },
839 #endif
840 #ifdef CONFIG_MT9E013
841 {
842 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
843 },
844 #endif
845 {
846 I2C_BOARD_INFO("sc628a", 0x6E),
847 },
848};
849
850static struct i2c_board_info i2c_camera_devices_qrd[] = {
851 #ifdef CONFIG_OV5640
852 {
853 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
854 },
855 #endif
856 #ifdef CONFIG_WEBCAM_OV7692_QRD
857 {
858 I2C_BOARD_INFO("ov7692", 0x78),
859 },
860 #endif
861};
862
Su Liuaca04702012-02-14 02:27:32 +0530863static struct i2c_board_info i2c_camera_devices_evb[] = {
864 #ifdef CONFIG_OV5647
865 {
866 I2C_BOARD_INFO("ov5647", 0x36 << 1),
867 },
868 {
869 I2C_BOARD_INFO("ov5647_af", 0x18 >> 1),
870 },
871 #endif
872 #ifdef CONFIG_WEBCAM_OV7692_QRD
873 {
874 I2C_BOARD_INFO("ov7692", 0x78),
875 },
876 #endif
877};
878
Chintan Pandya40762702011-12-06 13:47:06 +0530879static struct platform_device *camera_devices_msm[] __initdata = {
880#ifdef CONFIG_S5K4E1
881 &msm_camera_sensor_s5k4e1,
882#endif
883#ifdef CONFIG_IMX072
884 &msm_camera_sensor_imx072,
885#endif
886#ifdef CONFIG_WEBCAM_OV9726
887 &msm_camera_sensor_ov9726,
888#endif
889#ifdef CONFIG_MT9E013
890 &msm_camera_sensor_mt9e013,
891#endif
892};
893
894static struct platform_device *camera_devices_qrd[] __initdata = {
895#ifdef CONFIG_OV5640
896 &msm_camera_sensor_ov5640,
897#endif
898#ifdef CONFIG_WEBCAM_OV7692_QRD
899 &msm_camera_sensor_ov7692,
900#endif
901};
Su Liuaca04702012-02-14 02:27:32 +0530902
903static struct platform_device *camera_devices_evb[] __initdata = {
904#ifdef CONFIG_OV5647
905 &msm_camera_sensor_ov5647,
906#endif
907#ifdef CONFIG_WEBCAM_OV7692_QRD
908 &msm_camera_sensor_ov7692,
909#endif
910};
Suresh Vankadara87e195b2012-01-18 00:42:58 +0530911#endif
912
913enum {
914 SX150X_CAM,
915};
916
917static struct sx150x_platform_data sx150x_data[] __initdata = {
918 [SX150X_CAM] = {
919 .gpio_base = GPIO_CAM_EXPANDER_BASE,
920 .oscio_is_gpo = false,
921 .io_pullup_ena = 0,
922 .io_pulldn_ena = 0,
923 .io_open_drain_ena = 0x23,
924 .irq_summary = -1,
925 },
926};
927
928static struct i2c_board_info cam_exp_i2c_info[] __initdata = {
929 {
930 I2C_BOARD_INFO("sx1508q", 0x22),
931 .platform_data = &sx150x_data[SX150X_CAM],
932 },
933};
Chintan Pandya40762702011-12-06 13:47:06 +0530934
935static void __init register_i2c_devices(void)
936{
937 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
938 cam_exp_i2c_info,
939 ARRAY_SIZE(cam_exp_i2c_info));
940}
941
Su Liuaca04702012-02-14 02:27:32 +0530942#define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */
943#define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */
944
945static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8;
946
947static void lcd_camera_power_init(void)
948{
949 int rc = 0;
950
951 pr_debug("lcd_camera_power_init\n");
952
953 lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */
954
955 /* LDO_EXT2V8 */
956 if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
957 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
958 return;
959 }
960
961 rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0,
962 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
963 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
964 if (rc < 0) {
965 pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__);
966 goto fail_gpio2;
967 }
968
969 /* LDO_EVT1V8 */
970 if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) {
971 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
972 goto fail_gpio2;
973 }
974
975 rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0,
976 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
977 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
978 if (rc < 0) {
979 pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__);
980 goto fail_gpio1;
981 }
982
983 return;
984
985fail_gpio1:
986 gpio_free(lcd_camera_ldo_1v8);
987fail_gpio2:
988 gpio_free(LCD_CAMERA_LDO_2V8);
989
990 return;
991}
992
993static int lcd_camera_power_on_sku3(void)
994{
995 int rc = 0;
996
997 pr_debug("turn on sku3 lcd_camera_ldo_1v8\n");
998 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1);
999
1000 pr_debug("turn on sku3 lcd_camera_ldo\n");
1001 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1);
1002
1003 return rc;
1004}
1005
1006static int lcd_camera_power_off_sku3(void)
1007{
1008 int rc = 0;
1009
1010 pr_debug("turn off sku3 lcd_camera_ldo_1v8\n");
1011 gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0);
1012
1013 pr_debug("turn off sku3 lcd_camera_ldo\n");
1014 gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0);
1015
1016 gpio_free(lcd_camera_ldo_1v8);
1017 gpio_free(LCD_CAMERA_LDO_2V8);
1018
1019 return rc;
1020}
1021
1022int lcd_camera_power_onoff(int on)
1023{
1024 int rc = 0;
1025
1026 pr_debug("lcd_camera_power_onoff on = %d,\n", on);
1027
1028 if (on)
1029 rc = lcd_camera_power_on_sku3();
1030 else
1031 rc = lcd_camera_power_off_sku3();
1032
1033 return rc;
1034}
1035EXPORT_SYMBOL(lcd_camera_power_onoff);
1036
1037
Chintan Pandya40762702011-12-06 13:47:06 +05301038void __init msm7627a_camera_init(void)
1039{
1040 int rc;
1041
Su Liuaca04702012-02-14 02:27:32 +05301042 pr_debug("msm7627a_camera_init Entered\n");
1043 /* LCD and camera power (VREG & LDO) init */
1044 if (machine_is_msm7627a_evb())
1045 lcd_camera_power_init();
1046
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301047#ifndef CONFIG_MSM_CAMERA_V4L2
Chintan Pandya40762702011-12-06 13:47:06 +05301048 if (machine_is_msm7627a_qrd1()) {
1049 qrd1_camera_gpio_cfg();
1050 platform_add_devices(camera_devices_qrd,
1051 ARRAY_SIZE(camera_devices_qrd));
Su Liuaca04702012-02-14 02:27:32 +05301052 } else if (machine_is_msm7627a_evb()) {
1053 evb_camera_gpio_cfg();
1054 platform_add_devices(camera_devices_evb,
1055 ARRAY_SIZE(camera_devices_evb));
1056 } else if (machine_is_msm7627a_qrd3())
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301057 return;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301058 else
Chintan Pandya40762702011-12-06 13:47:06 +05301059 platform_add_devices(camera_devices_msm,
1060 ARRAY_SIZE(camera_devices_msm));
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301061#endif
Su Liuaca04702012-02-14 02:27:32 +05301062 if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb())
Chintan Pandya40762702011-12-06 13:47:06 +05301063 register_i2c_devices();
Chintan Pandya40762702011-12-06 13:47:06 +05301064 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1065
1066 if (rc) {
1067 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1068 return;
1069 }
1070
1071 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1072
1073 if (rc) {
1074 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1075 return;
1076 }
1077
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301078#if defined(CONFIG_MSM_CAMERA_V4L2)
1079 msm7x27a_init_cam();
1080#endif
1081#ifndef CONFIG_MSM_CAMERA_V4L2
Su Liuaca04702012-02-14 02:27:32 +05301082 if (machine_is_msm7627a_qrd1()) {
Chintan Pandya40762702011-12-06 13:47:06 +05301083 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1084 i2c_camera_devices_qrd,
1085 ARRAY_SIZE(i2c_camera_devices_qrd));
Su Liuaca04702012-02-14 02:27:32 +05301086 } else if (machine_is_msm7627a_evb()) {
1087 pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n");
1088 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1089 i2c_camera_devices_evb,
1090 ARRAY_SIZE(i2c_camera_devices_evb));
1091 } else
Suresh Vankadara87e195b2012-01-18 00:42:58 +05301092#endif
Chintan Pandya40762702011-12-06 13:47:06 +05301093 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID,
1094 i2c_camera_devices,
1095 ARRAY_SIZE(i2c_camera_devices));
1096}