diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2011-03-03 15:32:02 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-05-19 07:11:20 -0400 |
commit | afa77ef30ead4865ce2c0c1c55054d45521ce1c7 (patch) | |
tree | 87a455605b7d0ae9685e71ae7fd48a1a0d87d379 /arch/arm/plat-mxc | |
parent | 031e912741746e4350204bb0436590ca0e993a7d (diff) |
ARM: mx3: dynamically allocate "ipu-core" devices
... together with the related devices "mx3_camera" and "mx3_sdc_fb".
"mx3_camera" doesn't fit the scheme of the other devices that just are
allocated and registered in a single function because it needs additional
care to get some dmaable memory. So currently imx31_alloc_mx3_camera
duplicates most of imx_add_platform_device_dmamask, but I'm not sure it's
worth to split the latter to be able to reuse more code.
This gets rid of mach-mx3/devices.[ch] and so several files need to be
adapted not to #include devices.h anymore.
LAKML-Reference: 1299271882-2130-5-git-send-email-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/plat-mxc')
-rw-r--r-- | arch/arm/plat-mxc/devices/Kconfig | 3 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/platform-ipu-core.c | 129 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/devices-common.h | 18 |
4 files changed, 151 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig index 0e8d7ab7898a..a860b16d7258 100644 --- a/arch/arm/plat-mxc/devices/Kconfig +++ b/arch/arm/plat-mxc/devices/Kconfig | |||
@@ -41,6 +41,9 @@ config IMX_HAVE_PLATFORM_IMX_UART | |||
41 | config IMX_HAVE_PLATFORM_IMX_UDC | 41 | config IMX_HAVE_PLATFORM_IMX_UDC |
42 | bool | 42 | bool |
43 | 43 | ||
44 | config IMX_HAVE_PLATFORM_IPU_CORE | ||
45 | bool | ||
46 | |||
44 | config IMX_HAVE_PLATFORM_MX1_CAMERA | 47 | config IMX_HAVE_PLATFORM_MX1_CAMERA |
45 | bool | 48 | bool |
46 | 49 | ||
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile index ca227eaea7cc..ad2922acf480 100644 --- a/arch/arm/plat-mxc/devices/Makefile +++ b/arch/arm/plat-mxc/devices/Makefile | |||
@@ -12,6 +12,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_KEYPAD) += platform-imx-keypad.o | |||
12 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o | 12 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o |
13 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o | 13 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o |
14 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o | 14 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o |
15 | obj-$(CONFIG_IMX_HAVE_PLATFORM_IPU_CORE) += platform-ipu-core.o | ||
15 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o | 16 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o |
16 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o | 17 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o |
17 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o | 18 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o |
diff --git a/arch/arm/plat-mxc/devices/platform-ipu-core.c b/arch/arm/plat-mxc/devices/platform-ipu-core.c new file mode 100644 index 000000000000..edf65034aea5 --- /dev/null +++ b/arch/arm/plat-mxc/devices/platform-ipu-core.c | |||
@@ -0,0 +1,129 @@ | |||
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 <mach/hardware.h> | ||
10 | #include <mach/devices-common.h> | ||
11 | |||
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, \ | ||
17 | } | ||
18 | |||
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 | ||
23 | |||
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 | ||
28 | |||
29 | static struct platform_device *imx_ipu_coredev __initdata; | ||
30 | |||
31 | struct platform_device *__init imx_add_ipu_core( | ||
32 | const struct imx_ipu_core_data *data, | ||
33 | const struct ipu_platform_data *pdata) | ||
34 | { | ||
35 | /* The resource order is important! */ | ||
36 | struct resource res[] = { | ||
37 | { | ||
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, | ||
53 | }, | ||
54 | }; | ||
55 | |||
56 | return imx_ipu_coredev = imx_add_platform_device("ipu-core", -1, | ||
57 | res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); | ||
58 | } | ||
59 | |||
60 | struct platform_device *__init imx_alloc_mx3_camera( | ||
61 | const struct imx_ipu_core_data *data, | ||
62 | const struct mx3_camera_pdata *pdata) | ||
63 | { | ||
64 | struct resource res[] = { | ||
65 | { | ||
66 | .start = data->iobase + 0x60, | ||
67 | .end = data->iobase + 0x87, | ||
68 | .flags = IORESOURCE_MEM, | ||
69 | }, | ||
70 | }; | ||
71 | int ret = -ENOMEM; | ||
72 | struct platform_device *pdev; | ||
73 | |||
74 | if (IS_ERR_OR_NULL(imx_ipu_coredev)) | ||
75 | return ERR_PTR(-ENODEV); | ||
76 | |||
77 | pdev = platform_device_alloc("mx3-camera", 0); | ||
78 | if (!pdev) | ||
79 | goto err; | ||
80 | |||
81 | pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); | ||
82 | if (!pdev->dev.dma_mask) | ||
83 | goto err; | ||
84 | |||
85 | *pdev->dev.dma_mask = DMA_BIT_MASK(32); | ||
86 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
87 | |||
88 | ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); | ||
89 | if (ret) | ||
90 | goto err; | ||
91 | |||
92 | if (pdata) { | ||
93 | struct mx3_camera_pdata *copied_pdata; | ||
94 | |||
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); | ||
101 | } | ||
102 | copied_pdata = dev_get_platdata(&pdev->dev); | ||
103 | copied_pdata->dma_dev = &imx_ipu_coredev->dev; | ||
104 | } | ||
105 | |||
106 | return pdev; | ||
107 | } | ||
108 | |||
109 | struct platform_device *__init imx_add_mx3_sdc_fb( | ||
110 | const struct imx_ipu_core_data *data, | ||
111 | struct mx3fb_platform_data *pdata) | ||
112 | { | ||
113 | struct resource res[] = { | ||
114 | { | ||
115 | .start = data->iobase + 0xb4, | ||
116 | .end = data->iobase + 0x1bf, | ||
117 | .flags = IORESOURCE_MEM, | ||
118 | }, | ||
119 | }; | ||
120 | |||
121 | if (IS_ERR_OR_NULL(imx_ipu_coredev)) | ||
122 | return ERR_PTR(-ENODEV); | ||
123 | |||
124 | pdata->dma_dev = &imx_ipu_coredev->dev; | ||
125 | |||
126 | return imx_add_platform_device_dmamask("mx3_sdc_fb", -1, | ||
127 | res, ARRAY_SIZE(res), pdata, sizeof(*pdata), | ||
128 | DMA_BIT_MASK(32)); | ||
129 | } | ||
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h index b0bc1987c1d3..fa8477337f91 100644 --- a/arch/arm/plat-mxc/include/mach/devices-common.h +++ b/arch/arm/plat-mxc/include/mach/devices-common.h | |||
@@ -166,6 +166,24 @@ struct platform_device *__init imx_add_imx_udc( | |||
166 | const struct imx_imx_udc_data *data, | 166 | const struct imx_imx_udc_data *data, |
167 | const struct imxusb_platform_data *pdata); | 167 | const struct imxusb_platform_data *pdata); |
168 | 168 | ||
169 | #include <mach/ipu.h> | ||
170 | #include <mach/mx3fb.h> | ||
171 | #include <mach/mx3_camera.h> | ||
172 | struct imx_ipu_core_data { | ||
173 | resource_size_t iobase; | ||
174 | resource_size_t synirq; | ||
175 | resource_size_t errirq; | ||
176 | }; | ||
177 | struct platform_device *__init imx_add_ipu_core( | ||
178 | const struct imx_ipu_core_data *data, | ||
179 | const struct ipu_platform_data *pdata); | ||
180 | struct platform_device *__init imx_alloc_mx3_camera( | ||
181 | const struct imx_ipu_core_data *data, | ||
182 | const struct mx3_camera_pdata *pdata); | ||
183 | struct platform_device *__init imx_add_mx3_sdc_fb( | ||
184 | const struct imx_ipu_core_data *data, | ||
185 | struct mx3fb_platform_data *pdata); | ||
186 | |||
169 | #include <mach/mx1_camera.h> | 187 | #include <mach/mx1_camera.h> |
170 | struct imx_mx1_camera_data { | 188 | struct imx_mx1_camera_data { |
171 | resource_size_t iobase; | 189 | resource_size_t iobase; |