ASoC: rsnd: add CTU (Channel Transfer Unit) prototype support
[deliverable/linux.git] / sound / soc / sh / rcar / core.c
CommitLineData
1536a968
KM
1/*
2 * Renesas R-Car SRU/SCU/SSIU/SSI support
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * Based on fsi.c
8 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15/*
16 * Renesas R-Car sound device structure
17 *
18 * Gen1
19 *
20 * SRU : Sound Routing Unit
21 * - SRC : Sampling Rate Converter
22 * - CMD
23 * - CTU : Channel Count Conversion Unit
24 * - MIX : Mixer
25 * - DVC : Digital Volume and Mute Function
26 * - SSI : Serial Sound Interface
27 *
28 * Gen2
29 *
30 * SCU : Sampling Rate Converter Unit
31 * - SRC : Sampling Rate Converter
32 * - CMD
33 * - CTU : Channel Count Conversion Unit
34 * - MIX : Mixer
35 * - DVC : Digital Volume and Mute Function
36 * SSIU : Serial Sound Interface Unit
37 * - SSI : Serial Sound Interface
38 */
39
40/*
41 * driver data Image
42 *
43 * rsnd_priv
44 * |
45 * | ** this depends on Gen1/Gen2
46 * |
47 * +- gen
48 * |
49 * | ** these depend on data path
50 * | ** gen and platform data control it
51 * |
52 * +- rdai[0]
53 * | | sru ssiu ssi
54 * | +- playback -> [mod] -> [mod] -> [mod] -> ...
55 * | |
56 * | | sru ssiu ssi
57 * | +- capture -> [mod] -> [mod] -> [mod] -> ...
58 * |
59 * +- rdai[1]
60 * | | sru ssiu ssi
61 * | +- playback -> [mod] -> [mod] -> [mod] -> ...
62 * | |
63 * | | sru ssiu ssi
64 * | +- capture -> [mod] -> [mod] -> [mod] -> ...
65 * ...
66 * |
67 * | ** these control ssi
68 * |
69 * +- ssi
70 * | |
71 * | +- ssi[0]
72 * | +- ssi[1]
73 * | +- ssi[2]
74 * | ...
75 * |
ba9c949f 76 * | ** these control src
1536a968 77 * |
ba9c949f 78 * +- src
1536a968 79 * |
ba9c949f
KM
80 * +- src[0]
81 * +- src[1]
82 * +- src[2]
1536a968
KM
83 * ...
84 *
85 *
86 * for_each_rsnd_dai(xx, priv, xx)
87 * rdai[0] => rdai[1] => rdai[2] => ...
88 *
89 * for_each_rsnd_mod(xx, rdai, xx)
90 * [mod] => [mod] => [mod] => ...
91 *
92 * rsnd_dai_call(xxx, fn )
93 * [mod]->fn() -> [mod]->fn() -> [mod]->fn()...
94 *
95 */
96#include <linux/pm_runtime.h>
97#include "rsnd.h"
98
99#define RSND_RATES SNDRV_PCM_RATE_8000_96000
100#define RSND_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
101
969b8619 102static const struct rsnd_of_data rsnd_of_data_gen1 = {
90e8e50f
KM
103 .flags = RSND_GEN1,
104};
105
969b8619 106static const struct rsnd_of_data rsnd_of_data_gen2 = {
90e8e50f
KM
107 .flags = RSND_GEN2,
108};
109
33187fb4 110static const struct of_device_id rsnd_of_match[] = {
90e8e50f
KM
111 { .compatible = "renesas,rcar_sound-gen1", .data = &rsnd_of_data_gen1 },
112 { .compatible = "renesas,rcar_sound-gen2", .data = &rsnd_of_data_gen2 },
113 {},
114};
115MODULE_DEVICE_TABLE(of, rsnd_of_match);
116
1536a968
KM
117/*
118 * rsnd_platform functions
119 */
120#define rsnd_platform_call(priv, dai, func, param...) \
740ad6c3 121 (!(priv->info->func) ? 0 : \
1536a968
KM
122 priv->info->func(param))
123
389933d9
KM
124#define rsnd_is_enable_path(io, name) \
125 ((io)->info ? (io)->info->name : NULL)
126#define rsnd_info_id(priv, io, name) \
127 ((io)->info->name - priv->info->name##_info)
128
cdaa3cdf
KM
129/*
130 * rsnd_mod functions
131 */
132char *rsnd_mod_name(struct rsnd_mod *mod)
133{
134 if (!mod || !mod->ops)
135 return "unknown";
136
137 return mod->ops->name;
138}
139
9b99e9a7
KM
140struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
141 struct rsnd_mod *mod)
d9288d0b 142{
72adc61f
KM
143 if (!mod || !mod->ops || !mod->ops->dma_req)
144 return NULL;
d9288d0b 145
9b99e9a7 146 return mod->ops->dma_req(io, mod);
d9288d0b
KM
147}
148
2099bc8e
KM
149int rsnd_mod_init(struct rsnd_priv *priv,
150 struct rsnd_mod *mod,
cdaa3cdf 151 struct rsnd_mod_ops *ops,
85642952 152 struct clk *clk,
a126021d 153 enum rsnd_mod_type type,
cdaa3cdf
KM
154 int id)
155{
2f78dd7f
KM
156 int ret = clk_prepare(clk);
157
158 if (ret)
159 return ret;
160
cdaa3cdf
KM
161 mod->id = id;
162 mod->ops = ops;
a126021d 163 mod->type = type;
85642952 164 mod->clk = clk;
2099bc8e 165 mod->priv = priv;
2f78dd7f
KM
166
167 return ret;
168}
169
170void rsnd_mod_quit(struct rsnd_mod *mod)
171{
172 if (mod->clk)
173 clk_unprepare(mod->clk);
cdaa3cdf
KM
174}
175
f501b7a4
KM
176void rsnd_mod_interrupt(struct rsnd_mod *mod,
177 void (*callback)(struct rsnd_mod *mod,
178 struct rsnd_dai_stream *io))
179{
180 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
181 struct rsnd_dai_stream *io;
182 struct rsnd_dai *rdai;
183 int i, j;
184
185 for_each_rsnd_dai(rdai, priv, j) {
186
187 for (i = 0; i < RSND_MOD_MAX; i++) {
188 io = &rdai->playback;
189 if (mod == io->mod[i])
190 callback(mod, io);
191
192 io = &rdai->capture;
193 if (mod == io->mod[i])
194 callback(mod, io);
195 }
196 }
197}
198
d5bbe7de 199int rsnd_io_is_working(struct rsnd_dai_stream *io)
02299d98 200{
02299d98
KM
201 /* see rsnd_dai_stream_init/quit() */
202 return !!io->substream;
203}
204
d7bdbc5d 205/*
3023b384 206 * ADINR function
d7bdbc5d 207 */
3023b384 208u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
d7bdbc5d
KM
209{
210 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
d7bdbc5d
KM
211 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
212 struct device *dev = rsnd_priv_to_dev(priv);
213 u32 adinr = runtime->channels;
214
215 switch (runtime->sample_bits) {
216 case 16:
217 adinr |= (8 << 16);
218 break;
219 case 32:
220 adinr |= (0 << 16);
221 break;
222 default:
223 dev_warn(dev, "not supported sample bits\n");
224 return 0;
225 }
226
227 return adinr;
228}
229
bfe1360d
KM
230u32 rsnd_get_adinr_chan(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
231{
232 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
233 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
234 struct device *dev = rsnd_priv_to_dev(priv);
235 u32 chan = runtime->channels;
236
237 switch (chan) {
238 case 1:
239 case 2:
240 case 4:
241 case 6:
242 case 8:
243 break;
244 default:
245 dev_warn(dev, "not supported channel\n");
246 chan = 0;
247 break;
248 }
249
250 return chan;
251}
4689032b
KM
252
253/*
254 * DALIGN function
255 */
256u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
257{
258 struct rsnd_mod *src = rsnd_io_to_mod_src(io);
259 struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
260 struct rsnd_mod *target = src ? src : ssi;
261 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
262 u32 val = 0x76543210;
263 u32 mask = ~0;
264
265 mask <<= runtime->channels * 4;
266 val = val & mask;
267
268 switch (runtime->sample_bits) {
269 case 16:
270 val |= 0x67452301 & ~mask;
271 break;
272 case 32:
273 val |= 0x76543210 & ~mask;
274 break;
275 }
276
277 /*
278 * exchange channeles on SRC if possible,
279 * otherwise, R/L volume settings on DVC
280 * changes inverted channels
281 */
282 if (mod == target)
283 return val;
284 else
285 return 0x76543210;
286}
287
1536a968
KM
288/*
289 * rsnd_dai functions
290 */
2c0fac19 291#define __rsnd_mod_call(mod, io, func, param...) \
d870a91e
KM
292({ \
293 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \
294 struct device *dev = rsnd_priv_to_dev(priv); \
5451ea44
KM
295 u32 mask = 0xF << __rsnd_mod_shift_##func; \
296 u8 val = (mod->status >> __rsnd_mod_shift_##func) & 0xF; \
297 u8 add = ((val + __rsnd_mod_add_##func) & 0xF); \
417f9642 298 int ret = 0; \
5451ea44
KM
299 int called = 0; \
300 if (val == __rsnd_mod_call_##func) { \
301 called = 1; \
2c0fac19 302 ret = (mod)->ops->func(mod, io, param); \
417f9642 303 } \
a48e3f97
KM
304 mod->status = (mod->status & ~mask) + \
305 (add << __rsnd_mod_shift_##func); \
5451ea44
KM
306 dev_dbg(dev, "%s[%d] 0x%08x %s\n", \
307 rsnd_mod_name(mod), rsnd_mod_id(mod), mod->status, \
308 called ? #func : ""); \
417f9642 309 ret; \
d870a91e
KM
310})
311
2c0fac19 312#define rsnd_mod_call(mod, io, func, param...) \
d870a91e
KM
313 (!(mod) ? -ENODEV : \
314 !((mod)->ops->func) ? 0 : \
2c0fac19 315 __rsnd_mod_call(mod, io, func, param))
d870a91e 316
690602fc 317#define rsnd_dai_call(fn, io, param...) \
d870a91e 318({ \
a126021d
KM
319 struct rsnd_mod *mod; \
320 int ret = 0, i; \
321 for (i = 0; i < RSND_MOD_MAX; i++) { \
322 mod = (io)->mod[i]; \
323 if (!mod) \
324 continue; \
2c0fac19 325 ret = rsnd_mod_call(mod, io, fn, param); \
d870a91e
KM
326 if (ret < 0) \
327 break; \
328 } \
329 ret; \
cdaa3cdf
KM
330})
331
a126021d 332static int rsnd_dai_connect(struct rsnd_mod *mod,
9bfed6cf 333 struct rsnd_dai_stream *io)
cdaa3cdf 334{
84e95355
KM
335 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
336 struct device *dev = rsnd_priv_to_dev(priv);
337
6020779b 338 if (!mod)
cdaa3cdf 339 return -EIO;
cdaa3cdf 340
a126021d 341 io->mod[mod->type] = mod;
cdaa3cdf 342
84e95355
KM
343 dev_dbg(dev, "%s[%d] is connected to io (%s)\n",
344 rsnd_mod_name(mod), rsnd_mod_id(mod),
345 rsnd_io_is_play(io) ? "Playback" : "Capture");
346
cdaa3cdf
KM
347 return 0;
348}
349
d3a76823
KM
350static void rsnd_dai_disconnect(struct rsnd_mod *mod,
351 struct rsnd_dai_stream *io)
352{
d3a76823
KM
353 io->mod[mod->type] = NULL;
354}
355
710d0889 356struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id)
1536a968 357{
ecba9e72 358 if ((id < 0) || (id >= rsnd_rdai_nr(priv)))
2192f81c
KM
359 return NULL;
360
1536a968
KM
361 return priv->rdai + id;
362}
363
eb2535f5 364#define rsnd_dai_to_priv(dai) snd_soc_dai_get_drvdata(dai)
1536a968
KM
365static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai)
366{
eb2535f5 367 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
1536a968 368
710d0889 369 return rsnd_rdai_get(priv, dai->id);
1536a968
KM
370}
371
1536a968
KM
372/*
373 * rsnd_soc_dai functions
374 */
375int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional)
376{
377 struct snd_pcm_substream *substream = io->substream;
378 struct snd_pcm_runtime *runtime = substream->runtime;
379 int pos = io->byte_pos + additional;
380
381 pos %= (runtime->periods * io->byte_per_period);
382
383 return pos;
384}
385
75defee0 386bool rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte)
1536a968
KM
387{
388 io->byte_pos += byte;
389
390 if (io->byte_pos >= io->next_period_byte) {
391 struct snd_pcm_substream *substream = io->substream;
392 struct snd_pcm_runtime *runtime = substream->runtime;
393
394 io->period_pos++;
395 io->next_period_byte += io->byte_per_period;
396
397 if (io->period_pos >= runtime->periods) {
398 io->byte_pos = 0;
399 io->period_pos = 0;
400 io->next_period_byte = io->byte_per_period;
401 }
402
75defee0 403 return true;
1536a968 404 }
75defee0
KM
405
406 return false;
407}
408
409void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io)
410{
411 struct snd_pcm_substream *substream = io->substream;
412
413 /*
414 * this function should be called...
415 *
416 * - if rsnd_dai_pointer_update() returns true
417 * - without spin lock
418 */
419
420 snd_pcm_period_elapsed(substream);
1536a968
KM
421}
422
5626ad08 423static void rsnd_dai_stream_init(struct rsnd_dai_stream *io,
1536a968
KM
424 struct snd_pcm_substream *substream)
425{
426 struct snd_pcm_runtime *runtime = substream->runtime;
427
1536a968
KM
428 io->substream = substream;
429 io->byte_pos = 0;
430 io->period_pos = 0;
431 io->byte_per_period = runtime->period_size *
432 runtime->channels *
433 samples_to_bytes(runtime, 1);
434 io->next_period_byte = io->byte_per_period;
5626ad08 435}
1536a968 436
5626ad08
KM
437static void rsnd_dai_stream_quit(struct rsnd_dai_stream *io)
438{
439 io->substream = NULL;
1536a968
KM
440}
441
442static
443struct snd_soc_dai *rsnd_substream_to_dai(struct snd_pcm_substream *substream)
444{
445 struct snd_soc_pcm_runtime *rtd = substream->private_data;
446
447 return rtd->cpu_dai;
448}
449
450static
451struct rsnd_dai_stream *rsnd_rdai_to_io(struct rsnd_dai *rdai,
452 struct snd_pcm_substream *substream)
453{
454 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
455 return &rdai->playback;
456 else
457 return &rdai->capture;
458}
459
460static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
461 struct snd_soc_dai *dai)
462{
eb2535f5 463 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
1536a968
KM
464 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
465 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
29e69fd2 466 int ssi_id = rsnd_mod_id(rsnd_io_to_mod_ssi(io));
1536a968
KM
467 int ret;
468 unsigned long flags;
469
02299d98 470 spin_lock_irqsave(&priv->lock, flags);
1536a968
KM
471
472 switch (cmd) {
473 case SNDRV_PCM_TRIGGER_START:
5626ad08 474 rsnd_dai_stream_init(io, substream);
1536a968
KM
475
476 ret = rsnd_platform_call(priv, dai, start, ssi_id);
477 if (ret < 0)
478 goto dai_trigger_end;
479
690602fc 480 ret = rsnd_dai_call(init, io, priv);
cdaa3cdf
KM
481 if (ret < 0)
482 goto dai_trigger_end;
483
690602fc 484 ret = rsnd_dai_call(start, io, priv);
cdaa3cdf
KM
485 if (ret < 0)
486 goto dai_trigger_end;
1536a968
KM
487 break;
488 case SNDRV_PCM_TRIGGER_STOP:
690602fc 489 ret = rsnd_dai_call(stop, io, priv);
cdaa3cdf
KM
490 if (ret < 0)
491 goto dai_trigger_end;
492
690602fc 493 ret = rsnd_dai_call(quit, io, priv);
cdaa3cdf
KM
494 if (ret < 0)
495 goto dai_trigger_end;
496
3337744a
KM
497 ret = rsnd_platform_call(priv, dai, stop, ssi_id);
498 if (ret < 0)
499 goto dai_trigger_end;
5626ad08
KM
500
501 rsnd_dai_stream_quit(io);
1536a968
KM
502 break;
503 default:
504 ret = -EINVAL;
505 }
506
507dai_trigger_end:
02299d98 508 spin_unlock_irqrestore(&priv->lock, flags);
1536a968
KM
509
510 return ret;
511}
512
513static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
514{
515 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
516
517 /* set master/slave audio interface */
518 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
519 case SND_SOC_DAIFMT_CBM_CFM:
e1508289 520 rdai->clk_master = 0;
1536a968
KM
521 break;
522 case SND_SOC_DAIFMT_CBS_CFS:
e1508289 523 rdai->clk_master = 1; /* codec is slave, cpu is master */
1536a968
KM
524 break;
525 default:
526 return -EINVAL;
527 }
528
1536a968
KM
529 /* set format */
530 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
531 case SND_SOC_DAIFMT_I2S:
532 rdai->sys_delay = 0;
533 rdai->data_alignment = 0;
1a7889ca 534 rdai->frm_clk_inv = 0;
1536a968
KM
535 break;
536 case SND_SOC_DAIFMT_LEFT_J:
537 rdai->sys_delay = 1;
538 rdai->data_alignment = 0;
1a7889ca 539 rdai->frm_clk_inv = 1;
1536a968
KM
540 break;
541 case SND_SOC_DAIFMT_RIGHT_J:
542 rdai->sys_delay = 1;
543 rdai->data_alignment = 1;
1a7889ca
KM
544 rdai->frm_clk_inv = 1;
545 break;
546 }
547
548 /* set clock inversion */
549 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
550 case SND_SOC_DAIFMT_NB_IF:
551 rdai->bit_clk_inv = rdai->bit_clk_inv;
552 rdai->frm_clk_inv = !rdai->frm_clk_inv;
553 break;
554 case SND_SOC_DAIFMT_IB_NF:
555 rdai->bit_clk_inv = !rdai->bit_clk_inv;
556 rdai->frm_clk_inv = rdai->frm_clk_inv;
557 break;
558 case SND_SOC_DAIFMT_IB_IF:
559 rdai->bit_clk_inv = !rdai->bit_clk_inv;
560 rdai->frm_clk_inv = !rdai->frm_clk_inv;
561 break;
562 case SND_SOC_DAIFMT_NB_NF:
563 default:
1536a968
KM
564 break;
565 }
566
567 return 0;
568}
569
570static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
571 .trigger = rsnd_soc_dai_trigger,
572 .set_fmt = rsnd_soc_dai_set_fmt,
573};
574
c8cf15f6 575#define rsnd_path_add(priv, io, type) \
739f9502
KM
576({ \
577 struct rsnd_mod *mod; \
578 int ret = 0; \
579 int id = -1; \
580 \
581 if (rsnd_is_enable_path(io, type)) { \
582 id = rsnd_info_id(priv, io, type); \
583 if (id >= 0) { \
584 mod = rsnd_##type##_mod_get(priv, id); \
585 ret = rsnd_dai_connect(mod, io); \
586 } \
587 } \
588 ret; \
589})
590
c8cf15f6 591#define rsnd_path_remove(priv, io, type) \
d3a76823
KM
592{ \
593 struct rsnd_mod *mod; \
594 int id = -1; \
595 \
596 if (rsnd_is_enable_path(io, type)) { \
597 id = rsnd_info_id(priv, io, type); \
598 if (id >= 0) { \
599 mod = rsnd_##type##_mod_get(priv, id); \
600 rsnd_dai_disconnect(mod, io); \
601 } \
602 } \
603}
604
e2c08416
KM
605void rsnd_path_parse(struct rsnd_priv *priv,
606 struct rsnd_dai_stream *io)
607{
608 struct rsnd_mod *src = rsnd_io_to_mod_src(io);
609 struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
610 int src_id = rsnd_mod_id(src);
611 u32 path[] = {
612 [0] = 0x30000,
613 [1] = 0x30001,
614 [2] = 0x40000,
615 [3] = 0x10000,
616 [4] = 0x20000,
617 [5] = 0x40100
618 };
619
620 /* Gen1 is not supported */
621 if (rsnd_is_gen1(priv))
622 return;
623
624 rsnd_mod_write(dvc, CMD_ROUTE_SLCT, path[src_id]);
625}
626
9bfed6cf
KM
627static int rsnd_path_init(struct rsnd_priv *priv,
628 struct rsnd_dai *rdai,
629 struct rsnd_dai_stream *io)
630{
9bfed6cf 631 int ret;
9bfed6cf
KM
632
633 /*
634 * Gen1 is created by SRU/SSI, and this SRU is base module of
635 * Gen2's SCU/SSIU/SSI. (Gen2 SCU/SSIU came from SRU)
636 *
637 * Easy image is..
638 * Gen1 SRU = Gen2 SCU + SSIU + etc
639 *
640 * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
641 * using fixed path.
9bfed6cf 642 */
9bfed6cf 643
78edead4
KM
644 /* SSI */
645 ret = rsnd_path_add(priv, io, ssi);
739f9502
KM
646 if (ret < 0)
647 return ret;
9bfed6cf 648
78edead4
KM
649 /* SRC */
650 ret = rsnd_path_add(priv, io, src);
739f9502
KM
651 if (ret < 0)
652 return ret;
9bfed6cf 653
9269e3c3
KM
654 /* CTU */
655 ret = rsnd_path_add(priv, io, ctu);
656 if (ret < 0)
657 return ret;
658
bff58ea4 659 /* DVC */
c8cf15f6 660 ret = rsnd_path_add(priv, io, dvc);
bff58ea4
KM
661 if (ret < 0)
662 return ret;
9bfed6cf
KM
663
664 return ret;
665}
666
90e8e50f
KM
667static void rsnd_of_parse_dai(struct platform_device *pdev,
668 const struct rsnd_of_data *of_data,
669 struct rsnd_priv *priv)
670{
671 struct device_node *dai_node, *dai_np;
672 struct device_node *ssi_node, *ssi_np;
673 struct device_node *src_node, *src_np;
9269e3c3 674 struct device_node *ctu_node, *ctu_np;
34cb6123 675 struct device_node *dvc_node, *dvc_np;
90e8e50f
KM
676 struct device_node *playback, *capture;
677 struct rsnd_dai_platform_info *dai_info;
678 struct rcar_snd_info *info = rsnd_priv_to_info(priv);
679 struct device *dev = &pdev->dev;
680 int nr, i;
9269e3c3 681 int dai_i, ssi_i, src_i, ctu_i, dvc_i;
90e8e50f
KM
682
683 if (!of_data)
684 return;
685
686 dai_node = of_get_child_by_name(dev->of_node, "rcar_sound,dai");
687 if (!dai_node)
688 return;
689
690 nr = of_get_child_count(dai_node);
691 if (!nr)
692 return;
693
694 dai_info = devm_kzalloc(dev,
695 sizeof(struct rsnd_dai_platform_info) * nr,
696 GFP_KERNEL);
697 if (!dai_info) {
698 dev_err(dev, "dai info allocation error\n");
699 return;
700 }
701
702 info->dai_info_nr = nr;
703 info->dai_info = dai_info;
704
705 ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi");
706 src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
9269e3c3 707 ctu_node = of_get_child_by_name(dev->of_node, "rcar_sound,ctu");
34cb6123 708 dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");
90e8e50f
KM
709
710#define mod_parse(name) \
711if (name##_node) { \
712 struct rsnd_##name##_platform_info *name##_info; \
713 \
714 name##_i = 0; \
715 for_each_child_of_node(name##_node, name##_np) { \
716 name##_info = info->name##_info + name##_i; \
717 \
718 if (name##_np == playback) \
719 dai_info->playback.name = name##_info; \
720 if (name##_np == capture) \
721 dai_info->capture.name = name##_info; \
722 \
723 name##_i++; \
724 } \
725}
726
727 /*
728 * parse all dai
729 */
730 dai_i = 0;
731 for_each_child_of_node(dai_node, dai_np) {
732 dai_info = info->dai_info + dai_i;
733
734 for (i = 0;; i++) {
735
736 playback = of_parse_phandle(dai_np, "playback", i);
737 capture = of_parse_phandle(dai_np, "capture", i);
738
739 if (!playback && !capture)
740 break;
741
742 mod_parse(ssi);
743 mod_parse(src);
9269e3c3 744 mod_parse(ctu);
34cb6123 745 mod_parse(dvc);
90e8e50f 746
a493b6a6
JL
747 of_node_put(playback);
748 of_node_put(capture);
90e8e50f
KM
749 }
750
751 dai_i++;
752 }
753}
754
1536a968 755static int rsnd_dai_probe(struct platform_device *pdev,
90e8e50f 756 const struct rsnd_of_data *of_data,
1536a968
KM
757 struct rsnd_priv *priv)
758{
759 struct snd_soc_dai_driver *drv;
78f13d0c 760 struct rcar_snd_info *info = rsnd_priv_to_info(priv);
1536a968 761 struct rsnd_dai *rdai;
29e69fd2 762 struct rsnd_ssi_platform_info *pmod, *cmod;
1536a968 763 struct device *dev = rsnd_priv_to_dev(priv);
90e8e50f 764 int dai_nr;
4b4dab82
KM
765 int i;
766
90e8e50f
KM
767 rsnd_of_parse_dai(pdev, of_data, priv);
768
90e8e50f 769 dai_nr = info->dai_info_nr;
4b4dab82
KM
770 if (!dai_nr) {
771 dev_err(dev, "no dai\n");
772 return -EIO;
773 }
1536a968
KM
774
775 drv = devm_kzalloc(dev, sizeof(*drv) * dai_nr, GFP_KERNEL);
776 rdai = devm_kzalloc(dev, sizeof(*rdai) * dai_nr, GFP_KERNEL);
777 if (!drv || !rdai) {
778 dev_err(dev, "dai allocate failed\n");
779 return -ENOMEM;
780 }
781
ecba9e72 782 priv->rdai_nr = dai_nr;
49848073
KM
783 priv->daidrv = drv;
784 priv->rdai = rdai;
785
1536a968 786 for (i = 0; i < dai_nr; i++) {
1536a968 787
7c57d76f
KM
788 pmod = info->dai_info[i].playback.ssi;
789 cmod = info->dai_info[i].capture.ssi;
1536a968
KM
790
791 /*
792 * init rsnd_dai
793 */
1536a968 794 snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i);
1b13d118 795 rdai[i].priv = priv;
1536a968
KM
796
797 /*
798 * init snd_soc_dai_driver
799 */
800 drv[i].name = rdai[i].name;
801 drv[i].ops = &rsnd_soc_dai_ops;
4b4dab82 802 if (pmod) {
f8c3c309
KM
803 snprintf(rdai[i].playback.name, RSND_DAI_NAME_SIZE,
804 "DAI%d Playback", i);
805
1536a968
KM
806 drv[i].playback.rates = RSND_RATES;
807 drv[i].playback.formats = RSND_FMTS;
808 drv[i].playback.channels_min = 2;
809 drv[i].playback.channels_max = 2;
f8c3c309 810 drv[i].playback.stream_name = rdai[i].playback.name;
389933d9 811
29e69fd2 812 rdai[i].playback.info = &info->dai_info[i].playback;
54cb5562 813 rdai[i].playback.rdai = rdai + i;
9bfed6cf 814 rsnd_path_init(priv, &rdai[i], &rdai[i].playback);
1536a968 815 }
4b4dab82 816 if (cmod) {
f8c3c309
KM
817 snprintf(rdai[i].capture.name, RSND_DAI_NAME_SIZE,
818 "DAI%d Capture", i);
819
1536a968
KM
820 drv[i].capture.rates = RSND_RATES;
821 drv[i].capture.formats = RSND_FMTS;
822 drv[i].capture.channels_min = 2;
823 drv[i].capture.channels_max = 2;
f8c3c309 824 drv[i].capture.stream_name = rdai[i].capture.name;
389933d9 825
29e69fd2 826 rdai[i].capture.info = &info->dai_info[i].capture;
54cb5562 827 rdai[i].capture.rdai = rdai + i;
9bfed6cf 828 rsnd_path_init(priv, &rdai[i], &rdai[i].capture);
1536a968
KM
829 }
830
4b4dab82
KM
831 dev_dbg(dev, "%s (%s/%s)\n", rdai[i].name,
832 pmod ? "play" : " -- ",
833 cmod ? "capture" : " -- ");
1536a968
KM
834 }
835
1536a968
KM
836 return 0;
837}
838
1536a968
KM
839/*
840 * pcm ops
841 */
842static struct snd_pcm_hardware rsnd_pcm_hardware = {
843 .info = SNDRV_PCM_INFO_INTERLEAVED |
844 SNDRV_PCM_INFO_MMAP |
706c6621 845 SNDRV_PCM_INFO_MMAP_VALID,
1536a968
KM
846 .buffer_bytes_max = 64 * 1024,
847 .period_bytes_min = 32,
848 .period_bytes_max = 8192,
849 .periods_min = 1,
850 .periods_max = 32,
851 .fifo_size = 256,
852};
853
854static int rsnd_pcm_open(struct snd_pcm_substream *substream)
855{
856 struct snd_pcm_runtime *runtime = substream->runtime;
857 int ret = 0;
858
859 snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware);
860
861 ret = snd_pcm_hw_constraint_integer(runtime,
862 SNDRV_PCM_HW_PARAM_PERIODS);
863
864 return ret;
865}
866
867static int rsnd_hw_params(struct snd_pcm_substream *substream,
868 struct snd_pcm_hw_params *hw_params)
869{
3b7843ff
KM
870 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
871 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
872 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
873 int ret;
874
875 ret = rsnd_dai_call(hw_params, io, substream, hw_params);
876 if (ret)
877 return ret;
878
1536a968
KM
879 return snd_pcm_lib_malloc_pages(substream,
880 params_buffer_bytes(hw_params));
881}
882
883static snd_pcm_uframes_t rsnd_pointer(struct snd_pcm_substream *substream)
884{
885 struct snd_pcm_runtime *runtime = substream->runtime;
886 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
887 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
888 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
889
890 return bytes_to_frames(runtime, io->byte_pos);
891}
892
893static struct snd_pcm_ops rsnd_pcm_ops = {
894 .open = rsnd_pcm_open,
895 .ioctl = snd_pcm_lib_ioctl,
896 .hw_params = rsnd_hw_params,
897 .hw_free = snd_pcm_lib_free_pages,
898 .pointer = rsnd_pointer,
899};
900
170a2497
KM
901/*
902 * snd_kcontrol
903 */
904#define kcontrol_to_cfg(kctrl) ((struct rsnd_kctrl_cfg *)kctrl->private_value)
905static int rsnd_kctrl_info(struct snd_kcontrol *kctrl,
906 struct snd_ctl_elem_info *uinfo)
907{
908 struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl);
909
910 if (cfg->texts) {
911 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
912 uinfo->count = cfg->size;
913 uinfo->value.enumerated.items = cfg->max;
914 if (uinfo->value.enumerated.item >= cfg->max)
915 uinfo->value.enumerated.item = cfg->max - 1;
916 strlcpy(uinfo->value.enumerated.name,
917 cfg->texts[uinfo->value.enumerated.item],
918 sizeof(uinfo->value.enumerated.name));
919 } else {
920 uinfo->count = cfg->size;
921 uinfo->value.integer.min = 0;
922 uinfo->value.integer.max = cfg->max;
923 uinfo->type = (cfg->max == 1) ?
924 SNDRV_CTL_ELEM_TYPE_BOOLEAN :
925 SNDRV_CTL_ELEM_TYPE_INTEGER;
926 }
927
928 return 0;
929}
930
931static int rsnd_kctrl_get(struct snd_kcontrol *kctrl,
932 struct snd_ctl_elem_value *uc)
933{
934 struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl);
935 int i;
936
937 for (i = 0; i < cfg->size; i++)
938 if (cfg->texts)
939 uc->value.enumerated.item[i] = cfg->val[i];
940 else
941 uc->value.integer.value[i] = cfg->val[i];
942
943 return 0;
944}
945
946static int rsnd_kctrl_put(struct snd_kcontrol *kctrl,
947 struct snd_ctl_elem_value *uc)
948{
949 struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
950 struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl);
951 int i, change = 0;
952
953 for (i = 0; i < cfg->size; i++) {
954 if (cfg->texts) {
955 change |= (uc->value.enumerated.item[i] != cfg->val[i]);
956 cfg->val[i] = uc->value.enumerated.item[i];
957 } else {
958 change |= (uc->value.integer.value[i] != cfg->val[i]);
959 cfg->val[i] = uc->value.integer.value[i];
960 }
961 }
962
963 if (change)
b65a7ccc 964 cfg->update(cfg->io, mod);
170a2497
KM
965
966 return change;
967}
968
969static int __rsnd_kctrl_new(struct rsnd_mod *mod,
b65a7ccc 970 struct rsnd_dai_stream *io,
170a2497
KM
971 struct snd_soc_pcm_runtime *rtd,
972 const unsigned char *name,
973 struct rsnd_kctrl_cfg *cfg,
b65a7ccc
KM
974 void (*update)(struct rsnd_dai_stream *io,
975 struct rsnd_mod *mod))
170a2497 976{
da620d72 977 struct snd_soc_card *soc_card = rtd->card;
170a2497
KM
978 struct snd_card *card = rtd->card->snd_card;
979 struct snd_kcontrol *kctrl;
980 struct snd_kcontrol_new knew = {
981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
982 .name = name,
983 .info = rsnd_kctrl_info,
da620d72 984 .index = rtd - soc_card->rtd,
170a2497
KM
985 .get = rsnd_kctrl_get,
986 .put = rsnd_kctrl_put,
987 .private_value = (unsigned long)cfg,
988 };
989 int ret;
990
991 kctrl = snd_ctl_new1(&knew, mod);
992 if (!kctrl)
993 return -ENOMEM;
994
995 ret = snd_ctl_add(card, kctrl);
d1f83d6e
KM
996 if (ret < 0) {
997 snd_ctl_free_one(kctrl);
170a2497 998 return ret;
d1f83d6e 999 }
170a2497
KM
1000
1001 cfg->update = update;
d1f83d6e
KM
1002 cfg->card = card;
1003 cfg->kctrl = kctrl;
b65a7ccc 1004 cfg->io = io;
170a2497
KM
1005
1006 return 0;
1007}
1008
d1f83d6e
KM
1009void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg)
1010{
1011 snd_ctl_remove(cfg->card, cfg->kctrl);
1012}
1013
170a2497 1014int rsnd_kctrl_new_m(struct rsnd_mod *mod,
b65a7ccc 1015 struct rsnd_dai_stream *io,
170a2497
KM
1016 struct snd_soc_pcm_runtime *rtd,
1017 const unsigned char *name,
b65a7ccc
KM
1018 void (*update)(struct rsnd_dai_stream *io,
1019 struct rsnd_mod *mod),
170a2497
KM
1020 struct rsnd_kctrl_cfg_m *_cfg,
1021 u32 max)
1022{
1023 _cfg->cfg.max = max;
1024 _cfg->cfg.size = RSND_DVC_CHANNELS;
1025 _cfg->cfg.val = _cfg->val;
b65a7ccc 1026 return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
170a2497
KM
1027}
1028
1029int rsnd_kctrl_new_s(struct rsnd_mod *mod,
b65a7ccc 1030 struct rsnd_dai_stream *io,
170a2497
KM
1031 struct snd_soc_pcm_runtime *rtd,
1032 const unsigned char *name,
b65a7ccc
KM
1033 void (*update)(struct rsnd_dai_stream *io,
1034 struct rsnd_mod *mod),
170a2497
KM
1035 struct rsnd_kctrl_cfg_s *_cfg,
1036 u32 max)
1037{
1038 _cfg->cfg.max = max;
1039 _cfg->cfg.size = 1;
1040 _cfg->cfg.val = &_cfg->val;
b65a7ccc 1041 return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
170a2497
KM
1042}
1043
1044int rsnd_kctrl_new_e(struct rsnd_mod *mod,
b65a7ccc 1045 struct rsnd_dai_stream *io,
170a2497
KM
1046 struct snd_soc_pcm_runtime *rtd,
1047 const unsigned char *name,
1048 struct rsnd_kctrl_cfg_s *_cfg,
b65a7ccc
KM
1049 void (*update)(struct rsnd_dai_stream *io,
1050 struct rsnd_mod *mod),
170a2497
KM
1051 const char * const *texts,
1052 u32 max)
1053{
1054 _cfg->cfg.max = max;
1055 _cfg->cfg.size = 1;
1056 _cfg->cfg.val = &_cfg->val;
1057 _cfg->cfg.texts = texts;
b65a7ccc 1058 return __rsnd_kctrl_new(mod, io, rtd, name, &_cfg->cfg, update);
170a2497
KM
1059}
1060
1536a968
KM
1061/*
1062 * snd_soc_platform
1063 */
1064
1065#define PREALLOC_BUFFER (32 * 1024)
1066#define PREALLOC_BUFFER_MAX (32 * 1024)
1067
1068static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
1069{
7c63f3c0
KM
1070 struct snd_soc_dai *dai = rtd->cpu_dai;
1071 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
ae11a9be 1072 int ret;
bff58ea4 1073
ae11a9be
KM
1074 ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd);
1075 if (ret)
1076 return ret;
bff58ea4 1077
ae11a9be 1078 ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd);
7c63f3c0
KM
1079 if (ret)
1080 return ret;
bff58ea4 1081
1536a968
KM
1082 return snd_pcm_lib_preallocate_pages_for_all(
1083 rtd->pcm,
1084 SNDRV_DMA_TYPE_DEV,
1085 rtd->card->snd_card->dev,
1086 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1087}
1088
1536a968
KM
1089static struct snd_soc_platform_driver rsnd_soc_platform = {
1090 .ops = &rsnd_pcm_ops,
1091 .pcm_new = rsnd_pcm_new,
1536a968
KM
1092};
1093
1094static const struct snd_soc_component_driver rsnd_soc_component = {
1095 .name = "rsnd",
1096};
1097
d3a76823 1098static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv,
f708d944 1099 struct rsnd_dai_stream *io)
d3a76823 1100{
d3a76823
KM
1101 int ret;
1102
690602fc 1103 ret = rsnd_dai_call(probe, io, priv);
d3a76823
KM
1104 if (ret == -EAGAIN) {
1105 /*
1106 * Fallback to PIO mode
1107 */
1108
1109 /*
1110 * call "remove" for SSI/SRC/DVC
1111 * SSI will be switch to PIO mode if it was DMA mode
1112 * see
1113 * rsnd_dma_init()
97463e19 1114 * rsnd_ssi_fallback()
d3a76823 1115 */
690602fc 1116 rsnd_dai_call(remove, io, priv);
d3a76823
KM
1117
1118 /*
1119 * remove SRC/DVC from DAI,
1120 */
c8cf15f6
KM
1121 rsnd_path_remove(priv, io, src);
1122 rsnd_path_remove(priv, io, dvc);
d3a76823 1123
97463e19
KM
1124 /*
1125 * fallback
1126 */
690602fc 1127 rsnd_dai_call(fallback, io, priv);
97463e19 1128
d3a76823
KM
1129 /*
1130 * retry to "probe".
1131 * DAI has SSI which is PIO mode only now.
1132 */
690602fc 1133 ret = rsnd_dai_call(probe, io, priv);
d3a76823
KM
1134 }
1135
1136 return ret;
1137}
1138
1536a968
KM
1139/*
1140 * rsnd probe
1141 */
1142static int rsnd_probe(struct platform_device *pdev)
1143{
1144 struct rcar_snd_info *info;
1145 struct rsnd_priv *priv;
1146 struct device *dev = &pdev->dev;
7681f6ac 1147 struct rsnd_dai *rdai;
90e8e50f
KM
1148 const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev);
1149 const struct rsnd_of_data *of_data;
d1ac970f 1150 int (*probe_func[])(struct platform_device *pdev,
90e8e50f 1151 const struct rsnd_of_data *of_data,
d1ac970f
KM
1152 struct rsnd_priv *priv) = {
1153 rsnd_gen_probe,
288f392e 1154 rsnd_dma_probe,
d1ac970f 1155 rsnd_ssi_probe,
ba9c949f 1156 rsnd_src_probe,
9269e3c3 1157 rsnd_ctu_probe,
bff58ea4 1158 rsnd_dvc_probe,
d1ac970f
KM
1159 rsnd_adg_probe,
1160 rsnd_dai_probe,
1161 };
1162 int ret, i;
1536a968 1163
90e8e50f
KM
1164 info = NULL;
1165 of_data = NULL;
1166 if (of_id) {
1167 info = devm_kzalloc(&pdev->dev,
1168 sizeof(struct rcar_snd_info), GFP_KERNEL);
1169 of_data = of_id->data;
1170 } else {
1171 info = pdev->dev.platform_data;
1172 }
1173
1536a968
KM
1174 if (!info) {
1175 dev_err(dev, "driver needs R-Car sound information\n");
1176 return -ENODEV;
1177 }
1178
1179 /*
1180 * init priv data
1181 */
1182 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
1183 if (!priv) {
1184 dev_err(dev, "priv allocate failed\n");
1185 return -ENODEV;
1186 }
1187
9f464f8e 1188 priv->pdev = pdev;
1536a968
KM
1189 priv->info = info;
1190 spin_lock_init(&priv->lock);
1191
1192 /*
1193 * init each module
1194 */
d1ac970f 1195 for (i = 0; i < ARRAY_SIZE(probe_func); i++) {
90e8e50f 1196 ret = probe_func[i](pdev, of_data, priv);
d1ac970f
KM
1197 if (ret)
1198 return ret;
1199 }
07539c1d 1200
7681f6ac 1201 for_each_rsnd_dai(rdai, priv, i) {
f708d944 1202 ret = rsnd_rdai_continuance_probe(priv, &rdai->playback);
7681f6ac 1203 if (ret)
d62a3dcd 1204 goto exit_snd_probe;
dfc9403b 1205
f708d944 1206 ret = rsnd_rdai_continuance_probe(priv, &rdai->capture);
7681f6ac 1207 if (ret)
d62a3dcd 1208 goto exit_snd_probe;
7681f6ac 1209 }
4b4dab82 1210
0b1f6ec7
KM
1211 dev_set_drvdata(dev, priv);
1212
1536a968
KM
1213 /*
1214 * asoc register
1215 */
1216 ret = snd_soc_register_platform(dev, &rsnd_soc_platform);
1217 if (ret < 0) {
1218 dev_err(dev, "cannot snd soc register\n");
1219 return ret;
1220 }
1221
1222 ret = snd_soc_register_component(dev, &rsnd_soc_component,
ecba9e72 1223 priv->daidrv, rsnd_rdai_nr(priv));
1536a968
KM
1224 if (ret < 0) {
1225 dev_err(dev, "cannot snd dai register\n");
1226 goto exit_snd_soc;
1227 }
1228
1536a968
KM
1229 pm_runtime_enable(dev);
1230
1231 dev_info(dev, "probed\n");
1232 return ret;
1233
1234exit_snd_soc:
1235 snd_soc_unregister_platform(dev);
d62a3dcd
KM
1236exit_snd_probe:
1237 for_each_rsnd_dai(rdai, priv, i) {
690602fc
KM
1238 rsnd_dai_call(remove, &rdai->playback, priv);
1239 rsnd_dai_call(remove, &rdai->capture, priv);
d62a3dcd 1240 }
1536a968
KM
1241
1242 return ret;
1243}
1244
1245static int rsnd_remove(struct platform_device *pdev)
1246{
1247 struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
7681f6ac 1248 struct rsnd_dai *rdai;
2f78dd7f
KM
1249 void (*remove_func[])(struct platform_device *pdev,
1250 struct rsnd_priv *priv) = {
1251 rsnd_ssi_remove,
1252 rsnd_src_remove,
9269e3c3 1253 rsnd_ctu_remove,
2f78dd7f
KM
1254 rsnd_dvc_remove,
1255 };
d62a3dcd 1256 int ret = 0, i;
1536a968
KM
1257
1258 pm_runtime_disable(&pdev->dev);
1259
7681f6ac 1260 for_each_rsnd_dai(rdai, priv, i) {
690602fc
KM
1261 ret |= rsnd_dai_call(remove, &rdai->playback, priv);
1262 ret |= rsnd_dai_call(remove, &rdai->capture, priv);
7681f6ac 1263 }
1536a968 1264
2f78dd7f
KM
1265 for (i = 0; i < ARRAY_SIZE(remove_func); i++)
1266 remove_func[i](pdev, priv);
1267
d7c42ff8
KM
1268 snd_soc_unregister_component(&pdev->dev);
1269 snd_soc_unregister_platform(&pdev->dev);
1270
d62a3dcd 1271 return ret;
1536a968
KM
1272}
1273
1274static struct platform_driver rsnd_driver = {
1275 .driver = {
1276 .name = "rcar_sound",
90e8e50f 1277 .of_match_table = rsnd_of_match,
1536a968
KM
1278 },
1279 .probe = rsnd_probe,
1280 .remove = rsnd_remove,
1281};
1282module_platform_driver(rsnd_driver);
1283
1284MODULE_LICENSE("GPL");
1285MODULE_DESCRIPTION("Renesas R-Car audio driver");
1286MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
1287MODULE_ALIAS("platform:rcar-pcm-audio");
This page took 0.188134 seconds and 5 git commands to generate.