1 // SPDX-License-Identifier: GPL-2.0
3 // Samsung's S3C64XX generic DMA support using amba-pl08x driver.
5 // Copyright (c) 2013 Tomasz Figa <tomasz.figa@gmail.com>
7 #include <linux/kernel.h>
8 #include <linux/amba/bus.h>
9 #include <linux/amba/pl080.h>
10 #include <linux/amba/pl08x.h>
14 #include <mach/irqs.h>
19 static int pl08x_get_xfer_signal(const struct pl08x_channel_data
*cd
)
21 return cd
->min_signal
;
24 static void pl08x_put_xfer_signal(const struct pl08x_channel_data
*cd
, int ch
)
32 static struct pl08x_channel_data s3c64xx_dma0_info
[] = {
37 .periph_buses
= PL08X_AHB2
,
42 .periph_buses
= PL08X_AHB2
,
47 .periph_buses
= PL08X_AHB2
,
52 .periph_buses
= PL08X_AHB2
,
57 .periph_buses
= PL08X_AHB2
,
62 .periph_buses
= PL08X_AHB2
,
67 .periph_buses
= PL08X_AHB2
,
72 .periph_buses
= PL08X_AHB2
,
77 .periph_buses
= PL08X_AHB2
,
82 .periph_buses
= PL08X_AHB2
,
87 .periph_buses
= PL08X_AHB2
,
92 .periph_buses
= PL08X_AHB2
,
97 .periph_buses
= PL08X_AHB2
,
102 .periph_buses
= PL08X_AHB2
,
107 .periph_buses
= PL08X_AHB2
,
112 .periph_buses
= PL08X_AHB2
,
116 static const struct dma_slave_map s3c64xx_dma0_slave_map
[] = {
117 { "s3c6400-uart.0", "tx", &s3c64xx_dma0_info
[0] },
118 { "s3c6400-uart.0", "rx", &s3c64xx_dma0_info
[1] },
119 { "s3c6400-uart.1", "tx", &s3c64xx_dma0_info
[2] },
120 { "s3c6400-uart.1", "rx", &s3c64xx_dma0_info
[3] },
121 { "s3c6400-uart.2", "tx", &s3c64xx_dma0_info
[4] },
122 { "s3c6400-uart.2", "rx", &s3c64xx_dma0_info
[5] },
123 { "s3c6400-uart.3", "tx", &s3c64xx_dma0_info
[6] },
124 { "s3c6400-uart.3", "rx", &s3c64xx_dma0_info
[7] },
125 { "samsung-pcm.0", "tx", &s3c64xx_dma0_info
[8] },
126 { "samsung-pcm.0", "rx", &s3c64xx_dma0_info
[9] },
127 { "samsung-i2s.0", "tx", &s3c64xx_dma0_info
[10] },
128 { "samsung-i2s.0", "rx", &s3c64xx_dma0_info
[11] },
129 { "s3c6410-spi.0", "tx", &s3c64xx_dma0_info
[12] },
130 { "s3c6410-spi.0", "rx", &s3c64xx_dma0_info
[13] },
131 { "samsung-i2s.2", "tx", &s3c64xx_dma0_info
[14] },
132 { "samsung-i2s.2", "rx", &s3c64xx_dma0_info
[15] },
135 struct pl08x_platform_data s3c64xx_dma0_plat_data
= {
136 .memcpy_burst_size
= PL08X_BURST_SZ_4
,
137 .memcpy_bus_width
= PL08X_BUS_WIDTH_32_BITS
,
138 .memcpy_prot_buff
= true,
139 .memcpy_prot_cache
= true,
140 .lli_buses
= PL08X_AHB1
,
141 .mem_buses
= PL08X_AHB1
,
142 .get_xfer_signal
= pl08x_get_xfer_signal
,
143 .put_xfer_signal
= pl08x_put_xfer_signal
,
144 .slave_channels
= s3c64xx_dma0_info
,
145 .num_slave_channels
= ARRAY_SIZE(s3c64xx_dma0_info
),
146 .slave_map
= s3c64xx_dma0_slave_map
,
147 .slave_map_len
= ARRAY_SIZE(s3c64xx_dma0_slave_map
),
150 static AMBA_AHB_DEVICE(s3c64xx_dma0
, "dma-pl080s.0", 0,
151 0x75000000, {IRQ_DMA0
}, &s3c64xx_dma0_plat_data
);
157 static struct pl08x_channel_data s3c64xx_dma1_info
[] = {
162 .periph_buses
= PL08X_AHB2
,
167 .periph_buses
= PL08X_AHB2
,
172 .periph_buses
= PL08X_AHB2
,
177 .periph_buses
= PL08X_AHB2
,
182 .periph_buses
= PL08X_AHB2
,
187 .periph_buses
= PL08X_AHB2
,
189 .bus_id
= "ac97_out",
192 .periph_buses
= PL08X_AHB2
,
197 .periph_buses
= PL08X_AHB2
,
199 .bus_id
= "ac97_mic",
202 .periph_buses
= PL08X_AHB2
,
207 .periph_buses
= PL08X_AHB2
,
212 .periph_buses
= PL08X_AHB2
,
214 .bus_id
= "external",
217 .periph_buses
= PL08X_AHB2
,
221 static const struct dma_slave_map s3c64xx_dma1_slave_map
[] = {
222 { "samsung-pcm.1", "tx", &s3c64xx_dma1_info
[0] },
223 { "samsung-pcm.1", "rx", &s3c64xx_dma1_info
[1] },
224 { "samsung-i2s.1", "tx", &s3c64xx_dma1_info
[2] },
225 { "samsung-i2s.1", "rx", &s3c64xx_dma1_info
[3] },
226 { "s3c6410-spi.1", "tx", &s3c64xx_dma1_info
[4] },
227 { "s3c6410-spi.1", "rx", &s3c64xx_dma1_info
[5] },
230 struct pl08x_platform_data s3c64xx_dma1_plat_data
= {
231 .memcpy_burst_size
= PL08X_BURST_SZ_4
,
232 .memcpy_bus_width
= PL08X_BUS_WIDTH_32_BITS
,
233 .memcpy_prot_buff
= true,
234 .memcpy_prot_cache
= true,
235 .lli_buses
= PL08X_AHB1
,
236 .mem_buses
= PL08X_AHB1
,
237 .get_xfer_signal
= pl08x_get_xfer_signal
,
238 .put_xfer_signal
= pl08x_put_xfer_signal
,
239 .slave_channels
= s3c64xx_dma1_info
,
240 .num_slave_channels
= ARRAY_SIZE(s3c64xx_dma1_info
),
241 .slave_map
= s3c64xx_dma1_slave_map
,
242 .slave_map_len
= ARRAY_SIZE(s3c64xx_dma1_slave_map
),
245 static AMBA_AHB_DEVICE(s3c64xx_dma1
, "dma-pl080s.1", 0,
246 0x75100000, {IRQ_DMA1
}, &s3c64xx_dma1_plat_data
);
248 static int __init
s3c64xx_pl080_init(void)
250 if (!soc_is_s3c64xx())
253 /* Set all DMA configuration to be DMA, not SDMA */
254 writel(0xffffff, S3C64XX_SDMA_SEL
);
256 if (of_have_populated_dt())
259 amba_device_register(&s3c64xx_dma0_device
, &iomem_resource
);
260 amba_device_register(&s3c64xx_dma1_device
, &iomem_resource
);
264 arch_initcall(s3c64xx_pl080_init
);