11eb0e35b9cee303f115e32424725675dbc51393
[deliverable/linux.git] / sound / soc / sh / rcar / core.c
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 * |
76 * | ** these control scu
77 * |
78 * +- scu
79 * |
80 * +- scu[0]
81 * +- scu[1]
82 * +- scu[2]
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 <linux/shdma-base.h>
98 #include "rsnd.h"
99
100 #define RSND_RATES SNDRV_PCM_RATE_8000_96000
101 #define RSND_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
102
103 /*
104 * rsnd_platform functions
105 */
106 #define rsnd_platform_call(priv, dai, func, param...) \
107 (!(priv->info->func) ? 0 : \
108 priv->info->func(param))
109
110 /*
111 * rsnd_mod functions
112 */
113 char *rsnd_mod_name(struct rsnd_mod *mod)
114 {
115 if (!mod || !mod->ops)
116 return "unknown";
117
118 return mod->ops->name;
119 }
120
121 void rsnd_mod_init(struct rsnd_priv *priv,
122 struct rsnd_mod *mod,
123 struct rsnd_mod_ops *ops,
124 int id)
125 {
126 mod->priv = priv;
127 mod->id = id;
128 mod->ops = ops;
129 INIT_LIST_HEAD(&mod->list);
130 }
131
132 /*
133 * rsnd_dma functions
134 */
135 static void __rsnd_dma_start(struct rsnd_dma *dma);
136 static void rsnd_dma_continue(struct rsnd_dma *dma)
137 {
138 /* push next A or B plane */
139 dma->submit_loop = 1;
140 schedule_work(&dma->work);
141 }
142
143 void rsnd_dma_start(struct rsnd_dma *dma)
144 {
145 /* push both A and B plane*/
146 dma->submit_loop = 2;
147 __rsnd_dma_start(dma);
148 }
149
150 void rsnd_dma_stop(struct rsnd_dma *dma)
151 {
152 dma->submit_loop = 0;
153 cancel_work_sync(&dma->work);
154 dmaengine_terminate_all(dma->chan);
155 }
156
157 static void rsnd_dma_complete(void *data)
158 {
159 struct rsnd_dma *dma = (struct rsnd_dma *)data;
160 struct rsnd_priv *priv = rsnd_mod_to_priv(rsnd_dma_to_mod(dma));
161 unsigned long flags;
162
163 rsnd_lock(priv, flags);
164
165 dma->complete(dma);
166
167 if (dma->submit_loop)
168 rsnd_dma_continue(dma);
169
170 rsnd_unlock(priv, flags);
171 }
172
173 static void __rsnd_dma_start(struct rsnd_dma *dma)
174 {
175 struct rsnd_priv *priv = rsnd_mod_to_priv(rsnd_dma_to_mod(dma));
176 struct device *dev = rsnd_priv_to_dev(priv);
177 struct dma_async_tx_descriptor *desc;
178 dma_addr_t buf;
179 size_t len;
180 int i;
181
182 for (i = 0; i < dma->submit_loop; i++) {
183
184 if (dma->inquiry(dma, &buf, &len) < 0)
185 return;
186
187 desc = dmaengine_prep_slave_single(
188 dma->chan, buf, len, dma->dir,
189 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
190 if (!desc) {
191 dev_err(dev, "dmaengine_prep_slave_sg() fail\n");
192 return;
193 }
194
195 desc->callback = rsnd_dma_complete;
196 desc->callback_param = dma;
197
198 if (dmaengine_submit(desc) < 0) {
199 dev_err(dev, "dmaengine_submit() fail\n");
200 return;
201 }
202
203 dma_async_issue_pending(dma->chan);
204 }
205 }
206
207 static void rsnd_dma_do_work(struct work_struct *work)
208 {
209 struct rsnd_dma *dma = container_of(work, struct rsnd_dma, work);
210
211 __rsnd_dma_start(dma);
212 }
213
214 int rsnd_dma_available(struct rsnd_dma *dma)
215 {
216 return !!dma->chan;
217 }
218
219 int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
220 int is_play, int id,
221 int (*inquiry)(struct rsnd_dma *dma,
222 dma_addr_t *buf, int *len),
223 int (*complete)(struct rsnd_dma *dma))
224 {
225 struct device *dev = rsnd_priv_to_dev(priv);
226 struct dma_slave_config cfg;
227 dma_cap_mask_t mask;
228 int ret;
229
230 if (dma->chan) {
231 dev_err(dev, "it already has dma channel\n");
232 return -EIO;
233 }
234
235 dma_cap_zero(mask);
236 dma_cap_set(DMA_SLAVE, mask);
237
238 dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
239 (void *)id, dev,
240 is_play ? "tx" : "rx");
241 if (!dma->chan) {
242 dev_err(dev, "can't get dma channel\n");
243 return -EIO;
244 }
245
246 cfg.slave_id = id;
247 cfg.dst_addr = 0; /* use default addr when playback */
248 cfg.src_addr = 0; /* use default addr when capture */
249 cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
250
251 ret = dmaengine_slave_config(dma->chan, &cfg);
252 if (ret < 0)
253 goto rsnd_dma_init_err;
254
255 dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
256 dma->inquiry = inquiry;
257 dma->complete = complete;
258 INIT_WORK(&dma->work, rsnd_dma_do_work);
259
260 return 0;
261
262 rsnd_dma_init_err:
263 rsnd_dma_quit(priv, dma);
264
265 return ret;
266 }
267
268 void rsnd_dma_quit(struct rsnd_priv *priv,
269 struct rsnd_dma *dma)
270 {
271 if (dma->chan)
272 dma_release_channel(dma->chan);
273
274 dma->chan = NULL;
275 }
276
277 /*
278 * rsnd_dai functions
279 */
280 #define rsnd_dai_call(rdai, io, fn) \
281 ({ \
282 struct rsnd_mod *mod, *n; \
283 int ret = 0; \
284 for_each_rsnd_mod(mod, n, io) { \
285 ret = rsnd_mod_call(mod, fn, rdai, io); \
286 if (ret < 0) \
287 break; \
288 } \
289 ret; \
290 })
291
292 int rsnd_dai_connect(struct rsnd_dai *rdai,
293 struct rsnd_mod *mod,
294 struct rsnd_dai_stream *io)
295 {
296 if (!mod)
297 return -EIO;
298
299 if (!list_empty(&mod->list)) {
300 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
301 struct device *dev = rsnd_priv_to_dev(priv);
302
303 dev_err(dev, "%s%d is not empty\n",
304 rsnd_mod_name(mod),
305 rsnd_mod_id(mod));
306 return -EIO;
307 }
308
309 list_add_tail(&mod->list, &io->head);
310
311 return 0;
312 }
313
314 int rsnd_dai_disconnect(struct rsnd_mod *mod)
315 {
316 list_del_init(&mod->list);
317
318 return 0;
319 }
320
321 int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai)
322 {
323 int id = rdai - priv->rdai;
324
325 if ((id < 0) || (id >= rsnd_dai_nr(priv)))
326 return -EINVAL;
327
328 return id;
329 }
330
331 struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id)
332 {
333 if ((id < 0) || (id >= rsnd_dai_nr(priv)))
334 return NULL;
335
336 return priv->rdai + id;
337 }
338
339 static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai)
340 {
341 struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai);
342
343 return rsnd_dai_get(priv, dai->id);
344 }
345
346 int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io)
347 {
348 return &rdai->playback == io;
349 }
350
351 /*
352 * rsnd_soc_dai functions
353 */
354 int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional)
355 {
356 struct snd_pcm_substream *substream = io->substream;
357 struct snd_pcm_runtime *runtime = substream->runtime;
358 int pos = io->byte_pos + additional;
359
360 pos %= (runtime->periods * io->byte_per_period);
361
362 return pos;
363 }
364
365 void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte)
366 {
367 io->byte_pos += byte;
368
369 if (io->byte_pos >= io->next_period_byte) {
370 struct snd_pcm_substream *substream = io->substream;
371 struct snd_pcm_runtime *runtime = substream->runtime;
372
373 io->period_pos++;
374 io->next_period_byte += io->byte_per_period;
375
376 if (io->period_pos >= runtime->periods) {
377 io->byte_pos = 0;
378 io->period_pos = 0;
379 io->next_period_byte = io->byte_per_period;
380 }
381
382 snd_pcm_period_elapsed(substream);
383 }
384 }
385
386 static int rsnd_dai_stream_init(struct rsnd_dai_stream *io,
387 struct snd_pcm_substream *substream)
388 {
389 struct snd_pcm_runtime *runtime = substream->runtime;
390
391 if (!list_empty(&io->head))
392 return -EIO;
393
394 INIT_LIST_HEAD(&io->head);
395 io->substream = substream;
396 io->byte_pos = 0;
397 io->period_pos = 0;
398 io->byte_per_period = runtime->period_size *
399 runtime->channels *
400 samples_to_bytes(runtime, 1);
401 io->next_period_byte = io->byte_per_period;
402
403 return 0;
404 }
405
406 static
407 struct snd_soc_dai *rsnd_substream_to_dai(struct snd_pcm_substream *substream)
408 {
409 struct snd_soc_pcm_runtime *rtd = substream->private_data;
410
411 return rtd->cpu_dai;
412 }
413
414 static
415 struct rsnd_dai_stream *rsnd_rdai_to_io(struct rsnd_dai *rdai,
416 struct snd_pcm_substream *substream)
417 {
418 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
419 return &rdai->playback;
420 else
421 return &rdai->capture;
422 }
423
424 static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
425 struct snd_soc_dai *dai)
426 {
427 struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai);
428 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
429 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
430 struct rsnd_mod *mod = rsnd_ssi_mod_get_frm_dai(priv,
431 rsnd_dai_id(priv, rdai),
432 rsnd_dai_is_play(rdai, io));
433 int ssi_id = rsnd_mod_id(mod);
434 int ret;
435 unsigned long flags;
436
437 rsnd_lock(priv, flags);
438
439 switch (cmd) {
440 case SNDRV_PCM_TRIGGER_START:
441 ret = rsnd_dai_stream_init(io, substream);
442 if (ret < 0)
443 goto dai_trigger_end;
444
445 ret = rsnd_platform_call(priv, dai, start, ssi_id);
446 if (ret < 0)
447 goto dai_trigger_end;
448
449 ret = rsnd_gen_path_init(priv, rdai, io);
450 if (ret < 0)
451 goto dai_trigger_end;
452
453 ret = rsnd_dai_call(rdai, io, init);
454 if (ret < 0)
455 goto dai_trigger_end;
456
457 ret = rsnd_dai_call(rdai, io, start);
458 if (ret < 0)
459 goto dai_trigger_end;
460 break;
461 case SNDRV_PCM_TRIGGER_STOP:
462 ret = rsnd_dai_call(rdai, io, stop);
463 if (ret < 0)
464 goto dai_trigger_end;
465
466 ret = rsnd_dai_call(rdai, io, quit);
467 if (ret < 0)
468 goto dai_trigger_end;
469
470 ret = rsnd_gen_path_exit(priv, rdai, io);
471 if (ret < 0)
472 goto dai_trigger_end;
473
474 ret = rsnd_platform_call(priv, dai, stop, ssi_id);
475 if (ret < 0)
476 goto dai_trigger_end;
477 break;
478 default:
479 ret = -EINVAL;
480 }
481
482 dai_trigger_end:
483 rsnd_unlock(priv, flags);
484
485 return ret;
486 }
487
488 static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
489 {
490 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
491
492 /* set master/slave audio interface */
493 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
494 case SND_SOC_DAIFMT_CBM_CFM:
495 rdai->clk_master = 1;
496 break;
497 case SND_SOC_DAIFMT_CBS_CFS:
498 rdai->clk_master = 0;
499 break;
500 default:
501 return -EINVAL;
502 }
503
504 /* set clock inversion */
505 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
506 case SND_SOC_DAIFMT_NB_IF:
507 rdai->bit_clk_inv = 0;
508 rdai->frm_clk_inv = 1;
509 break;
510 case SND_SOC_DAIFMT_IB_NF:
511 rdai->bit_clk_inv = 1;
512 rdai->frm_clk_inv = 0;
513 break;
514 case SND_SOC_DAIFMT_IB_IF:
515 rdai->bit_clk_inv = 1;
516 rdai->frm_clk_inv = 1;
517 break;
518 case SND_SOC_DAIFMT_NB_NF:
519 default:
520 rdai->bit_clk_inv = 0;
521 rdai->frm_clk_inv = 0;
522 break;
523 }
524
525 /* set format */
526 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
527 case SND_SOC_DAIFMT_I2S:
528 rdai->sys_delay = 0;
529 rdai->data_alignment = 0;
530 break;
531 case SND_SOC_DAIFMT_LEFT_J:
532 rdai->sys_delay = 1;
533 rdai->data_alignment = 0;
534 break;
535 case SND_SOC_DAIFMT_RIGHT_J:
536 rdai->sys_delay = 1;
537 rdai->data_alignment = 1;
538 break;
539 }
540
541 return 0;
542 }
543
544 static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
545 .trigger = rsnd_soc_dai_trigger,
546 .set_fmt = rsnd_soc_dai_set_fmt,
547 };
548
549 static int rsnd_dai_probe(struct platform_device *pdev,
550 struct rcar_snd_info *info,
551 struct rsnd_priv *priv)
552 {
553 struct snd_soc_dai_driver *drv;
554 struct rsnd_dai *rdai;
555 struct rsnd_mod *pmod, *cmod;
556 struct device *dev = rsnd_priv_to_dev(priv);
557 int dai_nr;
558 int i;
559
560 /* get max dai nr */
561 for (dai_nr = 0; dai_nr < 32; dai_nr++) {
562 pmod = rsnd_ssi_mod_get_frm_dai(priv, dai_nr, 1);
563 cmod = rsnd_ssi_mod_get_frm_dai(priv, dai_nr, 0);
564
565 if (!pmod && !cmod)
566 break;
567 }
568
569 if (!dai_nr) {
570 dev_err(dev, "no dai\n");
571 return -EIO;
572 }
573
574 drv = devm_kzalloc(dev, sizeof(*drv) * dai_nr, GFP_KERNEL);
575 rdai = devm_kzalloc(dev, sizeof(*rdai) * dai_nr, GFP_KERNEL);
576 if (!drv || !rdai) {
577 dev_err(dev, "dai allocate failed\n");
578 return -ENOMEM;
579 }
580
581 for (i = 0; i < dai_nr; i++) {
582
583 pmod = rsnd_ssi_mod_get_frm_dai(priv, i, 1);
584 cmod = rsnd_ssi_mod_get_frm_dai(priv, i, 0);
585
586 /*
587 * init rsnd_dai
588 */
589 INIT_LIST_HEAD(&rdai[i].playback.head);
590 INIT_LIST_HEAD(&rdai[i].capture.head);
591
592 snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i);
593
594 /*
595 * init snd_soc_dai_driver
596 */
597 drv[i].name = rdai[i].name;
598 drv[i].ops = &rsnd_soc_dai_ops;
599 if (pmod) {
600 drv[i].playback.rates = RSND_RATES;
601 drv[i].playback.formats = RSND_FMTS;
602 drv[i].playback.channels_min = 2;
603 drv[i].playback.channels_max = 2;
604 }
605 if (cmod) {
606 drv[i].capture.rates = RSND_RATES;
607 drv[i].capture.formats = RSND_FMTS;
608 drv[i].capture.channels_min = 2;
609 drv[i].capture.channels_max = 2;
610 }
611
612 dev_dbg(dev, "%s (%s/%s)\n", rdai[i].name,
613 pmod ? "play" : " -- ",
614 cmod ? "capture" : " -- ");
615 }
616
617 priv->dai_nr = dai_nr;
618 priv->daidrv = drv;
619 priv->rdai = rdai;
620
621 return 0;
622 }
623
624 static void rsnd_dai_remove(struct platform_device *pdev,
625 struct rsnd_priv *priv)
626 {
627 }
628
629 /*
630 * pcm ops
631 */
632 static struct snd_pcm_hardware rsnd_pcm_hardware = {
633 .info = SNDRV_PCM_INFO_INTERLEAVED |
634 SNDRV_PCM_INFO_MMAP |
635 SNDRV_PCM_INFO_MMAP_VALID |
636 SNDRV_PCM_INFO_PAUSE,
637 .buffer_bytes_max = 64 * 1024,
638 .period_bytes_min = 32,
639 .period_bytes_max = 8192,
640 .periods_min = 1,
641 .periods_max = 32,
642 .fifo_size = 256,
643 };
644
645 static int rsnd_pcm_open(struct snd_pcm_substream *substream)
646 {
647 struct snd_pcm_runtime *runtime = substream->runtime;
648 int ret = 0;
649
650 snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware);
651
652 ret = snd_pcm_hw_constraint_integer(runtime,
653 SNDRV_PCM_HW_PARAM_PERIODS);
654
655 return ret;
656 }
657
658 static int rsnd_hw_params(struct snd_pcm_substream *substream,
659 struct snd_pcm_hw_params *hw_params)
660 {
661 return snd_pcm_lib_malloc_pages(substream,
662 params_buffer_bytes(hw_params));
663 }
664
665 static snd_pcm_uframes_t rsnd_pointer(struct snd_pcm_substream *substream)
666 {
667 struct snd_pcm_runtime *runtime = substream->runtime;
668 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
669 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
670 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
671
672 return bytes_to_frames(runtime, io->byte_pos);
673 }
674
675 static struct snd_pcm_ops rsnd_pcm_ops = {
676 .open = rsnd_pcm_open,
677 .ioctl = snd_pcm_lib_ioctl,
678 .hw_params = rsnd_hw_params,
679 .hw_free = snd_pcm_lib_free_pages,
680 .pointer = rsnd_pointer,
681 };
682
683 /*
684 * snd_soc_platform
685 */
686
687 #define PREALLOC_BUFFER (32 * 1024)
688 #define PREALLOC_BUFFER_MAX (32 * 1024)
689
690 static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
691 {
692 return snd_pcm_lib_preallocate_pages_for_all(
693 rtd->pcm,
694 SNDRV_DMA_TYPE_DEV,
695 rtd->card->snd_card->dev,
696 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
697 }
698
699 static void rsnd_pcm_free(struct snd_pcm *pcm)
700 {
701 snd_pcm_lib_preallocate_free_for_all(pcm);
702 }
703
704 static struct snd_soc_platform_driver rsnd_soc_platform = {
705 .ops = &rsnd_pcm_ops,
706 .pcm_new = rsnd_pcm_new,
707 .pcm_free = rsnd_pcm_free,
708 };
709
710 static const struct snd_soc_component_driver rsnd_soc_component = {
711 .name = "rsnd",
712 };
713
714 /*
715 * rsnd probe
716 */
717 static int rsnd_probe(struct platform_device *pdev)
718 {
719 struct rcar_snd_info *info;
720 struct rsnd_priv *priv;
721 struct device *dev = &pdev->dev;
722 int ret;
723
724 info = pdev->dev.platform_data;
725 if (!info) {
726 dev_err(dev, "driver needs R-Car sound information\n");
727 return -ENODEV;
728 }
729
730 /*
731 * init priv data
732 */
733 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
734 if (!priv) {
735 dev_err(dev, "priv allocate failed\n");
736 return -ENODEV;
737 }
738
739 priv->dev = dev;
740 priv->info = info;
741 spin_lock_init(&priv->lock);
742
743 /*
744 * init each module
745 */
746 ret = rsnd_gen_probe(pdev, info, priv);
747 if (ret)
748 return ret;
749
750 ret = rsnd_scu_probe(pdev, info, priv);
751 if (ret)
752 return ret;
753
754 ret = rsnd_adg_probe(pdev, info, priv);
755 if (ret)
756 return ret;
757
758 ret = rsnd_ssi_probe(pdev, info, priv);
759 if (ret)
760 return ret;
761
762 ret = rsnd_dai_probe(pdev, info, priv);
763 if (ret)
764 return ret;
765
766 /*
767 * asoc register
768 */
769 ret = snd_soc_register_platform(dev, &rsnd_soc_platform);
770 if (ret < 0) {
771 dev_err(dev, "cannot snd soc register\n");
772 return ret;
773 }
774
775 ret = snd_soc_register_component(dev, &rsnd_soc_component,
776 priv->daidrv, rsnd_dai_nr(priv));
777 if (ret < 0) {
778 dev_err(dev, "cannot snd dai register\n");
779 goto exit_snd_soc;
780 }
781
782 dev_set_drvdata(dev, priv);
783
784 pm_runtime_enable(dev);
785
786 dev_info(dev, "probed\n");
787 return ret;
788
789 exit_snd_soc:
790 snd_soc_unregister_platform(dev);
791
792 return ret;
793 }
794
795 static int rsnd_remove(struct platform_device *pdev)
796 {
797 struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
798
799 pm_runtime_disable(&pdev->dev);
800
801 /*
802 * remove each module
803 */
804 rsnd_ssi_remove(pdev, priv);
805 rsnd_adg_remove(pdev, priv);
806 rsnd_scu_remove(pdev, priv);
807 rsnd_dai_remove(pdev, priv);
808 rsnd_gen_remove(pdev, priv);
809
810 return 0;
811 }
812
813 static struct platform_driver rsnd_driver = {
814 .driver = {
815 .name = "rcar_sound",
816 },
817 .probe = rsnd_probe,
818 .remove = rsnd_remove,
819 };
820 module_platform_driver(rsnd_driver);
821
822 MODULE_LICENSE("GPL");
823 MODULE_DESCRIPTION("Renesas R-Car audio driver");
824 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
825 MODULE_ALIAS("platform:rcar-pcm-audio");
This page took 0.047773 seconds and 5 git commands to generate.