diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2009-05-04 10:54:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-05-05 05:12:36 -0400 |
commit | a195b51bc5abc745f12b7b2fe0e3422f55c1953f (patch) | |
tree | 80e59976a30eae31a45159f195ed580cd51b9324 /sound/soc/pxa | |
parent | ee8f6894f358b6a04d8190fd78990749de98a498 (diff) |
ASoC: IMote2 ASoC Support
This patch adds the ASoC side of the board support for the Crossbow
IMB400 daughter board.
Thanks to Crossbow for considerable assistance.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r-- | sound/soc/pxa/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/pxa/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/pxa/imote2.c | 114 |
3 files changed, 125 insertions, 0 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index ad8a10fe6298..eb75a1c061aa 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig | |||
@@ -134,3 +134,12 @@ config SND_PXA2XX_SOC_MIOA701 | |||
134 | help | 134 | help |
135 | Say Y if you want to add support for SoC audio on the | 135 | Say Y if you want to add support for SoC audio on the |
136 | MIO A701. | 136 | MIO A701. |
137 | |||
138 | config SND_PXA2XX_SOC_IMOTE2 | ||
139 | tristate "SoC Audio support for IMote 2" | ||
140 | depends on SND_PXA2XX_SOC && MACH_INTELMOTE2 | ||
141 | select SND_PXA2XX_SOC_I2S | ||
142 | select SND_SOC_WM8940 | ||
143 | help | ||
144 | Say Y if you want to add support for SoC audio on the | ||
145 | IMote 2. | ||
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 4b90c3ccae45..6e096b480335 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile | |||
@@ -22,6 +22,7 @@ snd-soc-palm27x-objs := palm27x.o | |||
22 | snd-soc-zylonite-objs := zylonite.o | 22 | snd-soc-zylonite-objs := zylonite.o |
23 | snd-soc-magician-objs := magician.o | 23 | snd-soc-magician-objs := magician.o |
24 | snd-soc-mioa701-objs := mioa701_wm9713.o | 24 | snd-soc-mioa701-objs := mioa701_wm9713.o |
25 | snd-soc-imote2-objs := imote2.o | ||
25 | 26 | ||
26 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o | 27 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o |
27 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o | 28 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o |
@@ -35,3 +36,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o | |||
35 | obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o | 36 | obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o |
36 | obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o | 37 | obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o |
37 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o | 38 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o |
39 | obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o | ||
diff --git a/sound/soc/pxa/imote2.c b/sound/soc/pxa/imote2.c new file mode 100644 index 000000000000..405587a01160 --- /dev/null +++ b/sound/soc/pxa/imote2.c | |||
@@ -0,0 +1,114 @@ | |||
1 | |||
2 | #include <linux/module.h> | ||
3 | #include <sound/soc.h> | ||
4 | |||
5 | #include <asm/mach-types.h> | ||
6 | |||
7 | #include "../codecs/wm8940.h" | ||
8 | #include "pxa2xx-i2s.h" | ||
9 | #include "pxa2xx-pcm.h" | ||
10 | |||
11 | static int imote2_asoc_hw_params(struct snd_pcm_substream *substream, | ||
12 | struct snd_pcm_hw_params *params) | ||
13 | { | ||
14 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
15 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
16 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
17 | unsigned int clk = 0; | ||
18 | int ret; | ||
19 | |||
20 | switch (params_rate(params)) { | ||
21 | case 8000: | ||
22 | case 16000: | ||
23 | case 48000: | ||
24 | case 96000: | ||
25 | clk = 12288000; | ||
26 | break; | ||
27 | case 11025: | ||
28 | case 22050: | ||
29 | case 44100: | ||
30 | clk = 11289600; | ||
31 | break; | ||
32 | } | ||
33 | |||
34 | /* set codec DAI configuration */ | ||
35 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | ||
36 | | SND_SOC_DAIFMT_NB_NF | ||
37 | | SND_SOC_DAIFMT_CBS_CFS); | ||
38 | if (ret < 0) | ||
39 | return ret; | ||
40 | |||
41 | /* CPU should be clock master */ | ||
42 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | ||
43 | | SND_SOC_DAIFMT_NB_NF | ||
44 | | SND_SOC_DAIFMT_CBS_CFS); | ||
45 | if (ret < 0) | ||
46 | return ret; | ||
47 | |||
48 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, | ||
49 | SND_SOC_CLOCK_IN); | ||
50 | if (ret < 0) | ||
51 | return ret; | ||
52 | |||
53 | /* set the I2S system clock as input (unused) */ | ||
54 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk, | ||
55 | SND_SOC_CLOCK_OUT); | ||
56 | |||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | static struct snd_soc_ops imote2_asoc_ops = { | ||
61 | .hw_params = imote2_asoc_hw_params, | ||
62 | }; | ||
63 | |||
64 | static struct snd_soc_dai_link imote2_dai = { | ||
65 | .name = "WM8940", | ||
66 | .stream_name = "WM8940", | ||
67 | .cpu_dai = &pxa_i2s_dai, | ||
68 | .codec_dai = &wm8940_dai, | ||
69 | .ops = &imote2_asoc_ops, | ||
70 | }; | ||
71 | |||
72 | static struct snd_soc_card snd_soc_imote2 = { | ||
73 | .name = "Imote2", | ||
74 | .platform = &pxa2xx_soc_platform, | ||
75 | .dai_link = &imote2_dai, | ||
76 | .num_links = 1, | ||
77 | }; | ||
78 | |||
79 | static struct snd_soc_device imote2_snd_devdata = { | ||
80 | .card = &snd_soc_imote2, | ||
81 | .codec_dev = &soc_codec_dev_wm8940, | ||
82 | }; | ||
83 | |||
84 | static struct platform_device *imote2_snd_device; | ||
85 | |||
86 | static int __init imote2_asoc_init(void) | ||
87 | { | ||
88 | int ret; | ||
89 | |||
90 | if (!machine_is_intelmote2()) | ||
91 | return -ENODEV; | ||
92 | imote2_snd_device = platform_device_alloc("soc-audio", -1); | ||
93 | if (!imote2_snd_device) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | platform_set_drvdata(imote2_snd_device, &imote2_snd_devdata); | ||
97 | imote2_snd_devdata.dev = &imote2_snd_device->dev; | ||
98 | ret = platform_device_add(imote2_snd_device); | ||
99 | if (ret) | ||
100 | platform_device_put(imote2_snd_device); | ||
101 | |||
102 | return ret; | ||
103 | } | ||
104 | module_init(imote2_asoc_init); | ||
105 | |||
106 | static void __exit imote2_asoc_exit(void) | ||
107 | { | ||
108 | platform_device_unregister(imote2_snd_device); | ||
109 | } | ||
110 | module_exit(imote2_asoc_exit); | ||
111 | |||
112 | MODULE_AUTHOR("Jonathan Cameron"); | ||
113 | MODULE_DESCRIPTION("ALSA SoC Imote 2"); | ||
114 | MODULE_LICENSE("GPL"); | ||