aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh/fsi-ak4642.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2010-11-29 21:32:04 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-30 06:34:44 -0500
commitc8d6bf9a7b282255cd155b676ff91b08266b8529 (patch)
treece498262399f2f1a03ea1a502c0de17759641ab7 /sound/soc/sh/fsi-ak4642.c
parent649e5fb033bbadbfa78aba5e2711f1faf2affaf0 (diff)
ASoC: sh: fsi-ak4642: Add FSI port and ak464x selection
Current FSI-Ak4642 device had niche settings which were FSI2-A-AK4643 and FSI-A-AK4642. This patch add platform_device_id which can control FSI/FSI2, PortA/PortB, AK4642/AK4643 from platform data. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/sh/fsi-ak4642.c')
-rw-r--r--sound/soc/sh/fsi-ak4642.c133
1 files changed, 121 insertions, 12 deletions
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c
index d96602de71de..4ef279c504db 100644
--- a/sound/soc/sh/fsi-ak4642.c
+++ b/sound/soc/sh/fsi-ak4642.c
@@ -12,6 +12,13 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <sound/sh_fsi.h> 13#include <sound/sh_fsi.h>
14 14
15struct fsi_ak4642_data {
16 const char *name;
17 const char *cpu_dai;
18 const char *codec;
19 const char *platform;
20};
21
15static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) 22static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd)
16{ 23{
17 struct snd_soc_dai *dai = rtd->codec_dai; 24 struct snd_soc_dai *dai = rtd->codec_dai;
@@ -27,17 +34,12 @@ static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd)
27} 34}
28 35
29static struct snd_soc_dai_link fsi_dai_link = { 36static struct snd_soc_dai_link fsi_dai_link = {
30 .name = "AK4642", 37 /* .name */
31 .stream_name = "AK4642", 38 /* .stream_name */
32 .cpu_dai_name = "fsia-dai", /* fsi A */ 39 /* .cpu_dai_name */
33 .codec_dai_name = "ak4642-hifi", 40 .codec_dai_name = "ak4642-hifi",
34#ifdef CONFIG_MACH_AP4EVB 41 /* .platform_name */
35 .platform_name = "sh_fsi2", 42 /* .codec_name */
36 .codec_name = "ak4642-codec.0-0013",
37#else
38 .platform_name = "sh_fsi.0",
39 .codec_name = "ak4642-codec.0-0012",
40#endif
41 .init = fsi_ak4642_dai_init, 43 .init = fsi_ak4642_dai_init,
42 .ops = NULL, 44 .ops = NULL,
43}; 45};
@@ -50,14 +52,30 @@ static struct snd_soc_card fsi_soc_card = {
50 52
51static struct platform_device *fsi_snd_device; 53static struct platform_device *fsi_snd_device;
52 54
53static int __init fsi_ak4642_init(void) 55static int fsi_ak4642_probe(struct platform_device *pdev)
54{ 56{
55 int ret = -ENOMEM; 57 int ret = -ENOMEM;
58 const struct platform_device_id *id_entry;
59 struct fsi_ak4642_data *pdata;
60
61 id_entry = pdev->id_entry;
62 if (!id_entry) {
63 dev_err(&pdev->dev, "unknown fsi ak4642\n");
64 return -ENODEV;
65 }
66
67 pdata = (struct fsi_ak4642_data *)id_entry->driver_data;
56 68
57 fsi_snd_device = platform_device_alloc("soc-audio", FSI_PORT_A); 69 fsi_snd_device = platform_device_alloc("soc-audio", FSI_PORT_A);
58 if (!fsi_snd_device) 70 if (!fsi_snd_device)
59 goto out; 71 goto out;
60 72
73 fsi_dai_link.name = pdata->name;
74 fsi_dai_link.stream_name = pdata->name;
75 fsi_dai_link.cpu_dai_name = pdata->cpu_dai;
76 fsi_dai_link.platform_name = pdata->platform;
77 fsi_dai_link.codec_name = pdata->codec;
78
61 platform_set_drvdata(fsi_snd_device, &fsi_soc_card); 79 platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
62 ret = platform_device_add(fsi_snd_device); 80 ret = platform_device_add(fsi_snd_device);
63 81
@@ -68,9 +86,100 @@ out:
68 return ret; 86 return ret;
69} 87}
70 88
71static void __exit fsi_ak4642_exit(void) 89static int fsi_ak4642_remove(struct platform_device *pdev)
72{ 90{
73 platform_device_unregister(fsi_snd_device); 91 platform_device_unregister(fsi_snd_device);
92 return 0;
93}
94
95static struct fsi_ak4642_data fsi_a_ak4642 = {
96 .name = "AK4642",
97 .cpu_dai = "fsia-dai",
98 .codec = "ak4642-codec.0-0012",
99 .platform = "sh_fsi.0",
100};
101
102static struct fsi_ak4642_data fsi_b_ak4642 = {
103 .name = "AK4642",
104 .cpu_dai = "fsib-dai",
105 .codec = "ak4642-codec.0-0012",
106 .platform = "sh_fsi.0",
107};
108
109static struct fsi_ak4642_data fsi_a_ak4643 = {
110 .name = "AK4643",
111 .cpu_dai = "fsia-dai",
112 .codec = "ak4642-codec.0-0013",
113 .platform = "sh_fsi.0",
114};
115
116static struct fsi_ak4642_data fsi_b_ak4643 = {
117 .name = "AK4643",
118 .cpu_dai = "fsib-dai",
119 .codec = "ak4642-codec.0-0013",
120 .platform = "sh_fsi.0",
121};
122
123static struct fsi_ak4642_data fsi2_a_ak4642 = {
124 .name = "AK4642",
125 .cpu_dai = "fsia-dai",
126 .codec = "ak4642-codec.0-0012",
127 .platform = "sh_fsi2",
128};
129
130static struct fsi_ak4642_data fsi2_b_ak4642 = {
131 .name = "AK4642",
132 .cpu_dai = "fsib-dai",
133 .codec = "ak4642-codec.0-0012",
134 .platform = "sh_fsi2",
135};
136
137static struct fsi_ak4642_data fsi2_a_ak4643 = {
138 .name = "AK4643",
139 .cpu_dai = "fsia-dai",
140 .codec = "ak4642-codec.0-0013",
141 .platform = "sh_fsi2",
142};
143
144static struct fsi_ak4642_data fsi2_b_ak4643 = {
145 .name = "AK4643",
146 .cpu_dai = "fsib-dai",
147 .codec = "ak4642-codec.0-0013",
148 .platform = "sh_fsi2",
149};
150
151static struct platform_device_id fsi_id_table[] = {
152 /* FSI */
153 { "sh_fsi_a_ak4642", (kernel_ulong_t)&fsi_a_ak4642 },
154 { "sh_fsi_b_ak4642", (kernel_ulong_t)&fsi_b_ak4642 },
155 { "sh_fsi_a_ak4643", (kernel_ulong_t)&fsi_a_ak4643 },
156 { "sh_fsi_b_ak4643", (kernel_ulong_t)&fsi_b_ak4643 },
157
158 /* FSI 2 */
159 { "sh_fsi2_a_ak4642", (kernel_ulong_t)&fsi2_a_ak4642 },
160 { "sh_fsi2_b_ak4642", (kernel_ulong_t)&fsi2_b_ak4642 },
161 { "sh_fsi2_a_ak4643", (kernel_ulong_t)&fsi2_a_ak4643 },
162 { "sh_fsi2_b_ak4643", (kernel_ulong_t)&fsi2_b_ak4643 },
163 {},
164};
165
166static struct platform_driver fsi_ak4642 = {
167 .driver = {
168 .name = "fsi-ak4642-audio",
169 },
170 .probe = fsi_ak4642_probe,
171 .remove = fsi_ak4642_remove,
172 .id_table = fsi_id_table,
173};
174
175static int __init fsi_ak4642_init(void)
176{
177 return platform_driver_register(&fsi_ak4642);
178}
179
180static void __exit fsi_ak4642_exit(void)
181{
182 platform_driver_unregister(&fsi_ak4642);
74} 183}
75 184
76module_init(fsi_ak4642_init); 185module_init(fsi_ak4642_init);