diff options
Diffstat (limited to 'sound/soc/sh/fsi-ak4642.c')
-rw-r--r-- | sound/soc/sh/fsi-ak4642.c | 140 |
1 files changed, 126 insertions, 14 deletions
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c index d96602de71d..a14820ac966 100644 --- a/sound/soc/sh/fsi-ak4642.c +++ b/sound/soc/sh/fsi-ak4642.c | |||
@@ -12,6 +12,14 @@ | |||
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 | ||
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 | |||
15 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) | 23 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) |
16 | { | 24 | { |
17 | struct snd_soc_dai *dai = rtd->codec_dai; | 25 | struct snd_soc_dai *dai = rtd->codec_dai; |
@@ -27,37 +35,42 @@ static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
27 | } | 35 | } |
28 | 36 | ||
29 | static struct snd_soc_dai_link fsi_dai_link = { | 37 | static struct snd_soc_dai_link fsi_dai_link = { |
30 | .name = "AK4642", | ||
31 | .stream_name = "AK4642", | ||
32 | .cpu_dai_name = "fsia-dai", /* fsi A */ | ||
33 | .codec_dai_name = "ak4642-hifi", | 38 | .codec_dai_name = "ak4642-hifi", |
34 | #ifdef CONFIG_MACH_AP4EVB | ||
35 | .platform_name = "sh_fsi2", | ||
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, | 39 | .init = fsi_ak4642_dai_init, |
42 | .ops = NULL, | ||
43 | }; | 40 | }; |
44 | 41 | ||
45 | static struct snd_soc_card fsi_soc_card = { | 42 | static struct snd_soc_card fsi_soc_card = { |
46 | .name = "FSI (AK4642)", | ||
47 | .dai_link = &fsi_dai_link, | 43 | .dai_link = &fsi_dai_link, |
48 | .num_links = 1, | 44 | .num_links = 1, |
49 | }; | 45 | }; |
50 | 46 | ||
51 | static struct platform_device *fsi_snd_device; | 47 | static struct platform_device *fsi_snd_device; |
52 | 48 | ||
53 | static int __init fsi_ak4642_init(void) | 49 | static int fsi_ak4642_probe(struct platform_device *pdev) |
54 | { | 50 | { |
55 | int ret = -ENOMEM; | 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; | ||
56 | 62 | ||
57 | fsi_snd_device = platform_device_alloc("soc-audio", FSI_PORT_A); | 63 | fsi_snd_device = platform_device_alloc("soc-audio", FSI_PORT_A); |
58 | if (!fsi_snd_device) | 64 | if (!fsi_snd_device) |
59 | goto out; | 65 | goto out; |
60 | 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 | |||
61 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); | 74 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); |
62 | ret = platform_device_add(fsi_snd_device); | 75 | ret = platform_device_add(fsi_snd_device); |
63 | 76 | ||
@@ -68,9 +81,108 @@ out: | |||
68 | return ret; | 81 | return ret; |
69 | } | 82 | } |
70 | 83 | ||
71 | static void __exit fsi_ak4642_exit(void) | 84 | static int fsi_ak4642_remove(struct platform_device *pdev) |
72 | { | 85 | { |
73 | platform_device_unregister(fsi_snd_device); | 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); | ||
74 | } | 186 | } |
75 | 187 | ||
76 | module_init(fsi_ak4642_init); | 188 | module_init(fsi_ak4642_init); |