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