2 * Copyright (C) 2010 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/compiler.h>
10 #include <linux/err.h>
11 #include <linux/init.h>
13 #include <mach/hardware.h>
14 #include <mach/devices-common.h>
16 #include <mach/sdma.h>
18 struct sdma_platform_data
{
25 struct imx_imx_sdma_data
{
26 resource_size_t iobase
;
28 struct sdma_platform_data pdata
;
31 #define imx_imx_sdma_data_entry_single(soc, _sdma_version, _cpu_name, _to_version)\
33 .iobase = soc ## _SDMA ## _BASE_ADDR, \
34 .irq = soc ## _INT_SDMA, \
36 .sdma_version = _sdma_version, \
37 .cpu_name = _cpu_name, \
38 .to_version = _to_version, \
42 #ifdef CONFIG_ARCH_MX25
43 const struct imx_imx_sdma_data imx25_imx_sdma_data __initconst
=
44 imx_imx_sdma_data_entry_single(MX25
, 1, "imx25", 0);
45 #endif /* ifdef CONFIG_ARCH_MX25 */
47 #ifdef CONFIG_ARCH_MX31
48 struct imx_imx_sdma_data imx31_imx_sdma_data __initdata
=
49 imx_imx_sdma_data_entry_single(MX31
, 1, "imx31", 0);
50 #endif /* ifdef CONFIG_ARCH_MX31 */
52 #ifdef CONFIG_ARCH_MX35
53 struct imx_imx_sdma_data imx35_imx_sdma_data __initdata
=
54 imx_imx_sdma_data_entry_single(MX35
, 2, "imx35", 0);
55 #endif /* ifdef CONFIG_ARCH_MX35 */
57 #ifdef CONFIG_ARCH_MX51
58 const struct imx_imx_sdma_data imx51_imx_sdma_data __initconst
=
59 imx_imx_sdma_data_entry_single(MX51
, 2, "imx51", 0);
60 #endif /* ifdef CONFIG_ARCH_MX51 */
62 static struct platform_device __init __maybe_unused
*imx_add_imx_sdma(
63 const struct imx_imx_sdma_data
*data
)
65 struct resource res
[] = {
67 .start
= data
->iobase
,
68 .end
= data
->iobase
+ SZ_4K
- 1,
69 .flags
= IORESOURCE_MEM
,
73 .flags
= IORESOURCE_IRQ
,
77 return imx_add_platform_device("imx-sdma", -1,
79 &data
->pdata
, sizeof(data
->pdata
));
82 static struct platform_device __init __maybe_unused
*imx_add_imx_dma(void)
84 return imx_add_platform_device("imx-dma", -1, NULL
, 0, NULL
, 0);
87 static int __init
imxXX_add_imx_dma(void)
89 struct platform_device
*ret
;
91 #if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
92 if (cpu_is_mx21() || cpu_is_mx27())
93 ret
= imx_add_imx_dma();
97 #if defined(CONFIG_ARCH_MX25)
99 ret
= imx_add_imx_sdma(&imx25_imx_sdma_data
);
103 #if defined(CONFIG_ARCH_MX31)
105 imx31_imx_sdma_data
.pdata
.to_version
= mx31_revision() >> 4;
106 ret
= imx_add_imx_sdma(&imx31_imx_sdma_data
);
110 #if defined(CONFIG_ARCH_MX35)
112 imx35_imx_sdma_data
.pdata
.to_version
= mx35_revision() >> 4;
113 ret
= imx_add_imx_sdma(&imx35_imx_sdma_data
);
117 #if defined(CONFIG_ARCH_MX51)
119 ret
= imx_add_imx_sdma(&imx51_imx_sdma_data
);
122 ret
= ERR_PTR(-ENODEV
);
129 arch_initcall(imxXX_add_imx_dma
);