18 #include <linux/module.h>
28 #define AC_CMD_ADDR(x) (x << 16)
29 #define AC_CMD_DATA(x) (x & 0xffff)
31 #define S3C_AC97_DAI_PCM 0
32 #define S3C_AC97_DAI_MIC 1
55 .client = &s3c_dma_client_out,
60 .client = &s3c_dma_client_in,
65 .client = &s3c_dma_client_micin,
69 static void s3c_ac97_activate(
struct snd_ac97 *ac97)
93 pr_err(
"AC97: Unable to activate!");
96 static unsigned short s3c_ac97_read(
struct snd_ac97 *ac97,
99 u32 ac_glbctrl, ac_codec_cmd;
104 s3c_ac97_activate(ac97);
119 pr_err(
"AC97: Unable to read!");
122 addr = (stat >> 16) & 0x7f;
123 data = (stat & 0xffff);
126 pr_err(
"ac97: req addr = %02x, rep addr = %02x\n",
131 return (
unsigned short)
data;
134 static void s3c_ac97_write(
struct snd_ac97 *ac97,
unsigned short reg,
137 u32 ac_glbctrl, ac_codec_cmd;
141 s3c_ac97_activate(ac97);
156 pr_err(
"AC97: Unable to write!");
165 static void s3c_ac97_cold_reset(
struct snd_ac97 *ac97)
176 static void s3c_ac97_warm_reset(
struct snd_ac97 *ac97)
192 s3c_ac97_activate(ac97);
197 u32 ac_glbctrl, ac_glbstat;
211 ac_glbctrl |= (1<<30);
218 .read = s3c_ac97_read,
219 .write = s3c_ac97_write,
220 .warm_reset = s3c_ac97_warm_reset,
221 .reset = s3c_ac97_cold_reset,
234 dma_data = &s3c_ac97_pcm_out;
236 dma_data = &s3c_ac97_pcm_in;
238 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
249 snd_soc_dai_get_dma_data(rtd->
cpu_dai, substream);
293 snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in);
304 snd_soc_dai_get_dma_data(rtd->
cpu_dai, substream);
333 .hw_params = s3c_ac97_hw_params,
334 .trigger = s3c_ac97_trigger,
338 .hw_params = s3c_ac97_hw_mic_params,
339 .trigger = s3c_ac97_mic_trigger,
344 .name =
"samsung-ac97",
347 .stream_name =
"AC97 Playback",
353 .stream_name =
"AC97 Capture",
358 .ops = &s3c_ac97_dai_ops,
361 .name =
"samsung-ac97-mic",
364 .stream_name =
"AC97 Mic Capture",
369 .ops = &s3c_ac97_mic_dai_ops,
375 struct resource *mem_res, *dmatx_res, *dmarx_res, *dmamic_res, *irq_res;
379 ac97_pdata = pdev->
dev.platform_data;
380 if (!ac97_pdata || !ac97_pdata->
cfg_gpio) {
381 dev_err(&pdev->
dev,
"cfg_gpio callback not provided!\n");
388 dev_err(&pdev->
dev,
"Unable to get AC97-TX dma resource\n");
394 dev_err(&pdev->
dev,
"Unable to get AC97-RX dma resource\n");
400 dev_err(&pdev->
dev,
"Unable to get AC97-MIC dma resource\n");
406 dev_err(&pdev->
dev,
"Unable to get register resource\n");
412 dev_err(&pdev->
dev,
"AC97 IRQ not provided!\n");
417 resource_size(mem_res),
"ac97")) {
418 dev_err(&pdev->
dev,
"Unable to request register region\n");
429 init_completion(&s3c_ac97.done);
432 s3c_ac97.regs =
ioremap(mem_res->
start, resource_size(mem_res));
433 if (s3c_ac97.regs ==
NULL) {
434 dev_err(&pdev->
dev,
"Unable to ioremap register region\n");
439 s3c_ac97.ac97_clk =
clk_get(&pdev->
dev,
"ac97");
440 if (IS_ERR(s3c_ac97.ac97_clk)) {
441 dev_err(&pdev->
dev,
"ac97 failed to get ac97_clock\n");
448 dev_err(&pdev->
dev,
"Unable to configure gpio\n");
456 dev_err(&pdev->
dev,
"ac97: interrupt request failed.\n");
504 .probe = s3c_ac97_probe,
507 .name =
"samsung-ac97",