blob: 7e5f0224e5f5c0133faa8007d940bbdc13af145d [file] [log] [blame]
Kevin Chan3be11612012-03-22 20:05:40 -07001/* 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
14#include <asm/mach-types.h>
Kevin Chan3be11612012-03-22 20:05:40 -070015#include <linux/gpio.h>
16#include <linux/i2c.h>
17#include <linux/mfd/pmic8901.h>
Jack Wangb88c8c22012-07-26 11:33:36 -070018#include <mach/camera.h>
Kevin Chan3be11612012-03-22 20:05:40 -070019#include <mach/board-msm8660.h>
20#include <mach/gpiomux.h>
21#include <mach/msm_bus_board.h>
Azam Sadiq Pasha Kapatrala Syed51509f02012-04-18 09:10:58 -070022#include "devices-msm8x60.h"
Kevin Chan3be11612012-03-22 20:05:40 -070023#include "devices.h"
24
25#define GPIO_EXT_CAMIF_PWR_EN1 (PM8901_MPP_BASE + PM8901_MPPS + 13)
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -070026#define GPIO_WEB_CAMIF_STANDBY1 (PM8901_MPP_BASE + PM8901_MPPS + 60)
Kevin Chan3be11612012-03-22 20:05:40 -070027#ifdef CONFIG_MSM_CAMERA_FLASH
28#define VFE_CAMIF_TIMER1_GPIO 29
29#define VFE_CAMIF_TIMER2_GPIO 30
30#define VFE_CAMIF_TIMER3_GPIO_INT 31
31#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
32
33static struct msm_camera_sensor_flash_src msm_flash_src = {
34 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
35 ._fsrc.pmic_src.num_of_src = 2,
36 ._fsrc.pmic_src.low_current = 100,
37 ._fsrc.pmic_src.high_current = 300,
38 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
39 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
40 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
41};
42static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
43 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
44 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
45 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
46 .flash_recharge_duration = 50000,
47 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
48};
49#endif
50
51static struct msm_bus_vectors cam_init_vectors[] = {
52 {
53 .src = MSM_BUS_MASTER_VFE,
54 .dst = MSM_BUS_SLAVE_SMI,
55 .ab = 0,
56 .ib = 0,
57 },
58 {
59 .src = MSM_BUS_MASTER_VFE,
60 .dst = MSM_BUS_SLAVE_EBI_CH0,
61 .ab = 0,
62 .ib = 0,
63 },
64 {
65 .src = MSM_BUS_MASTER_VPE,
66 .dst = MSM_BUS_SLAVE_SMI,
67 .ab = 0,
68 .ib = 0,
69 },
70 {
71 .src = MSM_BUS_MASTER_VPE,
72 .dst = MSM_BUS_SLAVE_EBI_CH0,
73 .ab = 0,
74 .ib = 0,
75 },
76 {
77 .src = MSM_BUS_MASTER_JPEG_ENC,
78 .dst = MSM_BUS_SLAVE_SMI,
79 .ab = 0,
80 .ib = 0,
81 },
82 {
83 .src = MSM_BUS_MASTER_JPEG_ENC,
84 .dst = MSM_BUS_SLAVE_EBI_CH0,
85 .ab = 0,
86 .ib = 0,
87 },
88};
89
90static struct msm_bus_vectors cam_preview_vectors[] = {
91 {
92 .src = MSM_BUS_MASTER_VFE,
93 .dst = MSM_BUS_SLAVE_SMI,
94 .ab = 0,
95 .ib = 0,
96 },
97 {
98 .src = MSM_BUS_MASTER_VFE,
99 .dst = MSM_BUS_SLAVE_EBI_CH0,
100 .ab = 283115520,
101 .ib = 452984832,
102 },
103 {
104 .src = MSM_BUS_MASTER_VPE,
105 .dst = MSM_BUS_SLAVE_SMI,
106 .ab = 0,
107 .ib = 0,
108 },
109 {
110 .src = MSM_BUS_MASTER_VPE,
111 .dst = MSM_BUS_SLAVE_EBI_CH0,
112 .ab = 0,
113 .ib = 0,
114 },
115 {
116 .src = MSM_BUS_MASTER_JPEG_ENC,
117 .dst = MSM_BUS_SLAVE_SMI,
118 .ab = 0,
119 .ib = 0,
120 },
121 {
122 .src = MSM_BUS_MASTER_JPEG_ENC,
123 .dst = MSM_BUS_SLAVE_EBI_CH0,
124 .ab = 0,
125 .ib = 0,
126 },
127};
128
129static struct msm_bus_vectors cam_video_vectors[] = {
130 {
131 .src = MSM_BUS_MASTER_VFE,
132 .dst = MSM_BUS_SLAVE_SMI,
133 .ab = 283115520,
134 .ib = 452984832,
135 },
136 {
137 .src = MSM_BUS_MASTER_VFE,
138 .dst = MSM_BUS_SLAVE_EBI_CH0,
139 .ab = 283115520,
140 .ib = 452984832,
141 },
142 {
143 .src = MSM_BUS_MASTER_VPE,
144 .dst = MSM_BUS_SLAVE_SMI,
145 .ab = 319610880,
146 .ib = 511377408,
147 },
148 {
149 .src = MSM_BUS_MASTER_VPE,
150 .dst = MSM_BUS_SLAVE_EBI_CH0,
151 .ab = 0,
152 .ib = 0,
153 },
154 {
155 .src = MSM_BUS_MASTER_JPEG_ENC,
156 .dst = MSM_BUS_SLAVE_SMI,
157 .ab = 0,
158 .ib = 0,
159 },
160 {
161 .src = MSM_BUS_MASTER_JPEG_ENC,
162 .dst = MSM_BUS_SLAVE_EBI_CH0,
163 .ab = 0,
164 .ib = 0,
165 },
166};
167
168static struct msm_bus_vectors cam_snapshot_vectors[] = {
169 {
170 .src = MSM_BUS_MASTER_VFE,
171 .dst = MSM_BUS_SLAVE_SMI,
172 .ab = 566231040,
173 .ib = 905969664,
174 },
175 {
176 .src = MSM_BUS_MASTER_VFE,
177 .dst = MSM_BUS_SLAVE_EBI_CH0,
178 .ab = 69984000,
179 .ib = 111974400,
180 },
181 {
182 .src = MSM_BUS_MASTER_VPE,
183 .dst = MSM_BUS_SLAVE_SMI,
184 .ab = 0,
185 .ib = 0,
186 },
187 {
188 .src = MSM_BUS_MASTER_VPE,
189 .dst = MSM_BUS_SLAVE_EBI_CH0,
190 .ab = 0,
191 .ib = 0,
192 },
193 {
194 .src = MSM_BUS_MASTER_JPEG_ENC,
195 .dst = MSM_BUS_SLAVE_SMI,
196 .ab = 320864256,
197 .ib = 513382810,
198 },
199 {
200 .src = MSM_BUS_MASTER_JPEG_ENC,
201 .dst = MSM_BUS_SLAVE_EBI_CH0,
202 .ab = 320864256,
203 .ib = 513382810,
204 },
205};
206
207static struct msm_bus_vectors cam_zsl_vectors[] = {
208 {
209 .src = MSM_BUS_MASTER_VFE,
210 .dst = MSM_BUS_SLAVE_SMI,
211 .ab = 566231040,
212 .ib = 905969664,
213 },
214 {
215 .src = MSM_BUS_MASTER_VFE,
216 .dst = MSM_BUS_SLAVE_EBI_CH0,
217 .ab = 706199040,
218 .ib = 1129918464,
219 },
220 {
221 .src = MSM_BUS_MASTER_VPE,
222 .dst = MSM_BUS_SLAVE_SMI,
223 .ab = 0,
224 .ib = 0,
225 },
226 {
227 .src = MSM_BUS_MASTER_VPE,
228 .dst = MSM_BUS_SLAVE_EBI_CH0,
229 .ab = 0,
230 .ib = 0,
231 },
232 {
233 .src = MSM_BUS_MASTER_JPEG_ENC,
234 .dst = MSM_BUS_SLAVE_SMI,
235 .ab = 320864256,
236 .ib = 513382810,
237 },
238 {
239 .src = MSM_BUS_MASTER_JPEG_ENC,
240 .dst = MSM_BUS_SLAVE_EBI_CH0,
241 .ab = 320864256,
242 .ib = 513382810,
243 },
244};
245
246static struct msm_bus_vectors cam_stereo_video_vectors[] = {
247 {
248 .src = MSM_BUS_MASTER_VFE,
249 .dst = MSM_BUS_SLAVE_SMI,
250 .ab = 212336640,
251 .ib = 339738624,
252 },
253 {
254 .src = MSM_BUS_MASTER_VFE,
255 .dst = MSM_BUS_SLAVE_EBI_CH0,
256 .ab = 25090560,
257 .ib = 40144896,
258 },
259 {
260 .src = MSM_BUS_MASTER_VPE,
261 .dst = MSM_BUS_SLAVE_SMI,
262 .ab = 239708160,
263 .ib = 383533056,
264 },
265 {
266 .src = MSM_BUS_MASTER_VPE,
267 .dst = MSM_BUS_SLAVE_EBI_CH0,
268 .ab = 79902720,
269 .ib = 127844352,
270 },
271 {
272 .src = MSM_BUS_MASTER_JPEG_ENC,
273 .dst = MSM_BUS_SLAVE_SMI,
274 .ab = 0,
275 .ib = 0,
276 },
277 {
278 .src = MSM_BUS_MASTER_JPEG_ENC,
279 .dst = MSM_BUS_SLAVE_EBI_CH0,
280 .ab = 0,
281 .ib = 0,
282 },
283};
284
285static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
286 {
287 .src = MSM_BUS_MASTER_VFE,
288 .dst = MSM_BUS_SLAVE_SMI,
289 .ab = 0,
290 .ib = 0,
291 },
292 {
293 .src = MSM_BUS_MASTER_VFE,
294 .dst = MSM_BUS_SLAVE_EBI_CH0,
295 .ab = 300902400,
296 .ib = 481443840,
297 },
298 {
299 .src = MSM_BUS_MASTER_VPE,
300 .dst = MSM_BUS_SLAVE_SMI,
301 .ab = 230307840,
302 .ib = 368492544,
303 },
304 {
305 .src = MSM_BUS_MASTER_VPE,
306 .dst = MSM_BUS_SLAVE_EBI_CH0,
307 .ab = 245113344,
308 .ib = 392181351,
309 },
310 {
311 .src = MSM_BUS_MASTER_JPEG_ENC,
312 .dst = MSM_BUS_SLAVE_SMI,
313 .ab = 106536960,
314 .ib = 170459136,
315 },
316 {
317 .src = MSM_BUS_MASTER_JPEG_ENC,
318 .dst = MSM_BUS_SLAVE_EBI_CH0,
319 .ab = 106536960,
320 .ib = 170459136,
321 },
322};
323
324static struct msm_bus_paths cam_bus_client_config[] = {
325 {
326 ARRAY_SIZE(cam_init_vectors),
327 cam_zsl_vectors,
328 },
329 {
330 ARRAY_SIZE(cam_preview_vectors),
331 cam_zsl_vectors,
332 },
333 {
334 ARRAY_SIZE(cam_video_vectors),
335 cam_zsl_vectors,
336 },
337 {
338 ARRAY_SIZE(cam_snapshot_vectors),
339 cam_snapshot_vectors,
340 },
341 {
342 ARRAY_SIZE(cam_zsl_vectors),
343 cam_zsl_vectors,
344 },
345 {
346 ARRAY_SIZE(cam_stereo_video_vectors),
347 cam_stereo_video_vectors,
348 },
349 {
350 ARRAY_SIZE(cam_stereo_snapshot_vectors),
351 cam_stereo_snapshot_vectors,
352 },
353};
354
355static struct msm_bus_scale_pdata cam_bus_client_pdata = {
356 cam_bus_client_config,
357 ARRAY_SIZE(cam_bus_client_config),
358 .name = "msm_camera",
359};
360
361static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
362 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700363 .csiphy_core = 0,
Kevin Chan3be11612012-03-22 20:05:40 -0700364 .csid_core = 0,
Kevin Chan3be11612012-03-22 20:05:40 -0700365 .is_vpe = 1,
366 .cam_bus_scale_table = &cam_bus_client_pdata,
367 .ioclk = {
368 .vfe_clk_rate = 228570000,
369 },
370 },
371 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700372 .csiphy_core = 1,
Kevin Chan3be11612012-03-22 20:05:40 -0700373 .csid_core = 1,
Kevin Chan3be11612012-03-22 20:05:40 -0700374 .is_vpe = 1,
375 .cam_bus_scale_table = &cam_bus_client_pdata,
376 .ioclk = {
377 .vfe_clk_rate = 228570000,
378 },
379 },
380};
381static struct camera_vreg_t msm_8x60_back_cam_vreg[] = {
382 {"cam_vana", REG_LDO, 2850000, 2850000, -1},
383 {"cam_vio", REG_VS, 0, 0, 0},
384 {"cam_vdig", REG_LDO, 1200000, 1200000, -1},
385};
386
387static struct gpio msm8x60_common_cam_gpio[] = {
388 {32, GPIOF_DIR_IN, "CAMIF_MCLK"},
389 {47, GPIOF_DIR_IN, "CAMIF_I2C_DATA"},
390 {48, GPIOF_DIR_IN, "CAMIF_I2C_CLK"},
391 {105, GPIOF_DIR_IN, "STANDBY"},
Kevin Chan3be11612012-03-22 20:05:40 -0700392};
393
394static struct gpio msm8x60_back_cam_gpio[] = {
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -0700395 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_DIR_OUT, "CAMIF_PWR_EN"},
Kevin Chan3be11612012-03-22 20:05:40 -0700396 {106, GPIOF_DIR_OUT, "CAM_RESET"},
397};
398
399static struct msm_gpio_set_tbl msm8x60_back_cam_gpio_set_tbl[] = {
400 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_OUT_INIT_LOW, 10000},
401 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_OUT_INIT_HIGH, 5000},
402 {106, GPIOF_OUT_INIT_LOW, 1000},
403 {106, GPIOF_OUT_INIT_HIGH, 4000},
404};
405
406static struct msm_camera_gpio_conf msm_8x60_back_cam_gpio_conf = {
407 .cam_gpio_common_tbl = msm8x60_common_cam_gpio,
408 .cam_gpio_common_tbl_size = ARRAY_SIZE(msm8x60_common_cam_gpio),
409 .cam_gpio_req_tbl = msm8x60_back_cam_gpio,
410 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm8x60_back_cam_gpio),
411 .cam_gpio_set_tbl = msm8x60_back_cam_gpio_set_tbl,
412 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm8x60_back_cam_gpio_set_tbl),
413};
414
415
416static struct i2c_board_info imx074_actuator_i2c_info = {
Kevin Chan197dbf32012-04-26 17:12:29 -0700417 I2C_BOARD_INFO("msm_actuator", 0x11),
Kevin Chan3be11612012-03-22 20:05:40 -0700418};
419
420static struct msm_actuator_info imx074_actuator_info = {
421 .board_info = &imx074_actuator_i2c_info,
Kevin Chan197dbf32012-04-26 17:12:29 -0700422 .cam_name = MSM_ACTUATOR_MAIN_CAM_0,
Kevin Chan3be11612012-03-22 20:05:40 -0700423 .bus_id = MSM_GSBI4_QUP_I2C_BUS_ID,
Kevin Chan197dbf32012-04-26 17:12:29 -0700424 .vcm_enable = 0,
Kevin Chan3be11612012-03-22 20:05:40 -0700425};
426
427static struct msm_camera_sensor_flash_data flash_imx074 = {
428 .flash_type = MSM_CAMERA_FLASH_LED,
429#ifdef CONFIG_MSM_CAMERA_FLASH
430 .flash_src = &msm_flash_src,
431#endif
432};
433
434static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
Ankit Premrajka13d7cb52012-04-12 22:06:39 -0700435 .mount_angle = 180,
Kevin Chan3be11612012-03-22 20:05:40 -0700436 .cam_vreg = msm_8x60_back_cam_vreg,
437 .num_vreg = ARRAY_SIZE(msm_8x60_back_cam_vreg),
438 .gpio_conf = &msm_8x60_back_cam_gpio_conf,
439};
440
441static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
442 .sensor_name = "imx074",
443 .pdata = &msm_camera_csi_device_data[0],
444 .flash_data = &flash_imx074,
445 .strobe_flash_data = &strobe_flash_xenon,
446 .sensor_platform_info = &sensor_board_info_imx074,
447 .csi_if = 1,
448 .camera_type = BACK_CAMERA_2D,
449 .actuator_info = &imx074_actuator_info
450};
451
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -0700452static struct msm_camera_sensor_flash_data flash_mt9e013 = {
453 .flash_type = MSM_CAMERA_FLASH_NONE,
454};
455
456static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = {
457 .mount_angle = 0,
458 .cam_vreg = msm_8x60_back_cam_vreg,
459 .num_vreg = ARRAY_SIZE(msm_8x60_back_cam_vreg),
460 .gpio_conf = &msm_8x60_back_cam_gpio_conf,
461};
462
463static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
464 .sensor_name = "mt9e013",
465 .pdata = &msm_camera_csi_device_data[0],
466 .flash_data = &flash_mt9e013,
467 .sensor_platform_info = &sensor_board_info_mt9e013,
468 .csi_if = 1,
469 .camera_type = BACK_CAMERA_2D,
470};
471
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -0700472static struct gpio ov7692_cam_gpio[] = {
473 {GPIO_WEB_CAMIF_STANDBY1, GPIOF_DIR_OUT, "CAM_EN"},
474};
475
476static struct msm_gpio_set_tbl ov7692_cam_gpio_set_tbl[] = {
477 {GPIO_WEB_CAMIF_STANDBY1, GPIOF_OUT_INIT_LOW, 10000},
478};
479
480static struct msm_camera_gpio_conf ov7692_cam_gpio_conf = {
481 .cam_gpio_common_tbl = msm8x60_common_cam_gpio,
482 .cam_gpio_common_tbl_size = ARRAY_SIZE(msm8x60_common_cam_gpio),
483 .cam_gpio_req_tbl = ov7692_cam_gpio,
484 .cam_gpio_req_tbl_size = ARRAY_SIZE(ov7692_cam_gpio),
485 .cam_gpio_set_tbl = ov7692_cam_gpio_set_tbl,
486 .cam_gpio_set_tbl_size = ARRAY_SIZE(ov7692_cam_gpio_set_tbl),
487};
488
489static struct msm_camera_sensor_flash_data flash_ov7692 = {
490 .flash_type = MSM_CAMERA_FLASH_NONE,
491};
492
493static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = {
494 .mount_angle = 0,
495 .cam_vreg = msm_8x60_back_cam_vreg,
496 .num_vreg = ARRAY_SIZE(msm_8x60_back_cam_vreg),
497 .gpio_conf = &ov7692_cam_gpio_conf,
498};
499
500static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
501 .sensor_name = "ov7692",
502 .pdata = &msm_camera_csi_device_data[1],
503 .flash_data = &flash_ov7692,
504 .sensor_platform_info = &sensor_board_info_ov7692,
505 .csi_if = 1,
506 .camera_type = FRONT_CAMERA_2D,
507};
508
Kevin Chan94b4c832012-03-02 21:27:16 -0800509static struct platform_device msm_camera_server = {
510 .name = "msm_cam_server",
511 .id = 0,
512};
513
Kevin Chan3be11612012-03-22 20:05:40 -0700514void __init msm8x60_init_cam(void)
515{
Kevin Chan94b4c832012-03-02 21:27:16 -0800516 platform_device_register(&msm_camera_server);
Kevin Chan3be11612012-03-22 20:05:40 -0700517 platform_device_register(&msm_device_csic0);
518 platform_device_register(&msm_device_csic1);
519 platform_device_register(&msm_device_vfe);
520 platform_device_register(&msm_device_vpe);
521}
522
523#ifdef CONFIG_I2C
524static struct i2c_board_info msm8x60_camera_i2c_boardinfo[] = {
525 {
526 I2C_BOARD_INFO("imx074", 0x1A),
527 .platform_data = &msm_camera_sensor_imx074_data,
528 },
Sreesudhan Ramakrish Ramkumar93701d32012-04-26 15:04:05 -0700529 {
530 I2C_BOARD_INFO("mt9e013", 0x6C),
531 .platform_data = &msm_camera_sensor_mt9e013_data,
532 },
Sreesudhan Ramakrish Ramkumar9719a992012-04-16 15:28:05 -0700533 {
534 I2C_BOARD_INFO("ov7692", 0x78),
535 .platform_data = &msm_camera_sensor_ov7692_data,
536 },
Kevin Chan3be11612012-03-22 20:05:40 -0700537};
538
539struct msm_camera_board_info msm8x60_camera_board_info = {
540 .board_info = msm8x60_camera_i2c_boardinfo,
541 .num_i2c_board_info = ARRAY_SIZE(msm8x60_camera_i2c_boardinfo),
542};
543#endif