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.
9 #include <linux/dma-mapping.h>
10 #include <mach/hardware.h>
11 #include "devices-common.h"
13 #define imx_ipu_core_entry_single(soc) \
15 .iobase = soc ## _IPU_CTRL_BASE_ADDR, \
16 .synirq = soc ## _INT_IPU_SYN, \
17 .errirq = soc ## _INT_IPU_ERR, \
20 #ifdef CONFIG_SOC_IMX31
21 const struct imx_ipu_core_data imx31_ipu_core_data __initconst
=
22 imx_ipu_core_entry_single(MX31
);
25 #ifdef CONFIG_SOC_IMX35
26 const struct imx_ipu_core_data imx35_ipu_core_data __initconst
=
27 imx_ipu_core_entry_single(MX35
);
30 static struct platform_device
*imx_ipu_coredev __initdata
;
32 struct platform_device
*__init
imx_add_ipu_core(
33 const struct imx_ipu_core_data
*data
)
35 /* The resource order is important! */
36 struct resource res
[] = {
38 .start
= data
->iobase
,
39 .end
= data
->iobase
+ 0x5f,
40 .flags
= IORESOURCE_MEM
,
42 .start
= data
->iobase
+ 0x88,
43 .end
= data
->iobase
+ 0xb3,
44 .flags
= IORESOURCE_MEM
,
46 .start
= data
->synirq
,
48 .flags
= IORESOURCE_IRQ
,
50 .start
= data
->errirq
,
52 .flags
= IORESOURCE_IRQ
,
56 return imx_ipu_coredev
= imx_add_platform_device("ipu-core", -1,
57 res
, ARRAY_SIZE(res
), NULL
, 0);
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
,
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);
81 pdev
->dev
.dma_mask
= kmalloc(sizeof(*pdev
->dev
.dma_mask
), GFP_KERNEL
);
82 if (!pdev
->dev
.dma_mask
)
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
));
93 struct mx3_camera_pdata
*copied_pdata
;
95 ret
= platform_device_add_data(pdev
, pdata
, sizeof(*pdata
));
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
;
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
),