dev-audio.c 6.0 KB
Newer Older
K
Kukjin Kim 已提交
1 2 3 4
/* linux/arch/arm/mach-exynos4/dev-audio.c
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * Copyright (c) 2010 Samsung Electronics Co. Ltd
 *	Jaswinder Singh <jassi.brar@samsung.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/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/gpio.h>
17
#include <linux/platform_data/asoc-s3c.h>
18 19 20 21 22 23

#include <plat/gpio-cfg.h>

#include <mach/map.h>
#include <mach/dma.h>
#include <mach/irqs.h>
24
#include <mach/regs-audss.h>
25

K
Kukjin Kim 已提交
26
static int exynos4_cfg_i2s(struct platform_device *pdev)
27 28 29 30
{
	/* configure GPIO for i2s port */
	switch (pdev->id) {
	case 0:
K
Kukjin Kim 已提交
31
		s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 7, S3C_GPIO_SFN(2));
32 33
		break;
	case 1:
K
Kukjin Kim 已提交
34
		s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(2));
35 36
		break;
	case 2:
K
Kukjin Kim 已提交
37
		s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(4));
38 39 40 41 42 43 44 45 46 47
		break;
	default:
		printk(KERN_ERR "Invalid Device %d\n", pdev->id);
		return -EINVAL;
	}

	return 0;
}

static struct s3c_audio_pdata i2sv5_pdata = {
K
Kukjin Kim 已提交
48
	.cfg_gpio = exynos4_cfg_i2s,
49 50 51 52
	.type = {
		.i2s = {
			.quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
					 | QUIRK_NEED_RSTCLR,
53
			.idma_addr = EXYNOS4_AUDSS_INT_MEM,
54 55 56 57
		},
	},
};

K
Kukjin Kim 已提交
58
static struct resource exynos4_i2s0_resource[] = {
59 60 61 62
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S0, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_I2S0_TX),
	[2] = DEFINE_RES_DMA(DMACH_I2S0_RX),
	[3] = DEFINE_RES_DMA(DMACH_I2S0S_TX),
63 64
};

K
Kukjin Kim 已提交
65
struct platform_device exynos4_device_i2s0 = {
66 67
	.name = "samsung-i2s",
	.id = 0,
K
Kukjin Kim 已提交
68 69
	.num_resources = ARRAY_SIZE(exynos4_i2s0_resource),
	.resource = exynos4_i2s0_resource,
70 71 72 73 74 75
	.dev = {
		.platform_data = &i2sv5_pdata,
	},
};

static struct s3c_audio_pdata i2sv3_pdata = {
K
Kukjin Kim 已提交
76
	.cfg_gpio = exynos4_cfg_i2s,
77 78 79 80 81 82 83
	.type = {
		.i2s = {
			.quirks = QUIRK_NO_MUXPSR,
		},
	},
};

K
Kukjin Kim 已提交
84
static struct resource exynos4_i2s1_resource[] = {
85 86 87
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S1, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
	[2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
88 89
};

K
Kukjin Kim 已提交
90
struct platform_device exynos4_device_i2s1 = {
91 92
	.name = "samsung-i2s",
	.id = 1,
K
Kukjin Kim 已提交
93 94
	.num_resources = ARRAY_SIZE(exynos4_i2s1_resource),
	.resource = exynos4_i2s1_resource,
95 96 97 98 99
	.dev = {
		.platform_data = &i2sv3_pdata,
	},
};

K
Kukjin Kim 已提交
100
static struct resource exynos4_i2s2_resource[] = {
101 102 103
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S2, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
	[2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
104 105
};

K
Kukjin Kim 已提交
106
struct platform_device exynos4_device_i2s2 = {
107 108
	.name = "samsung-i2s",
	.id = 2,
K
Kukjin Kim 已提交
109 110
	.num_resources = ARRAY_SIZE(exynos4_i2s2_resource),
	.resource = exynos4_i2s2_resource,
111 112 113 114 115 116 117
	.dev = {
		.platform_data = &i2sv3_pdata,
	},
};

/* PCM Controller platform_devices */

K
Kukjin Kim 已提交
118
static int exynos4_pcm_cfg_gpio(struct platform_device *pdev)
119 120 121
{
	switch (pdev->id) {
	case 0:
K
Kukjin Kim 已提交
122
		s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 5, S3C_GPIO_SFN(3));
123 124
		break;
	case 1:
K
Kukjin Kim 已提交
125
		s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(3));
126 127
		break;
	case 2:
K
Kukjin Kim 已提交
128
		s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(3));
129 130 131 132 133 134 135 136 137 138
		break;
	default:
		printk(KERN_DEBUG "Invalid PCM Controller number!");
		return -EINVAL;
	}

	return 0;
}

static struct s3c_audio_pdata s3c_pcm_pdata = {
K
Kukjin Kim 已提交
139
	.cfg_gpio = exynos4_pcm_cfg_gpio,
140 141
};

K
Kukjin Kim 已提交
142
static struct resource exynos4_pcm0_resource[] = {
143 144 145
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM0, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
	[2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
146 147
};

K
Kukjin Kim 已提交
148
struct platform_device exynos4_device_pcm0 = {
149 150
	.name = "samsung-pcm",
	.id = 0,
K
Kukjin Kim 已提交
151 152
	.num_resources = ARRAY_SIZE(exynos4_pcm0_resource),
	.resource = exynos4_pcm0_resource,
153 154 155 156 157
	.dev = {
		.platform_data = &s3c_pcm_pdata,
	},
};

K
Kukjin Kim 已提交
158
static struct resource exynos4_pcm1_resource[] = {
159 160 161
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM1, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
	[2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
162 163
};

K
Kukjin Kim 已提交
164
struct platform_device exynos4_device_pcm1 = {
165 166
	.name = "samsung-pcm",
	.id = 1,
K
Kukjin Kim 已提交
167 168
	.num_resources = ARRAY_SIZE(exynos4_pcm1_resource),
	.resource = exynos4_pcm1_resource,
169 170 171 172 173
	.dev = {
		.platform_data = &s3c_pcm_pdata,
	},
};

K
Kukjin Kim 已提交
174
static struct resource exynos4_pcm2_resource[] = {
175 176 177
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM2, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_PCM2_TX),
	[2] = DEFINE_RES_DMA(DMACH_PCM2_RX),
178 179
};

K
Kukjin Kim 已提交
180
struct platform_device exynos4_device_pcm2 = {
181 182
	.name = "samsung-pcm",
	.id = 2,
K
Kukjin Kim 已提交
183 184
	.num_resources = ARRAY_SIZE(exynos4_pcm2_resource),
	.resource = exynos4_pcm2_resource,
185 186 187 188 189 190 191
	.dev = {
		.platform_data = &s3c_pcm_pdata,
	},
};

/* AC97 Controller platform devices */

K
Kukjin Kim 已提交
192
static int exynos4_ac97_cfg_gpio(struct platform_device *pdev)
193
{
K
Kukjin Kim 已提交
194
	return s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(4));
195 196
}

K
Kukjin Kim 已提交
197
static struct resource exynos4_ac97_resource[] = {
198 199 200 201 202
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_AC97, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
	[2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
	[3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
	[4] = DEFINE_RES_IRQ(EXYNOS4_IRQ_AC97),
203 204 205
};

static struct s3c_audio_pdata s3c_ac97_pdata = {
K
Kukjin Kim 已提交
206
	.cfg_gpio = exynos4_ac97_cfg_gpio,
207 208
};

K
Kukjin Kim 已提交
209
static u64 exynos4_ac97_dmamask = DMA_BIT_MASK(32);
210

K
Kukjin Kim 已提交
211
struct platform_device exynos4_device_ac97 = {
212 213
	.name = "samsung-ac97",
	.id = -1,
K
Kukjin Kim 已提交
214 215
	.num_resources = ARRAY_SIZE(exynos4_ac97_resource),
	.resource = exynos4_ac97_resource,
216 217
	.dev = {
		.platform_data = &s3c_ac97_pdata,
K
Kukjin Kim 已提交
218
		.dma_mask = &exynos4_ac97_dmamask,
219 220 221 222 223 224
		.coherent_dma_mask = DMA_BIT_MASK(32),
	},
};

/* S/PDIF Controller platform_device */

K
Kukjin Kim 已提交
225
static int exynos4_spdif_cfg_gpio(struct platform_device *pdev)
226
{
227
	s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(4));
228 229 230 231

	return 0;
}

K
Kukjin Kim 已提交
232
static struct resource exynos4_spdif_resource[] = {
233 234
	[0] = DEFINE_RES_MEM(EXYNOS4_PA_SPDIF, SZ_256),
	[1] = DEFINE_RES_DMA(DMACH_SPDIF),
235 236 237
};

static struct s3c_audio_pdata samsung_spdif_pdata = {
K
Kukjin Kim 已提交
238
	.cfg_gpio = exynos4_spdif_cfg_gpio,
239 240
};

K
Kukjin Kim 已提交
241
static u64 exynos4_spdif_dmamask = DMA_BIT_MASK(32);
242

K
Kukjin Kim 已提交
243
struct platform_device exynos4_device_spdif = {
244 245
	.name = "samsung-spdif",
	.id = -1,
K
Kukjin Kim 已提交
246 247
	.num_resources = ARRAY_SIZE(exynos4_spdif_resource),
	.resource = exynos4_spdif_resource,
248 249
	.dev = {
		.platform_data = &samsung_spdif_pdata,
K
Kukjin Kim 已提交
250
		.dma_mask = &exynos4_spdif_dmamask,
251 252 253
		.coherent_dma_mask = DMA_BIT_MASK(32),
	},
};