]> git.karo-electronics.de Git - mv-sheeva.git/blob - sound/soc/sh/fsi-ak4642.c
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / sound / soc / sh / fsi-ak4642.c
1 /*
2  * FSI-AK464x sound support for ms7724se
3  *
4  * Copyright (C) 2009 Renesas Solutions Corp.
5  * Kuninori Morimoto <morimoto.kuninori@renesas.com>
6  *
7  * This file is subject to the terms and conditions of the GNU General Public
8  * License.  See the file "COPYING" in the main directory of this archive
9  * for more details.
10  */
11
12 #include <linux/platform_device.h>
13 #include <sound/sh_fsi.h>
14
15 struct fsi_ak4642_data {
16         const char *name;
17         const char *card;
18         const char *cpu_dai;
19         const char *codec;
20         const char *platform;
21 };
22
23 static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd)
24 {
25         struct snd_soc_dai *dai = rtd->codec_dai;
26         int ret;
27
28         ret = snd_soc_dai_set_fmt(dai, SND_SOC_DAIFMT_CBM_CFM);
29         if (ret < 0)
30                 return ret;
31
32         ret = snd_soc_dai_set_sysclk(dai, 0, 11289600, 0);
33
34         return ret;
35 }
36
37 static struct snd_soc_dai_link fsi_dai_link = {
38         .codec_dai_name = "ak4642-hifi",
39         .init           = fsi_ak4642_dai_init,
40 };
41
42 static struct snd_soc_card fsi_soc_card  = {
43         .dai_link       = &fsi_dai_link,
44         .num_links      = 1,
45 };
46
47 static struct platform_device *fsi_snd_device;
48
49 static int fsi_ak4642_probe(struct platform_device *pdev)
50 {
51         int ret = -ENOMEM;
52         const struct platform_device_id *id_entry;
53         struct fsi_ak4642_data *pdata;
54
55         id_entry = pdev->id_entry;
56         if (!id_entry) {
57                 dev_err(&pdev->dev, "unknown fsi ak4642\n");
58                 return -ENODEV;
59         }
60
61         pdata = (struct fsi_ak4642_data *)id_entry->driver_data;
62
63         fsi_snd_device = platform_device_alloc("soc-audio", FSI_PORT_A);
64         if (!fsi_snd_device)
65                 goto out;
66
67         fsi_dai_link.name               = pdata->name;
68         fsi_dai_link.stream_name        = pdata->name;
69         fsi_dai_link.cpu_dai_name       = pdata->cpu_dai;
70         fsi_dai_link.platform_name      = pdata->platform;
71         fsi_dai_link.codec_name         = pdata->codec;
72         fsi_soc_card.name               = pdata->card;
73
74         platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
75         ret = platform_device_add(fsi_snd_device);
76
77         if (ret)
78                 platform_device_put(fsi_snd_device);
79
80 out:
81         return ret;
82 }
83
84 static int fsi_ak4642_remove(struct platform_device *pdev)
85 {
86         platform_device_unregister(fsi_snd_device);
87         return 0;
88 }
89
90 static struct fsi_ak4642_data fsi_a_ak4642 = {
91         .name           = "AK4642",
92         .card           = "FSIA (AK4642)",
93         .cpu_dai        = "fsia-dai",
94         .codec          = "ak4642-codec.0-0012",
95         .platform       = "sh_fsi.0",
96 };
97
98 static struct fsi_ak4642_data fsi_b_ak4642 = {
99         .name           = "AK4642",
100         .card           = "FSIB (AK4642)",
101         .cpu_dai        = "fsib-dai",
102         .codec          = "ak4642-codec.0-0012",
103         .platform       = "sh_fsi.0",
104 };
105
106 static struct fsi_ak4642_data fsi_a_ak4643 = {
107         .name           = "AK4643",
108         .card           = "FSIA (AK4643)",
109         .cpu_dai        = "fsia-dai",
110         .codec          = "ak4642-codec.0-0013",
111         .platform       = "sh_fsi.0",
112 };
113
114 static struct fsi_ak4642_data fsi_b_ak4643 = {
115         .name           = "AK4643",
116         .card           = "FSIB (AK4643)",
117         .cpu_dai        = "fsib-dai",
118         .codec          = "ak4642-codec.0-0013",
119         .platform       = "sh_fsi.0",
120 };
121
122 static struct fsi_ak4642_data fsi2_a_ak4642 = {
123         .name           = "AK4642",
124         .card           = "FSI2A (AK4642)",
125         .cpu_dai        = "fsia-dai",
126         .codec          = "ak4642-codec.0-0012",
127         .platform       = "sh_fsi2",
128 };
129
130 static struct fsi_ak4642_data fsi2_b_ak4642 = {
131         .name           = "AK4642",
132         .card           = "FSI2B (AK4642)",
133         .cpu_dai        = "fsib-dai",
134         .codec          = "ak4642-codec.0-0012",
135         .platform       = "sh_fsi2",
136 };
137
138 static struct fsi_ak4642_data fsi2_a_ak4643 = {
139         .name           = "AK4643",
140         .card           = "FSI2A (AK4643)",
141         .cpu_dai        = "fsia-dai",
142         .codec          = "ak4642-codec.0-0013",
143         .platform       = "sh_fsi2",
144 };
145
146 static struct fsi_ak4642_data fsi2_b_ak4643 = {
147         .name           = "AK4643",
148         .card           = "FSI2B (AK4643)",
149         .cpu_dai        = "fsib-dai",
150         .codec          = "ak4642-codec.0-0013",
151         .platform       = "sh_fsi2",
152 };
153
154 static struct platform_device_id fsi_id_table[] = {
155         /* FSI */
156         { "sh_fsi_a_ak4642",    (kernel_ulong_t)&fsi_a_ak4642 },
157         { "sh_fsi_b_ak4642",    (kernel_ulong_t)&fsi_b_ak4642 },
158         { "sh_fsi_a_ak4643",    (kernel_ulong_t)&fsi_a_ak4643 },
159         { "sh_fsi_b_ak4643",    (kernel_ulong_t)&fsi_b_ak4643 },
160
161         /* FSI 2 */
162         { "sh_fsi2_a_ak4642",   (kernel_ulong_t)&fsi2_a_ak4642 },
163         { "sh_fsi2_b_ak4642",   (kernel_ulong_t)&fsi2_b_ak4642 },
164         { "sh_fsi2_a_ak4643",   (kernel_ulong_t)&fsi2_a_ak4643 },
165         { "sh_fsi2_b_ak4643",   (kernel_ulong_t)&fsi2_b_ak4643 },
166         {},
167 };
168
169 static struct platform_driver fsi_ak4642 = {
170         .driver = {
171                 .name   = "fsi-ak4642-audio",
172         },
173         .probe          = fsi_ak4642_probe,
174         .remove         = fsi_ak4642_remove,
175         .id_table       = fsi_id_table,
176 };
177
178 static int __init fsi_ak4642_init(void)
179 {
180         return platform_driver_register(&fsi_ak4642);
181 }
182
183 static void __exit fsi_ak4642_exit(void)
184 {
185         platform_driver_unregister(&fsi_ak4642);
186 }
187
188 module_init(fsi_ak4642_init);
189 module_exit(fsi_ak4642_exit);
190
191 MODULE_LICENSE("GPL");
192 MODULE_DESCRIPTION("Generic SH4 FSI-AK4642 sound card");
193 MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>");