blob: 33530d2d5ed1595bf4925c4646f3fe574a63bad7 [file] [log] [blame]
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +02001/*
2 * Copyright (C) 2010 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/compiler.h>
10#include <linux/err.h>
11#include <linux/init.h>
12
13#include <mach/hardware.h>
14#include <mach/devices-common.h>
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020015#include <mach/sdma.h>
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020016
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
Uwe Kleine-König972cc482010-11-11 18:35:01 +010034#ifdef CONFIG_SOC_IMX25
Sascha Hauer4e5cf412010-11-04 15:50:38 +010035struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020036 imx_imx_sdma_data_entry_single(MX25, 1, "imx25", 0);
Uwe Kleine-König972cc482010-11-11 18:35:01 +010037#endif /* ifdef CONFIG_SOC_IMX25 */
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020038
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010039#ifdef CONFIG_SOC_IMX31
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020040struct imx_imx_sdma_data imx31_imx_sdma_data __initdata =
41 imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 0);
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010042#endif /* ifdef CONFIG_SOC_IMX31 */
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020043
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010044#ifdef CONFIG_SOC_IMX35
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020045struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
46 imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 0);
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010047#endif /* ifdef CONFIG_SOC_IMX35 */
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020048
Fabio Estevamd94ed122010-11-26 12:25:58 -020049#ifdef CONFIG_SOC_IMX51
Sascha Hauer4e5cf412010-11-04 15:50:38 +010050struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020051 imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 0);
Fabio Estevamd94ed122010-11-26 12:25:58 -020052#endif /* ifdef CONFIG_SOC_IMX51 */
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +020053
54static struct platform_device __init __maybe_unused *imx_add_imx_sdma(
55 const struct imx_imx_sdma_data *data)
56{
57 struct resource res[] = {
58 {
59 .start = data->iobase,
60 .end = data->iobase + SZ_4K - 1,
61 .flags = IORESOURCE_MEM,
62 }, {
63 .start = data->irq,
64 .end = data->irq,
65 .flags = IORESOURCE_IRQ,
66 },
67 };
68
69 return imx_add_platform_device("imx-sdma", -1,
70 res, ARRAY_SIZE(res),
71 &data->pdata, sizeof(data->pdata));
72}
73
74static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
75{
76 return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
77}
78
Sascha Hauer4e5cf412010-11-04 15:50:38 +010079#ifdef CONFIG_ARCH_MX25
80static struct sdma_script_start_addrs addr_imx25_to1 = {
81 .ap_2_ap_addr = 729,
82 .uart_2_mcu_addr = 904,
83 .per_2_app_addr = 1255,
84 .mcu_2_app_addr = 834,
85 .uartsh_2_mcu_addr = 1120,
86 .per_2_shp_addr = 1329,
87 .mcu_2_shp_addr = 1048,
88 .ata_2_mcu_addr = 1560,
89 .mcu_2_ata_addr = 1479,
90 .app_2_per_addr = 1189,
91 .app_2_mcu_addr = 770,
92 .shp_2_per_addr = 1407,
93 .shp_2_mcu_addr = 979,
94};
95#endif
96
97#ifdef CONFIG_ARCH_MX31
98static struct sdma_script_start_addrs addr_imx31_to1 = {
99 .per_2_per_addr = 1677,
100};
101
102static struct sdma_script_start_addrs addr_imx31_to2 = {
103 .ap_2_ap_addr = 423,
104 .ap_2_bp_addr = 829,
105 .bp_2_ap_addr = 1029,
106};
107#endif
108
109#ifdef CONFIG_ARCH_MX35
110static struct sdma_script_start_addrs addr_imx35_to1 = {
111 .ap_2_ap_addr = 642,
112 .uart_2_mcu_addr = 817,
113 .mcu_2_app_addr = 747,
114 .uartsh_2_mcu_addr = 1183,
115 .per_2_shp_addr = 1033,
116 .mcu_2_shp_addr = 961,
117 .ata_2_mcu_addr = 1333,
118 .mcu_2_ata_addr = 1252,
119 .app_2_mcu_addr = 683,
120 .shp_2_per_addr = 1111,
121 .shp_2_mcu_addr = 892,
122};
123
124static struct sdma_script_start_addrs addr_imx35_to2 = {
125 .ap_2_ap_addr = 729,
126 .uart_2_mcu_addr = 904,
127 .per_2_app_addr = 1597,
128 .mcu_2_app_addr = 834,
129 .uartsh_2_mcu_addr = 1270,
130 .per_2_shp_addr = 1120,
131 .mcu_2_shp_addr = 1048,
132 .ata_2_mcu_addr = 1429,
133 .mcu_2_ata_addr = 1339,
134 .app_2_per_addr = 1531,
135 .app_2_mcu_addr = 770,
136 .shp_2_per_addr = 1198,
137 .shp_2_mcu_addr = 979,
138};
139#endif
140
Fabio Estevamd94ed122010-11-26 12:25:58 -0200141#ifdef CONFIG_SOC_IMX51
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100142static struct sdma_script_start_addrs addr_imx51_to1 = {
143 .ap_2_ap_addr = 642,
144 .uart_2_mcu_addr = 817,
145 .mcu_2_app_addr = 747,
146 .mcu_2_shp_addr = 961,
147 .ata_2_mcu_addr = 1473,
148 .mcu_2_ata_addr = 1392,
149 .app_2_per_addr = 1033,
150 .app_2_mcu_addr = 683,
151 .shp_2_per_addr = 1251,
152 .shp_2_mcu_addr = 892,
153};
154#endif
155
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200156static int __init imxXX_add_imx_dma(void)
157{
158 struct platform_device *ret;
159
160#if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
161 if (cpu_is_mx21() || cpu_is_mx27())
162 ret = imx_add_imx_dma();
163 else
164#endif
165
Uwe Kleine-König972cc482010-11-11 18:35:01 +0100166#if defined(CONFIG_SOC_IMX25)
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100167 if (cpu_is_mx25()) {
168 imx25_imx_sdma_data.pdata.script_addrs = &addr_imx25_to1;
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200169 ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100170 } else
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200171#endif
172
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +0100173#if defined(CONFIG_SOC_IMX31)
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200174 if (cpu_is_mx31()) {
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100175 int to_version = mx31_revision() >> 4;
176 imx31_imx_sdma_data.pdata.to_version = to_version;
177 if (to_version == 1)
178 imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to1;
179 else
180 imx31_imx_sdma_data.pdata.script_addrs = &addr_imx31_to2;
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200181 ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
182 } else
183#endif
184
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +0100185#if defined(CONFIG_SOC_IMX35)
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200186 if (cpu_is_mx35()) {
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100187 int to_version = mx35_revision() >> 4;
188 imx35_imx_sdma_data.pdata.to_version = to_version;
189 if (to_version == 1)
190 imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to1;
191 else
192 imx35_imx_sdma_data.pdata.script_addrs = &addr_imx35_to2;
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200193 ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
194 } else
195#endif
196
197#if defined(CONFIG_ARCH_MX51)
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100198 if (cpu_is_mx51()) {
199 imx51_imx_sdma_data.pdata.script_addrs = &addr_imx51_to1;
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200200 ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
Sascha Hauer4e5cf412010-11-04 15:50:38 +0100201 } else
Uwe Kleine-König8a8d2062010-10-08 16:00:11 +0200202#endif
203 ret = ERR_PTR(-ENODEV);
204
205 if (IS_ERR(ret))
206 return PTR_ERR(ret);
207
208 return 0;
209}
210arch_initcall(imxXX_add_imx_dma);