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