blob: 6b5f9170e578c5ac806913ac10d1cb4960eec28b [file] [log] [blame]
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08001/* Copyright (c) 2011, 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
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080014#include <asm/mach-types.h>
15#include <mach/board.h>
16#include <mach/msm_bus_board.h>
17#include <mach/gpio.h>
18#include <mach/gpiomux.h>
19#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080020#include "board-8930.h"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080021
22#if (defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)) && \
23 defined(CONFIG_I2C)
24
25static struct i2c_board_info cam_expander_i2c_info[] = {
26 {
27 I2C_BOARD_INFO("sx1508q", 0x22),
28 .platform_data = &msm8930_sx150x_data[SX150X_CAM]
29 },
30};
31
32static struct msm_cam_expander_info cam_expander_info[] = {
33 {
34 cam_expander_i2c_info,
35 MSM_8930_GSBI4_QUP_I2C_BUS_ID,
36 },
37};
38#endif
39
40static struct gpiomux_setting cam_settings[] = {
41 {
42 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
43 .drv = GPIOMUX_DRV_2MA,
44 .pull = GPIOMUX_PULL_DOWN,
45 },
46
47 {
48 .func = GPIOMUX_FUNC_1, /*active 1*/
49 .drv = GPIOMUX_DRV_2MA,
50 .pull = GPIOMUX_PULL_NONE,
51 },
52
53 {
54 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
55 .drv = GPIOMUX_DRV_2MA,
56 .pull = GPIOMUX_PULL_NONE,
57 },
58
59 {
60 .func = GPIOMUX_FUNC_1, /*active 3*/
61 .drv = GPIOMUX_DRV_8MA,
62 .pull = GPIOMUX_PULL_NONE,
63 },
64
65 {
66 .func = GPIOMUX_FUNC_5, /*active 4*/
67 .drv = GPIOMUX_DRV_8MA,
68 .pull = GPIOMUX_PULL_UP,
69 },
70
71 {
72 .func = GPIOMUX_FUNC_6, /*active 5*/
73 .drv = GPIOMUX_DRV_8MA,
74 .pull = GPIOMUX_PULL_UP,
75 },
76
77 {
78 .func = GPIOMUX_FUNC_2, /*active 6*/
79 .drv = GPIOMUX_DRV_2MA,
80 .pull = GPIOMUX_PULL_UP,
81 },
82
83 {
84 .func = GPIOMUX_FUNC_3, /*active 7*/
85 .drv = GPIOMUX_DRV_8MA,
86 .pull = GPIOMUX_PULL_UP,
87 },
88
89 {
90 .func = GPIOMUX_FUNC_GPIO, /*i2c suspend*/
91 .drv = GPIOMUX_DRV_2MA,
92 .pull = GPIOMUX_PULL_KEEPER,
93 },
94
95};
96
97
98static struct msm_gpiomux_config msm8960_cam_common_configs[] = {
99 {
100 .gpio = 2,
101 .settings = {
102 [GPIOMUX_ACTIVE] = &cam_settings[2],
103 [GPIOMUX_SUSPENDED] = &cam_settings[0],
104 },
105 },
106 {
107 .gpio = 3,
108 .settings = {
109 [GPIOMUX_ACTIVE] = &cam_settings[1],
110 [GPIOMUX_SUSPENDED] = &cam_settings[0],
111 },
112 },
113 {
114 .gpio = 4,
115 .settings = {
116 [GPIOMUX_ACTIVE] = &cam_settings[1],
117 [GPIOMUX_SUSPENDED] = &cam_settings[0],
118 },
119 },
120 {
121 .gpio = 5,
122 .settings = {
123 [GPIOMUX_ACTIVE] = &cam_settings[1],
124 [GPIOMUX_SUSPENDED] = &cam_settings[0],
125 },
126 },
127 {
128 .gpio = 76,
129 .settings = {
130 [GPIOMUX_ACTIVE] = &cam_settings[2],
131 [GPIOMUX_SUSPENDED] = &cam_settings[0],
132 },
133 },
134 {
135 .gpio = 107,
136 .settings = {
137 [GPIOMUX_ACTIVE] = &cam_settings[2],
138 [GPIOMUX_SUSPENDED] = &cam_settings[0],
139 },
140 },
141};
142
143static struct msm_gpiomux_config msm8960_cam_2d_configs[] = {
144 {
145 .gpio = 18,
146 .settings = {
147 [GPIOMUX_ACTIVE] = &cam_settings[3],
148 [GPIOMUX_SUSPENDED] = &cam_settings[8],
149 },
150 },
151 {
152 .gpio = 19,
153 .settings = {
154 [GPIOMUX_ACTIVE] = &cam_settings[3],
155 [GPIOMUX_SUSPENDED] = &cam_settings[8],
156 },
157 },
158 {
159 .gpio = 20,
160 .settings = {
161 [GPIOMUX_ACTIVE] = &cam_settings[3],
162 [GPIOMUX_SUSPENDED] = &cam_settings[8],
163 },
164 },
165 {
166 .gpio = 21,
167 .settings = {
168 [GPIOMUX_ACTIVE] = &cam_settings[3],
169 [GPIOMUX_SUSPENDED] = &cam_settings[8],
170 },
171 },
172};
173
174#ifdef CONFIG_MSM_CAMERA
175
176static uint16_t msm_cam_gpio_2d_tbl[] = {
177 5, /*CAMIF_MCLK*/
178 20, /*CAMIF_I2C_DATA*/
179 21, /*CAMIF_I2C_CLK*/
180};
181
182static struct msm_camera_gpio_conf gpio_conf = {
183 .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
184 .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
185 .cam_gpio_tbl = msm_cam_gpio_2d_tbl,
186 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_2d_tbl),
187};
188
189#define VFE_CAMIF_TIMER1_GPIO 2
190#define VFE_CAMIF_TIMER2_GPIO 3
191#define VFE_CAMIF_TIMER3_GPIO_INT 4
192static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
193 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
194 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
195 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
196 .flash_recharge_duration = 50000,
197 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
198};
199
200#ifdef CONFIG_MSM_CAMERA_FLASH
201static struct msm_camera_sensor_flash_src msm_flash_src = {
202 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
203 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
204 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
205#if defined(CONFIG_I2C) && (defined(CONFIG_GPIO_SX150X) || \
206 defined(CONFIG_GPIO_SX150X_MODULE))
207 ._fsrc.ext_driver_src.expander_info = cam_expander_info,
208#endif
209};
210#endif
211
212static struct msm_bus_vectors cam_init_vectors[] = {
213 {
214 .src = MSM_BUS_MASTER_VFE,
215 .dst = MSM_BUS_SLAVE_EBI_CH0,
216 .ab = 0,
217 .ib = 0,
218 },
219 {
220 .src = MSM_BUS_MASTER_VPE,
221 .dst = MSM_BUS_SLAVE_EBI_CH0,
222 .ab = 0,
223 .ib = 0,
224 },
225 {
226 .src = MSM_BUS_MASTER_JPEG_ENC,
227 .dst = MSM_BUS_SLAVE_EBI_CH0,
228 .ab = 0,
229 .ib = 0,
230 },
231};
232
233static struct msm_bus_vectors cam_preview_vectors[] = {
234 {
235 .src = MSM_BUS_MASTER_VFE,
236 .dst = MSM_BUS_SLAVE_EBI_CH0,
237 .ab = 27648000,
238 .ib = 110592000,
239 },
240 {
241 .src = MSM_BUS_MASTER_VPE,
242 .dst = MSM_BUS_SLAVE_EBI_CH0,
243 .ab = 0,
244 .ib = 0,
245 },
246 {
247 .src = MSM_BUS_MASTER_JPEG_ENC,
248 .dst = MSM_BUS_SLAVE_EBI_CH0,
249 .ab = 0,
250 .ib = 0,
251 },
252};
253
254static struct msm_bus_vectors cam_video_vectors[] = {
255 {
256 .src = MSM_BUS_MASTER_VFE,
257 .dst = MSM_BUS_SLAVE_EBI_CH0,
258 .ab = 140451840,
259 .ib = 561807360,
260 },
261 {
262 .src = MSM_BUS_MASTER_VPE,
263 .dst = MSM_BUS_SLAVE_EBI_CH0,
264 .ab = 206807040,
265 .ib = 488816640,
266 },
267 {
268 .src = MSM_BUS_MASTER_JPEG_ENC,
269 .dst = MSM_BUS_SLAVE_EBI_CH0,
270 .ab = 0,
271 .ib = 0,
272 },
273};
274
275static struct msm_bus_vectors cam_snapshot_vectors[] = {
276 {
277 .src = MSM_BUS_MASTER_VFE,
278 .dst = MSM_BUS_SLAVE_EBI_CH0,
279 .ab = 274423680,
280 .ib = 1097694720,
281 },
282 {
283 .src = MSM_BUS_MASTER_VPE,
284 .dst = MSM_BUS_SLAVE_EBI_CH0,
285 .ab = 0,
286 .ib = 0,
287 },
288 {
289 .src = MSM_BUS_MASTER_JPEG_ENC,
290 .dst = MSM_BUS_SLAVE_EBI_CH0,
291 .ab = 540000000,
292 .ib = 1350000000,
293 },
294};
295
296static struct msm_bus_vectors cam_zsl_vectors[] = {
297 {
298 .src = MSM_BUS_MASTER_VFE,
299 .dst = MSM_BUS_SLAVE_EBI_CH0,
300 .ab = 302071680,
301 .ib = 1208286720,
302 },
303 {
304 .src = MSM_BUS_MASTER_VPE,
305 .dst = MSM_BUS_SLAVE_EBI_CH0,
306 .ab = 0,
307 .ib = 0,
308 },
309 {
310 .src = MSM_BUS_MASTER_JPEG_ENC,
311 .dst = MSM_BUS_SLAVE_EBI_CH0,
312 .ab = 540000000,
313 .ib = 1350000000,
314 },
315};
316
317static struct msm_bus_paths cam_bus_client_config[] = {
318 {
319 ARRAY_SIZE(cam_init_vectors),
320 cam_init_vectors,
321 },
322 {
323 ARRAY_SIZE(cam_preview_vectors),
324 cam_preview_vectors,
325 },
326 {
327 ARRAY_SIZE(cam_video_vectors),
328 cam_video_vectors,
329 },
330 {
331 ARRAY_SIZE(cam_snapshot_vectors),
332 cam_snapshot_vectors,
333 },
334 {
335 ARRAY_SIZE(cam_zsl_vectors),
336 cam_zsl_vectors,
337 },
338};
339
340static struct msm_bus_scale_pdata cam_bus_client_pdata = {
341 cam_bus_client_config,
342 ARRAY_SIZE(cam_bus_client_config),
343 .name = "msm_camera",
344};
345
346static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
347 {
348 .ioclk.mclk_clk_rate = 24000000,
349 .ioclk.vfe_clk_rate = 228570000,
350 .csid_core = 0,
351 .cam_bus_scale_table = &cam_bus_client_pdata,
352 },
353 {
354 .ioclk.mclk_clk_rate = 24000000,
355 .ioclk.vfe_clk_rate = 228570000,
356 .csid_core = 1,
357 .cam_bus_scale_table = &cam_bus_client_pdata,
358 },
359};
360
361#ifdef CONFIG_IMX074_ACT
362static struct i2c_board_info imx074_actuator_i2c_info = {
363 I2C_BOARD_INFO("imx074_act", 0x11),
364};
365
366static struct msm_actuator_info imx074_actuator_info = {
367 .board_info = &imx074_actuator_i2c_info,
368 .bus_id = MSM_8930_GSBI4_QUP_I2C_BUS_ID,
369 .vcm_pwd = 0,
370 .vcm_enable = 1,
371};
372#endif
373
374#ifdef CONFIG_IMX074
375static struct msm_camera_sensor_flash_data flash_imx074 = {
376 .flash_type = MSM_CAMERA_FLASH_LED,
377#ifdef CONFIG_MSM_CAMERA_FLASH
378 .flash_src = &msm_flash_src
379#endif
380};
381
382static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
383 .mount_angle = 90,
384 .sensor_reset = 107,
385 .sensor_pwd = 85,
386 .vcm_pwd = 0,
387 .vcm_enable = 1,
388};
389
390static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
391 .sensor_name = "imx074",
392 .pdata = &msm_camera_csi_device_data[0],
393 .flash_data = &flash_imx074,
394 .strobe_flash_data = &strobe_flash_xenon,
395 .sensor_platform_info = &sensor_board_info_imx074,
396 .gpio_conf = &gpio_conf,
397 .csi_if = 1,
398 .camera_type = BACK_CAMERA_2D,
399#ifdef CONFIG_IMX074_ACT
400 .actuator_info = &imx074_actuator_info
401#endif
402};
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800403#endif
Sreesudhan Ramakrish Ramkumarbc5f5b82011-12-28 17:10:30 -0800404
405#ifdef CONFIG_MT9M114
406static struct msm_camera_sensor_flash_data flash_mt9m114 = {
407 .flash_type = MSM_CAMERA_FLASH_NONE
408};
409
410static struct msm_camera_sensor_platform_info sensor_board_info_mt9m114 = {
411 .mount_angle = 90,
412 .sensor_reset = 107,
413};
414
415static struct msm_camera_sensor_info msm_camera_sensor_mt9m114_data = {
416 .sensor_name = "mt9m114",
417 .pdata = &msm_camera_csi_device_data[0],
418 .flash_data = &flash_mt9m114,
419 .sensor_platform_info = &sensor_board_info_mt9m114,
420 .gpio_conf = &gpio_conf,
421 .csi_if = 1,
422 .camera_type = BACK_CAMERA_2D,
423};
424#endif
425
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800426#ifdef CONFIG_OV2720
427static struct msm_camera_sensor_flash_data flash_ov2720 = {
428 .flash_type = MSM_CAMERA_FLASH_NONE,
429};
430
431static struct msm_camera_sensor_platform_info sensor_board_info_ov2720 = {
432 .mount_angle = 0,
433 .sensor_reset = 76,
434 .sensor_pwd = 85,
435 .vcm_pwd = 0,
436 .vcm_enable = 1,
437};
438
439static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
440 .sensor_name = "ov2720",
441 .pdata = &msm_camera_csi_device_data[1],
442 .flash_data = &flash_ov2720,
443 .sensor_platform_info = &sensor_board_info_ov2720,
444 .gpio_conf = &gpio_conf,
445 .csi_if = 1,
446 .camera_type = FRONT_CAMERA_2D,
447};
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800448#endif
449
450void __init msm8930_init_cam(void)
451{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800452 msm_gpiomux_install(msm8960_cam_common_configs,
453 ARRAY_SIZE(msm8960_cam_common_configs));
454
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800455 platform_device_register(&msm8960_device_csiphy0);
456 platform_device_register(&msm8960_device_csiphy1);
457 platform_device_register(&msm8960_device_csid0);
458 platform_device_register(&msm8960_device_csid1);
459 platform_device_register(&msm8960_device_ispif);
460 platform_device_register(&msm8960_device_vfe);
461 platform_device_register(&msm8960_device_vpe);
462}
Kevin Chan09f4e662011-12-16 08:17:02 -0800463
464#ifdef CONFIG_I2C
465struct i2c_board_info msm8930_camera_i2c_boardinfo[] = {
466#ifdef CONFIG_IMX074
467 {
468 I2C_BOARD_INFO("imx074", 0x1A),
469 .platform_data = &msm_camera_sensor_imx074_data,
470 },
471#endif
472#ifdef CONFIG_OV2720
473 {
474 I2C_BOARD_INFO("ov2720", 0x6C),
475 .platform_data = &msm_camera_sensor_ov2720_data,
476 },
477#endif
Sreesudhan Ramakrish Ramkumarbc5f5b82011-12-28 17:10:30 -0800478 {
479 I2C_BOARD_INFO("mt9m114", 0x48),
480 .platform_data = &msm_camera_sensor_mt9m114_data,
481 },
Kevin Chan09f4e662011-12-16 08:17:02 -0800482#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
483 {
484 I2C_BOARD_INFO("sc628a", 0x6E),
485 },
486#endif
487};
488
489struct msm_camera_board_info msm8930_camera_board_info = {
490 .board_info = msm8930_camera_i2c_boardinfo,
491 .num_i2c_board_info = ARRAY_SIZE(msm8930_camera_i2c_boardinfo),
492};
493#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800494#endif