aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-mxc/devices
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2011-06-22 10:41:30 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2011-07-07 04:01:12 -0400
commit3622360430e90d47a0d028dd5333a13771589331 (patch)
treea2a4df6d905d4157bf0e3cb5e5d6b3b5d481d0b6 /arch/arm/plat-mxc/devices
parent8dd7b817a1135940406a3271346a4a8e39e2b87c (diff)
ARM: mxc: clean up imx-dma device registration
The patch follows the implementation of gpio-mxc device registration to break the concentrated imx-dma device registration into soc specific setup function. Then we can avoid the churn of "#ifdef" and the cpu_is_mx checking on such a long list, which makes no sense, considering more soc supports need to be added and we need to support single image for multiple socs in the long run. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/plat-mxc/devices')
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-dma.c232
1 files changed, 13 insertions, 219 deletions
diff --git a/arch/arm/plat-mxc/devices/platform-imx-dma.c b/arch/arm/plat-mxc/devices/platform-imx-dma.c
index 27104f581700..2b0fdb23beb8 100644
--- a/arch/arm/plat-mxc/devices/platform-imx-dma.c
+++ b/arch/arm/plat-mxc/devices/platform-imx-dma.c
@@ -6,235 +6,29 @@
6 * the terms of the GNU General Public License version 2 as published by the 6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation. 7 * Free Software Foundation.
8 */ 8 */
9#include <linux/compiler.h>
10#include <linux/err.h>
11#include <linux/init.h>
12
13#include <mach/hardware.h>
14#include <mach/devices-common.h> 9#include <mach/devices-common.h>
15#include <mach/sdma.h>
16
17struct imx_imx_sdma_data {
18 resource_size_t iobase;
19 resource_size_t irq;
20 struct sdma_platform_data pdata;
21};
22
23#define imx_imx_sdma_data_entry_single(soc, _sdma_version, _cpu_name, _to_version)\
24 { \
25 .iobase = soc ## _SDMA ## _BASE_ADDR, \
26 .irq = soc ## _INT_SDMA, \
27 .pdata = { \
28 .sdma_version = _sdma_version, \
29 .cpu_name = _cpu_name, \
30 .to_version = _to_version, \
31 }, \
32 }
33
34#ifdef CONFIG_SOC_IMX25
35struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
36 imx_imx_sdma_data_entry_single(MX25, 2, "imx25", 1);
37#endif /* ifdef CONFIG_SOC_IMX25 */
38 10
39#ifdef CONFIG_SOC_IMX31 11struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
40struct imx_imx_sdma_data imx31_imx_sdma_data __initdata = 12{
41 imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 1); 13 return platform_device_register_resndata(&mxc_ahb_bus,
42#endif /* ifdef CONFIG_SOC_IMX31 */ 14 "imx-dma", -1, NULL, 0, NULL, 0);
43 15}
44#ifdef CONFIG_SOC_IMX35
45struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
46 imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 1);
47#endif /* ifdef CONFIG_SOC_IMX35 */
48
49#ifdef CONFIG_SOC_IMX51
50struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
51 imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 1);
52#endif /* ifdef CONFIG_SOC_IMX51 */
53
54#ifdef CONFIG_SOC_IMX53
55struct imx_imx_sdma_data imx53_imx_sdma_data __initconst =
56 imx_imx_sdma_data_entry_single(MX53, 2, "imx53", 0);
57#endif /* ifdef CONFIG_SOC_IMX53 */
58 16
59static struct platform_device __init __maybe_unused *imx_add_imx_sdma( 17struct platform_device __init __maybe_unused *imx_add_imx_sdma(
60 const struct imx_imx_sdma_data *data) 18 resource_size_t iobase, int irq, struct sdma_platform_data *pdata)
61{ 19{
62 struct resource res[] = { 20 struct resource res[] = {
63 { 21 {
64 .start = data->iobase, 22 .start = iobase,
65 .end = data->iobase + SZ_16K - 1, 23 .end = iobase + SZ_16K - 1,
66 .flags = IORESOURCE_MEM, 24 .flags = IORESOURCE_MEM,
67 }, { 25 }, {
68 .start = data->irq, 26 .start = irq,
69 .end = data->irq, 27 .end = irq,
70 .flags = IORESOURCE_IRQ, 28 .flags = IORESOURCE_IRQ,
71 }, 29 },
72 }; 30 };
73 31
74 return imx_add_platform_device("imx-sdma", -1, 32 return platform_device_register_resndata(&mxc_ahb_bus, "imx-sdma",
75 res, ARRAY_SIZE(res), 33 -1, res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
76 &data->pdata, sizeof(data->pdata));
77}
78
79static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
80{
81 return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
82}
83
84#ifdef CONFIG_ARCH_MX25
85static struct sdma_script_start_addrs addr_imx25 = {
86 .ap_2_ap_addr = 729,
87 .uart_2_mcu_addr = 904,
88 .per_2_app_addr = 1255,
89 .mcu_2_app_addr = 834,
90 .uartsh_2_mcu_addr = 1120,
91 .per_2_shp_addr = 1329,
92 .mcu_2_shp_addr = 1048,
93 .ata_2_mcu_addr = 1560,
94 .mcu_2_ata_addr = 1479,
95 .app_2_per_addr = 1189,
96 .app_2_mcu_addr = 770,
97 .shp_2_per_addr = 1407,
98 .shp_2_mcu_addr = 979,
99};
100#endif
101
102#ifdef CONFIG_SOC_IMX31
103static struct sdma_script_start_addrs addr_imx31_to1 = {
104 .per_2_per_addr = 1677,
105};
106
107static struct sdma_script_start_addrs addr_imx31_to2 = {
108 .ap_2_ap_addr = 423,
109 .ap_2_bp_addr = 829,
110 .bp_2_ap_addr = 1029,
111};
112#endif
113
114#ifdef CONFIG_SOC_IMX35
115static struct sdma_script_start_addrs addr_imx35_to1 = {
116 .ap_2_ap_addr = 642,
117 .uart_2_mcu_addr = 817,
118 .mcu_2_app_addr = 747,
119 .uartsh_2_mcu_addr = 1183,
120 .per_2_shp_addr = 1033,
121 .mcu_2_shp_addr = 961,
122 .ata_2_mcu_addr = 1333,
123 .mcu_2_ata_addr = 1252,
124 .app_2_mcu_addr = 683,
125 .shp_2_per_addr = 1111,
126 .shp_2_mcu_addr = 892,
127};
128
129static struct sdma_script_start_addrs addr_imx35_to2 = {
130 .ap_2_ap_addr = 729,
131 .uart_2_mcu_addr = 904,
132 .per_2_app_addr = 1597,
133 .mcu_2_app_addr = 834,
134 .uartsh_2_mcu_addr = 1270,
135 .per_2_shp_addr = 1120,
136 .mcu_2_shp_addr = 1048,
137 .ata_2_mcu_addr = 1429,
138 .mcu_2_ata_addr = 1339,
139 .app_2_per_addr = 1531,
140 .app_2_mcu_addr = 770,
141 .shp_2_per_addr = 1198,
142 .shp_2_mcu_addr = 979,
143};
144#endif
145
146#ifdef CONFIG_SOC_IMX51
147static struct sdma_script_start_addrs addr_imx51 = {
148 .ap_2_ap_addr = 642,
149 .uart_2_mcu_addr = 817,
150 .mcu_2_app_addr = 747,
151 .mcu_2_shp_addr = 961,
152 .ata_2_mcu_addr = 1473,
153 .mcu_2_ata_addr = 1392,
154 .app_2_per_addr = 1033,
155 .app_2_mcu_addr = 683,
156 .shp_2_per_addr = 1251,
157 .shp_2_mcu_addr = 892,
158};
159#endif
160
161#ifdef CONFIG_SOC_IMX53
162static struct sdma_script_start_addrs addr_imx53 = {
163 .ap_2_ap_addr = 642,
164 .app_2_mcu_addr = 683,
165 .mcu_2_app_addr = 747,
166 .uart_2_mcu_addr = 817,
167 .shp_2_mcu_addr = 891,
168 .mcu_2_shp_addr = 960,
169 .uartsh_2_mcu_addr = 1032,
170 .spdif_2_mcu_addr = 1100,
171 .mcu_2_spdif_addr = 1134,
172 .firi_2_mcu_addr = 1193,
173 .mcu_2_firi_addr = 1290,
174};
175#endif
176
177static int __init imxXX_add_imx_dma(void)
178{
179 struct platform_device *ret;
180
181#if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
182 if (cpu_is_mx21() || cpu_is_mx27())
183 ret = imx_add_imx_dma();
184 else
185#endif
186
187#if defined(CONFIG_SOC_IMX25)
188 if (cpu_is_mx25()) {
189 imx25_imx_sdma_data.pdata.script_addrs = &addr_imx25;
190 ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
191 } else
192#endif
193
194#if defined(CONFIG_SOC_IMX31)
195 if (cpu_is_mx31()) {
196 int to_version = mx31_revision() >> 4;
197 imx31_imx_sdma_data.pdata.to_version = to_version;
198 if (to_version == 1)
199 imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to1;
200 else
201 imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to2;
202 ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
203 } else
204#endif
205
206#if defined(CONFIG_SOC_IMX35)
207 if (cpu_is_mx35()) {
208 int to_version = mx35_revision() >> 4;
209 imx35_imx_sdma_data.pdata.to_version = to_version;
210 if (to_version == 1)
211 imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to1;
212 else
213 imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to2;
214 ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
215 } else
216#endif
217
218#if defined(CONFIG_SOC_IMX51)
219 if (cpu_is_mx51()) {
220 int to_version = mx51_revision() >> 4;
221 imx51_imx_sdma_data.pdata.to_version = to_version;
222 imx51_imx_sdma_data.pdata.script_addrs = &addr_imx51;
223 ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
224 } else
225#endif
226
227#if defined(CONFIG_SOC_IMX53)
228 if (cpu_is_mx53()) {
229 imx53_imx_sdma_data.pdata.script_addrs = &addr_imx53;
230 ret = imx_add_imx_sdma(&imx53_imx_sdma_data);
231 } else
232#endif
233 ret = ERR_PTR(-ENODEV);
234
235 if (IS_ERR(ret))
236 return PTR_ERR(ret);
237
238 return 0;
239} 34}
240arch_initcall(imxXX_add_imx_dma);