Linux Audio

Check our new training course

Loading...
v3.5.6
  1/* linux/arch/arm/plat-s3c/dev-audio.c
  2 *
  3 * Copyright 2009 Wolfson Microelectronics
  4 *      Mark Brown <broonie@opensource.wolfsonmicro.com>
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License version 2 as
  8 * published by the Free Software Foundation.
  9 */
 10
 11#include <linux/kernel.h>
 12#include <linux/string.h>
 13#include <linux/platform_device.h>
 14#include <linux/dma-mapping.h>
 15#include <linux/gpio.h>
 16#include <linux/export.h>
 17
 18#include <mach/irqs.h>
 19#include <mach/map.h>
 20#include <mach/dma.h>
 21
 22#include <plat/devs.h>
 23#include <plat/audio.h>
 24#include <plat/gpio-cfg.h>
 25
 26static const char *rclksrc[] = {
 27	[0] = "iis",
 28	[1] = "audio-bus",
 29};
 30
 31static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
 32{
 33	unsigned int base;
 34
 35	switch (pdev->id) {
 36	case 0:
 37		base = S3C64XX_GPD(0);
 38		break;
 39	case 1:
 40		base = S3C64XX_GPE(0);
 41		break;
 42	case 2:
 43		s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
 44		s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
 45		s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
 46		s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
 47		return 0;
 48	default:
 49		printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
 50			pdev->id);
 51		return -EINVAL;
 52	}
 53
 54	s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
 55
 56	return 0;
 57}
 58
 59static struct resource s3c64xx_iis0_resource[] = {
 60	[0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
 61	[1] = DEFINE_RES_DMA(DMACH_I2S0_OUT),
 62	[2] = DEFINE_RES_DMA(DMACH_I2S0_IN),
 63};
 64
 65static struct s3c_audio_pdata i2sv3_pdata = {
 66	.cfg_gpio = s3c64xx_i2s_cfg_gpio,
 67	.type = {
 68		.i2s = {
 69			.src_clk = rclksrc,
 70		},
 71	},
 72};
 73
 74struct platform_device s3c64xx_device_iis0 = {
 75	.name		  = "samsung-i2s",
 76	.id		  = 0,
 77	.num_resources	  = ARRAY_SIZE(s3c64xx_iis0_resource),
 78	.resource	  = s3c64xx_iis0_resource,
 79	.dev = {
 80		.platform_data = &i2sv3_pdata,
 81	},
 82};
 83EXPORT_SYMBOL(s3c64xx_device_iis0);
 84
 85static struct resource s3c64xx_iis1_resource[] = {
 86	[0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
 87	[1] = DEFINE_RES_DMA(DMACH_I2S1_OUT),
 88	[2] = DEFINE_RES_DMA(DMACH_I2S1_IN),
 
 
 
 
 
 89};
 90
 91struct platform_device s3c64xx_device_iis1 = {
 92	.name		  = "samsung-i2s",
 93	.id		  = 1,
 94	.num_resources	  = ARRAY_SIZE(s3c64xx_iis1_resource),
 95	.resource	  = s3c64xx_iis1_resource,
 96	.dev = {
 97		.platform_data = &i2sv3_pdata,
 98	},
 99};
100EXPORT_SYMBOL(s3c64xx_device_iis1);
101
102static struct resource s3c64xx_iisv4_resource[] = {
103	[0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
104	[1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX),
105	[2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX),
106};
107
108static struct s3c_audio_pdata i2sv4_pdata = {
109	.cfg_gpio = s3c64xx_i2s_cfg_gpio,
 
 
 
110	.type = {
111		.i2s = {
112			.quirks = QUIRK_PRI_6CHAN,
113			.src_clk = rclksrc,
114		},
115	},
116};
117
118struct platform_device s3c64xx_device_iisv4 = {
119	.name = "samsung-i2s",
120	.id = 2,
121	.num_resources	  = ARRAY_SIZE(s3c64xx_iisv4_resource),
122	.resource	  = s3c64xx_iisv4_resource,
123	.dev = {
124		.platform_data = &i2sv4_pdata,
125	},
126};
127EXPORT_SYMBOL(s3c64xx_device_iisv4);
128
129
130/* PCM Controller platform_devices */
131
132static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
133{
134	unsigned int base;
135
136	switch (pdev->id) {
137	case 0:
138		base = S3C64XX_GPD(0);
139		break;
140	case 1:
141		base = S3C64XX_GPE(0);
142		break;
143	default:
144		printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
145			pdev->id);
146		return -EINVAL;
147	}
148
149	s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
150	return 0;
151}
152
153static struct resource s3c64xx_pcm0_resource[] = {
154	[0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
155	[1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
156	[2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
157};
158
159static struct s3c_audio_pdata s3c_pcm0_pdata = {
160	.cfg_gpio = s3c64xx_pcm_cfg_gpio,
 
 
 
161};
162
163struct platform_device s3c64xx_device_pcm0 = {
164	.name		  = "samsung-pcm",
165	.id		  = 0,
166	.num_resources	  = ARRAY_SIZE(s3c64xx_pcm0_resource),
167	.resource	  = s3c64xx_pcm0_resource,
168	.dev = {
169		.platform_data = &s3c_pcm0_pdata,
170	},
171};
172EXPORT_SYMBOL(s3c64xx_device_pcm0);
173
174static struct resource s3c64xx_pcm1_resource[] = {
175	[0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
176	[1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
177	[2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
178};
179
180static struct s3c_audio_pdata s3c_pcm1_pdata = {
181	.cfg_gpio = s3c64xx_pcm_cfg_gpio,
 
 
 
182};
183
184struct platform_device s3c64xx_device_pcm1 = {
185	.name		  = "samsung-pcm",
186	.id		  = 1,
187	.num_resources	  = ARRAY_SIZE(s3c64xx_pcm1_resource),
188	.resource	  = s3c64xx_pcm1_resource,
189	.dev = {
190		.platform_data = &s3c_pcm1_pdata,
191	},
192};
193EXPORT_SYMBOL(s3c64xx_device_pcm1);
194
195/* AC97 Controller platform devices */
196
197static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
198{
199	return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
200}
201
202static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
203{
204	return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
205}
206
207static struct resource s3c64xx_ac97_resource[] = {
208	[0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
209	[1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
210	[2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
211	[3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
212	[4] = DEFINE_RES_IRQ(IRQ_AC97),
213};
214
215static struct s3c_audio_pdata s3c_ac97_pdata;
 
 
 
 
 
216
217static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
218
219struct platform_device s3c64xx_device_ac97 = {
220	.name		  = "samsung-ac97",
221	.id		  = -1,
222	.num_resources	  = ARRAY_SIZE(s3c64xx_ac97_resource),
223	.resource	  = s3c64xx_ac97_resource,
224	.dev = {
225		.platform_data = &s3c_ac97_pdata,
226		.dma_mask = &s3c64xx_ac97_dmamask,
227		.coherent_dma_mask = DMA_BIT_MASK(32),
228	},
229};
230EXPORT_SYMBOL(s3c64xx_device_ac97);
231
232void __init s3c64xx_ac97_setup_gpio(int num)
233{
234	if (num == S3C64XX_AC97_GPD)
235		s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
236	else
237		s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
238}
v4.10.11
  1/* linux/arch/arm/plat-s3c/dev-audio.c
  2 *
  3 * Copyright 2009 Wolfson Microelectronics
  4 *      Mark Brown <broonie@opensource.wolfsonmicro.com>
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License version 2 as
  8 * published by the Free Software Foundation.
  9 */
 10
 11#include <linux/kernel.h>
 12#include <linux/string.h>
 13#include <linux/platform_device.h>
 14#include <linux/dma-mapping.h>
 15#include <linux/gpio.h>
 16#include <linux/export.h>
 17
 18#include <mach/irqs.h>
 19#include <mach/map.h>
 20#include <mach/dma.h>
 21
 22#include <plat/devs.h>
 23#include <linux/platform_data/asoc-s3c.h>
 24#include <plat/gpio-cfg.h>
 25#include <mach/gpio-samsung.h>
 
 
 
 
 26
 27static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
 28{
 29	unsigned int base;
 30
 31	switch (pdev->id) {
 32	case 0:
 33		base = S3C64XX_GPD(0);
 34		break;
 35	case 1:
 36		base = S3C64XX_GPE(0);
 37		break;
 38	case 2:
 39		s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
 40		s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
 41		s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
 42		s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
 43		return 0;
 44	default:
 45		printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
 46			pdev->id);
 47		return -EINVAL;
 48	}
 49
 50	s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
 51
 52	return 0;
 53}
 54
 55static struct resource s3c64xx_iis0_resource[] = {
 56	[0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
 
 
 57};
 58
 59static struct s3c_audio_pdata i2s0_pdata = {
 60	.cfg_gpio = s3c64xx_i2s_cfg_gpio,
 61	.dma_filter = pl08x_filter_id,
 62	.dma_playback = DMACH_I2S0_OUT,
 63	.dma_capture = DMACH_I2S0_IN,
 
 
 64};
 65
 66struct platform_device s3c64xx_device_iis0 = {
 67	.name		  = "samsung-i2s",
 68	.id		  = 0,
 69	.num_resources	  = ARRAY_SIZE(s3c64xx_iis0_resource),
 70	.resource	  = s3c64xx_iis0_resource,
 71	.dev = {
 72		.platform_data = &i2s0_pdata,
 73	},
 74};
 75EXPORT_SYMBOL(s3c64xx_device_iis0);
 76
 77static struct resource s3c64xx_iis1_resource[] = {
 78	[0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
 79};
 80
 81static struct s3c_audio_pdata i2s1_pdata = {
 82	.cfg_gpio = s3c64xx_i2s_cfg_gpio,
 83	.dma_filter = pl08x_filter_id,
 84	.dma_playback = DMACH_I2S1_OUT,
 85	.dma_capture = DMACH_I2S1_IN,
 86};
 87
 88struct platform_device s3c64xx_device_iis1 = {
 89	.name		  = "samsung-i2s",
 90	.id		  = 1,
 91	.num_resources	  = ARRAY_SIZE(s3c64xx_iis1_resource),
 92	.resource	  = s3c64xx_iis1_resource,
 93	.dev = {
 94		.platform_data = &i2s1_pdata,
 95	},
 96};
 97EXPORT_SYMBOL(s3c64xx_device_iis1);
 98
 99static struct resource s3c64xx_iisv4_resource[] = {
100	[0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
 
 
101};
102
103static struct s3c_audio_pdata i2sv4_pdata = {
104	.cfg_gpio = s3c64xx_i2s_cfg_gpio,
105	.dma_filter = pl08x_filter_id,
106	.dma_playback = DMACH_HSI_I2SV40_TX,
107	.dma_capture = DMACH_HSI_I2SV40_RX,
108	.type = {
109		.i2s = {
110			.quirks = QUIRK_PRI_6CHAN,
 
111		},
112	},
113};
114
115struct platform_device s3c64xx_device_iisv4 = {
116	.name = "samsung-i2s",
117	.id = 2,
118	.num_resources	  = ARRAY_SIZE(s3c64xx_iisv4_resource),
119	.resource	  = s3c64xx_iisv4_resource,
120	.dev = {
121		.platform_data = &i2sv4_pdata,
122	},
123};
124EXPORT_SYMBOL(s3c64xx_device_iisv4);
125
126
127/* PCM Controller platform_devices */
128
129static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
130{
131	unsigned int base;
132
133	switch (pdev->id) {
134	case 0:
135		base = S3C64XX_GPD(0);
136		break;
137	case 1:
138		base = S3C64XX_GPE(0);
139		break;
140	default:
141		printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
142			pdev->id);
143		return -EINVAL;
144	}
145
146	s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
147	return 0;
148}
149
150static struct resource s3c64xx_pcm0_resource[] = {
151	[0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
 
 
152};
153
154static struct s3c_audio_pdata s3c_pcm0_pdata = {
155	.cfg_gpio = s3c64xx_pcm_cfg_gpio,
156	.dma_filter = pl08x_filter_id,
157	.dma_capture = DMACH_PCM0_RX,
158	.dma_playback = DMACH_PCM0_TX,
159};
160
161struct platform_device s3c64xx_device_pcm0 = {
162	.name		  = "samsung-pcm",
163	.id		  = 0,
164	.num_resources	  = ARRAY_SIZE(s3c64xx_pcm0_resource),
165	.resource	  = s3c64xx_pcm0_resource,
166	.dev = {
167		.platform_data = &s3c_pcm0_pdata,
168	},
169};
170EXPORT_SYMBOL(s3c64xx_device_pcm0);
171
172static struct resource s3c64xx_pcm1_resource[] = {
173	[0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
 
 
174};
175
176static struct s3c_audio_pdata s3c_pcm1_pdata = {
177	.cfg_gpio = s3c64xx_pcm_cfg_gpio,
178	.dma_filter = pl08x_filter_id,
179	.dma_playback = DMACH_PCM1_TX,
180	.dma_capture = DMACH_PCM1_RX,
181};
182
183struct platform_device s3c64xx_device_pcm1 = {
184	.name		  = "samsung-pcm",
185	.id		  = 1,
186	.num_resources	  = ARRAY_SIZE(s3c64xx_pcm1_resource),
187	.resource	  = s3c64xx_pcm1_resource,
188	.dev = {
189		.platform_data = &s3c_pcm1_pdata,
190	},
191};
192EXPORT_SYMBOL(s3c64xx_device_pcm1);
193
194/* AC97 Controller platform devices */
195
196static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
197{
198	return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
199}
200
201static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
202{
203	return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
204}
205
206static struct resource s3c64xx_ac97_resource[] = {
207	[0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
208	[1] = DEFINE_RES_IRQ(IRQ_AC97),
 
 
 
209};
210
211static struct s3c_audio_pdata s3c_ac97_pdata = {
212	.dma_playback = DMACH_AC97_PCMOUT,
213	.dma_filter = pl08x_filter_id,
214	.dma_capture = DMACH_AC97_PCMIN,
215	.dma_capture_mic = DMACH_AC97_MICIN,
216};
217
218static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
219
220struct platform_device s3c64xx_device_ac97 = {
221	.name		  = "samsung-ac97",
222	.id		  = -1,
223	.num_resources	  = ARRAY_SIZE(s3c64xx_ac97_resource),
224	.resource	  = s3c64xx_ac97_resource,
225	.dev = {
226		.platform_data = &s3c_ac97_pdata,
227		.dma_mask = &s3c64xx_ac97_dmamask,
228		.coherent_dma_mask = DMA_BIT_MASK(32),
229	},
230};
231EXPORT_SYMBOL(s3c64xx_device_ac97);
232
233void __init s3c64xx_ac97_setup_gpio(int num)
234{
235	if (num == S3C64XX_AC97_GPD)
236		s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
237	else
238		s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
239}