]>
Commit | Line | Data |
---|---|---|
b8e583f6 KM |
1 | /* |
2 | * FSI-AK464x sound support for ms7724se | |
3 | * | |
4 | * Copyright (C) 2009 Renesas Solutions Corp. | |
5 | * Kuninori Morimoto <[email protected]> | |
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 | ||
b8e583f6 | 12 | #include <linux/platform_device.h> |
da155d5b | 13 | #include <linux/module.h> |
b8e583f6 | 14 | #include <sound/sh_fsi.h> |
b8e583f6 | 15 | |
c8d6bf9a KM |
16 | struct fsi_ak4642_data { |
17 | const char *name; | |
806bfedf | 18 | const char *card; |
c8d6bf9a KM |
19 | const char *cpu_dai; |
20 | const char *codec; | |
21 | const char *platform; | |
a193436c | 22 | int id; |
c8d6bf9a KM |
23 | }; |
24 | ||
f0fba2ad | 25 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) |
4b6316b4 | 26 | { |
4d805f7b KM |
27 | struct snd_soc_dai *codec = rtd->codec_dai; |
28 | struct snd_soc_dai *cpu = rtd->cpu_dai; | |
4b6316b4 KM |
29 | int ret; |
30 | ||
4d805f7b KM |
31 | ret = snd_soc_dai_set_fmt(codec, SND_SOC_DAIFMT_LEFT_J | |
32 | SND_SOC_DAIFMT_CBM_CFM); | |
0643ce8f KM |
33 | if (ret < 0) |
34 | return ret; | |
35 | ||
4d805f7b KM |
36 | ret = snd_soc_dai_set_sysclk(codec, 0, 11289600, 0); |
37 | if (ret < 0) | |
38 | return ret; | |
39 | ||
f17c13ca KM |
40 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_LEFT_J | |
41 | SND_SOC_DAIFMT_CBS_CFS); | |
4b6316b4 KM |
42 | |
43 | return ret; | |
44 | } | |
45 | ||
b8e583f6 | 46 | static struct snd_soc_dai_link fsi_dai_link = { |
f0fba2ad | 47 | .codec_dai_name = "ak4642-hifi", |
4b6316b4 | 48 | .init = fsi_ak4642_dai_init, |
b8e583f6 KM |
49 | }; |
50 | ||
51 | static struct snd_soc_card fsi_soc_card = { | |
b8e583f6 KM |
52 | .dai_link = &fsi_dai_link, |
53 | .num_links = 1, | |
54 | }; | |
55 | ||
b8e583f6 KM |
56 | static struct platform_device *fsi_snd_device; |
57 | ||
c8d6bf9a | 58 | static int fsi_ak4642_probe(struct platform_device *pdev) |
b8e583f6 KM |
59 | { |
60 | int ret = -ENOMEM; | |
c8d6bf9a KM |
61 | const struct platform_device_id *id_entry; |
62 | struct fsi_ak4642_data *pdata; | |
63 | ||
64 | id_entry = pdev->id_entry; | |
65 | if (!id_entry) { | |
66 | dev_err(&pdev->dev, "unknown fsi ak4642\n"); | |
67 | return -ENODEV; | |
68 | } | |
69 | ||
70 | pdata = (struct fsi_ak4642_data *)id_entry->driver_data; | |
b8e583f6 | 71 | |
a193436c | 72 | fsi_snd_device = platform_device_alloc("soc-audio", pdata->id); |
b8e583f6 KM |
73 | if (!fsi_snd_device) |
74 | goto out; | |
75 | ||
c8d6bf9a KM |
76 | fsi_dai_link.name = pdata->name; |
77 | fsi_dai_link.stream_name = pdata->name; | |
78 | fsi_dai_link.cpu_dai_name = pdata->cpu_dai; | |
79 | fsi_dai_link.platform_name = pdata->platform; | |
80 | fsi_dai_link.codec_name = pdata->codec; | |
806bfedf | 81 | fsi_soc_card.name = pdata->card; |
c8d6bf9a | 82 | |
f0fba2ad | 83 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); |
b8e583f6 KM |
84 | ret = platform_device_add(fsi_snd_device); |
85 | ||
86 | if (ret) | |
87 | platform_device_put(fsi_snd_device); | |
88 | ||
89 | out: | |
90 | return ret; | |
91 | } | |
92 | ||
c8d6bf9a | 93 | static int fsi_ak4642_remove(struct platform_device *pdev) |
b8e583f6 KM |
94 | { |
95 | platform_device_unregister(fsi_snd_device); | |
c8d6bf9a KM |
96 | return 0; |
97 | } | |
98 | ||
99 | static struct fsi_ak4642_data fsi_a_ak4642 = { | |
100 | .name = "AK4642", | |
505b04e0 | 101 | .card = "FSIA-AK4642", |
c8d6bf9a KM |
102 | .cpu_dai = "fsia-dai", |
103 | .codec = "ak4642-codec.0-0012", | |
104 | .platform = "sh_fsi.0", | |
a193436c | 105 | .id = FSI_PORT_A, |
c8d6bf9a KM |
106 | }; |
107 | ||
108 | static struct fsi_ak4642_data fsi_b_ak4642 = { | |
109 | .name = "AK4642", | |
505b04e0 | 110 | .card = "FSIB-AK4642", |
c8d6bf9a KM |
111 | .cpu_dai = "fsib-dai", |
112 | .codec = "ak4642-codec.0-0012", | |
113 | .platform = "sh_fsi.0", | |
a193436c | 114 | .id = FSI_PORT_B, |
c8d6bf9a KM |
115 | }; |
116 | ||
117 | static struct fsi_ak4642_data fsi_a_ak4643 = { | |
118 | .name = "AK4643", | |
505b04e0 | 119 | .card = "FSIA-AK4643", |
c8d6bf9a KM |
120 | .cpu_dai = "fsia-dai", |
121 | .codec = "ak4642-codec.0-0013", | |
122 | .platform = "sh_fsi.0", | |
a193436c | 123 | .id = FSI_PORT_A, |
c8d6bf9a KM |
124 | }; |
125 | ||
126 | static struct fsi_ak4642_data fsi_b_ak4643 = { | |
127 | .name = "AK4643", | |
505b04e0 | 128 | .card = "FSIB-AK4643", |
c8d6bf9a KM |
129 | .cpu_dai = "fsib-dai", |
130 | .codec = "ak4642-codec.0-0013", | |
131 | .platform = "sh_fsi.0", | |
a193436c | 132 | .id = FSI_PORT_B, |
c8d6bf9a KM |
133 | }; |
134 | ||
135 | static struct fsi_ak4642_data fsi2_a_ak4642 = { | |
136 | .name = "AK4642", | |
505b04e0 | 137 | .card = "FSI2A-AK4642", |
c8d6bf9a KM |
138 | .cpu_dai = "fsia-dai", |
139 | .codec = "ak4642-codec.0-0012", | |
140 | .platform = "sh_fsi2", | |
a193436c | 141 | .id = FSI_PORT_A, |
c8d6bf9a KM |
142 | }; |
143 | ||
144 | static struct fsi_ak4642_data fsi2_b_ak4642 = { | |
145 | .name = "AK4642", | |
505b04e0 | 146 | .card = "FSI2B-AK4642", |
c8d6bf9a KM |
147 | .cpu_dai = "fsib-dai", |
148 | .codec = "ak4642-codec.0-0012", | |
149 | .platform = "sh_fsi2", | |
a193436c | 150 | .id = FSI_PORT_B, |
c8d6bf9a KM |
151 | }; |
152 | ||
153 | static struct fsi_ak4642_data fsi2_a_ak4643 = { | |
154 | .name = "AK4643", | |
505b04e0 | 155 | .card = "FSI2A-AK4643", |
c8d6bf9a KM |
156 | .cpu_dai = "fsia-dai", |
157 | .codec = "ak4642-codec.0-0013", | |
158 | .platform = "sh_fsi2", | |
a193436c | 159 | .id = FSI_PORT_A, |
c8d6bf9a KM |
160 | }; |
161 | ||
162 | static struct fsi_ak4642_data fsi2_b_ak4643 = { | |
163 | .name = "AK4643", | |
505b04e0 | 164 | .card = "FSI2B-AK4643", |
c8d6bf9a KM |
165 | .cpu_dai = "fsib-dai", |
166 | .codec = "ak4642-codec.0-0013", | |
167 | .platform = "sh_fsi2", | |
a193436c | 168 | .id = FSI_PORT_B, |
c8d6bf9a KM |
169 | }; |
170 | ||
171 | static struct platform_device_id fsi_id_table[] = { | |
172 | /* FSI */ | |
173 | { "sh_fsi_a_ak4642", (kernel_ulong_t)&fsi_a_ak4642 }, | |
174 | { "sh_fsi_b_ak4642", (kernel_ulong_t)&fsi_b_ak4642 }, | |
175 | { "sh_fsi_a_ak4643", (kernel_ulong_t)&fsi_a_ak4643 }, | |
176 | { "sh_fsi_b_ak4643", (kernel_ulong_t)&fsi_b_ak4643 }, | |
177 | ||
178 | /* FSI 2 */ | |
179 | { "sh_fsi2_a_ak4642", (kernel_ulong_t)&fsi2_a_ak4642 }, | |
180 | { "sh_fsi2_b_ak4642", (kernel_ulong_t)&fsi2_b_ak4642 }, | |
181 | { "sh_fsi2_a_ak4643", (kernel_ulong_t)&fsi2_a_ak4643 }, | |
182 | { "sh_fsi2_b_ak4643", (kernel_ulong_t)&fsi2_b_ak4643 }, | |
183 | {}, | |
184 | }; | |
185 | ||
186 | static struct platform_driver fsi_ak4642 = { | |
187 | .driver = { | |
188 | .name = "fsi-ak4642-audio", | |
189 | }, | |
190 | .probe = fsi_ak4642_probe, | |
191 | .remove = fsi_ak4642_remove, | |
192 | .id_table = fsi_id_table, | |
193 | }; | |
194 | ||
195 | static int __init fsi_ak4642_init(void) | |
196 | { | |
197 | return platform_driver_register(&fsi_ak4642); | |
198 | } | |
199 | ||
200 | static void __exit fsi_ak4642_exit(void) | |
201 | { | |
202 | platform_driver_unregister(&fsi_ak4642); | |
b8e583f6 KM |
203 | } |
204 | ||
205 | module_init(fsi_ak4642_init); | |
206 | module_exit(fsi_ak4642_exit); | |
207 | ||
208 | MODULE_LICENSE("GPL"); | |
209 | MODULE_DESCRIPTION("Generic SH4 FSI-AK4642 sound card"); | |
210 | MODULE_AUTHOR("Kuninori Morimoto <[email protected]>"); |