Commit | Line | Data |
---|---|---|
f2390880 KM |
1 | /* |
2 | * ASoC simple sound card support | |
3 | * | |
4 | * Copyright (C) 2012 Renesas Solutions Corp. | |
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | */ | |
fa558c28 | 11 | #include <linux/clk.h> |
6ff62eed | 12 | #include <linux/device.h> |
f2390880 | 13 | #include <linux/module.h> |
fa558c28 | 14 | #include <linux/of.h> |
f2390880 | 15 | #include <linux/platform_device.h> |
ca919fe4 | 16 | #include <linux/string.h> |
f2390880 | 17 | #include <sound/simple_card.h> |
6ff62eed XL |
18 | #include <sound/soc-dai.h> |
19 | #include <sound/soc.h> | |
f2390880 | 20 | |
45fce594 JFM |
21 | struct simple_card_data { |
22 | struct snd_soc_card snd_card; | |
cf7dc23c JFM |
23 | struct simple_dai_props { |
24 | struct asoc_simple_dai cpu_dai; | |
25 | struct asoc_simple_dai codec_dai; | |
26 | } *dai_props; | |
2942a0e2 | 27 | unsigned int mclk_fs; |
cf7dc23c | 28 | struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ |
45fce594 JFM |
29 | }; |
30 | ||
f531913f KM |
31 | #define simple_priv_to_dev(priv) ((priv)->snd_card.dev) |
32 | ||
2942a0e2 AL |
33 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, |
34 | struct snd_pcm_hw_params *params) | |
35 | { | |
36 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
37 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | |
38 | struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); | |
39 | unsigned int mclk; | |
40 | int ret = 0; | |
41 | ||
42 | if (priv->mclk_fs) { | |
43 | mclk = params_rate(params) * priv->mclk_fs; | |
44 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, | |
45 | SND_SOC_CLOCK_IN); | |
46 | } | |
47 | ||
48 | return ret; | |
49 | } | |
50 | ||
51 | static struct snd_soc_ops asoc_simple_card_ops = { | |
52 | .hw_params = asoc_simple_card_hw_params, | |
53 | }; | |
54 | ||
a4a2992c | 55 | static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, |
30d0341e | 56 | struct asoc_simple_dai *set) |
a4a2992c | 57 | { |
4763ebe2 | 58 | int ret; |
a4a2992c | 59 | |
30d0341e XL |
60 | if (set->fmt) { |
61 | ret = snd_soc_dai_set_fmt(dai, set->fmt); | |
4763ebe2 XL |
62 | if (ret && ret != -ENOTSUPP) { |
63 | dev_err(dai->dev, "simple-card: set_fmt error\n"); | |
64 | goto err; | |
65 | } | |
e244bb9b KM |
66 | } |
67 | ||
4763ebe2 | 68 | if (set->sysclk) { |
a4a2992c | 69 | ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); |
4763ebe2 XL |
70 | if (ret && ret != -ENOTSUPP) { |
71 | dev_err(dai->dev, "simple-card: set_sysclk error\n"); | |
72 | goto err; | |
73 | } | |
74 | } | |
75 | ||
6ff62eed XL |
76 | if (set->slots) { |
77 | ret = snd_soc_dai_set_tdm_slot(dai, 0, 0, | |
78 | set->slots, | |
79 | set->slot_width); | |
80 | if (ret && ret != -ENOTSUPP) { | |
81 | dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); | |
82 | goto err; | |
83 | } | |
84 | } | |
85 | ||
4763ebe2 | 86 | ret = 0; |
a4a2992c | 87 | |
4763ebe2 | 88 | err: |
a4a2992c KM |
89 | return ret; |
90 | } | |
91 | ||
f2390880 KM |
92 | static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) |
93 | { | |
781cbebe | 94 | struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); |
f2390880 KM |
95 | struct snd_soc_dai *codec = rtd->codec_dai; |
96 | struct snd_soc_dai *cpu = rtd->cpu_dai; | |
6a91a17b JFM |
97 | struct simple_dai_props *dai_props; |
98 | int num, ret; | |
f2390880 | 99 | |
6a91a17b JFM |
100 | num = rtd - rtd->card->rtd; |
101 | dai_props = &priv->dai_props[num]; | |
102 | ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai); | |
a4a2992c KM |
103 | if (ret < 0) |
104 | return ret; | |
f2390880 | 105 | |
6a91a17b | 106 | ret = __asoc_simple_card_dai_init(cpu, &dai_props->cpu_dai); |
a4a2992c KM |
107 | if (ret < 0) |
108 | return ret; | |
f2390880 KM |
109 | |
110 | return 0; | |
111 | } | |
112 | ||
fa558c28 KM |
113 | static int |
114 | asoc_simple_card_sub_parse_of(struct device_node *np, | |
115 | struct asoc_simple_dai *dai, | |
8ea21348 | 116 | struct device_node **p_node, |
7c7b9cf5 KM |
117 | const char **name, |
118 | int *args_count) | |
fa558c28 | 119 | { |
7c7b9cf5 | 120 | struct of_phandle_args args; |
fa558c28 | 121 | struct clk *clk; |
c7099eb1 | 122 | u32 val; |
fa558c28 KM |
123 | int ret; |
124 | ||
125 | /* | |
0dd4fc3c | 126 | * Get node via "sound-dai = <&phandle port>" |
fa558c28 KM |
127 | * it will be used as xxx_of_node on soc_bind_dai_link() |
128 | */ | |
7c7b9cf5 KM |
129 | ret = of_parse_phandle_with_args(np, "sound-dai", |
130 | "#sound-dai-cells", 0, &args); | |
131 | if (ret) | |
132 | return ret; | |
133 | ||
134 | *p_node = args.np; | |
135 | ||
136 | if (args_count) | |
137 | *args_count = args.args_count; | |
fa558c28 | 138 | |
0dd4fc3c | 139 | /* Get dai->name */ |
52008472 | 140 | ret = snd_soc_of_get_dai_name(np, name); |
fa558c28 | 141 | if (ret < 0) |
e512e001 | 142 | return ret; |
fa558c28 | 143 | |
0dd4fc3c | 144 | /* Parse TDM slot */ |
6ff62eed XL |
145 | ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width); |
146 | if (ret) | |
e512e001 | 147 | return ret; |
6ff62eed | 148 | |
fa558c28 | 149 | /* |
0dd4fc3c XL |
150 | * Parse dai->sysclk come from "clocks = <&xxx>" |
151 | * (if system has common clock) | |
fa558c28 | 152 | * or "system-clock-frequency = <xxx>" |
71467e46 | 153 | * or device's module clock. |
fa558c28 | 154 | */ |
71467e46 XL |
155 | if (of_property_read_bool(np, "clocks")) { |
156 | clk = of_clk_get(np, 0); | |
157 | if (IS_ERR(clk)) { | |
158 | ret = PTR_ERR(clk); | |
e512e001 | 159 | return ret; |
71467e46 XL |
160 | } |
161 | ||
162 | dai->sysclk = clk_get_rate(clk); | |
c7099eb1 JS |
163 | } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { |
164 | dai->sysclk = val; | |
71467e46 | 165 | } else { |
88a60e55 | 166 | clk = of_clk_get(args.np, 0); |
e2a19ac6 XL |
167 | if (!IS_ERR(clk)) |
168 | dai->sysclk = clk_get_rate(clk); | |
71467e46 | 169 | } |
fa558c28 | 170 | |
e512e001 | 171 | return 0; |
fa558c28 KM |
172 | } |
173 | ||
2d82eeb0 | 174 | static int asoc_simple_card_dai_link_of(struct device_node *node, |
f531913f | 175 | struct simple_card_data *priv, |
2d82eeb0 KM |
176 | struct snd_soc_dai_link *dai_link, |
177 | struct simple_dai_props *dai_props, | |
178 | bool is_top_level_node) | |
6a91a17b | 179 | { |
f531913f | 180 | struct device *dev = simple_priv_to_dev(priv); |
b3ca11ff JS |
181 | struct device_node *np = NULL; |
182 | struct device_node *bitclkmaster = NULL; | |
183 | struct device_node *framemaster = NULL; | |
184 | unsigned int daifmt; | |
185 | char *name; | |
186 | char prop[128]; | |
187 | char *prefix = ""; | |
7c7b9cf5 | 188 | int ret, cpu_args; |
6a91a17b | 189 | |
2080437d | 190 | /* For single DAI link & old style of DT node */ |
64872215 JS |
191 | if (is_top_level_node) |
192 | prefix = "simple-audio-card,"; | |
b3ca11ff JS |
193 | |
194 | daifmt = snd_soc_of_parse_daifmt(node, prefix, | |
195 | &bitclkmaster, &framemaster); | |
196 | daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; | |
197 | ||
198 | snprintf(prop, sizeof(prop), "%scpu", prefix); | |
199 | np = of_get_child_by_name(node, prop); | |
200 | if (!np) { | |
201 | ret = -EINVAL; | |
966b8063 | 202 | dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop); |
b3ca11ff | 203 | goto dai_link_of_err; |
6a91a17b | 204 | } |
b3ca11ff JS |
205 | |
206 | ret = asoc_simple_card_sub_parse_of(np, &dai_props->cpu_dai, | |
207 | &dai_link->cpu_of_node, | |
7c7b9cf5 KM |
208 | &dai_link->cpu_dai_name, |
209 | &cpu_args); | |
6a91a17b | 210 | if (ret < 0) |
b3ca11ff JS |
211 | goto dai_link_of_err; |
212 | ||
213 | dai_props->cpu_dai.fmt = daifmt; | |
781cbebe | 214 | switch (((np == bitclkmaster) << 4) | (np == framemaster)) { |
b3ca11ff JS |
215 | case 0x11: |
216 | dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS; | |
217 | break; | |
218 | case 0x10: | |
219 | dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM; | |
220 | break; | |
221 | case 0x01: | |
222 | dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS; | |
223 | break; | |
224 | default: | |
225 | dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM; | |
226 | break; | |
227 | } | |
6a91a17b | 228 | |
b3ca11ff JS |
229 | of_node_put(np); |
230 | snprintf(prop, sizeof(prop), "%scodec", prefix); | |
231 | np = of_get_child_by_name(node, prop); | |
232 | if (!np) { | |
233 | ret = -EINVAL; | |
966b8063 | 234 | dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop); |
b3ca11ff | 235 | goto dai_link_of_err; |
6a91a17b | 236 | } |
b3ca11ff JS |
237 | |
238 | ret = asoc_simple_card_sub_parse_of(np, &dai_props->codec_dai, | |
239 | &dai_link->codec_of_node, | |
7c7b9cf5 | 240 | &dai_link->codec_dai_name, NULL); |
b3ca11ff JS |
241 | if (ret < 0) |
242 | goto dai_link_of_err; | |
243 | ||
244 | if (strlen(prefix) && !bitclkmaster && !framemaster) { | |
0dd4fc3c XL |
245 | /* |
246 | * No DAI link level and master setting was found | |
247 | * from sound node level, revert back to legacy DT | |
248 | * parsing and take the settings from codec node. | |
249 | */ | |
b3ca11ff JS |
250 | dev_dbg(dev, "%s: Revert to legacy daifmt parsing\n", |
251 | __func__); | |
252 | dai_props->cpu_dai.fmt = dai_props->codec_dai.fmt = | |
253 | snd_soc_of_parse_daifmt(np, NULL, NULL, NULL) | | |
254 | (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK); | |
255 | } else { | |
256 | dai_props->codec_dai.fmt = daifmt; | |
781cbebe | 257 | switch (((np == bitclkmaster) << 4) | (np == framemaster)) { |
b3ca11ff JS |
258 | case 0x11: |
259 | dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM; | |
260 | break; | |
261 | case 0x10: | |
262 | dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS; | |
263 | break; | |
264 | case 0x01: | |
265 | dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM; | |
266 | break; | |
267 | default: | |
268 | dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS; | |
269 | break; | |
270 | } | |
271 | } | |
272 | ||
273 | if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) { | |
781cbebe NC |
274 | ret = -EINVAL; |
275 | goto dai_link_of_err; | |
b3ca11ff JS |
276 | } |
277 | ||
0dd4fc3c | 278 | /* Simple Card assumes platform == cpu */ |
b3ca11ff JS |
279 | dai_link->platform_of_node = dai_link->cpu_of_node; |
280 | ||
0dd4fc3c | 281 | /* DAI link name is created from CPU/CODEC dai name */ |
b3ca11ff JS |
282 | name = devm_kzalloc(dev, |
283 | strlen(dai_link->cpu_dai_name) + | |
284 | strlen(dai_link->codec_dai_name) + 2, | |
285 | GFP_KERNEL); | |
286 | sprintf(name, "%s-%s", dai_link->cpu_dai_name, | |
287 | dai_link->codec_dai_name); | |
288 | dai_link->name = dai_link->stream_name = name; | |
2942a0e2 | 289 | dai_link->ops = &asoc_simple_card_ops; |
a5960bd5 | 290 | dai_link->init = asoc_simple_card_dai_init; |
b3ca11ff JS |
291 | |
292 | dev_dbg(dev, "\tname : %s\n", dai_link->stream_name); | |
293 | dev_dbg(dev, "\tcpu : %s / %04x / %d\n", | |
294 | dai_link->cpu_dai_name, | |
295 | dai_props->cpu_dai.fmt, | |
296 | dai_props->cpu_dai.sysclk); | |
297 | dev_dbg(dev, "\tcodec : %s / %04x / %d\n", | |
298 | dai_link->codec_dai_name, | |
299 | dai_props->codec_dai.fmt, | |
300 | dai_props->codec_dai.sysclk); | |
301 | ||
179949bc | 302 | /* |
0dd4fc3c XL |
303 | * In soc_bind_dai_link() will check cpu name after |
304 | * of_node matching if dai_link has cpu_dai_name. | |
305 | * but, it will never match if name was created by | |
306 | * fmt_single_name() remove cpu_dai_name if cpu_args | |
307 | * was 0. See: | |
179949bc KM |
308 | * fmt_single_name() |
309 | * fmt_multiple_name() | |
310 | */ | |
7c7b9cf5 KM |
311 | if (!cpu_args) |
312 | dai_link->cpu_dai_name = NULL; | |
179949bc | 313 | |
b3ca11ff JS |
314 | dai_link_of_err: |
315 | if (np) | |
316 | of_node_put(np); | |
317 | if (bitclkmaster) | |
318 | of_node_put(bitclkmaster); | |
319 | if (framemaster) | |
320 | of_node_put(framemaster); | |
6a91a17b JFM |
321 | return ret; |
322 | } | |
323 | ||
fa558c28 | 324 | static int asoc_simple_card_parse_of(struct device_node *node, |
f531913f | 325 | struct simple_card_data *priv) |
fa558c28 | 326 | { |
f531913f | 327 | struct device *dev = simple_priv_to_dev(priv); |
b367a325 | 328 | struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link; |
6a91a17b | 329 | struct simple_dai_props *dai_props = priv->dai_props; |
c7099eb1 | 330 | u32 val; |
d4c22094 | 331 | int ret; |
fa558c28 | 332 | |
2080437d XL |
333 | if (!node) |
334 | return -EINVAL; | |
335 | ||
0dd4fc3c | 336 | /* Parse the card name from DT */ |
2772555b XL |
337 | snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name"); |
338 | ||
0dd4fc3c | 339 | /* The off-codec widgets */ |
9d681f5b XL |
340 | if (of_property_read_bool(node, "simple-audio-card,widgets")) { |
341 | ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card, | |
342 | "simple-audio-card,widgets"); | |
343 | if (ret) | |
344 | return ret; | |
345 | } | |
346 | ||
d4c22094 | 347 | /* DAPM routes */ |
8c0b8230 | 348 | if (of_property_read_bool(node, "simple-audio-card,routing")) { |
b367a325 | 349 | ret = snd_soc_of_parse_audio_routing(&priv->snd_card, |
8c0b8230 | 350 | "simple-audio-card,routing"); |
f87a3e82 XL |
351 | if (ret) |
352 | return ret; | |
353 | } | |
d4c22094 | 354 | |
2942a0e2 | 355 | /* Factor to mclk, used in hw_params() */ |
c7099eb1 JS |
356 | ret = of_property_read_u32(node, "simple-audio-card,mclk-fs", &val); |
357 | if (ret == 0) | |
358 | priv->mclk_fs = val; | |
2942a0e2 | 359 | |
b3ca11ff JS |
360 | dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? |
361 | priv->snd_card.name : ""); | |
362 | ||
2080437d XL |
363 | /* Single/Muti DAI link(s) & New style of DT node */ |
364 | if (of_get_child_by_name(node, "simple-audio-card,dai-link")) { | |
b3ca11ff | 365 | struct device_node *np = NULL; |
a44a750e KM |
366 | int i = 0; |
367 | ||
368 | for_each_child_of_node(node, np) { | |
b3ca11ff | 369 | dev_dbg(dev, "\tlink %d:\n", i); |
f531913f | 370 | ret = asoc_simple_card_dai_link_of(np, priv, |
2d82eeb0 KM |
371 | dai_link + i, |
372 | dai_props + i, | |
373 | false); | |
b3ca11ff JS |
374 | if (ret < 0) { |
375 | of_node_put(np); | |
376 | return ret; | |
377 | } | |
a44a750e | 378 | i++; |
6a91a17b | 379 | } |
b3ca11ff | 380 | } else { |
2080437d | 381 | /* For single DAI link & old style of DT node */ |
f531913f | 382 | ret = asoc_simple_card_dai_link_of(node, priv, |
2d82eeb0 | 383 | dai_link, dai_props, true); |
6a91a17b | 384 | if (ret < 0) |
b3ca11ff | 385 | return ret; |
6a91a17b | 386 | } |
dd41e0c4 | 387 | |
2772555b | 388 | if (!priv->snd_card.name) |
b3ca11ff | 389 | priv->snd_card.name = priv->snd_card.dai_link->name; |
f687d900 | 390 | |
fa558c28 KM |
391 | return 0; |
392 | } | |
393 | ||
0dd4fc3c | 394 | /* Decrease the reference count of the device nodes */ |
e512e001 JFM |
395 | static int asoc_simple_card_unref(struct platform_device *pdev) |
396 | { | |
397 | struct snd_soc_card *card = platform_get_drvdata(pdev); | |
398 | struct snd_soc_dai_link *dai_link; | |
399 | struct device_node *np; | |
400 | int num_links; | |
401 | ||
402 | for (num_links = 0, dai_link = card->dai_link; | |
403 | num_links < card->num_links; | |
404 | num_links++, dai_link++) { | |
405 | np = (struct device_node *) dai_link->cpu_of_node; | |
406 | if (np) | |
407 | of_node_put(np); | |
408 | np = (struct device_node *) dai_link->codec_of_node; | |
409 | if (np) | |
410 | of_node_put(np); | |
411 | } | |
412 | return 0; | |
413 | } | |
414 | ||
f2390880 KM |
415 | static int asoc_simple_card_probe(struct platform_device *pdev) |
416 | { | |
45fce594 | 417 | struct simple_card_data *priv; |
5ca8ba41 | 418 | struct snd_soc_dai_link *dai_link; |
fa558c28 | 419 | struct device_node *np = pdev->dev.of_node; |
f89983ef | 420 | struct device *dev = &pdev->dev; |
2080437d | 421 | int num_links, ret; |
6a91a17b | 422 | |
0dd4fc3c | 423 | /* Get the number of DAI links */ |
2080437d | 424 | if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) |
6a91a17b | 425 | num_links = of_get_child_count(np); |
2080437d | 426 | else |
6a91a17b | 427 | num_links = 1; |
f2390880 | 428 | |
0dd4fc3c | 429 | /* Allocate the private data and the DAI link array */ |
cf7dc23c | 430 | priv = devm_kzalloc(dev, |
6a91a17b | 431 | sizeof(*priv) + sizeof(*dai_link) * num_links, |
cf7dc23c | 432 | GFP_KERNEL); |
ca65b492 | 433 | if (!priv) |
ca919fe4 XL |
434 | return -ENOMEM; |
435 | ||
0dd4fc3c | 436 | /* Init snd_soc_card */ |
ca65b492 JFM |
437 | priv->snd_card.owner = THIS_MODULE; |
438 | priv->snd_card.dev = dev; | |
cf7dc23c | 439 | dai_link = priv->dai_link; |
ca65b492 | 440 | priv->snd_card.dai_link = dai_link; |
6a91a17b | 441 | priv->snd_card.num_links = num_links; |
201a0eac | 442 | |
0dd4fc3c | 443 | /* Get room for the other properties */ |
cf7dc23c | 444 | priv->dai_props = devm_kzalloc(dev, |
6a91a17b | 445 | sizeof(*priv->dai_props) * num_links, |
cf7dc23c JFM |
446 | GFP_KERNEL); |
447 | if (!priv->dai_props) | |
448 | return -ENOMEM; | |
449 | ||
fa558c28 | 450 | if (np && of_device_is_available(np)) { |
ca919fe4 | 451 | |
f531913f | 452 | ret = asoc_simple_card_parse_of(np, priv); |
ca919fe4 XL |
453 | if (ret < 0) { |
454 | if (ret != -EPROBE_DEFER) | |
455 | dev_err(dev, "parse error %d\n", ret); | |
e512e001 | 456 | goto err; |
fa558c28 | 457 | } |
6a91a17b | 458 | |
fa558c28 | 459 | } else { |
ca65b492 JFM |
460 | struct asoc_simple_card_info *cinfo; |
461 | ||
462 | cinfo = dev->platform_data; | |
463 | if (!cinfo) { | |
34787d0a XL |
464 | dev_err(dev, "no info for asoc-simple-card\n"); |
465 | return -EINVAL; | |
466 | } | |
fa558c28 | 467 | |
781cbebe NC |
468 | if (!cinfo->name || |
469 | !cinfo->codec_dai.name || | |
470 | !cinfo->codec || | |
471 | !cinfo->platform || | |
7722f830 JFM |
472 | !cinfo->cpu_dai.name) { |
473 | dev_err(dev, "insufficient asoc_simple_card_info settings\n"); | |
474 | return -EINVAL; | |
475 | } | |
2bee9914 | 476 | |
12ffa6fc | 477 | priv->snd_card.name = (cinfo->card) ? cinfo->card : cinfo->name; |
5ca8ba41 JFM |
478 | dai_link->name = cinfo->name; |
479 | dai_link->stream_name = cinfo->name; | |
480 | dai_link->platform_name = cinfo->platform; | |
481 | dai_link->codec_name = cinfo->codec; | |
52008472 JFM |
482 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; |
483 | dai_link->codec_dai_name = cinfo->codec_dai.name; | |
a5960bd5 | 484 | dai_link->init = asoc_simple_card_dai_init; |
cf7dc23c JFM |
485 | memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai, |
486 | sizeof(priv->dai_props->cpu_dai)); | |
487 | memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai, | |
488 | sizeof(priv->dai_props->codec_dai)); | |
81985bd6 | 489 | |
cf7dc23c JFM |
490 | priv->dai_props->cpu_dai.fmt |= cinfo->daifmt; |
491 | priv->dai_props->codec_dai.fmt |= cinfo->daifmt; | |
f2390880 KM |
492 | } |
493 | ||
ca65b492 | 494 | snd_soc_card_set_drvdata(&priv->snd_card, priv); |
f2390880 | 495 | |
e512e001 JFM |
496 | ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card); |
497 | ||
498 | err: | |
499 | asoc_simple_card_unref(pdev); | |
500 | return ret; | |
f2390880 KM |
501 | } |
502 | ||
fa558c28 KM |
503 | static const struct of_device_id asoc_simple_of_match[] = { |
504 | { .compatible = "simple-audio-card", }, | |
505 | {}, | |
506 | }; | |
507 | MODULE_DEVICE_TABLE(of, asoc_simple_of_match); | |
508 | ||
f2390880 KM |
509 | static struct platform_driver asoc_simple_card = { |
510 | .driver = { | |
781cbebe | 511 | .name = "asoc-simple-card", |
c445be35 | 512 | .owner = THIS_MODULE, |
fa558c28 | 513 | .of_match_table = asoc_simple_of_match, |
f2390880 | 514 | }, |
781cbebe | 515 | .probe = asoc_simple_card_probe, |
f2390880 KM |
516 | }; |
517 | ||
518 | module_platform_driver(asoc_simple_card); | |
519 | ||
c445be35 | 520 | MODULE_ALIAS("platform:asoc-simple-card"); |
f2390880 KM |
521 | MODULE_LICENSE("GPL"); |
522 | MODULE_DESCRIPTION("ASoC Simple Sound Card"); | |
523 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); |