pl080.c 5.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Samsung's S3C64XX generic DMA support using amba-pl08x driver.
 *
 * Copyright (c) 2013 Tomasz Figa <tomasz.figa@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/amba/bus.h>
#include <linux/amba/pl080.h>
#include <linux/amba/pl08x.h>
#include <linux/of.h>

17
#include <plat/cpu.h>
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
#include <mach/irqs.h>
#include <mach/map.h>

#include "regs-sys.h"

static int pl08x_get_xfer_signal(const struct pl08x_channel_data *cd)
{
	return cd->min_signal;
}

static void pl08x_put_xfer_signal(const struct pl08x_channel_data *cd, int ch)
{
}

/*
 * DMA0
 */

static struct pl08x_channel_data s3c64xx_dma0_info[] = {
	{
		.bus_id = "uart0_tx",
		.min_signal = 0,
		.max_signal = 0,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart0_rx",
		.min_signal = 1,
		.max_signal = 1,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart1_tx",
		.min_signal = 2,
		.max_signal = 2,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart1_rx",
		.min_signal = 3,
		.max_signal = 3,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart2_tx",
		.min_signal = 4,
		.max_signal = 4,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart2_rx",
		.min_signal = 5,
		.max_signal = 5,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart3_tx",
		.min_signal = 6,
		.max_signal = 6,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "uart3_rx",
		.min_signal = 7,
		.max_signal = 7,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "pcm0_tx",
		.min_signal = 8,
		.max_signal = 8,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "pcm0_rx",
		.min_signal = 9,
		.max_signal = 9,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s0_tx",
		.min_signal = 10,
		.max_signal = 10,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s0_rx",
		.min_signal = 11,
		.max_signal = 11,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "spi0_tx",
		.min_signal = 12,
		.max_signal = 12,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "spi0_rx",
		.min_signal = 13,
		.max_signal = 13,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s2_tx",
		.min_signal = 14,
		.max_signal = 14,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s2_rx",
		.min_signal = 15,
		.max_signal = 15,
		.periph_buses = PL08X_AHB2,
	}
};

struct pl08x_platform_data s3c64xx_dma0_plat_data = {
	.memcpy_channel = {
		.bus_id = "memcpy",
		.cctl_memcpy =
			(PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
			PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
			PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
			PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
			PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
			PL080_CONTROL_PROT_SYS),
	},
	.lli_buses = PL08X_AHB1,
	.mem_buses = PL08X_AHB1,
	.get_xfer_signal = pl08x_get_xfer_signal,
	.put_xfer_signal = pl08x_put_xfer_signal,
	.slave_channels = s3c64xx_dma0_info,
	.num_slave_channels = ARRAY_SIZE(s3c64xx_dma0_info),
};

static AMBA_AHB_DEVICE(s3c64xx_dma0, "dma-pl080s.0", 0,
			0x75000000, {IRQ_DMA0}, &s3c64xx_dma0_plat_data);

/*
 * DMA1
 */

static struct pl08x_channel_data s3c64xx_dma1_info[] = {
	{
		.bus_id = "pcm1_tx",
		.min_signal = 0,
		.max_signal = 0,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "pcm1_rx",
		.min_signal = 1,
		.max_signal = 1,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s1_tx",
		.min_signal = 2,
		.max_signal = 2,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "i2s1_rx",
		.min_signal = 3,
		.max_signal = 3,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "spi1_tx",
		.min_signal = 4,
		.max_signal = 4,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "spi1_rx",
		.min_signal = 5,
		.max_signal = 5,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "ac97_out",
		.min_signal = 6,
		.max_signal = 6,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "ac97_in",
		.min_signal = 7,
		.max_signal = 7,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "ac97_mic",
		.min_signal = 8,
		.max_signal = 8,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "pwm",
		.min_signal = 9,
		.max_signal = 9,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "irda",
		.min_signal = 10,
		.max_signal = 10,
		.periph_buses = PL08X_AHB2,
	}, {
		.bus_id = "external",
		.min_signal = 11,
		.max_signal = 11,
		.periph_buses = PL08X_AHB2,
	},
};

struct pl08x_platform_data s3c64xx_dma1_plat_data = {
	.memcpy_channel = {
		.bus_id = "memcpy",
		.cctl_memcpy =
			(PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT |
			PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT |
			PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT |
			PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT |
			PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE |
			PL080_CONTROL_PROT_SYS),
	},
	.lli_buses = PL08X_AHB1,
	.mem_buses = PL08X_AHB1,
	.get_xfer_signal = pl08x_get_xfer_signal,
	.put_xfer_signal = pl08x_put_xfer_signal,
	.slave_channels = s3c64xx_dma1_info,
	.num_slave_channels = ARRAY_SIZE(s3c64xx_dma1_info),
};

static AMBA_AHB_DEVICE(s3c64xx_dma1, "dma-pl080s.1", 0,
			0x75100000, {IRQ_DMA1}, &s3c64xx_dma1_plat_data);

static int __init s3c64xx_pl080_init(void)
{
234 235 236
	if (!soc_is_s3c64xx())
		return 0;

237 238 239 240 241 242 243 244 245 246 247 248
	/* Set all DMA configuration to be DMA, not SDMA */
	writel(0xffffff, S3C64XX_SDMA_SEL);

	if (of_have_populated_dt())
		return 0;

	amba_device_register(&s3c64xx_dma0_device, &iomem_resource);
	amba_device_register(&s3c64xx_dma1_device, &iomem_resource);

	return 0;
}
arch_initcall(s3c64xx_pl080_init);