diff options
Diffstat (limited to 'arch/arm/mach-mx3/pcm037.c')
-rw-r--r-- | arch/arm/mach-mx3/pcm037.c | 225 |
1 files changed, 201 insertions, 24 deletions
diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c index c6f61a1f06c8..6cbaabedf386 100644 --- a/arch/arm/mach-mx3/pcm037.c +++ b/arch/arm/mach-mx3/pcm037.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | 21 | #include <linux/dma-mapping.h> | |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/mtd/physmap.h> | 23 | #include <linux/mtd/physmap.h> |
24 | #include <linux/mtd/plat-ram.h> | 24 | #include <linux/mtd/plat-ram.h> |
@@ -32,30 +32,69 @@ | |||
32 | #include <linux/spi/spi.h> | 32 | #include <linux/spi/spi.h> |
33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
34 | #include <linux/fsl_devices.h> | 34 | #include <linux/fsl_devices.h> |
35 | #include <linux/can/platform/sja1000.h> | ||
36 | |||
37 | #include <media/soc_camera.h> | ||
35 | 38 | ||
36 | #include <mach/hardware.h> | ||
37 | #include <asm/mach-types.h> | 39 | #include <asm/mach-types.h> |
38 | #include <asm/mach/arch.h> | 40 | #include <asm/mach/arch.h> |
39 | #include <asm/mach/time.h> | 41 | #include <asm/mach/time.h> |
40 | #include <asm/mach/map.h> | 42 | #include <asm/mach/map.h> |
43 | #include <mach/board-pcm037.h> | ||
41 | #include <mach/common.h> | 44 | #include <mach/common.h> |
45 | #include <mach/hardware.h> | ||
46 | #include <mach/i2c.h> | ||
42 | #include <mach/imx-uart.h> | 47 | #include <mach/imx-uart.h> |
43 | #include <mach/iomux-mx3.h> | 48 | #include <mach/iomux-mx3.h> |
44 | #include <mach/ipu.h> | 49 | #include <mach/ipu.h> |
45 | #include <mach/board-pcm037.h> | 50 | #include <mach/mmc.h> |
51 | #include <mach/mx3_camera.h> | ||
46 | #include <mach/mx3fb.h> | 52 | #include <mach/mx3fb.h> |
47 | #include <mach/mxc_nand.h> | 53 | #include <mach/mxc_nand.h> |
48 | #include <mach/mmc.h> | ||
49 | #ifdef CONFIG_I2C_IMX | ||
50 | #include <mach/i2c.h> | ||
51 | #endif | ||
52 | 54 | ||
53 | #include "devices.h" | 55 | #include "devices.h" |
56 | #include "pcm037.h" | ||
57 | |||
58 | static enum pcm037_board_variant pcm037_instance = PCM037_PCM970; | ||
59 | |||
60 | static int __init pcm037_variant_setup(char *str) | ||
61 | { | ||
62 | if (!strcmp("eet", str)) | ||
63 | pcm037_instance = PCM037_EET; | ||
64 | else if (strcmp("pcm970", str)) | ||
65 | pr_warning("Unknown pcm037 baseboard variant %s\n", str); | ||
66 | |||
67 | return 1; | ||
68 | } | ||
69 | |||
70 | /* Supported values: "pcm970" (default) and "eet" */ | ||
71 | __setup("pcm037_variant=", pcm037_variant_setup); | ||
72 | |||
73 | enum pcm037_board_variant pcm037_variant(void) | ||
74 | { | ||
75 | return pcm037_instance; | ||
76 | } | ||
77 | |||
78 | /* UART1 with RTS/CTS handshake signals */ | ||
79 | static unsigned int pcm037_uart1_handshake_pins[] = { | ||
80 | MX31_PIN_CTS1__CTS1, | ||
81 | MX31_PIN_RTS1__RTS1, | ||
82 | MX31_PIN_TXD1__TXD1, | ||
83 | MX31_PIN_RXD1__RXD1, | ||
84 | }; | ||
85 | |||
86 | /* UART1 without RTS/CTS handshake signals */ | ||
87 | static unsigned int pcm037_uart1_pins[] = { | ||
88 | MX31_PIN_TXD1__TXD1, | ||
89 | MX31_PIN_RXD1__RXD1, | ||
90 | }; | ||
54 | 91 | ||
55 | static unsigned int pcm037_pins[] = { | 92 | static unsigned int pcm037_pins[] = { |
56 | /* I2C */ | 93 | /* I2C */ |
57 | MX31_PIN_CSPI2_MOSI__SCL, | 94 | MX31_PIN_CSPI2_MOSI__SCL, |
58 | MX31_PIN_CSPI2_MISO__SDA, | 95 | MX31_PIN_CSPI2_MISO__SDA, |
96 | MX31_PIN_CSPI2_SS2__I2C3_SDA, | ||
97 | MX31_PIN_CSPI2_SCLK__I2C3_SCL, | ||
59 | /* SDHC1 */ | 98 | /* SDHC1 */ |
60 | MX31_PIN_SD1_DATA3__SD1_DATA3, | 99 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
61 | MX31_PIN_SD1_DATA2__SD1_DATA2, | 100 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
@@ -73,11 +112,6 @@ static unsigned int pcm037_pins[] = { | |||
73 | MX31_PIN_CSPI1_SS0__SS0, | 112 | MX31_PIN_CSPI1_SS0__SS0, |
74 | MX31_PIN_CSPI1_SS1__SS1, | 113 | MX31_PIN_CSPI1_SS1__SS1, |
75 | MX31_PIN_CSPI1_SS2__SS2, | 114 | MX31_PIN_CSPI1_SS2__SS2, |
76 | /* UART1 */ | ||
77 | MX31_PIN_CTS1__CTS1, | ||
78 | MX31_PIN_RTS1__RTS1, | ||
79 | MX31_PIN_TXD1__TXD1, | ||
80 | MX31_PIN_RXD1__RXD1, | ||
81 | /* UART2 */ | 115 | /* UART2 */ |
82 | MX31_PIN_TXD2__TXD2, | 116 | MX31_PIN_TXD2__TXD2, |
83 | MX31_PIN_RXD2__RXD2, | 117 | MX31_PIN_RXD2__RXD2, |
@@ -120,6 +154,24 @@ static unsigned int pcm037_pins[] = { | |||
120 | MX31_PIN_D3_SPL__D3_SPL, | 154 | MX31_PIN_D3_SPL__D3_SPL, |
121 | MX31_PIN_D3_CLS__D3_CLS, | 155 | MX31_PIN_D3_CLS__D3_CLS, |
122 | MX31_PIN_LCS0__GPI03_23, | 156 | MX31_PIN_LCS0__GPI03_23, |
157 | /* CSI */ | ||
158 | IOMUX_MODE(MX31_PIN_CSI_D5, IOMUX_CONFIG_GPIO), | ||
159 | MX31_PIN_CSI_D6__CSI_D6, | ||
160 | MX31_PIN_CSI_D7__CSI_D7, | ||
161 | MX31_PIN_CSI_D8__CSI_D8, | ||
162 | MX31_PIN_CSI_D9__CSI_D9, | ||
163 | MX31_PIN_CSI_D10__CSI_D10, | ||
164 | MX31_PIN_CSI_D11__CSI_D11, | ||
165 | MX31_PIN_CSI_D12__CSI_D12, | ||
166 | MX31_PIN_CSI_D13__CSI_D13, | ||
167 | MX31_PIN_CSI_D14__CSI_D14, | ||
168 | MX31_PIN_CSI_D15__CSI_D15, | ||
169 | MX31_PIN_CSI_HSYNC__CSI_HSYNC, | ||
170 | MX31_PIN_CSI_MCLK__CSI_MCLK, | ||
171 | MX31_PIN_CSI_PIXCLK__CSI_PIXCLK, | ||
172 | MX31_PIN_CSI_VSYNC__CSI_VSYNC, | ||
173 | /* GPIO */ | ||
174 | IOMUX_MODE(MX31_PIN_ATA_DMACK, IOMUX_CONFIG_GPIO), | ||
123 | }; | 175 | }; |
124 | 176 | ||
125 | static struct physmap_flash_data pcm037_flash_data = { | 177 | static struct physmap_flash_data pcm037_flash_data = { |
@@ -195,12 +247,11 @@ static struct imxuart_platform_data uart_pdata = { | |||
195 | }; | 247 | }; |
196 | 248 | ||
197 | static struct resource smsc911x_resources[] = { | 249 | static struct resource smsc911x_resources[] = { |
198 | [0] = { | 250 | { |
199 | .start = CS1_BASE_ADDR + 0x300, | 251 | .start = CS1_BASE_ADDR + 0x300, |
200 | .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1, | 252 | .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1, |
201 | .flags = IORESOURCE_MEM, | 253 | .flags = IORESOURCE_MEM, |
202 | }, | 254 | }, { |
203 | [1] = { | ||
204 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), | 255 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
205 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), | 256 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
206 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | 257 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
@@ -250,27 +301,57 @@ static struct mxc_nand_platform_data pcm037_nand_board_info = { | |||
250 | .hw_ecc = 1, | 301 | .hw_ecc = 1, |
251 | }; | 302 | }; |
252 | 303 | ||
253 | #ifdef CONFIG_I2C_IMX | ||
254 | static struct imxi2c_platform_data pcm037_i2c_1_data = { | 304 | static struct imxi2c_platform_data pcm037_i2c_1_data = { |
255 | .bitrate = 100000, | 305 | .bitrate = 100000, |
256 | }; | 306 | }; |
257 | 307 | ||
308 | static struct imxi2c_platform_data pcm037_i2c_2_data = { | ||
309 | .bitrate = 20000, | ||
310 | }; | ||
311 | |||
258 | static struct at24_platform_data board_eeprom = { | 312 | static struct at24_platform_data board_eeprom = { |
259 | .byte_len = 4096, | 313 | .byte_len = 4096, |
260 | .page_size = 32, | 314 | .page_size = 32, |
261 | .flags = AT24_FLAG_ADDR16, | 315 | .flags = AT24_FLAG_ADDR16, |
262 | }; | 316 | }; |
263 | 317 | ||
318 | static int pcm037_camera_power(struct device *dev, int on) | ||
319 | { | ||
320 | /* disable or enable the camera in X7 or X8 PCM970 connector */ | ||
321 | gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), !on); | ||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static struct i2c_board_info pcm037_i2c_2_devices[] = { | ||
326 | { | ||
327 | I2C_BOARD_INFO("mt9t031", 0x5d), | ||
328 | }, | ||
329 | }; | ||
330 | |||
331 | static struct soc_camera_link iclink = { | ||
332 | .bus_id = 0, /* Must match with the camera ID */ | ||
333 | .power = pcm037_camera_power, | ||
334 | .board_info = &pcm037_i2c_2_devices[0], | ||
335 | .i2c_adapter_id = 2, | ||
336 | .module_name = "mt9t031", | ||
337 | }; | ||
338 | |||
264 | static struct i2c_board_info pcm037_i2c_devices[] = { | 339 | static struct i2c_board_info pcm037_i2c_devices[] = { |
265 | { | 340 | { |
266 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ | 341 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ |
267 | .platform_data = &board_eeprom, | 342 | .platform_data = &board_eeprom, |
268 | }, { | 343 | }, { |
269 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), | 344 | I2C_BOARD_INFO("pcf8563", 0x51), |
270 | .type = "pcf8563", | ||
271 | } | 345 | } |
272 | }; | 346 | }; |
273 | #endif | 347 | |
348 | static struct platform_device pcm037_camera = { | ||
349 | .name = "soc-camera-pdrv", | ||
350 | .id = 0, | ||
351 | .dev = { | ||
352 | .platform_data = &iclink, | ||
353 | }, | ||
354 | }; | ||
274 | 355 | ||
275 | /* Not connected by default */ | 356 | /* Not connected by default */ |
276 | #ifdef PCM970_SDHC_RW_SWITCH | 357 | #ifdef PCM970_SDHC_RW_SWITCH |
@@ -334,9 +415,41 @@ static struct imxmmc_platform_data sdhc_pdata = { | |||
334 | .exit = pcm970_sdhc1_exit, | 415 | .exit = pcm970_sdhc1_exit, |
335 | }; | 416 | }; |
336 | 417 | ||
418 | struct mx3_camera_pdata camera_pdata = { | ||
419 | .dma_dev = &mx3_ipu.dev, | ||
420 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, | ||
421 | .mclk_10khz = 2000, | ||
422 | }; | ||
423 | |||
424 | static int __init pcm037_camera_alloc_dma(const size_t buf_size) | ||
425 | { | ||
426 | dma_addr_t dma_handle; | ||
427 | void *buf; | ||
428 | int dma; | ||
429 | |||
430 | if (buf_size < 2 * 1024 * 1024) | ||
431 | return -EINVAL; | ||
432 | |||
433 | buf = dma_alloc_coherent(NULL, buf_size, &dma_handle, GFP_KERNEL); | ||
434 | if (!buf) { | ||
435 | pr_err("%s: cannot allocate camera buffer-memory\n", __func__); | ||
436 | return -ENOMEM; | ||
437 | } | ||
438 | |||
439 | memset(buf, 0, buf_size); | ||
440 | |||
441 | dma = dma_declare_coherent_memory(&mx3_camera.dev, | ||
442 | dma_handle, dma_handle, buf_size, | ||
443 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); | ||
444 | |||
445 | /* The way we call dma_declare_coherent_memory only a malloc can fail */ | ||
446 | return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; | ||
447 | } | ||
448 | |||
337 | static struct platform_device *devices[] __initdata = { | 449 | static struct platform_device *devices[] __initdata = { |
338 | &pcm037_flash, | 450 | &pcm037_flash, |
339 | &pcm037_sram_device, | 451 | &pcm037_sram_device, |
452 | &pcm037_camera, | ||
340 | }; | 453 | }; |
341 | 454 | ||
342 | static struct ipu_platform_data mx3_ipu_data = { | 455 | static struct ipu_platform_data mx3_ipu_data = { |
@@ -377,6 +490,22 @@ static const struct fb_videomode fb_modedb[] = { | |||
377 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH, | 490 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH, |
378 | .vmode = FB_VMODE_NONINTERLACED, | 491 | .vmode = FB_VMODE_NONINTERLACED, |
379 | .flag = 0, | 492 | .flag = 0, |
493 | }, { | ||
494 | /* 240x320 @ 60 Hz */ | ||
495 | .name = "CMEL-OLED", | ||
496 | .refresh = 60, | ||
497 | .xres = 240, | ||
498 | .yres = 320, | ||
499 | .pixclock = 185925, | ||
500 | .left_margin = 9, | ||
501 | .right_margin = 16, | ||
502 | .upper_margin = 7, | ||
503 | .lower_margin = 9, | ||
504 | .hsync_len = 1, | ||
505 | .vsync_len = 1, | ||
506 | .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT, | ||
507 | .vmode = FB_VMODE_NONINTERLACED, | ||
508 | .flag = 0, | ||
380 | }, | 509 | }, |
381 | }; | 510 | }; |
382 | 511 | ||
@@ -387,6 +516,33 @@ static struct mx3fb_platform_data mx3fb_pdata = { | |||
387 | .num_modes = ARRAY_SIZE(fb_modedb), | 516 | .num_modes = ARRAY_SIZE(fb_modedb), |
388 | }; | 517 | }; |
389 | 518 | ||
519 | static struct resource pcm970_sja1000_resources[] = { | ||
520 | { | ||
521 | .start = CS5_BASE_ADDR, | ||
522 | .end = CS5_BASE_ADDR + 0x100 - 1, | ||
523 | .flags = IORESOURCE_MEM, | ||
524 | }, { | ||
525 | .start = IOMUX_TO_IRQ(IOMUX_PIN(48, 105)), | ||
526 | .end = IOMUX_TO_IRQ(IOMUX_PIN(48, 105)), | ||
527 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, | ||
528 | }, | ||
529 | }; | ||
530 | |||
531 | struct sja1000_platform_data pcm970_sja1000_platform_data = { | ||
532 | .clock = 16000000 / 2, | ||
533 | .ocr = 0x40 | 0x18, | ||
534 | .cdr = 0x40, | ||
535 | }; | ||
536 | |||
537 | static struct platform_device pcm970_sja1000 = { | ||
538 | .name = "sja1000_platform", | ||
539 | .dev = { | ||
540 | .platform_data = &pcm970_sja1000_platform_data, | ||
541 | }, | ||
542 | .resource = pcm970_sja1000_resources, | ||
543 | .num_resources = ARRAY_SIZE(pcm970_sja1000_resources), | ||
544 | }; | ||
545 | |||
390 | /* | 546 | /* |
391 | * Board specific initialization. | 547 | * Board specific initialization. |
392 | */ | 548 | */ |
@@ -397,6 +553,14 @@ static void __init mxc_board_init(void) | |||
397 | mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins), | 553 | mxc_iomux_setup_multiple_pins(pcm037_pins, ARRAY_SIZE(pcm037_pins), |
398 | "pcm037"); | 554 | "pcm037"); |
399 | 555 | ||
556 | if (pcm037_variant() == PCM037_EET) | ||
557 | mxc_iomux_setup_multiple_pins(pcm037_uart1_pins, | ||
558 | ARRAY_SIZE(pcm037_uart1_pins), "pcm037_uart1"); | ||
559 | else | ||
560 | mxc_iomux_setup_multiple_pins(pcm037_uart1_handshake_pins, | ||
561 | ARRAY_SIZE(pcm037_uart1_handshake_pins), | ||
562 | "pcm037_uart1"); | ||
563 | |||
400 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 564 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
401 | 565 | ||
402 | mxc_register_device(&mxc_uart_device0, &uart_pdata); | 566 | mxc_register_device(&mxc_uart_device0, &uart_pdata); |
@@ -415,18 +579,32 @@ static void __init mxc_board_init(void) | |||
415 | } | 579 | } |
416 | 580 | ||
417 | 581 | ||
418 | #ifdef CONFIG_I2C_IMX | 582 | /* I2C adapters and devices */ |
419 | i2c_register_board_info(1, pcm037_i2c_devices, | 583 | i2c_register_board_info(1, pcm037_i2c_devices, |
420 | ARRAY_SIZE(pcm037_i2c_devices)); | 584 | ARRAY_SIZE(pcm037_i2c_devices)); |
421 | 585 | ||
422 | mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data); | 586 | mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data); |
423 | #endif | 587 | mxc_register_device(&mxc_i2c_device2, &pcm037_i2c_2_data); |
588 | |||
424 | mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); | 589 | mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); |
425 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); | 590 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); |
426 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); | 591 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
427 | mxc_register_device(&mx3_fb, &mx3fb_pdata); | 592 | mxc_register_device(&mx3_fb, &mx3fb_pdata); |
428 | if (!gpio_usbotg_hs_activate()) | 593 | if (!gpio_usbotg_hs_activate()) |
429 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); | 594 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); |
595 | |||
596 | /* CSI */ | ||
597 | /* Camera power: default - off */ | ||
598 | ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), "mt9t031-power"); | ||
599 | if (!ret) | ||
600 | gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), 1); | ||
601 | else | ||
602 | iclink.power = NULL; | ||
603 | |||
604 | if (!pcm037_camera_alloc_dma(4 * 1024 * 1024)) | ||
605 | mxc_register_device(&mx3_camera, &camera_pdata); | ||
606 | |||
607 | platform_device_register(&pcm970_sja1000); | ||
430 | } | 608 | } |
431 | 609 | ||
432 | static void __init pcm037_timer_init(void) | 610 | static void __init pcm037_timer_init(void) |
@@ -444,8 +622,7 @@ MACHINE_START(PCM037, "Phytec Phycore pcm037") | |||
444 | .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, | 622 | .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
445 | .boot_params = PHYS_OFFSET + 0x100, | 623 | .boot_params = PHYS_OFFSET + 0x100, |
446 | .map_io = mx31_map_io, | 624 | .map_io = mx31_map_io, |
447 | .init_irq = mxc_init_irq, | 625 | .init_irq = mx31_init_irq, |
448 | .init_machine = mxc_board_init, | 626 | .init_machine = mxc_board_init, |
449 | .timer = &pcm037_timer, | 627 | .timer = &pcm037_timer, |
450 | MACHINE_END | 628 | MACHINE_END |
451 | |||