diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-mx3/pcm037.c | 118 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/iomux-mx3.h | 2 |
2 files changed, 108 insertions, 12 deletions
diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c index c6f61a1f06c8..d7b29b724a61 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> |
@@ -33,22 +33,23 @@ | |||
33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
34 | #include <linux/fsl_devices.h> | 34 | #include <linux/fsl_devices.h> |
35 | 35 | ||
36 | #include <mach/hardware.h> | 36 | #include <media/soc_camera.h> |
37 | |||
37 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
38 | #include <asm/mach/arch.h> | 39 | #include <asm/mach/arch.h> |
39 | #include <asm/mach/time.h> | 40 | #include <asm/mach/time.h> |
40 | #include <asm/mach/map.h> | 41 | #include <asm/mach/map.h> |
42 | #include <mach/board-pcm037.h> | ||
41 | #include <mach/common.h> | 43 | #include <mach/common.h> |
44 | #include <mach/hardware.h> | ||
45 | #include <mach/i2c.h> | ||
42 | #include <mach/imx-uart.h> | 46 | #include <mach/imx-uart.h> |
43 | #include <mach/iomux-mx3.h> | 47 | #include <mach/iomux-mx3.h> |
44 | #include <mach/ipu.h> | 48 | #include <mach/ipu.h> |
45 | #include <mach/board-pcm037.h> | 49 | #include <mach/mmc.h> |
50 | #include <mach/mx3_camera.h> | ||
46 | #include <mach/mx3fb.h> | 51 | #include <mach/mx3fb.h> |
47 | #include <mach/mxc_nand.h> | 52 | #include <mach/mxc_nand.h> |
48 | #include <mach/mmc.h> | ||
49 | #ifdef CONFIG_I2C_IMX | ||
50 | #include <mach/i2c.h> | ||
51 | #endif | ||
52 | 53 | ||
53 | #include "devices.h" | 54 | #include "devices.h" |
54 | 55 | ||
@@ -56,6 +57,8 @@ static unsigned int pcm037_pins[] = { | |||
56 | /* I2C */ | 57 | /* I2C */ |
57 | MX31_PIN_CSPI2_MOSI__SCL, | 58 | MX31_PIN_CSPI2_MOSI__SCL, |
58 | MX31_PIN_CSPI2_MISO__SDA, | 59 | MX31_PIN_CSPI2_MISO__SDA, |
60 | MX31_PIN_CSPI2_SS2__I2C3_SDA, | ||
61 | MX31_PIN_CSPI2_SCLK__I2C3_SCL, | ||
59 | /* SDHC1 */ | 62 | /* SDHC1 */ |
60 | MX31_PIN_SD1_DATA3__SD1_DATA3, | 63 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
61 | MX31_PIN_SD1_DATA2__SD1_DATA2, | 64 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
@@ -120,6 +123,22 @@ static unsigned int pcm037_pins[] = { | |||
120 | MX31_PIN_D3_SPL__D3_SPL, | 123 | MX31_PIN_D3_SPL__D3_SPL, |
121 | MX31_PIN_D3_CLS__D3_CLS, | 124 | MX31_PIN_D3_CLS__D3_CLS, |
122 | MX31_PIN_LCS0__GPI03_23, | 125 | MX31_PIN_LCS0__GPI03_23, |
126 | /* CSI */ | ||
127 | IOMUX_MODE(MX31_PIN_CSI_D5, IOMUX_CONFIG_GPIO), | ||
128 | MX31_PIN_CSI_D6__CSI_D6, | ||
129 | MX31_PIN_CSI_D7__CSI_D7, | ||
130 | MX31_PIN_CSI_D8__CSI_D8, | ||
131 | MX31_PIN_CSI_D9__CSI_D9, | ||
132 | MX31_PIN_CSI_D10__CSI_D10, | ||
133 | MX31_PIN_CSI_D11__CSI_D11, | ||
134 | MX31_PIN_CSI_D12__CSI_D12, | ||
135 | MX31_PIN_CSI_D13__CSI_D13, | ||
136 | MX31_PIN_CSI_D14__CSI_D14, | ||
137 | MX31_PIN_CSI_D15__CSI_D15, | ||
138 | MX31_PIN_CSI_HSYNC__CSI_HSYNC, | ||
139 | MX31_PIN_CSI_MCLK__CSI_MCLK, | ||
140 | MX31_PIN_CSI_PIXCLK__CSI_PIXCLK, | ||
141 | MX31_PIN_CSI_VSYNC__CSI_VSYNC, | ||
123 | }; | 142 | }; |
124 | 143 | ||
125 | static struct physmap_flash_data pcm037_flash_data = { | 144 | static struct physmap_flash_data pcm037_flash_data = { |
@@ -250,19 +269,43 @@ static struct mxc_nand_platform_data pcm037_nand_board_info = { | |||
250 | .hw_ecc = 1, | 269 | .hw_ecc = 1, |
251 | }; | 270 | }; |
252 | 271 | ||
253 | #ifdef CONFIG_I2C_IMX | ||
254 | static struct imxi2c_platform_data pcm037_i2c_1_data = { | 272 | static struct imxi2c_platform_data pcm037_i2c_1_data = { |
255 | .bitrate = 100000, | 273 | .bitrate = 100000, |
256 | }; | 274 | }; |
257 | 275 | ||
276 | static struct imxi2c_platform_data pcm037_i2c_2_data = { | ||
277 | .bitrate = 20000, | ||
278 | }; | ||
279 | |||
258 | static struct at24_platform_data board_eeprom = { | 280 | static struct at24_platform_data board_eeprom = { |
259 | .byte_len = 4096, | 281 | .byte_len = 4096, |
260 | .page_size = 32, | 282 | .page_size = 32, |
261 | .flags = AT24_FLAG_ADDR16, | 283 | .flags = AT24_FLAG_ADDR16, |
262 | }; | 284 | }; |
263 | 285 | ||
286 | static int pcm037_camera_power(struct device *dev, int on) | ||
287 | { | ||
288 | /* disable or enable the camera in X7 or X8 PCM970 connector */ | ||
289 | gpio_set_value(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), !on); | ||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static struct i2c_board_info pcm037_i2c_2_devices[] = { | ||
294 | { | ||
295 | I2C_BOARD_INFO("mt9t031", 0x5d), | ||
296 | }, | ||
297 | }; | ||
298 | |||
299 | static struct soc_camera_link iclink = { | ||
300 | .bus_id = 0, /* Must match with the camera ID */ | ||
301 | .power = pcm037_camera_power, | ||
302 | .board_info = &pcm037_i2c_2_devices[0], | ||
303 | .i2c_adapter_id = 2, | ||
304 | .module_name = "mt9t031", | ||
305 | }; | ||
306 | |||
264 | static struct i2c_board_info pcm037_i2c_devices[] = { | 307 | static struct i2c_board_info pcm037_i2c_devices[] = { |
265 | { | 308 | { |
266 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ | 309 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ |
267 | .platform_data = &board_eeprom, | 310 | .platform_data = &board_eeprom, |
268 | }, { | 311 | }, { |
@@ -270,7 +313,14 @@ static struct i2c_board_info pcm037_i2c_devices[] = { | |||
270 | .type = "pcf8563", | 313 | .type = "pcf8563", |
271 | } | 314 | } |
272 | }; | 315 | }; |
273 | #endif | 316 | |
317 | static struct platform_device pcm037_camera = { | ||
318 | .name = "soc-camera-pdrv", | ||
319 | .id = 0, | ||
320 | .dev = { | ||
321 | .platform_data = &iclink, | ||
322 | }, | ||
323 | }; | ||
274 | 324 | ||
275 | /* Not connected by default */ | 325 | /* Not connected by default */ |
276 | #ifdef PCM970_SDHC_RW_SWITCH | 326 | #ifdef PCM970_SDHC_RW_SWITCH |
@@ -334,9 +384,41 @@ static struct imxmmc_platform_data sdhc_pdata = { | |||
334 | .exit = pcm970_sdhc1_exit, | 384 | .exit = pcm970_sdhc1_exit, |
335 | }; | 385 | }; |
336 | 386 | ||
387 | struct mx3_camera_pdata camera_pdata = { | ||
388 | .dma_dev = &mx3_ipu.dev, | ||
389 | .flags = MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10, | ||
390 | .mclk_10khz = 2000, | ||
391 | }; | ||
392 | |||
393 | static int __init pcm037_camera_alloc_dma(const size_t buf_size) | ||
394 | { | ||
395 | dma_addr_t dma_handle; | ||
396 | void *buf; | ||
397 | int dma; | ||
398 | |||
399 | if (buf_size < 2 * 1024 * 1024) | ||
400 | return -EINVAL; | ||
401 | |||
402 | buf = dma_alloc_coherent(NULL, buf_size, &dma_handle, GFP_KERNEL); | ||
403 | if (!buf) { | ||
404 | pr_err("%s: cannot allocate camera buffer-memory\n", __func__); | ||
405 | return -ENOMEM; | ||
406 | } | ||
407 | |||
408 | memset(buf, 0, buf_size); | ||
409 | |||
410 | dma = dma_declare_coherent_memory(&mx3_camera.dev, | ||
411 | dma_handle, dma_handle, buf_size, | ||
412 | DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); | ||
413 | |||
414 | /* The way we call dma_declare_coherent_memory only a malloc can fail */ | ||
415 | return dma & DMA_MEMORY_MAP ? 0 : -ENOMEM; | ||
416 | } | ||
417 | |||
337 | static struct platform_device *devices[] __initdata = { | 418 | static struct platform_device *devices[] __initdata = { |
338 | &pcm037_flash, | 419 | &pcm037_flash, |
339 | &pcm037_sram_device, | 420 | &pcm037_sram_device, |
421 | &pcm037_camera, | ||
340 | }; | 422 | }; |
341 | 423 | ||
342 | static struct ipu_platform_data mx3_ipu_data = { | 424 | static struct ipu_platform_data mx3_ipu_data = { |
@@ -415,18 +497,30 @@ static void __init mxc_board_init(void) | |||
415 | } | 497 | } |
416 | 498 | ||
417 | 499 | ||
418 | #ifdef CONFIG_I2C_IMX | 500 | /* I2C adapters and devices */ |
419 | i2c_register_board_info(1, pcm037_i2c_devices, | 501 | i2c_register_board_info(1, pcm037_i2c_devices, |
420 | ARRAY_SIZE(pcm037_i2c_devices)); | 502 | ARRAY_SIZE(pcm037_i2c_devices)); |
421 | 503 | ||
422 | mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data); | 504 | mxc_register_device(&mxc_i2c_device1, &pcm037_i2c_1_data); |
423 | #endif | 505 | mxc_register_device(&mxc_i2c_device2, &pcm037_i2c_2_data); |
506 | |||
424 | mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); | 507 | mxc_register_device(&mxc_nand_device, &pcm037_nand_board_info); |
425 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); | 508 | mxc_register_device(&mxcsdhc_device0, &sdhc_pdata); |
426 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); | 509 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
427 | mxc_register_device(&mx3_fb, &mx3fb_pdata); | 510 | mxc_register_device(&mx3_fb, &mx3fb_pdata); |
428 | if (!gpio_usbotg_hs_activate()) | 511 | if (!gpio_usbotg_hs_activate()) |
429 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); | 512 | mxc_register_device(&mxc_otg_udc_device, &usb_pdata); |
513 | |||
514 | /* CSI */ | ||
515 | /* Camera power: default - off */ | ||
516 | ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), "mt9t031-power"); | ||
517 | if (!ret) | ||
518 | gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_CSI_D5), 1); | ||
519 | else | ||
520 | iclink.power = NULL; | ||
521 | |||
522 | if (!pcm037_camera_alloc_dma(4 * 1024 * 1024)) | ||
523 | mxc_register_device(&mx3_camera, &camera_pdata); | ||
430 | } | 524 | } |
431 | 525 | ||
432 | static void __init pcm037_timer_init(void) | 526 | static void __init pcm037_timer_init(void) |
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx3.h b/arch/arm/plat-mxc/include/mach/iomux-mx3.h index 27f8d1b2bc6b..2eb182f73876 100644 --- a/arch/arm/plat-mxc/include/mach/iomux-mx3.h +++ b/arch/arm/plat-mxc/include/mach/iomux-mx3.h | |||
@@ -602,6 +602,8 @@ enum iomux_pins { | |||
602 | #define MX31_PIN_I2C_DAT__SDA IOMUX_MODE(MX31_PIN_I2C_DAT, IOMUX_CONFIG_FUNC) | 602 | #define MX31_PIN_I2C_DAT__SDA IOMUX_MODE(MX31_PIN_I2C_DAT, IOMUX_CONFIG_FUNC) |
603 | #define MX31_PIN_DCD_DTE1__I2C2_SDA IOMUX_MODE(MX31_PIN_DCD_DTE1, IOMUX_CONFIG_ALT2) | 603 | #define MX31_PIN_DCD_DTE1__I2C2_SDA IOMUX_MODE(MX31_PIN_DCD_DTE1, IOMUX_CONFIG_ALT2) |
604 | #define MX31_PIN_RI_DTE1__I2C2_SCL IOMUX_MODE(MX31_PIN_RI_DTE1, IOMUX_CONFIG_ALT2) | 604 | #define MX31_PIN_RI_DTE1__I2C2_SCL IOMUX_MODE(MX31_PIN_RI_DTE1, IOMUX_CONFIG_ALT2) |
605 | #define MX31_PIN_CSPI2_SS2__I2C3_SDA IOMUX_MODE(MX31_PIN_CSPI2_SS2, IOMUX_CONFIG_ALT1) | ||
606 | #define MX31_PIN_CSPI2_SCLK__I2C3_SCL IOMUX_MODE(MX31_PIN_CSPI2_SCLK, IOMUX_CONFIG_ALT1) | ||
605 | #define MX31_PIN_CSI_D4__CSI_D4 IOMUX_MODE(MX31_PIN_CSI_D4, IOMUX_CONFIG_FUNC) | 607 | #define MX31_PIN_CSI_D4__CSI_D4 IOMUX_MODE(MX31_PIN_CSI_D4, IOMUX_CONFIG_FUNC) |
606 | #define MX31_PIN_CSI_D5__CSI_D5 IOMUX_MODE(MX31_PIN_CSI_D5, IOMUX_CONFIG_FUNC) | 608 | #define MX31_PIN_CSI_D5__CSI_D5 IOMUX_MODE(MX31_PIN_CSI_D5, IOMUX_CONFIG_FUNC) |
607 | #define MX31_PIN_CSI_D6__CSI_D6 IOMUX_MODE(MX31_PIN_CSI_D6, IOMUX_CONFIG_FUNC) | 609 | #define MX31_PIN_CSI_D6__CSI_D6 IOMUX_MODE(MX31_PIN_CSI_D6, IOMUX_CONFIG_FUNC) |