plat-nomadik: support secondary GPIO interrupts
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / blackfin / bf5xx-ad1836.c
blob83012da9dfc24969c14d01de5ccd1e0bc047cbd7
1 /*
2 * File: sound/soc/blackfin/bf5xx-ad1836.c
3 * Author: Barry Song <Barry.Song@analog.com>
5 * Created: Aug 4 2009
6 * Description: Board driver for ad1836 sound chip
8 * Bugs: Enter bugs at http://blackfin.uclinux.org/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
17 #include <linux/module.h>
18 #include <linux/moduleparam.h>
19 #include <linux/device.h>
20 #include <sound/core.h>
21 #include <sound/pcm.h>
22 #include <sound/soc.h>
23 #include <sound/pcm_params.h>
25 #include <asm/blackfin.h>
26 #include <asm/cacheflush.h>
27 #include <asm/irq.h>
28 #include <asm/dma.h>
29 #include <asm/portmux.h>
31 #include "../codecs/ad1836.h"
32 #include "bf5xx-sport.h"
34 #include "bf5xx-tdm-pcm.h"
35 #include "bf5xx-tdm.h"
37 static struct snd_soc_card bf5xx_ad1836;
39 static int bf5xx_ad1836_startup(struct snd_pcm_substream *substream)
41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
44 snd_soc_dai_set_drvdata(cpu_dai, sport_handle);
45 return 0;
48 static int bf5xx_ad1836_hw_params(struct snd_pcm_substream *substream,
49 struct snd_pcm_hw_params *params)
51 struct snd_soc_pcm_runtime *rtd = substream->private_data;
52 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
53 struct snd_soc_dai *codec_dai = rtd->codec_dai;
54 unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7};
55 int ret = 0;
56 /* set cpu DAI configuration */
57 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
58 SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);
59 if (ret < 0)
60 return ret;
62 /* set codec DAI configuration */
63 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |
64 SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);
65 if (ret < 0)
66 return ret;
68 /* set cpu DAI channel mapping */
69 ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),
70 channel_map, ARRAY_SIZE(channel_map), channel_map);
71 if (ret < 0)
72 return ret;
74 return 0;
77 static struct snd_soc_ops bf5xx_ad1836_ops = {
78 .startup = bf5xx_ad1836_startup,
79 .hw_params = bf5xx_ad1836_hw_params,
82 static struct snd_soc_dai_link bf5xx_ad1836_dai = {
83 .name = "ad1836",
84 .stream_name = "AD1836",
85 .cpu_dai_name = "bf5xx-tdm",
86 .codec_dai_name = "ad1836-hifi",
87 .platform_name = "bf5xx-tdm-pcm-audio",
88 .codec_name = "ad1836-codec.0",
89 .ops = &bf5xx_ad1836_ops,
92 static struct snd_soc_card bf5xx_ad1836 = {
93 .name = "bf5xx_ad1836",
94 .dai_link = &bf5xx_ad1836_dai,
95 .num_links = 1,
98 static struct platform_device *bfxx_ad1836_snd_device;
100 static int __init bf5xx_ad1836_init(void)
102 int ret;
104 bfxx_ad1836_snd_device = platform_device_alloc("soc-audio", -1);
105 if (!bfxx_ad1836_snd_device)
106 return -ENOMEM;
108 platform_set_drvdata(bfxx_ad1836_snd_device, &bf5xx_ad1836);
109 ret = platform_device_add(bfxx_ad1836_snd_device);
111 if (ret)
112 platform_device_put(bfxx_ad1836_snd_device);
114 return ret;
117 static void __exit bf5xx_ad1836_exit(void)
119 platform_device_unregister(bfxx_ad1836_snd_device);
122 module_init(bf5xx_ad1836_init);
123 module_exit(bf5xx_ad1836_exit);
125 /* Module information */
126 MODULE_AUTHOR("Barry Song");
127 MODULE_DESCRIPTION("ALSA SoC AD1836 board driver");
128 MODULE_LICENSE("GPL");