blob: cd84722df92b96f2849a3439e9a29ef7b3774892 [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>
Kevin Chaneb6b6072012-01-17 11:54:54 -080016#include <linux/gpio.h>
Kevin Chan412e9f92012-01-24 10:45:23 -080017#include <mach/board.h>
18#include <mach/msm_bus_board.h>
Kevin Chan412e9f92012-01-24 10:45:23 -080019#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
Kevin Chan412e9f92012-01-24 10:45:23 -0800160static struct msm_bus_vectors cam_init_vectors[] = {
161 {
162 .src = MSM_BUS_MASTER_VFE,
163 .dst = MSM_BUS_SLAVE_EBI_CH0,
164 .ab = 0,
165 .ib = 0,
166 },
167 {
168 .src = MSM_BUS_MASTER_VPE,
169 .dst = MSM_BUS_SLAVE_EBI_CH0,
170 .ab = 0,
171 .ib = 0,
172 },
173 {
174 .src = MSM_BUS_MASTER_JPEG_ENC,
175 .dst = MSM_BUS_SLAVE_EBI_CH0,
176 .ab = 0,
177 .ib = 0,
178 },
179};
180
181static struct msm_bus_vectors cam_preview_vectors[] = {
182 {
183 .src = MSM_BUS_MASTER_VFE,
184 .dst = MSM_BUS_SLAVE_EBI_CH0,
185 .ab = 27648000,
186 .ib = 110592000,
187 },
188 {
189 .src = MSM_BUS_MASTER_VPE,
190 .dst = MSM_BUS_SLAVE_EBI_CH0,
191 .ab = 0,
192 .ib = 0,
193 },
194 {
195 .src = MSM_BUS_MASTER_JPEG_ENC,
196 .dst = MSM_BUS_SLAVE_EBI_CH0,
197 .ab = 0,
198 .ib = 0,
199 },
200};
201
202static struct msm_bus_vectors cam_video_vectors[] = {
203 {
204 .src = MSM_BUS_MASTER_VFE,
205 .dst = MSM_BUS_SLAVE_EBI_CH0,
206 .ab = 140451840,
207 .ib = 561807360,
208 },
209 {
210 .src = MSM_BUS_MASTER_VPE,
211 .dst = MSM_BUS_SLAVE_EBI_CH0,
212 .ab = 206807040,
213 .ib = 488816640,
214 },
215 {
216 .src = MSM_BUS_MASTER_JPEG_ENC,
217 .dst = MSM_BUS_SLAVE_EBI_CH0,
218 .ab = 0,
219 .ib = 0,
220 },
221};
222
223static struct msm_bus_vectors cam_snapshot_vectors[] = {
224 {
225 .src = MSM_BUS_MASTER_VFE,
226 .dst = MSM_BUS_SLAVE_EBI_CH0,
227 .ab = 274423680,
228 .ib = 1097694720,
229 },
230 {
231 .src = MSM_BUS_MASTER_VPE,
232 .dst = MSM_BUS_SLAVE_EBI_CH0,
233 .ab = 0,
234 .ib = 0,
235 },
236 {
237 .src = MSM_BUS_MASTER_JPEG_ENC,
238 .dst = MSM_BUS_SLAVE_EBI_CH0,
239 .ab = 540000000,
240 .ib = 1350000000,
241 },
242};
243
244static struct msm_bus_vectors cam_zsl_vectors[] = {
245 {
246 .src = MSM_BUS_MASTER_VFE,
247 .dst = MSM_BUS_SLAVE_EBI_CH0,
248 .ab = 302071680,
249 .ib = 1208286720,
250 },
251 {
252 .src = MSM_BUS_MASTER_VPE,
253 .dst = MSM_BUS_SLAVE_EBI_CH0,
254 .ab = 0,
255 .ib = 0,
256 },
257 {
258 .src = MSM_BUS_MASTER_JPEG_ENC,
259 .dst = MSM_BUS_SLAVE_EBI_CH0,
260 .ab = 540000000,
261 .ib = 1350000000,
262 },
263};
264
265static struct msm_bus_paths cam_bus_client_config[] = {
266 {
267 ARRAY_SIZE(cam_init_vectors),
268 cam_init_vectors,
269 },
270 {
271 ARRAY_SIZE(cam_preview_vectors),
272 cam_preview_vectors,
273 },
274 {
275 ARRAY_SIZE(cam_video_vectors),
276 cam_video_vectors,
277 },
278 {
279 ARRAY_SIZE(cam_snapshot_vectors),
280 cam_snapshot_vectors,
281 },
282 {
283 ARRAY_SIZE(cam_zsl_vectors),
284 cam_zsl_vectors,
285 },
286};
287
288static struct msm_bus_scale_pdata cam_bus_client_pdata = {
289 cam_bus_client_config,
290 ARRAY_SIZE(cam_bus_client_config),
291 .name = "msm_camera",
292};
293
294static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
295 {
Kevin Chan412e9f92012-01-24 10:45:23 -0800296 .csid_core = 0,
Kevin Chaneb6b6072012-01-17 11:54:54 -0800297 .is_csiphy = 1,
298 .is_csid = 1,
299 .is_ispif = 1,
300 .is_vpe = 1,
Kevin Chan412e9f92012-01-24 10:45:23 -0800301 .cam_bus_scale_table = &cam_bus_client_pdata,
302 },
303 {
Kevin Chan412e9f92012-01-24 10:45:23 -0800304 .csid_core = 1,
Kevin Chaneb6b6072012-01-17 11:54:54 -0800305 .is_csiphy = 1,
306 .is_csid = 1,
307 .is_ispif = 1,
308 .is_vpe = 1,
Kevin Chan412e9f92012-01-24 10:45:23 -0800309 .cam_bus_scale_table = &cam_bus_client_pdata,
310 },
311};
312
Kevin Chaneb6b6072012-01-17 11:54:54 -0800313static struct camera_vreg_t msm_8064_back_cam_vreg[] = {
314 {"mipi_csi_vdd", REG_LDO, 1200000, 1200000, 20000},
315 {"cam_vana", REG_LDO, 2800000, 2850000, 85600},
316 {"cam_vio", REG_LDO, 1800000, 1800000, 16000},
317 {"cam_vdig", REG_LDO, 1200000, 1200000, 105000},
318 {"cam_vaf", REG_LDO, 2800000, 2850000, 300000},
319};
320
321static struct gpio apq8064_common_cam_gpio[] = {
322 {5, GPIOF_DIR_IN, "CAMIF_MCLK"},
323 {20, GPIOF_DIR_IN, "CAMIF_I2C_DATA"},
324 {21, GPIOF_DIR_IN, "CAMIF_I2C_CLK"},
325};
326
327static struct gpio apq8064_back_cam_gpio[] = {
328 {107, GPIOF_DIR_OUT, "CAM_RESET"},
329};
330
331static struct msm_gpio_set_tbl apq8064_back_cam_gpio_set_tbl[] = {
332 {107, GPIOF_OUT_INIT_LOW, 1000},
333 {107, GPIOF_OUT_INIT_HIGH, 4000},
334};
335
336static struct msm_camera_gpio_conf apq8064_back_cam_gpio_conf = {
337 .cam_gpiomux_conf_tbl = apq8064_cam_2d_configs,
338 .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(apq8064_cam_2d_configs),
339 .cam_gpio_common_tbl = apq8064_common_cam_gpio,
340 .cam_gpio_common_tbl_size = ARRAY_SIZE(apq8064_common_cam_gpio),
341 .cam_gpio_req_tbl = apq8064_back_cam_gpio,
342 .cam_gpio_req_tbl_size = ARRAY_SIZE(apq8064_back_cam_gpio),
343 .cam_gpio_set_tbl = apq8064_back_cam_gpio_set_tbl,
344 .cam_gpio_set_tbl_size = ARRAY_SIZE(apq8064_back_cam_gpio_set_tbl),
345};
346
Kevin Chan412e9f92012-01-24 10:45:23 -0800347#ifdef CONFIG_IMX074
348static struct msm_camera_sensor_flash_data flash_imx074 = {
349 .flash_type = MSM_CAMERA_FLASH_NONE,
350};
351
352static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
353 .mount_angle = 90,
Kevin Chaneb6b6072012-01-17 11:54:54 -0800354 .cam_vreg = msm_8064_back_cam_vreg,
355 .num_vreg = ARRAY_SIZE(msm_8064_back_cam_vreg),
356 .gpio_conf = &apq8064_back_cam_gpio_conf,
Kevin Chan412e9f92012-01-24 10:45:23 -0800357};
358
359static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
360 .sensor_name = "imx074",
361 .pdata = &msm_camera_csi_device_data[0],
362 .flash_data = &flash_imx074,
363 .sensor_platform_info = &sensor_board_info_imx074,
Kevin Chan412e9f92012-01-24 10:45:23 -0800364 .csi_if = 1,
365 .camera_type = BACK_CAMERA_2D,
366};
367#endif
368
369void __init apq8064_init_cam(void)
370{
371 msm_gpiomux_install(apq8064_cam_common_configs,
372 ARRAY_SIZE(apq8064_cam_common_configs));
373
374 platform_device_register(&msm8960_device_csiphy0);
375 platform_device_register(&msm8960_device_csiphy1);
376 platform_device_register(&msm8960_device_csid0);
377 platform_device_register(&msm8960_device_csid1);
378 platform_device_register(&msm8960_device_ispif);
379 platform_device_register(&msm8960_device_vfe);
380 platform_device_register(&msm8960_device_vpe);
381}
382
383#ifdef CONFIG_I2C
384static struct i2c_board_info apq8064_camera_i2c_boardinfo[] = {
385#ifdef CONFIG_IMX074
386 {
387 I2C_BOARD_INFO("imx074", 0x1A),
388 .platform_data = &msm_camera_sensor_imx074_data,
389 },
390#endif
391};
392
393struct msm_camera_board_info apq8064_camera_board_info = {
394 .board_info = apq8064_camera_i2c_boardinfo,
395 .num_i2c_board_info = ARRAY_SIZE(apq8064_camera_i2c_boardinfo),
396};
397#endif
398#endif