mm: move shmem prototypes to shmem_fs.h
[linux/fpc-iii.git] / arch / arm / plat-mxc / devices / platform-ipu-core.c
blobedf65034aea5b4956df4cf3e36badc6b223917bd
1 /*
2 * Copyright (C) 2011 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9 #include <mach/hardware.h>
10 #include <mach/devices-common.h>
12 #define imx_ipu_core_entry_single(soc) \
13 { \
14 .iobase = soc ## _IPU_CTRL_BASE_ADDR, \
15 .synirq = soc ## _INT_IPU_SYN, \
16 .errirq = soc ## _INT_IPU_ERR, \
19 #ifdef CONFIG_SOC_IMX31
20 const struct imx_ipu_core_data imx31_ipu_core_data __initconst =
21 imx_ipu_core_entry_single(MX31);
22 #endif
24 #ifdef CONFIG_SOC_IMX35
25 const struct imx_ipu_core_data imx35_ipu_core_data __initconst =
26 imx_ipu_core_entry_single(MX35);
27 #endif
29 static struct platform_device *imx_ipu_coredev __initdata;
31 struct platform_device *__init imx_add_ipu_core(
32 const struct imx_ipu_core_data *data,
33 const struct ipu_platform_data *pdata)
35 /* The resource order is important! */
36 struct resource res[] = {
38 .start = data->iobase,
39 .end = data->iobase + 0x5f,
40 .flags = IORESOURCE_MEM,
41 }, {
42 .start = data->iobase + 0x88,
43 .end = data->iobase + 0xb3,
44 .flags = IORESOURCE_MEM,
45 }, {
46 .start = data->synirq,
47 .end = data->synirq,
48 .flags = IORESOURCE_IRQ,
49 }, {
50 .start = data->errirq,
51 .end = data->errirq,
52 .flags = IORESOURCE_IRQ,
56 return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1,
57 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
60 struct platform_device *__init imx_alloc_mx3_camera(
61 const struct imx_ipu_core_data *data,
62 const struct mx3_camera_pdata *pdata)
64 struct resource res[] = {
66 .start = data->iobase + 0x60,
67 .end = data->iobase + 0x87,
68 .flags = IORESOURCE_MEM,
71 int ret = -ENOMEM;
72 struct platform_device *pdev;
74 if (IS_ERR_OR_NULL(imx_ipu_coredev))
75 return ERR_PTR(-ENODEV);
77 pdev = platform_device_alloc("mx3-camera", 0);
78 if (!pdev)
79 goto err;
81 pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
82 if (!pdev->dev.dma_mask)
83 goto err;
85 *pdev->dev.dma_mask = DMA_BIT_MASK(32);
86 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
88 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
89 if (ret)
90 goto err;
92 if (pdata) {
93 struct mx3_camera_pdata *copied_pdata;
95 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
96 if (ret) {
97 err:
98 kfree(pdev->dev.dma_mask);
99 platform_device_put(pdev);
100 return ERR_PTR(-ENODEV);
102 copied_pdata = dev_get_platdata(&pdev->dev);
103 copied_pdata->dma_dev = &imx_ipu_coredev->dev;
106 return pdev;
109 struct platform_device *__init imx_add_mx3_sdc_fb(
110 const struct imx_ipu_core_data *data,
111 struct mx3fb_platform_data *pdata)
113 struct resource res[] = {
115 .start = data->iobase + 0xb4,
116 .end = data->iobase + 0x1bf,
117 .flags = IORESOURCE_MEM,
121 if (IS_ERR_OR_NULL(imx_ipu_coredev))
122 return ERR_PTR(-ENODEV);
124 pdata->dma_dev = &imx_ipu_coredev->dev;
126 return imx_add_platform_device_dmamask("mx3_sdc_fb", -1,
127 res, ARRAY_SIZE(res), pdata, sizeof(*pdata),
128 DMA_BIT_MASK(32));