Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / sound / soc / kirkwood / kirkwood-t5325.c
blobb47cc4e9b746a39dc7d91e86244d430c03b0fde3
1 /*
2 * kirkwood-t5325.c
4 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/slab.h>
17 #include <sound/soc.h>
18 #include <mach/kirkwood.h>
19 #include <plat/audio.h>
20 #include <asm/mach-types.h>
21 #include "../codecs/alc5623.h"
23 static int t5325_hw_params(struct snd_pcm_substream *substream,
24 struct snd_pcm_hw_params *params)
26 struct snd_soc_pcm_runtime *rtd = substream->private_data;
27 struct snd_soc_dai *codec_dai = rtd->codec_dai;
28 unsigned int freq;
30 freq = params_rate(params) * 256;
32 return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
36 static struct snd_soc_ops t5325_ops = {
37 .hw_params = t5325_hw_params,
40 static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = {
41 SND_SOC_DAPM_HP("Headphone Jack", NULL),
42 SND_SOC_DAPM_SPK("Speaker", NULL),
43 SND_SOC_DAPM_MIC("Mic Jack", NULL),
46 static const struct snd_soc_dapm_route t5325_route[] = {
47 { "Headphone Jack", NULL, "HPL" },
48 { "Headphone Jack", NULL, "HPR" },
50 {"Speaker", NULL, "SPKOUT"},
51 {"Speaker", NULL, "SPKOUTN"},
53 { "MIC1", NULL, "Mic Jack" },
54 { "MIC2", NULL, "Mic Jack" },
57 static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd)
59 struct snd_soc_codec *codec = rtd->codec;
60 struct snd_soc_dapm_context *dapm = &codec->dapm;
62 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
63 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
64 snd_soc_dapm_enable_pin(dapm, "Speaker");
66 return 0;
69 static struct snd_soc_dai_link t5325_dai[] = {
71 .name = "ALC5621",
72 .stream_name = "ALC5621 HiFi",
73 .cpu_dai_name = "kirkwood-i2s",
74 .platform_name = "kirkwood-pcm-audio",
75 .codec_dai_name = "alc5621-hifi",
76 .codec_name = "alc562x-codec.0-001a",
77 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
78 .ops = &t5325_ops,
79 .init = t5325_dai_init,
84 static struct snd_soc_card t5325 = {
85 .name = "t5325",
86 .owner = THIS_MODULE,
87 .dai_link = t5325_dai,
88 .num_links = ARRAY_SIZE(t5325_dai),
90 .dapm_widgets = t5325_dapm_widgets,
91 .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets),
92 .dapm_routes = t5325_route,
93 .num_dapm_routes = ARRAY_SIZE(t5325_route),
96 static struct platform_device *t5325_snd_device;
98 static int __init t5325_init(void)
100 int ret;
102 if (!machine_is_t5325())
103 return 0;
105 t5325_snd_device = platform_device_alloc("soc-audio", -1);
106 if (!t5325_snd_device)
107 return -ENOMEM;
109 platform_set_drvdata(t5325_snd_device,
110 &t5325);
112 ret = platform_device_add(t5325_snd_device);
113 if (ret) {
114 printk(KERN_ERR "%s: platform_device_add failed\n", __func__);
115 platform_device_put(t5325_snd_device);
118 return ret;
120 module_init(t5325_init);
122 static void __exit t5325_exit(void)
124 platform_device_unregister(t5325_snd_device);
126 module_exit(t5325_exit);
128 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
129 MODULE_DESCRIPTION("ALSA SoC t5325 audio client");
130 MODULE_LICENSE("GPL");