]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/arm/plat-mxc/devices/platform-ipu-core.c
net: remove mm.h inclusion from netdevice.h
[mirror_ubuntu-bionic-kernel.git] / arch / arm / plat-mxc / devices / platform-ipu-core.c
1 /*
2 * Copyright (C) 2011 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
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 <linux/dma-mapping.h>
10 #include <mach/hardware.h>
11 #include <mach/devices-common.h>
12
13 #define imx_ipu_core_entry_single(soc) \
14 { \
15 .iobase = soc ## _IPU_CTRL_BASE_ADDR, \
16 .synirq = soc ## _INT_IPU_SYN, \
17 .errirq = soc ## _INT_IPU_ERR, \
18 }
19
20 #ifdef CONFIG_SOC_IMX31
21 const struct imx_ipu_core_data imx31_ipu_core_data __initconst =
22 imx_ipu_core_entry_single(MX31);
23 #endif
24
25 #ifdef CONFIG_SOC_IMX35
26 const struct imx_ipu_core_data imx35_ipu_core_data __initconst =
27 imx_ipu_core_entry_single(MX35);
28 #endif
29
30 static struct platform_device *imx_ipu_coredev __initdata;
31
32 struct platform_device *__init imx_add_ipu_core(
33 const struct imx_ipu_core_data *data,
34 const struct ipu_platform_data *pdata)
35 {
36 /* The resource order is important! */
37 struct resource res[] = {
38 {
39 .start = data->iobase,
40 .end = data->iobase + 0x5f,
41 .flags = IORESOURCE_MEM,
42 }, {
43 .start = data->iobase + 0x88,
44 .end = data->iobase + 0xb3,
45 .flags = IORESOURCE_MEM,
46 }, {
47 .start = data->synirq,
48 .end = data->synirq,
49 .flags = IORESOURCE_IRQ,
50 }, {
51 .start = data->errirq,
52 .end = data->errirq,
53 .flags = IORESOURCE_IRQ,
54 },
55 };
56
57 return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1,
58 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
59 }
60
61 struct platform_device *__init imx_alloc_mx3_camera(
62 const struct imx_ipu_core_data *data,
63 const struct mx3_camera_pdata *pdata)
64 {
65 struct resource res[] = {
66 {
67 .start = data->iobase + 0x60,
68 .end = data->iobase + 0x87,
69 .flags = IORESOURCE_MEM,
70 },
71 };
72 int ret = -ENOMEM;
73 struct platform_device *pdev;
74
75 if (IS_ERR_OR_NULL(imx_ipu_coredev))
76 return ERR_PTR(-ENODEV);
77
78 pdev = platform_device_alloc("mx3-camera", 0);
79 if (!pdev)
80 goto err;
81
82 pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
83 if (!pdev->dev.dma_mask)
84 goto err;
85
86 *pdev->dev.dma_mask = DMA_BIT_MASK(32);
87 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
88
89 ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
90 if (ret)
91 goto err;
92
93 if (pdata) {
94 struct mx3_camera_pdata *copied_pdata;
95
96 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
97 if (ret) {
98 err:
99 kfree(pdev->dev.dma_mask);
100 platform_device_put(pdev);
101 return ERR_PTR(-ENODEV);
102 }
103 copied_pdata = dev_get_platdata(&pdev->dev);
104 copied_pdata->dma_dev = &imx_ipu_coredev->dev;
105 }
106
107 return pdev;
108 }
109
110 struct platform_device *__init imx_add_mx3_sdc_fb(
111 const struct imx_ipu_core_data *data,
112 struct mx3fb_platform_data *pdata)
113 {
114 struct resource res[] = {
115 {
116 .start = data->iobase + 0xb4,
117 .end = data->iobase + 0x1bf,
118 .flags = IORESOURCE_MEM,
119 },
120 };
121
122 if (IS_ERR_OR_NULL(imx_ipu_coredev))
123 return ERR_PTR(-ENODEV);
124
125 pdata->dma_dev = &imx_ipu_coredev->dev;
126
127 return imx_add_platform_device_dmamask("mx3_sdc_fb", -1,
128 res, ARRAY_SIZE(res), pdata, sizeof(*pdata),
129 DMA_BIT_MASK(32));
130 }