30da8272fbc055680894f8d11d99ccb9291ec302
[linux-2.6-microblaze.git] / sound / soc / generic / simple-card.c
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // ASoC simple sound card support
4 //
5 // Copyright (C) 2012 Renesas Solutions Corp.
6 // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7
8 #include <linux/clk.h>
9 #include <linux/device.h>
10 #include <linux/module.h>
11 #include <linux/of.h>
12 #include <linux/of_device.h>
13 #include <linux/platform_device.h>
14 #include <linux/string.h>
15 #include <sound/simple_card.h>
16 #include <sound/soc-dai.h>
17 #include <sound/soc.h>
18
19 #define DPCM_SELECTABLE 1
20
21 #define DAI     "sound-dai"
22 #define CELL    "#sound-dai-cells"
23 #define PREFIX  "simple-audio-card,"
24
25 static const struct snd_soc_ops simple_ops = {
26         .startup        = asoc_simple_startup,
27         .shutdown       = asoc_simple_shutdown,
28         .hw_params      = asoc_simple_hw_params,
29 };
30
31 static int asoc_simple_parse_dai(struct device_node *node,
32                                  struct snd_soc_dai_link_component *dlc,
33                                  int *is_single_link)
34 {
35         struct of_phandle_args args;
36         int ret;
37
38         if (!node)
39                 return 0;
40
41         /*
42          * Get node via "sound-dai = <&phandle port>"
43          * it will be used as xxx_of_node on soc_bind_dai_link()
44          */
45         ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
46         if (ret)
47                 return ret;
48
49         /*
50          * FIXME
51          *
52          * Here, dlc->dai_name is pointer to CPU/Codec DAI name.
53          * If user unbinded CPU or Codec driver, but not for Sound Card,
54          * dlc->dai_name is keeping unbinded CPU or Codec
55          * driver's pointer.
56          *
57          * If user re-bind CPU or Codec driver again, ALSA SoC will try
58          * to rebind Card via snd_soc_try_rebind_card(), but because of
59          * above reason, it might can't bind Sound Card.
60          * Because Sound Card is pointing to released dai_name pointer.
61          *
62          * To avoid this rebind Card issue,
63          * 1) It needs to alloc memory to keep dai_name eventhough
64          *    CPU or Codec driver was unbinded, or
65          * 2) user need to rebind Sound Card everytime
66          *    if he unbinded CPU or Codec.
67          */
68         ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
69         if (ret < 0)
70                 return ret;
71
72         dlc->of_node = args.np;
73
74         if (is_single_link)
75                 *is_single_link = !args.args_count;
76
77         return 0;
78 }
79
80 static void simple_parse_convert(struct device *dev,
81                                  struct device_node *np,
82                                  struct asoc_simple_data *adata)
83 {
84         struct device_node *top = dev->of_node;
85         struct device_node *node = of_get_parent(np);
86
87         asoc_simple_parse_convert(dev, top,  PREFIX, adata);
88         asoc_simple_parse_convert(dev, node, PREFIX, adata);
89         asoc_simple_parse_convert(dev, node, NULL,   adata);
90         asoc_simple_parse_convert(dev, np,   NULL,   adata);
91
92         of_node_put(node);
93 }
94
95 static void simple_parse_mclk_fs(struct device_node *top,
96                                  struct device_node *cpu,
97                                  struct device_node *codec,
98                                  struct simple_dai_props *props,
99                                  char *prefix)
100 {
101         struct device_node *node = of_get_parent(cpu);
102         char prop[128];
103
104         snprintf(prop, sizeof(prop), "%smclk-fs", PREFIX);
105         of_property_read_u32(top,       prop, &props->mclk_fs);
106
107         snprintf(prop, sizeof(prop), "%smclk-fs", prefix);
108         of_property_read_u32(node,      prop, &props->mclk_fs);
109         of_property_read_u32(cpu,       prop, &props->mclk_fs);
110         of_property_read_u32(codec,     prop, &props->mclk_fs);
111
112         of_node_put(node);
113 }
114
115 static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
116                                    struct device_node *np,
117                                    struct device_node *codec,
118                                    struct link_info *li,
119                                    bool is_top)
120 {
121         struct device *dev = simple_priv_to_dev(priv);
122         struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
123         struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
124         struct asoc_simple_dai *dai;
125         struct snd_soc_dai_link_component *cpus = dai_link->cpus;
126         struct snd_soc_dai_link_component *codecs = dai_link->codecs;
127         struct device_node *top = dev->of_node;
128         struct device_node *node = of_get_parent(np);
129         char *prefix = "";
130         int ret;
131
132         dev_dbg(dev, "link_of DPCM (%pOF)\n", np);
133
134         li->link++;
135
136         /* For single DAI link & old style of DT node */
137         if (is_top)
138                 prefix = PREFIX;
139
140         if (li->cpu) {
141                 int is_single_links = 0;
142
143                 /* Codec is dummy */
144
145                 /* FE settings */
146                 dai_link->dynamic               = 1;
147                 dai_link->dpcm_merged_format    = 1;
148
149                 dai = dai_props->cpu_dai;
150
151                 ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links);
152                 if (ret)
153                         goto out_put_node;
154
155                 ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai);
156                 if (ret < 0)
157                         goto out_put_node;
158
159                 ret = asoc_simple_set_dailink_name(dev, dai_link,
160                                                    "fe.%s",
161                                                    cpus->dai_name);
162                 if (ret < 0)
163                         goto out_put_node;
164
165                 asoc_simple_canonicalize_cpu(dai_link, is_single_links);
166                 asoc_simple_canonicalize_platform(dai_link);
167         } else {
168                 struct snd_soc_codec_conf *cconf;
169
170                 /* CPU is dummy */
171
172                 /* BE settings */
173                 dai_link->no_pcm                = 1;
174                 dai_link->be_hw_params_fixup    = asoc_simple_be_hw_params_fixup;
175
176                 dai   = dai_props->codec_dai;
177                 cconf = dai_props->codec_conf;
178
179                 ret = asoc_simple_parse_codec(np, dai_link);
180                 if (ret < 0)
181                         goto out_put_node;
182
183                 ret = asoc_simple_parse_clk_codec(dev, np, dai_link, dai);
184                 if (ret < 0)
185                         goto out_put_node;
186
187                 ret = asoc_simple_set_dailink_name(dev, dai_link,
188                                                    "be.%s",
189                                                    codecs->dai_name);
190                 if (ret < 0)
191                         goto out_put_node;
192
193                 /* check "prefix" from top node */
194                 snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
195                                               PREFIX "prefix");
196                 snd_soc_of_parse_node_prefix(node, cconf, codecs->of_node,
197                                              "prefix");
198                 snd_soc_of_parse_node_prefix(np, cconf, codecs->of_node,
199                                              "prefix");
200         }
201
202         simple_parse_convert(dev, np, &dai_props->adata);
203         simple_parse_mclk_fs(top, np, codec, dai_props, prefix);
204
205         ret = asoc_simple_parse_tdm(np, dai);
206         if (ret)
207                 goto out_put_node;
208
209         ret = asoc_simple_parse_daifmt(dev, node, codec,
210                                        prefix, &dai_link->dai_fmt);
211         if (ret < 0)
212                 goto out_put_node;
213
214         snd_soc_dai_link_set_capabilities(dai_link);
215
216         dai_link->ops                   = &simple_ops;
217         dai_link->init                  = asoc_simple_dai_init;
218
219 out_put_node:
220         of_node_put(node);
221         return ret;
222 }
223
224 static int simple_dai_link_of(struct asoc_simple_priv *priv,
225                               struct device_node *np,
226                               struct device_node *codec,
227                               struct link_info *li,
228                               bool is_top)
229 {
230         struct device *dev = simple_priv_to_dev(priv);
231         struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
232         struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
233         struct asoc_simple_dai *cpu_dai = dai_props->cpu_dai;
234         struct asoc_simple_dai *codec_dai = dai_props->codec_dai;
235         struct device_node *top = dev->of_node;
236         struct device_node *cpu = NULL;
237         struct device_node *node = NULL;
238         struct device_node *plat = NULL;
239         char prop[128];
240         char *prefix = "";
241         int ret, single_cpu = 0;
242
243         cpu  = np;
244         node = of_get_parent(np);
245         li->link++;
246
247         dev_dbg(dev, "link_of (%pOF)\n", node);
248
249         /* For single DAI link & old style of DT node */
250         if (is_top)
251                 prefix = PREFIX;
252
253         snprintf(prop, sizeof(prop), "%splat", prefix);
254         plat = of_get_child_by_name(node, prop);
255
256         ret = asoc_simple_parse_daifmt(dev, node, codec,
257                                        prefix, &dai_link->dai_fmt);
258         if (ret < 0)
259                 goto dai_link_of_err;
260
261         simple_parse_mclk_fs(top, cpu, codec, dai_props, prefix);
262
263         ret = asoc_simple_parse_cpu(cpu, dai_link, &single_cpu);
264         if (ret < 0)
265                 goto dai_link_of_err;
266
267         ret = asoc_simple_parse_codec(codec, dai_link);
268         if (ret < 0)
269                 goto dai_link_of_err;
270
271         ret = asoc_simple_parse_platform(plat, dai_link);
272         if (ret < 0)
273                 goto dai_link_of_err;
274
275         ret = asoc_simple_parse_tdm(cpu, cpu_dai);
276         if (ret < 0)
277                 goto dai_link_of_err;
278
279         ret = asoc_simple_parse_tdm(codec, codec_dai);
280         if (ret < 0)
281                 goto dai_link_of_err;
282
283         ret = asoc_simple_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
284         if (ret < 0)
285                 goto dai_link_of_err;
286
287         ret = asoc_simple_parse_clk_codec(dev, codec, dai_link, codec_dai);
288         if (ret < 0)
289                 goto dai_link_of_err;
290
291         ret = asoc_simple_set_dailink_name(dev, dai_link,
292                                            "%s-%s",
293                                            dai_link->cpus->dai_name,
294                                            dai_link->codecs->dai_name);
295         if (ret < 0)
296                 goto dai_link_of_err;
297
298         dai_link->ops = &simple_ops;
299         dai_link->init = asoc_simple_dai_init;
300
301         asoc_simple_canonicalize_cpu(dai_link, single_cpu);
302         asoc_simple_canonicalize_platform(dai_link);
303
304 dai_link_of_err:
305         of_node_put(plat);
306         of_node_put(node);
307
308         return ret;
309 }
310
311 static int __simple_for_each_link(struct asoc_simple_priv *priv,
312                         struct link_info *li,
313                         int (*func_noml)(struct asoc_simple_priv *priv,
314                                          struct device_node *np,
315                                          struct device_node *codec,
316                                          struct link_info *li, bool is_top),
317                         int (*func_dpcm)(struct asoc_simple_priv *priv,
318                                          struct device_node *np,
319                                          struct device_node *codec,
320                                          struct link_info *li, bool is_top))
321 {
322         struct device *dev = simple_priv_to_dev(priv);
323         struct device_node *top = dev->of_node;
324         struct device_node *node;
325         uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
326         bool is_top = 0;
327         int ret = 0;
328
329         /* Check if it has dai-link */
330         node = of_get_child_by_name(top, PREFIX "dai-link");
331         if (!node) {
332                 node = of_node_get(top);
333                 is_top = 1;
334         }
335
336         /* loop for all dai-link */
337         do {
338                 struct asoc_simple_data adata;
339                 struct device_node *codec;
340                 struct device_node *plat;
341                 struct device_node *np;
342                 int num = of_get_child_count(node);
343
344                 /* get codec */
345                 codec = of_get_child_by_name(node, is_top ?
346                                              PREFIX "codec" : "codec");
347                 if (!codec) {
348                         ret = -ENODEV;
349                         goto error;
350                 }
351                 /* get platform */
352                 plat = of_get_child_by_name(node, is_top ?
353                                             PREFIX "plat" : "plat");
354
355                 /* get convert-xxx property */
356                 memset(&adata, 0, sizeof(adata));
357                 for_each_child_of_node(node, np)
358                         simple_parse_convert(dev, np, &adata);
359
360                 /* loop for all CPU/Codec node */
361                 for_each_child_of_node(node, np) {
362                         if (plat == np)
363                                 continue;
364                         /*
365                          * It is DPCM
366                          * if it has many CPUs,
367                          * or has convert-xxx property
368                          */
369                         if (dpcm_selectable &&
370                             (num > 2 ||
371                              adata.convert_rate || adata.convert_channels)) {
372                                 /*
373                                  * np
374                                  *       |1(CPU)|0(Codec)  li->cpu
375                                  * CPU   |Pass  |return
376                                  * Codec |return|Pass
377                                  */
378                                 if (li->cpu != (np == codec))
379                                         ret = func_dpcm(priv, np, codec, li, is_top);
380                         /* else normal sound */
381                         } else {
382                                 /*
383                                  * np
384                                  *       |1(CPU)|0(Codec)  li->cpu
385                                  * CPU   |Pass  |return
386                                  * Codec |return|return
387                                  */
388                                 if (li->cpu && (np != codec))
389                                         ret = func_noml(priv, np, codec, li, is_top);
390                         }
391
392                         if (ret < 0) {
393                                 of_node_put(codec);
394                                 of_node_put(np);
395                                 goto error;
396                         }
397                 }
398
399                 of_node_put(codec);
400                 node = of_get_next_child(top, node);
401         } while (!is_top && node);
402
403  error:
404         of_node_put(node);
405         return ret;
406 }
407
408 static int simple_for_each_link(struct asoc_simple_priv *priv,
409                                 struct link_info *li,
410                                 int (*func_noml)(struct asoc_simple_priv *priv,
411                                                  struct device_node *np,
412                                                  struct device_node *codec,
413                                                  struct link_info *li, bool is_top),
414                                 int (*func_dpcm)(struct asoc_simple_priv *priv,
415                                                  struct device_node *np,
416                                                  struct device_node *codec,
417                                                  struct link_info *li, bool is_top))
418 {
419         int ret;
420         /*
421          * Detect all CPU first, and Detect all Codec 2nd.
422          *
423          * In Normal sound case, all DAIs are detected
424          * as "CPU-Codec".
425          *
426          * In DPCM sound case,
427          * all CPUs   are detected as "CPU-dummy", and
428          * all Codecs are detected as "dummy-Codec".
429          * To avoid random sub-device numbering,
430          * detect "dummy-Codec" in last;
431          */
432         for (li->cpu = 1; li->cpu >= 0; li->cpu--) {
433                 ret = __simple_for_each_link(priv, li, func_noml, func_dpcm);
434                 if (ret < 0)
435                         break;
436         }
437
438         return ret;
439 }
440
441 static int simple_parse_of(struct asoc_simple_priv *priv)
442 {
443         struct device *dev = simple_priv_to_dev(priv);
444         struct device_node *top = dev->of_node;
445         struct snd_soc_card *card = simple_priv_to_card(priv);
446         struct link_info li;
447         int ret;
448
449         if (!top)
450                 return -EINVAL;
451
452         ret = asoc_simple_parse_widgets(card, PREFIX);
453         if (ret < 0)
454                 return ret;
455
456         ret = asoc_simple_parse_routing(card, PREFIX);
457         if (ret < 0)
458                 return ret;
459
460         ret = asoc_simple_parse_pin_switches(card, PREFIX);
461         if (ret < 0)
462                 return ret;
463
464         /* Single/Muti DAI link(s) & New style of DT node */
465         memset(&li, 0, sizeof(li));
466         ret = simple_for_each_link(priv, &li,
467                                    simple_dai_link_of,
468                                    simple_dai_link_of_dpcm);
469         if (ret < 0)
470                 return ret;
471
472         ret = asoc_simple_parse_card_name(card, PREFIX);
473         if (ret < 0)
474                 return ret;
475
476         ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs");
477
478         return ret;
479 }
480
481 static int simple_count_noml(struct asoc_simple_priv *priv,
482                              struct device_node *np,
483                              struct device_node *codec,
484                              struct link_info *li, bool is_top)
485 {
486         if (li->link >= SNDRV_MINOR_DEVICES) {
487                 struct device *dev = simple_priv_to_dev(priv);
488
489                 dev_err(dev, "too many links\n");
490                 return -EINVAL;
491         }
492
493         li->num[li->link].cpus          = 1;
494         li->num[li->link].codecs        = 1;
495         li->num[li->link].platforms     = 1;
496
497         li->link += 1;
498         li->dais += 2;
499
500         return 0;
501 }
502
503 static int simple_count_dpcm(struct asoc_simple_priv *priv,
504                              struct device_node *np,
505                              struct device_node *codec,
506                              struct link_info *li, bool is_top)
507 {
508         if (li->link >= SNDRV_MINOR_DEVICES) {
509                 struct device *dev = simple_priv_to_dev(priv);
510
511                 dev_err(dev, "too many links\n");
512                 return -EINVAL;
513         }
514
515         if (li->cpu) {
516                 li->num[li->link].cpus          = 1;
517                 li->num[li->link].platforms     = 1;
518
519                 li->link++; /* CPU-dummy */
520                 li->dais++;
521         } else {
522                 li->num[li->link].codecs        = 1;
523
524                 li->link++; /* dummy-Codec */
525                 li->dais++;
526                 li->conf++;
527         }
528
529         return 0;
530 }
531
532 static void simple_get_dais_count(struct asoc_simple_priv *priv,
533                                   struct link_info *li)
534 {
535         struct device *dev = simple_priv_to_dev(priv);
536         struct device_node *top = dev->of_node;
537
538         /*
539          * link_num :   number of links.
540          *              CPU-Codec / CPU-dummy / dummy-Codec
541          * dais_num :   number of DAIs
542          * ccnf_num :   number of codec_conf
543          *              same number for "dummy-Codec"
544          *
545          * ex1)
546          * CPU0 --- Codec0      link : 5
547          * CPU1 --- Codec1      dais : 7
548          * CPU2 -/              ccnf : 1
549          * CPU3 --- Codec2
550          *
551          *      => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec
552          *      => 7 DAIs  = 4xCPU + 3xCodec
553          *      => 1 ccnf  = 1xdummy-Codec
554          *
555          * ex2)
556          * CPU0 --- Codec0      link : 5
557          * CPU1 --- Codec1      dais : 6
558          * CPU2 -/              ccnf : 1
559          * CPU3 -/
560          *
561          *      => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec
562          *      => 6 DAIs  = 4xCPU + 2xCodec
563          *      => 1 ccnf  = 1xdummy-Codec
564          *
565          * ex3)
566          * CPU0 --- Codec0      link : 6
567          * CPU1 -/              dais : 6
568          * CPU2 --- Codec1      ccnf : 2
569          * CPU3 -/
570          *
571          *      => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec
572          *      => 6 DAIs  = 4xCPU + 2xCodec
573          *      => 2 ccnf  = 2xdummy-Codec
574          *
575          * ex4)
576          * CPU0 --- Codec0 (convert-rate)       link : 3
577          * CPU1 --- Codec1                      dais : 4
578          *                                      ccnf : 1
579          *
580          *      => 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec
581          *      => 4 DAIs  = 2xCPU + 2xCodec
582          *      => 1 ccnf  = 1xdummy-Codec
583          */
584         if (!top) {
585                 li->num[0].cpus         = 1;
586                 li->num[0].codecs       = 1;
587                 li->num[0].platforms    = 1;
588
589                 li->link = 1;
590                 li->dais = 2;
591                 li->conf = 0;
592                 return;
593         }
594
595         simple_for_each_link(priv, li,
596                              simple_count_noml,
597                              simple_count_dpcm);
598
599         dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
600                 li->link, li->dais, li->conf);
601 }
602
603 static int simple_soc_probe(struct snd_soc_card *card)
604 {
605         struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
606         int ret;
607
608         ret = asoc_simple_init_hp(card, &priv->hp_jack, PREFIX);
609         if (ret < 0)
610                 return ret;
611
612         ret = asoc_simple_init_mic(card, &priv->mic_jack, PREFIX);
613         if (ret < 0)
614                 return ret;
615
616         return 0;
617 }
618
619 static int asoc_simple_probe(struct platform_device *pdev)
620 {
621         struct asoc_simple_priv *priv;
622         struct device *dev = &pdev->dev;
623         struct device_node *np = dev->of_node;
624         struct snd_soc_card *card;
625         struct link_info li;
626         int ret;
627
628         /* Allocate the private data and the DAI link array */
629         priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
630         if (!priv)
631                 return -ENOMEM;
632
633         card = simple_priv_to_card(priv);
634         card->owner             = THIS_MODULE;
635         card->dev               = dev;
636         card->probe             = simple_soc_probe;
637
638         memset(&li, 0, sizeof(li));
639         simple_get_dais_count(priv, &li);
640         if (!li.link || !li.dais)
641                 return -EINVAL;
642
643         ret = asoc_simple_init_priv(priv, &li);
644         if (ret < 0)
645                 return ret;
646
647         if (np && of_device_is_available(np)) {
648
649                 ret = simple_parse_of(priv);
650                 if (ret < 0) {
651                         if (ret != -EPROBE_DEFER)
652                                 dev_err(dev, "parse error %d\n", ret);
653                         goto err;
654                 }
655
656         } else {
657                 struct asoc_simple_card_info *cinfo;
658                 struct snd_soc_dai_link_component *cpus;
659                 struct snd_soc_dai_link_component *codecs;
660                 struct snd_soc_dai_link_component *platform;
661                 struct snd_soc_dai_link *dai_link = priv->dai_link;
662                 struct simple_dai_props *dai_props = priv->dai_props;
663
664                 cinfo = dev->platform_data;
665                 if (!cinfo) {
666                         dev_err(dev, "no info for asoc-simple-card\n");
667                         return -EINVAL;
668                 }
669
670                 if (!cinfo->name ||
671                     !cinfo->codec_dai.name ||
672                     !cinfo->codec ||
673                     !cinfo->platform ||
674                     !cinfo->cpu_dai.name) {
675                         dev_err(dev, "insufficient asoc_simple_card_info settings\n");
676                         return -EINVAL;
677                 }
678
679                 cpus                    = dai_link->cpus;
680                 cpus->dai_name          = cinfo->cpu_dai.name;
681
682                 codecs                  = dai_link->codecs;
683                 codecs->name            = cinfo->codec;
684                 codecs->dai_name        = cinfo->codec_dai.name;
685
686                 platform                = dai_link->platforms;
687                 platform->name          = cinfo->platform;
688
689                 card->name              = (cinfo->card) ? cinfo->card : cinfo->name;
690                 dai_link->name          = cinfo->name;
691                 dai_link->stream_name   = cinfo->name;
692                 dai_link->dai_fmt       = cinfo->daifmt;
693                 dai_link->init          = asoc_simple_dai_init;
694                 memcpy(dai_props->cpu_dai, &cinfo->cpu_dai,
695                                         sizeof(*dai_props->cpu_dai));
696                 memcpy(dai_props->codec_dai, &cinfo->codec_dai,
697                                         sizeof(*dai_props->codec_dai));
698         }
699
700         snd_soc_card_set_drvdata(card, priv);
701
702         asoc_simple_debug_info(priv);
703
704         ret = devm_snd_soc_register_card(dev, card);
705         if (ret < 0)
706                 goto err;
707
708         return 0;
709 err:
710         asoc_simple_clean_reference(card);
711
712         return ret;
713 }
714
715 static int asoc_simple_remove(struct platform_device *pdev)
716 {
717         struct snd_soc_card *card = platform_get_drvdata(pdev);
718
719         return asoc_simple_clean_reference(card);
720 }
721
722 static const struct of_device_id simple_of_match[] = {
723         { .compatible = "simple-audio-card", },
724         { .compatible = "simple-scu-audio-card",
725           .data = (void *)DPCM_SELECTABLE },
726         {},
727 };
728 MODULE_DEVICE_TABLE(of, simple_of_match);
729
730 static struct platform_driver asoc_simple_card = {
731         .driver = {
732                 .name = "asoc-simple-card",
733                 .pm = &snd_soc_pm_ops,
734                 .of_match_table = simple_of_match,
735         },
736         .probe = asoc_simple_probe,
737         .remove = asoc_simple_remove,
738 };
739
740 module_platform_driver(asoc_simple_card);
741
742 MODULE_ALIAS("platform:asoc-simple-card");
743 MODULE_LICENSE("GPL v2");
744 MODULE_DESCRIPTION("ASoC Simple Sound Card");
745 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");