[SCSI] libfc: remove redundant timer init for fcp
[sfrench/cifs-2.6.git] / sound / soc / kirkwood / kirkwood-t5325.c
1 /*
2  * kirkwood-t5325.c
3  *
4  * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
5  *
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.
10  */
11
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"
22
23 static int t5325_hw_params(struct snd_pcm_substream *substream,
24                 struct snd_pcm_hw_params *params)
25 {
26         struct snd_soc_pcm_runtime *rtd = substream->private_data;
27         struct snd_soc_dai *codec_dai = rtd->codec_dai;
28         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
29         int ret;
30         unsigned int freq, fmt;
31
32         fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
33         ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
34         if (ret < 0)
35                 return ret;
36
37         ret = snd_soc_dai_set_fmt(codec_dai, fmt);
38         if (ret < 0)
39                 return ret;
40
41         freq = params_rate(params) * 256;
42
43         return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
44
45 }
46
47 static struct snd_soc_ops t5325_ops = {
48         .hw_params = t5325_hw_params,
49 };
50
51 static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = {
52         SND_SOC_DAPM_HP("Headphone Jack", NULL),
53         SND_SOC_DAPM_SPK("Speaker", NULL),
54         SND_SOC_DAPM_MIC("Mic Jack", NULL),
55 };
56
57 static const struct snd_soc_dapm_route t5325_route[] = {
58         { "Headphone Jack",     NULL,   "HPL" },
59         { "Headphone Jack",     NULL,   "HPR" },
60
61         {"Speaker",             NULL,   "SPKOUT"},
62         {"Speaker",             NULL,   "SPKOUTN"},
63
64         { "MIC1",               NULL,   "Mic Jack" },
65         { "MIC2",               NULL,   "Mic Jack" },
66 };
67
68 static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd)
69 {
70         struct snd_soc_codec *codec = rtd->codec;
71         struct snd_soc_dapm_context *dapm = &codec->dapm;
72
73         snd_soc_dapm_new_controls(dapm, t5325_dapm_widgets,
74                                 ARRAY_SIZE(t5325_dapm_widgets));
75
76         snd_soc_dapm_add_routes(dapm, t5325_route, ARRAY_SIZE(t5325_route));
77
78         snd_soc_dapm_enable_pin(dapm, "Mic Jack");
79         snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
80         snd_soc_dapm_enable_pin(dapm, "Speaker");
81
82         return 0;
83 }
84
85 static struct snd_soc_dai_link t5325_dai[] = {
86 {
87         .name = "ALC5621",
88         .stream_name = "ALC5621 HiFi",
89         .cpu_dai_name = "kirkwood-i2s",
90         .platform_name = "kirkwood-pcm-audio",
91         .codec_dai_name = "alc5621-hifi",
92         .codec_name = "alc562x-codec.0-001a",
93         .ops = &t5325_ops,
94         .init = t5325_dai_init,
95 },
96 };
97
98
99 static struct snd_soc_card t5325 = {
100         .name = "t5325",
101         .dai_link = t5325_dai,
102         .num_links = ARRAY_SIZE(t5325_dai),
103 };
104
105 static struct platform_device *t5325_snd_device;
106
107 static int __init t5325_init(void)
108 {
109         int ret;
110
111         if (!machine_is_t5325())
112                 return 0;
113
114         t5325_snd_device = platform_device_alloc("soc-audio", -1);
115         if (!t5325_snd_device)
116                 return -ENOMEM;
117
118         platform_set_drvdata(t5325_snd_device,
119                         &t5325);
120
121         ret = platform_device_add(t5325_snd_device);
122         if (ret) {
123                 printk(KERN_ERR "%s: platform_device_add failed\n", __func__);
124                 platform_device_put(t5325_snd_device);
125         }
126
127         return ret;
128 }
129 module_init(t5325_init);
130
131 static void __exit t5325_exit(void)
132 {
133         platform_device_unregister(t5325_snd_device);
134 }
135 module_exit(t5325_exit);
136
137 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
138 MODULE_DESCRIPTION("ALSA SoC t5325 audio client");
139 MODULE_LICENSE("GPL");