blob: f30f0bfc9a38f902897de325449d267325c584c4 [file] [log] [blame]
Kevin Chan412e9f92012-01-24 10:45:23 -08001/* 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 <linux/i2c.h>
16#include <mach/board.h>
17#include <mach/msm_bus_board.h>
18#include <mach/gpio.h>
19#include <mach/gpiomux.h>
20
21#include "devices.h"
22#include "board-8064.h"
23
24static struct gpiomux_setting cam_settings[] = {
25 {
26 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
27 .drv = GPIOMUX_DRV_2MA,
28 .pull = GPIOMUX_PULL_DOWN,
29 },
30
31 {
32 .func = GPIOMUX_FUNC_1, /*active 1*/
33 .drv = GPIOMUX_DRV_2MA,
34 .pull = GPIOMUX_PULL_NONE,
35 },
36
37 {
38 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
39 .drv = GPIOMUX_DRV_2MA,
40 .pull = GPIOMUX_PULL_NONE,
41 },
42
43 {
44 .func = GPIOMUX_FUNC_1, /*active 3*/
45 .drv = GPIOMUX_DRV_8MA,
46 .pull = GPIOMUX_PULL_NONE,
47 },
48
49 {
50 .func = GPIOMUX_FUNC_5, /*active 4*/
51 .drv = GPIOMUX_DRV_8MA,
52 .pull = GPIOMUX_PULL_UP,
53 },
54
55 {
56 .func = GPIOMUX_FUNC_6, /*active 5*/
57 .drv = GPIOMUX_DRV_8MA,
58 .pull = GPIOMUX_PULL_UP,
59 },
60
61 {
62 .func = GPIOMUX_FUNC_2, /*active 6*/
63 .drv = GPIOMUX_DRV_2MA,
64 .pull = GPIOMUX_PULL_UP,
65 },
66
67 {
68 .func = GPIOMUX_FUNC_3, /*active 7*/
69 .drv = GPIOMUX_DRV_8MA,
70 .pull = GPIOMUX_PULL_UP,
71 },
72
73 {
74 .func = GPIOMUX_FUNC_GPIO, /*i2c suspend*/
75 .drv = GPIOMUX_DRV_2MA,
76 .pull = GPIOMUX_PULL_KEEPER,
77 },
78
79};
80
81
82static struct msm_gpiomux_config apq8064_cam_common_configs[] = {
83 {
84 .gpio = 2,
85 .settings = {
86 [GPIOMUX_ACTIVE] = &cam_settings[2],
87 [GPIOMUX_SUSPENDED] = &cam_settings[0],
88 },
89 },
90 {
91 .gpio = 3,
92 .settings = {
93 [GPIOMUX_ACTIVE] = &cam_settings[1],
94 [GPIOMUX_SUSPENDED] = &cam_settings[0],
95 },
96 },
97 {
98 .gpio = 4,
99 .settings = {
100 [GPIOMUX_ACTIVE] = &cam_settings[1],
101 [GPIOMUX_SUSPENDED] = &cam_settings[0],
102 },
103 },
104 {
105 .gpio = 5,
106 .settings = {
107 [GPIOMUX_ACTIVE] = &cam_settings[1],
108 [GPIOMUX_SUSPENDED] = &cam_settings[0],
109 },
110 },
111 {
112 .gpio = 76,
113 .settings = {
114 [GPIOMUX_ACTIVE] = &cam_settings[2],
115 [GPIOMUX_SUSPENDED] = &cam_settings[0],
116 },
117 },
118 {
119 .gpio = 107,
120 .settings = {
121 [GPIOMUX_ACTIVE] = &cam_settings[2],
122 [GPIOMUX_SUSPENDED] = &cam_settings[0],
123 },
124 },
125};
126
127static struct msm_gpiomux_config apq8064_cam_2d_configs[] = {
128 {
129 .gpio = 10,
130 .settings = {
131 [GPIOMUX_ACTIVE] = &cam_settings[3],
132 [GPIOMUX_SUSPENDED] = &cam_settings[8],
133 },
134 },
135 {
136 .gpio = 11,
137 .settings = {
138 [GPIOMUX_ACTIVE] = &cam_settings[3],
139 [GPIOMUX_SUSPENDED] = &cam_settings[8],
140 },
141 },
142 {
143 .gpio = 12,
144 .settings = {
145 [GPIOMUX_ACTIVE] = &cam_settings[3],
146 [GPIOMUX_SUSPENDED] = &cam_settings[8],
147 },
148 },
149 {
150 .gpio = 13,
151 .settings = {
152 [GPIOMUX_ACTIVE] = &cam_settings[3],
153 [GPIOMUX_SUSPENDED] = &cam_settings[8],
154 },
155 },
156};
157
158#ifdef CONFIG_MSM_CAMERA
159
160static uint16_t msm_cam_gpio_2d_tbl[] = {
161 5, /*CAMIF_MCLK*/
162 10, /*CAMIF_I2C_DATA*/
163 11, /*CAMIF_I2C_CLK*/
164};
165
166static struct msm_camera_gpio_conf gpio_conf = {
167 .cam_gpiomux_conf_tbl = apq8064_cam_2d_configs,
168 .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(apq8064_cam_2d_configs),
169 .cam_gpio_tbl = msm_cam_gpio_2d_tbl,
170 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_2d_tbl),
171};
172
173static struct msm_bus_vectors cam_init_vectors[] = {
174 {
175 .src = MSM_BUS_MASTER_VFE,
176 .dst = MSM_BUS_SLAVE_EBI_CH0,
177 .ab = 0,
178 .ib = 0,
179 },
180 {
181 .src = MSM_BUS_MASTER_VPE,
182 .dst = MSM_BUS_SLAVE_EBI_CH0,
183 .ab = 0,
184 .ib = 0,
185 },
186 {
187 .src = MSM_BUS_MASTER_JPEG_ENC,
188 .dst = MSM_BUS_SLAVE_EBI_CH0,
189 .ab = 0,
190 .ib = 0,
191 },
192};
193
194static struct msm_bus_vectors cam_preview_vectors[] = {
195 {
196 .src = MSM_BUS_MASTER_VFE,
197 .dst = MSM_BUS_SLAVE_EBI_CH0,
198 .ab = 27648000,
199 .ib = 110592000,
200 },
201 {
202 .src = MSM_BUS_MASTER_VPE,
203 .dst = MSM_BUS_SLAVE_EBI_CH0,
204 .ab = 0,
205 .ib = 0,
206 },
207 {
208 .src = MSM_BUS_MASTER_JPEG_ENC,
209 .dst = MSM_BUS_SLAVE_EBI_CH0,
210 .ab = 0,
211 .ib = 0,
212 },
213};
214
215static struct msm_bus_vectors cam_video_vectors[] = {
216 {
217 .src = MSM_BUS_MASTER_VFE,
218 .dst = MSM_BUS_SLAVE_EBI_CH0,
219 .ab = 140451840,
220 .ib = 561807360,
221 },
222 {
223 .src = MSM_BUS_MASTER_VPE,
224 .dst = MSM_BUS_SLAVE_EBI_CH0,
225 .ab = 206807040,
226 .ib = 488816640,
227 },
228 {
229 .src = MSM_BUS_MASTER_JPEG_ENC,
230 .dst = MSM_BUS_SLAVE_EBI_CH0,
231 .ab = 0,
232 .ib = 0,
233 },
234};
235
236static struct msm_bus_vectors cam_snapshot_vectors[] = {
237 {
238 .src = MSM_BUS_MASTER_VFE,
239 .dst = MSM_BUS_SLAVE_EBI_CH0,
240 .ab = 274423680,
241 .ib = 1097694720,
242 },
243 {
244 .src = MSM_BUS_MASTER_VPE,
245 .dst = MSM_BUS_SLAVE_EBI_CH0,
246 .ab = 0,
247 .ib = 0,
248 },
249 {
250 .src = MSM_BUS_MASTER_JPEG_ENC,
251 .dst = MSM_BUS_SLAVE_EBI_CH0,
252 .ab = 540000000,
253 .ib = 1350000000,
254 },
255};
256
257static struct msm_bus_vectors cam_zsl_vectors[] = {
258 {
259 .src = MSM_BUS_MASTER_VFE,
260 .dst = MSM_BUS_SLAVE_EBI_CH0,
261 .ab = 302071680,
262 .ib = 1208286720,
263 },
264 {
265 .src = MSM_BUS_MASTER_VPE,
266 .dst = MSM_BUS_SLAVE_EBI_CH0,
267 .ab = 0,
268 .ib = 0,
269 },
270 {
271 .src = MSM_BUS_MASTER_JPEG_ENC,
272 .dst = MSM_BUS_SLAVE_EBI_CH0,
273 .ab = 540000000,
274 .ib = 1350000000,
275 },
276};
277
278static struct msm_bus_paths cam_bus_client_config[] = {
279 {
280 ARRAY_SIZE(cam_init_vectors),
281 cam_init_vectors,
282 },
283 {
284 ARRAY_SIZE(cam_preview_vectors),
285 cam_preview_vectors,
286 },
287 {
288 ARRAY_SIZE(cam_video_vectors),
289 cam_video_vectors,
290 },
291 {
292 ARRAY_SIZE(cam_snapshot_vectors),
293 cam_snapshot_vectors,
294 },
295 {
296 ARRAY_SIZE(cam_zsl_vectors),
297 cam_zsl_vectors,
298 },
299};
300
301static struct msm_bus_scale_pdata cam_bus_client_pdata = {
302 cam_bus_client_config,
303 ARRAY_SIZE(cam_bus_client_config),
304 .name = "msm_camera",
305};
306
307static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
308 {
309 .ioclk.mclk_clk_rate = 24000000,
310 .ioclk.vfe_clk_rate = 228570000,
311 .csid_core = 0,
312 .cam_bus_scale_table = &cam_bus_client_pdata,
313 },
314 {
315 .ioclk.mclk_clk_rate = 24000000,
316 .ioclk.vfe_clk_rate = 228570000,
317 .csid_core = 1,
318 .cam_bus_scale_table = &cam_bus_client_pdata,
319 },
320};
321
322#ifdef CONFIG_IMX074
323static struct msm_camera_sensor_flash_data flash_imx074 = {
324 .flash_type = MSM_CAMERA_FLASH_NONE,
325};
326
327static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
328 .mount_angle = 90,
329 .sensor_reset = 107,
330 .sensor_pwd = 85,
331 .vcm_pwd = 0,
332 .vcm_enable = 1,
333};
334
335static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
336 .sensor_name = "imx074",
337 .pdata = &msm_camera_csi_device_data[0],
338 .flash_data = &flash_imx074,
339 .sensor_platform_info = &sensor_board_info_imx074,
340 .gpio_conf = &gpio_conf,
341 .csi_if = 1,
342 .camera_type = BACK_CAMERA_2D,
343};
344#endif
345
346void __init apq8064_init_cam(void)
347{
348 msm_gpiomux_install(apq8064_cam_common_configs,
349 ARRAY_SIZE(apq8064_cam_common_configs));
350
351 platform_device_register(&msm8960_device_csiphy0);
352 platform_device_register(&msm8960_device_csiphy1);
353 platform_device_register(&msm8960_device_csid0);
354 platform_device_register(&msm8960_device_csid1);
355 platform_device_register(&msm8960_device_ispif);
356 platform_device_register(&msm8960_device_vfe);
357 platform_device_register(&msm8960_device_vpe);
358}
359
360#ifdef CONFIG_I2C
361static struct i2c_board_info apq8064_camera_i2c_boardinfo[] = {
362#ifdef CONFIG_IMX074
363 {
364 I2C_BOARD_INFO("imx074", 0x1A),
365 .platform_data = &msm_camera_sensor_imx074_data,
366 },
367#endif
368};
369
370struct msm_camera_board_info apq8064_camera_board_info = {
371 .board_info = apq8064_camera_i2c_boardinfo,
372 .num_i2c_board_info = ARRAY_SIZE(apq8064_camera_i2c_boardinfo),
373};
374#endif
375#endif