aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-imx/mach-mx27_3ds.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-imx/mach-mx27_3ds.c')
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index 18f35816706a..c6d385c52257 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -31,6 +31,8 @@
31#include <linux/regulator/machine.h> 31#include <linux/regulator/machine.h>
32#include <linux/spi/l4f00242t03.h> 32#include <linux/spi/l4f00242t03.h>
33 33
34#include <media/soc_camera.h>
35
34#include <asm/mach-types.h> 36#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
36#include <asm/mach/time.h> 38#include <asm/mach/time.h>
@@ -52,6 +54,8 @@
52#define SD1_CD IMX_GPIO_NR(2, 26) 54#define SD1_CD IMX_GPIO_NR(2, 26)
53#define LCD_RESET IMX_GPIO_NR(1, 3) 55#define LCD_RESET IMX_GPIO_NR(1, 3)
54#define LCD_ENABLE IMX_GPIO_NR(1, 31) 56#define LCD_ENABLE IMX_GPIO_NR(1, 31)
57#define CSI_PWRDWN IMX_GPIO_NR(4, 19)
58#define CSI_RESET IMX_GPIO_NR(3, 6)
55 59
56static const int mx27pdk_pins[] __initconst = { 60static const int mx27pdk_pins[] __initconst = {
57 /* UART1 */ 61 /* UART1 */
@@ -141,6 +145,26 @@ static const int mx27pdk_pins[] __initconst = {
141 PA30_PF_CONTRAST, 145 PA30_PF_CONTRAST,
142 LCD_ENABLE | GPIO_GPIO | GPIO_OUT, 146 LCD_ENABLE | GPIO_GPIO | GPIO_OUT,
143 LCD_RESET | GPIO_GPIO | GPIO_OUT, 147 LCD_RESET | GPIO_GPIO | GPIO_OUT,
148 /* CSI */
149 PB10_PF_CSI_D0,
150 PB11_PF_CSI_D1,
151 PB12_PF_CSI_D2,
152 PB13_PF_CSI_D3,
153 PB14_PF_CSI_D4,
154 PB15_PF_CSI_MCLK,
155 PB16_PF_CSI_PIXCLK,
156 PB17_PF_CSI_D5,
157 PB18_PF_CSI_D6,
158 PB19_PF_CSI_D7,
159 PB20_PF_CSI_VSYNC,
160 PB21_PF_CSI_HSYNC,
161 CSI_PWRDWN | GPIO_GPIO | GPIO_OUT,
162 CSI_RESET | GPIO_GPIO | GPIO_OUT,
163};
164
165static struct gpio mx27_3ds_camera_gpios[] = {
166 { CSI_PWRDWN, GPIOF_OUT_INIT_HIGH, "camera-power" },
167 { CSI_RESET, GPIOF_OUT_INIT_HIGH, "camera-reset" },
144}; 168};
145 169
146static const struct imxuart_platform_data uart_pdata __initconst = { 170static const struct imxuart_platform_data uart_pdata __initconst = {
@@ -242,6 +266,7 @@ static struct regulator_init_data gpo_init = {
242 266
243static struct regulator_consumer_supply vmmc1_consumers[] = { 267static struct regulator_consumer_supply vmmc1_consumers[] = {
244 REGULATOR_SUPPLY("vcore", "spi0.0"), 268 REGULATOR_SUPPLY("vcore", "spi0.0"),
269 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
245}; 270};
246 271
247static struct regulator_init_data vmmc1_init = { 272static struct regulator_init_data vmmc1_init = {
@@ -270,6 +295,22 @@ static struct regulator_init_data vgen_init = {
270 .consumer_supplies = vgen_consumers, 295 .consumer_supplies = vgen_consumers,
271}; 296};
272 297
298static struct regulator_consumer_supply vvib_consumers[] = {
299 REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),
300};
301
302static struct regulator_init_data vvib_init = {
303 .constraints = {
304 .min_uV = 1300000,
305 .max_uV = 1300000,
306 .apply_uV = 1,
307 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
308 REGULATOR_CHANGE_STATUS,
309 },
310 .num_consumer_supplies = ARRAY_SIZE(vvib_consumers),
311 .consumer_supplies = vvib_consumers,
312};
313
273static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = { 314static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
274 { 315 {
275 .id = MC13783_REG_VMMC1, 316 .id = MC13783_REG_VMMC1,
@@ -283,6 +324,9 @@ static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
283 }, { 324 }, {
284 .id = MC13783_REG_GPO3, /* Turn on 3.3V */ 325 .id = MC13783_REG_GPO3, /* Turn on 3.3V */
285 .init_data = &gpo_init, 326 .init_data = &gpo_init,
327 }, {
328 .id = MC13783_REG_VVIB, /* Power OV2640 */
329 .init_data = &vvib_init,
286 }, 330 },
287}; 331};
288 332
@@ -311,6 +355,51 @@ static const struct spi_imx_master spi2_pdata __initconst = {
311 .num_chipselect = ARRAY_SIZE(spi2_chipselect), 355 .num_chipselect = ARRAY_SIZE(spi2_chipselect),
312}; 356};
313 357
358static int mx27_3ds_camera_power(struct device *dev, int on)
359{
360 /* enable or disable the camera */
361 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
362 gpio_set_value(CSI_PWRDWN, on ? 0 : 1);
363
364 if (!on)
365 goto out;
366
367 /* If enabled, give a reset impulse */
368 gpio_set_value(CSI_RESET, 0);
369 msleep(20);
370 gpio_set_value(CSI_RESET, 1);
371 msleep(100);
372
373out:
374 return 0;
375}
376
377static struct i2c_board_info mx27_3ds_i2c_camera = {
378 I2C_BOARD_INFO("ov2640", 0x30),
379};
380
381static struct regulator_bulk_data mx27_3ds_camera_regs[] = {
382 { .supply = "cmos_vcore" },
383 { .supply = "cmos_2v8" },
384};
385
386static struct soc_camera_link iclink_ov2640 = {
387 .bus_id = 0,
388 .board_info = &mx27_3ds_i2c_camera,
389 .i2c_adapter_id = 0,
390 .power = mx27_3ds_camera_power,
391 .regulators = mx27_3ds_camera_regs,
392 .num_regulators = ARRAY_SIZE(mx27_3ds_camera_regs),
393};
394
395static struct platform_device mx27_3ds_ov2640 = {
396 .name = "soc-camera-pdrv",
397 .id = 0,
398 .dev = {
399 .platform_data = &iclink_ov2640,
400 },
401};
402
314static struct imx_fb_videomode mx27_3ds_modes[] = { 403static struct imx_fb_videomode mx27_3ds_modes[] = {
315 { /* 480x640 @ 60 Hz */ 404 { /* 480x640 @ 60 Hz */
316 .mode = { 405 .mode = {
@@ -367,12 +456,21 @@ static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
367 }, 456 },
368}; 457};
369 458
459static struct platform_device *devices[] __initdata = {
460 &mx27_3ds_ov2640,
461};
462
463static const struct mx2_camera_platform_data mx27_3ds_cam_pdata __initconst = {
464 .clk = 26000000,
465};
466
370static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = { 467static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = {
371 .bitrate = 100000, 468 .bitrate = 100000,
372}; 469};
373 470
374static void __init mx27pdk_init(void) 471static void __init mx27pdk_init(void)
375{ 472{
473 int ret;
376 imx27_soc_init(); 474 imx27_soc_init();
377 475
378 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), 476 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
@@ -404,7 +502,17 @@ static void __init mx27pdk_init(void)
404 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 502 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT))
405 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n"); 503 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
406 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data); 504 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
505 platform_add_devices(devices, ARRAY_SIZE(devices));
407 imx27_add_imx_fb(&mx27_3ds_fb_data); 506 imx27_add_imx_fb(&mx27_3ds_fb_data);
507
508 ret = gpio_request_array(mx27_3ds_camera_gpios,
509 ARRAY_SIZE(mx27_3ds_camera_gpios));
510 if (ret) {
511 pr_err("Failed to request camera gpios");
512 iclink_ov2640.power = NULL;
513 }
514
515 imx27_add_mx2_camera(&mx27_3ds_cam_pdata);
408} 516}
409 517
410static void __init mx27pdk_timer_init(void) 518static void __init mx27pdk_timer_init(void)