blob: 95561e4ec306a3f898962d92490b1e97876bc71b [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>
15#include <devices-msm8x60.h>
16#include <linux/gpio.h>
17#include <linux/i2c.h>
18#include <linux/mfd/pmic8901.h>
19#include <mach/board.h>
20#include <mach/board-msm8660.h>
21#include <mach/gpiomux.h>
22#include <mach/msm_bus_board.h>
23#include "devices.h"
24
25#define GPIO_EXT_CAMIF_PWR_EN1 (PM8901_MPP_BASE + PM8901_MPPS + 13)
26#ifdef CONFIG_MSM_CAMERA_FLASH
27#define VFE_CAMIF_TIMER1_GPIO 29
28#define VFE_CAMIF_TIMER2_GPIO 30
29#define VFE_CAMIF_TIMER3_GPIO_INT 31
30#define FUSION_VFE_CAMIF_TIMER1_GPIO 42
31
32static struct msm_camera_sensor_flash_src msm_flash_src = {
33 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
34 ._fsrc.pmic_src.num_of_src = 2,
35 ._fsrc.pmic_src.low_current = 100,
36 ._fsrc.pmic_src.high_current = 300,
37 ._fsrc.pmic_src.led_src_1 = PMIC8058_ID_FLASH_LED_0,
38 ._fsrc.pmic_src.led_src_2 = PMIC8058_ID_FLASH_LED_1,
39 ._fsrc.pmic_src.pmic_set_current = pm8058_set_flash_led_current,
40};
41static struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
42 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
43 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
44 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
45 .flash_recharge_duration = 50000,
46 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
47};
48#endif
49
50static struct msm_bus_vectors cam_init_vectors[] = {
51 {
52 .src = MSM_BUS_MASTER_VFE,
53 .dst = MSM_BUS_SLAVE_SMI,
54 .ab = 0,
55 .ib = 0,
56 },
57 {
58 .src = MSM_BUS_MASTER_VFE,
59 .dst = MSM_BUS_SLAVE_EBI_CH0,
60 .ab = 0,
61 .ib = 0,
62 },
63 {
64 .src = MSM_BUS_MASTER_VPE,
65 .dst = MSM_BUS_SLAVE_SMI,
66 .ab = 0,
67 .ib = 0,
68 },
69 {
70 .src = MSM_BUS_MASTER_VPE,
71 .dst = MSM_BUS_SLAVE_EBI_CH0,
72 .ab = 0,
73 .ib = 0,
74 },
75 {
76 .src = MSM_BUS_MASTER_JPEG_ENC,
77 .dst = MSM_BUS_SLAVE_SMI,
78 .ab = 0,
79 .ib = 0,
80 },
81 {
82 .src = MSM_BUS_MASTER_JPEG_ENC,
83 .dst = MSM_BUS_SLAVE_EBI_CH0,
84 .ab = 0,
85 .ib = 0,
86 },
87};
88
89static struct msm_bus_vectors cam_preview_vectors[] = {
90 {
91 .src = MSM_BUS_MASTER_VFE,
92 .dst = MSM_BUS_SLAVE_SMI,
93 .ab = 0,
94 .ib = 0,
95 },
96 {
97 .src = MSM_BUS_MASTER_VFE,
98 .dst = MSM_BUS_SLAVE_EBI_CH0,
99 .ab = 283115520,
100 .ib = 452984832,
101 },
102 {
103 .src = MSM_BUS_MASTER_VPE,
104 .dst = MSM_BUS_SLAVE_SMI,
105 .ab = 0,
106 .ib = 0,
107 },
108 {
109 .src = MSM_BUS_MASTER_VPE,
110 .dst = MSM_BUS_SLAVE_EBI_CH0,
111 .ab = 0,
112 .ib = 0,
113 },
114 {
115 .src = MSM_BUS_MASTER_JPEG_ENC,
116 .dst = MSM_BUS_SLAVE_SMI,
117 .ab = 0,
118 .ib = 0,
119 },
120 {
121 .src = MSM_BUS_MASTER_JPEG_ENC,
122 .dst = MSM_BUS_SLAVE_EBI_CH0,
123 .ab = 0,
124 .ib = 0,
125 },
126};
127
128static struct msm_bus_vectors cam_video_vectors[] = {
129 {
130 .src = MSM_BUS_MASTER_VFE,
131 .dst = MSM_BUS_SLAVE_SMI,
132 .ab = 283115520,
133 .ib = 452984832,
134 },
135 {
136 .src = MSM_BUS_MASTER_VFE,
137 .dst = MSM_BUS_SLAVE_EBI_CH0,
138 .ab = 283115520,
139 .ib = 452984832,
140 },
141 {
142 .src = MSM_BUS_MASTER_VPE,
143 .dst = MSM_BUS_SLAVE_SMI,
144 .ab = 319610880,
145 .ib = 511377408,
146 },
147 {
148 .src = MSM_BUS_MASTER_VPE,
149 .dst = MSM_BUS_SLAVE_EBI_CH0,
150 .ab = 0,
151 .ib = 0,
152 },
153 {
154 .src = MSM_BUS_MASTER_JPEG_ENC,
155 .dst = MSM_BUS_SLAVE_SMI,
156 .ab = 0,
157 .ib = 0,
158 },
159 {
160 .src = MSM_BUS_MASTER_JPEG_ENC,
161 .dst = MSM_BUS_SLAVE_EBI_CH0,
162 .ab = 0,
163 .ib = 0,
164 },
165};
166
167static struct msm_bus_vectors cam_snapshot_vectors[] = {
168 {
169 .src = MSM_BUS_MASTER_VFE,
170 .dst = MSM_BUS_SLAVE_SMI,
171 .ab = 566231040,
172 .ib = 905969664,
173 },
174 {
175 .src = MSM_BUS_MASTER_VFE,
176 .dst = MSM_BUS_SLAVE_EBI_CH0,
177 .ab = 69984000,
178 .ib = 111974400,
179 },
180 {
181 .src = MSM_BUS_MASTER_VPE,
182 .dst = MSM_BUS_SLAVE_SMI,
183 .ab = 0,
184 .ib = 0,
185 },
186 {
187 .src = MSM_BUS_MASTER_VPE,
188 .dst = MSM_BUS_SLAVE_EBI_CH0,
189 .ab = 0,
190 .ib = 0,
191 },
192 {
193 .src = MSM_BUS_MASTER_JPEG_ENC,
194 .dst = MSM_BUS_SLAVE_SMI,
195 .ab = 320864256,
196 .ib = 513382810,
197 },
198 {
199 .src = MSM_BUS_MASTER_JPEG_ENC,
200 .dst = MSM_BUS_SLAVE_EBI_CH0,
201 .ab = 320864256,
202 .ib = 513382810,
203 },
204};
205
206static struct msm_bus_vectors cam_zsl_vectors[] = {
207 {
208 .src = MSM_BUS_MASTER_VFE,
209 .dst = MSM_BUS_SLAVE_SMI,
210 .ab = 566231040,
211 .ib = 905969664,
212 },
213 {
214 .src = MSM_BUS_MASTER_VFE,
215 .dst = MSM_BUS_SLAVE_EBI_CH0,
216 .ab = 706199040,
217 .ib = 1129918464,
218 },
219 {
220 .src = MSM_BUS_MASTER_VPE,
221 .dst = MSM_BUS_SLAVE_SMI,
222 .ab = 0,
223 .ib = 0,
224 },
225 {
226 .src = MSM_BUS_MASTER_VPE,
227 .dst = MSM_BUS_SLAVE_EBI_CH0,
228 .ab = 0,
229 .ib = 0,
230 },
231 {
232 .src = MSM_BUS_MASTER_JPEG_ENC,
233 .dst = MSM_BUS_SLAVE_SMI,
234 .ab = 320864256,
235 .ib = 513382810,
236 },
237 {
238 .src = MSM_BUS_MASTER_JPEG_ENC,
239 .dst = MSM_BUS_SLAVE_EBI_CH0,
240 .ab = 320864256,
241 .ib = 513382810,
242 },
243};
244
245static struct msm_bus_vectors cam_stereo_video_vectors[] = {
246 {
247 .src = MSM_BUS_MASTER_VFE,
248 .dst = MSM_BUS_SLAVE_SMI,
249 .ab = 212336640,
250 .ib = 339738624,
251 },
252 {
253 .src = MSM_BUS_MASTER_VFE,
254 .dst = MSM_BUS_SLAVE_EBI_CH0,
255 .ab = 25090560,
256 .ib = 40144896,
257 },
258 {
259 .src = MSM_BUS_MASTER_VPE,
260 .dst = MSM_BUS_SLAVE_SMI,
261 .ab = 239708160,
262 .ib = 383533056,
263 },
264 {
265 .src = MSM_BUS_MASTER_VPE,
266 .dst = MSM_BUS_SLAVE_EBI_CH0,
267 .ab = 79902720,
268 .ib = 127844352,
269 },
270 {
271 .src = MSM_BUS_MASTER_JPEG_ENC,
272 .dst = MSM_BUS_SLAVE_SMI,
273 .ab = 0,
274 .ib = 0,
275 },
276 {
277 .src = MSM_BUS_MASTER_JPEG_ENC,
278 .dst = MSM_BUS_SLAVE_EBI_CH0,
279 .ab = 0,
280 .ib = 0,
281 },
282};
283
284static struct msm_bus_vectors cam_stereo_snapshot_vectors[] = {
285 {
286 .src = MSM_BUS_MASTER_VFE,
287 .dst = MSM_BUS_SLAVE_SMI,
288 .ab = 0,
289 .ib = 0,
290 },
291 {
292 .src = MSM_BUS_MASTER_VFE,
293 .dst = MSM_BUS_SLAVE_EBI_CH0,
294 .ab = 300902400,
295 .ib = 481443840,
296 },
297 {
298 .src = MSM_BUS_MASTER_VPE,
299 .dst = MSM_BUS_SLAVE_SMI,
300 .ab = 230307840,
301 .ib = 368492544,
302 },
303 {
304 .src = MSM_BUS_MASTER_VPE,
305 .dst = MSM_BUS_SLAVE_EBI_CH0,
306 .ab = 245113344,
307 .ib = 392181351,
308 },
309 {
310 .src = MSM_BUS_MASTER_JPEG_ENC,
311 .dst = MSM_BUS_SLAVE_SMI,
312 .ab = 106536960,
313 .ib = 170459136,
314 },
315 {
316 .src = MSM_BUS_MASTER_JPEG_ENC,
317 .dst = MSM_BUS_SLAVE_EBI_CH0,
318 .ab = 106536960,
319 .ib = 170459136,
320 },
321};
322
323static struct msm_bus_paths cam_bus_client_config[] = {
324 {
325 ARRAY_SIZE(cam_init_vectors),
326 cam_zsl_vectors,
327 },
328 {
329 ARRAY_SIZE(cam_preview_vectors),
330 cam_zsl_vectors,
331 },
332 {
333 ARRAY_SIZE(cam_video_vectors),
334 cam_zsl_vectors,
335 },
336 {
337 ARRAY_SIZE(cam_snapshot_vectors),
338 cam_snapshot_vectors,
339 },
340 {
341 ARRAY_SIZE(cam_zsl_vectors),
342 cam_zsl_vectors,
343 },
344 {
345 ARRAY_SIZE(cam_stereo_video_vectors),
346 cam_stereo_video_vectors,
347 },
348 {
349 ARRAY_SIZE(cam_stereo_snapshot_vectors),
350 cam_stereo_snapshot_vectors,
351 },
352};
353
354static struct msm_bus_scale_pdata cam_bus_client_pdata = {
355 cam_bus_client_config,
356 ARRAY_SIZE(cam_bus_client_config),
357 .name = "msm_camera",
358};
359
360static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
361 {
362 .csid_core = 0,
363 .is_csic = 1,
364 .is_vpe = 1,
365 .cam_bus_scale_table = &cam_bus_client_pdata,
366 .ioclk = {
367 .vfe_clk_rate = 228570000,
368 },
369 },
370 {
371 .csid_core = 1,
372 .is_csic = 1,
373 .is_vpe = 1,
374 .cam_bus_scale_table = &cam_bus_client_pdata,
375 .ioclk = {
376 .vfe_clk_rate = 228570000,
377 },
378 },
379};
380static struct camera_vreg_t msm_8x60_back_cam_vreg[] = {
381 {"cam_vana", REG_LDO, 2850000, 2850000, -1},
382 {"cam_vio", REG_VS, 0, 0, 0},
383 {"cam_vdig", REG_LDO, 1200000, 1200000, -1},
384};
385
386static struct gpio msm8x60_common_cam_gpio[] = {
387 {32, GPIOF_DIR_IN, "CAMIF_MCLK"},
388 {47, GPIOF_DIR_IN, "CAMIF_I2C_DATA"},
389 {48, GPIOF_DIR_IN, "CAMIF_I2C_CLK"},
390 {105, GPIOF_DIR_IN, "STANDBY"},
391 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_DIR_OUT, "CAMIF_PWR_EN"},
392};
393
394static struct gpio msm8x60_back_cam_gpio[] = {
395 {106, GPIOF_DIR_OUT, "CAM_RESET"},
396};
397
398static struct msm_gpio_set_tbl msm8x60_back_cam_gpio_set_tbl[] = {
399 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_OUT_INIT_LOW, 10000},
400 {GPIO_EXT_CAMIF_PWR_EN1, GPIOF_OUT_INIT_HIGH, 5000},
401 {106, GPIOF_OUT_INIT_LOW, 1000},
402 {106, GPIOF_OUT_INIT_HIGH, 4000},
403};
404
405static struct msm_camera_gpio_conf msm_8x60_back_cam_gpio_conf = {
406 .cam_gpio_common_tbl = msm8x60_common_cam_gpio,
407 .cam_gpio_common_tbl_size = ARRAY_SIZE(msm8x60_common_cam_gpio),
408 .cam_gpio_req_tbl = msm8x60_back_cam_gpio,
409 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm8x60_back_cam_gpio),
410 .cam_gpio_set_tbl = msm8x60_back_cam_gpio_set_tbl,
411 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm8x60_back_cam_gpio_set_tbl),
412};
413
414
415static struct i2c_board_info imx074_actuator_i2c_info = {
416 I2C_BOARD_INFO("imx074_act", 0x11),
417};
418
419static struct msm_actuator_info imx074_actuator_info = {
420 .board_info = &imx074_actuator_i2c_info,
421 .bus_id = MSM_GSBI4_QUP_I2C_BUS_ID,
422 .vcm_pwd = 0,
423 .vcm_enable = 1,
424};
425
426static struct msm_camera_sensor_flash_data flash_imx074 = {
427 .flash_type = MSM_CAMERA_FLASH_LED,
428#ifdef CONFIG_MSM_CAMERA_FLASH
429 .flash_src = &msm_flash_src,
430#endif
431};
432
433static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
434 .mount_angle = 0,
435 .cam_vreg = msm_8x60_back_cam_vreg,
436 .num_vreg = ARRAY_SIZE(msm_8x60_back_cam_vreg),
437 .gpio_conf = &msm_8x60_back_cam_gpio_conf,
438};
439
440static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
441 .sensor_name = "imx074",
442 .pdata = &msm_camera_csi_device_data[0],
443 .flash_data = &flash_imx074,
444 .strobe_flash_data = &strobe_flash_xenon,
445 .sensor_platform_info = &sensor_board_info_imx074,
446 .csi_if = 1,
447 .camera_type = BACK_CAMERA_2D,
448 .actuator_info = &imx074_actuator_info
449};
450
451void __init msm8x60_init_cam(void)
452{
453 platform_device_register(&msm_device_csic0);
454 platform_device_register(&msm_device_csic1);
455 platform_device_register(&msm_device_vfe);
456 platform_device_register(&msm_device_vpe);
457}
458
459#ifdef CONFIG_I2C
460static struct i2c_board_info msm8x60_camera_i2c_boardinfo[] = {
461 {
462 I2C_BOARD_INFO("imx074", 0x1A),
463 .platform_data = &msm_camera_sensor_imx074_data,
464 },
465};
466
467struct msm_camera_board_info msm8x60_camera_board_info = {
468 .board_info = msm8x60_camera_i2c_boardinfo,
469 .num_i2c_board_info = ARRAY_SIZE(msm8x60_camera_i2c_boardinfo),
470};
471#endif