Merge tag 'v3.14.25' into backport/v3.14.24-ltsi-rc1+v3.14.25/snapshot-merge.wip
[platform/adaptation/renesas_rcar/renesas_kernel.git] / sound / soc / sh / rcar / src.c
1 /*
2  * Renesas R-Car SRC support
3  *
4  * Copyright (C) 2013 Renesas Solutions Corp.
5  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 #include "rsnd.h"
12
13 #define SRC_NAME "src"
14
15 struct rsnd_src {
16         struct rsnd_src_platform_info *info; /* rcar_snd.h */
17         struct rsnd_mod mod;
18         struct clk *clk;
19 };
20
21 #define RSND_SRC_NAME_SIZE 16
22
23 #define rsnd_src_convert_rate(p) ((p)->info->convert_rate)
24 #define rsnd_mod_to_src(_mod)                           \
25         container_of((_mod), struct rsnd_src, mod)
26 #define rsnd_src_dma_available(src) \
27         rsnd_dma_available(rsnd_mod_to_dma(&(src)->mod))
28
29 #define for_each_rsnd_src(pos, priv, i)                         \
30         for ((i) = 0;                                           \
31              ((i) < rsnd_src_nr(priv)) &&                       \
32              ((pos) = (struct rsnd_src *)(priv)->src + i);      \
33              i++)
34
35
36 /*
37  *              image of SRC (Sampling Rate Converter)
38  *
39  * 96kHz   <-> +-----+  48kHz   +-----+  48kHz  +-------+
40  * 48kHz   <-> | SRC | <------> | SSI | <-----> | codec |
41  * 44.1kHz <-> +-----+          +-----+         +-------+
42  * ...
43  *
44  */
45
46 /*
47  * src.c is caring...
48  *
49  * Gen1
50  *
51  * [mem] -> [SRU] -> [SSI]
52  *        |--------|
53  *
54  * Gen2
55  *
56  * [mem] -> [SRC] -> [SSIU] -> [SSI]
57  *        |-----------------|
58  */
59
60 /*
61  *      How to use SRC bypass mode for debugging
62  *
63  * SRC has bypass mode, and it is useful for debugging.
64  * In Gen2 case,
65  * SRCm_MODE controls whether SRC is used or not
66  * SSI_MODE0 controls whether SSIU which receives SRC data
67  * is used or not.
68  * Both SRCm_MODE/SSI_MODE0 settings are needed if you use SRC,
69  * but SRC bypass mode needs SSI_MODE0 only.
70  *
71  * This driver request
72  * struct rsnd_src_platform_info {
73  *      u32 convert_rate;
74  *      int dma_id;
75  * }
76  *
77  * rsnd_src_convert_rate() indicates
78  * above convert_rate, and it controls
79  * whether SRC is used or not.
80  *
81  * ex) doesn't use SRC
82  * static struct rsnd_dai_platform_info rsnd_dai = {
83  *      .playback = { .ssi = &rsnd_ssi[0], },
84  * };
85  *
86  * ex) uses SRC
87  * static struct rsnd_src_platform_info rsnd_src[] = {
88  *      RSND_SCU(48000, 0),
89  *      ...
90  * };
91  * static struct rsnd_dai_platform_info rsnd_dai = {
92  *      .playback = { .ssi = &rsnd_ssi[0], .src = &rsnd_src[0] },
93  * };
94  *
95  * ex) uses SRC bypass mode
96  * static struct rsnd_src_platform_info rsnd_src[] = {
97  *      RSND_SCU(0, 0),
98  *      ...
99  * };
100  * static struct rsnd_dai_platform_info rsnd_dai = {
101  *      .playback = { .ssi = &rsnd_ssi[0], .src = &rsnd_src[0] },
102  * };
103  *
104  */
105
106 /*
107  *              Gen1/Gen2 common functions
108  */
109 int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
110                         struct rsnd_dai *rdai,
111                         int use_busif)
112 {
113         struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod);
114         struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
115         int ssi_id = rsnd_mod_id(ssi_mod);
116
117         /*
118          * SSI_MODE0
119          */
120         rsnd_mod_bset(ssi_mod, SSI_MODE0, (1 << ssi_id),
121                       !use_busif << ssi_id);
122
123         /*
124          * SSI_MODE1
125          */
126         if (rsnd_ssi_is_pin_sharing(ssi_mod)) {
127                 int shift = -1;
128                 switch (ssi_id) {
129                 case 1:
130                         shift = 0;
131                         break;
132                 case 2:
133                         shift = 2;
134                         break;
135                 case 4:
136                         shift = 16;
137                         break;
138                 }
139
140                 if (shift >= 0)
141                         rsnd_mod_bset(ssi_mod, SSI_MODE1,
142                                       0x3 << shift,
143                                       rsnd_dai_is_clk_master(rdai) ?
144                                       0x2 << shift : 0x1 << shift);
145         }
146
147         /*
148          * DMA settings for SSIU
149          */
150         if (use_busif) {
151                 u32 val = 0x76543210;
152                 u32 mask = ~0;
153
154                 rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR,
155                                rsnd_get_adinr(ssi_mod));
156                 rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE,  1);
157                 rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1);
158
159                 mask <<= runtime->channels * 4;
160                 val = val & mask;
161
162                 switch (runtime->sample_bits) {
163                 case 16:
164                         val |= 0x67452301 & ~mask;
165                         break;
166                 case 32:
167                         val |= 0x76543210 & ~mask;
168                         break;
169                 }
170                 rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val);
171
172         }
173
174         return 0;
175 }
176
177 int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
178                         struct rsnd_dai *rdai,
179                         int use_busif)
180 {
181         /*
182          * DMA settings for SSIU
183          */
184         if (use_busif)
185                 rsnd_mod_write(ssi_mod, SSI_CTRL, 0);
186
187         return 0;
188 }
189
190 int rsnd_src_enable_ssi_irq(struct rsnd_mod *ssi_mod,
191                             struct rsnd_dai *rdai)
192 {
193         struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod);
194
195         /* enable PIO interrupt if Gen2 */
196         if (rsnd_is_gen2(priv))
197                 rsnd_mod_write(ssi_mod, INT_ENABLE, 0x0f000000);
198
199         return 0;
200 }
201
202 unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
203                                    struct rsnd_dai_stream *io,
204                                    struct snd_pcm_runtime *runtime)
205 {
206         struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
207         struct rsnd_src *src;
208         unsigned int rate = 0;
209
210         if (src_mod) {
211                 src = rsnd_mod_to_src(src_mod);
212
213                 /*
214                  * return convert rate if SRC is used,
215                  * otherwise, return runtime->rate as usual
216                  */
217                 rate = rsnd_src_convert_rate(src);
218         }
219
220         if (!rate)
221                 rate = runtime->rate;
222
223         return rate;
224 }
225
226 static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
227                                      struct rsnd_dai *rdai)
228 {
229         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
230         struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
231         struct rsnd_src *src = rsnd_mod_to_src(mod);
232         u32 convert_rate = rsnd_src_convert_rate(src);
233         u32 fsrate = 0;
234
235         if (convert_rate)
236                 fsrate = 0x0400000 / convert_rate * runtime->rate;
237
238         /* set/clear soft reset */
239         rsnd_mod_write(mod, SRC_SWRSR, 0);
240         rsnd_mod_write(mod, SRC_SWRSR, 1);
241
242         /*
243          * Initialize the operation of the SRC internal circuits
244          * see rsnd_src_start()
245          */
246         rsnd_mod_write(mod, SRC_SRCIR, 1);
247
248         /* Set channel number and output bit length */
249         rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod));
250
251         /* Enable the initial value of IFS */
252         if (fsrate) {
253                 rsnd_mod_write(mod, SRC_IFSCR, 1);
254
255                 /* Set initial value of IFS */
256                 rsnd_mod_write(mod, SRC_IFSVR, fsrate);
257         }
258
259         /* use DMA transfer */
260         rsnd_mod_write(mod, SRC_BUSIF_MODE, 1);
261
262         return 0;
263 }
264
265 static int rsnd_src_init(struct rsnd_mod *mod,
266                          struct rsnd_dai *rdai)
267 {
268         struct rsnd_src *src = rsnd_mod_to_src(mod);
269
270         clk_prepare_enable(src->clk);
271
272         return 0;
273 }
274
275 static int rsnd_src_quit(struct rsnd_mod *mod,
276                          struct rsnd_dai *rdai)
277 {
278         struct rsnd_src *src = rsnd_mod_to_src(mod);
279
280         clk_disable_unprepare(src->clk);
281
282         return 0;
283 }
284
285 static int rsnd_src_start(struct rsnd_mod *mod,
286                           struct rsnd_dai *rdai)
287 {
288         struct rsnd_src *src = rsnd_mod_to_src(mod);
289
290         /*
291          * Cancel the initialization and operate the SRC function
292          * see rsnd_src_set_convert_rate()
293          */
294         rsnd_mod_write(mod, SRC_SRCIR, 0);
295
296         if (rsnd_src_convert_rate(src))
297                 rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1);
298
299         return 0;
300 }
301
302
303 static int rsnd_src_stop(struct rsnd_mod *mod,
304                          struct rsnd_dai *rdai)
305 {
306         struct rsnd_src *src = rsnd_mod_to_src(mod);
307
308         if (rsnd_src_convert_rate(src))
309                 rsnd_mod_write(mod, SRC_ROUTE_MODE0, 0);
310
311         return 0;
312 }
313
314 /*
315  *              Gen1 functions
316  */
317 static int rsnd_src_set_route_gen1(struct rsnd_mod *mod,
318                                    struct rsnd_dai *rdai)
319 {
320         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
321         struct src_route_config {
322                 u32 mask;
323                 int shift;
324         } routes[] = {
325                 { 0xF,  0, }, /* 0 */
326                 { 0xF,  4, }, /* 1 */
327                 { 0xF,  8, }, /* 2 */
328                 { 0x7, 12, }, /* 3 */
329                 { 0x7, 16, }, /* 4 */
330                 { 0x7, 20, }, /* 5 */
331                 { 0x7, 24, }, /* 6 */
332                 { 0x3, 28, }, /* 7 */
333                 { 0x3, 30, }, /* 8 */
334         };
335         u32 mask;
336         u32 val;
337         int id;
338
339         id = rsnd_mod_id(mod);
340         if (id < 0 || id >= ARRAY_SIZE(routes))
341                 return -EIO;
342
343         /*
344          * SRC_ROUTE_SELECT
345          */
346         val = rsnd_dai_is_play(rdai, io) ? 0x1 : 0x2;
347         val = val               << routes[id].shift;
348         mask = routes[id].mask  << routes[id].shift;
349
350         rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val);
351
352         return 0;
353 }
354
355 static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod,
356                                             struct rsnd_dai *rdai)
357 {
358         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
359         struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
360         struct rsnd_src *src = rsnd_mod_to_src(mod);
361         struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
362         u32 convert_rate = rsnd_src_convert_rate(src);
363         u32 mask;
364         u32 val;
365         int shift;
366         int id = rsnd_mod_id(mod);
367         int ret;
368
369         /*
370          * SRC_TIMING_SELECT
371          */
372         shift   = (id % 4) * 8;
373         mask    = 0x1F << shift;
374
375         /*
376          * ADG is used as source clock if SRC was used,
377          * then, SSI WS is used as destination clock.
378          * SSI WS is used as source clock if SRC is not used
379          * (when playback, source/destination become reverse when capture)
380          */
381         ret = 0;
382         if (convert_rate) {
383                 /* use ADG */
384                 val = 0;
385                 ret = rsnd_adg_set_convert_clk_gen1(priv, mod,
386                                                     runtime->rate,
387                                                     convert_rate);
388         } else if (8 == id) {
389                 /* use SSI WS, but SRU8 is special */
390                 val = id << shift;
391         } else {
392                 /* use SSI WS */
393                 val = (id + 1) << shift;
394         }
395
396         if (ret < 0)
397                 return ret;
398
399         switch (id / 4) {
400         case 0:
401                 rsnd_mod_bset(mod, SRC_TMG_SEL0, mask, val);
402                 break;
403         case 1:
404                 rsnd_mod_bset(mod, SRC_TMG_SEL1, mask, val);
405                 break;
406         case 2:
407                 rsnd_mod_bset(mod, SRC_TMG_SEL2, mask, val);
408                 break;
409         }
410
411         return 0;
412 }
413
414 static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod,
415                                           struct rsnd_dai *rdai)
416 {
417         int ret;
418
419         ret = rsnd_src_set_convert_rate(mod, rdai);
420         if (ret < 0)
421                 return ret;
422
423         /* Select SRC mode (fixed value) */
424         rsnd_mod_write(mod, SRC_SRCCR, 0x00010110);
425
426         /* Set the restriction value of the FS ratio (98%) */
427         rsnd_mod_write(mod, SRC_MNFSR,
428                        rsnd_mod_read(mod, SRC_IFSVR) / 100 * 98);
429
430         /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */
431
432         return 0;
433 }
434
435 static int rsnd_src_probe_gen1(struct rsnd_mod *mod,
436                               struct rsnd_dai *rdai)
437 {
438         struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
439         struct device *dev = rsnd_priv_to_dev(priv);
440
441         dev_dbg(dev, "%s (Gen1) is probed\n", rsnd_mod_name(mod));
442
443         return 0;
444 }
445
446 static int rsnd_src_init_gen1(struct rsnd_mod *mod,
447                               struct rsnd_dai *rdai)
448 {
449         int ret;
450
451         ret = rsnd_src_init(mod, rdai);
452         if (ret < 0)
453                 return ret;
454
455         ret = rsnd_src_set_route_gen1(mod, rdai);
456         if (ret < 0)
457                 return ret;
458
459         ret = rsnd_src_set_convert_rate_gen1(mod, rdai);
460         if (ret < 0)
461                 return ret;
462
463         ret = rsnd_src_set_convert_timing_gen1(mod, rdai);
464         if (ret < 0)
465                 return ret;
466
467         return 0;
468 }
469
470 static int rsnd_src_start_gen1(struct rsnd_mod *mod,
471                                struct rsnd_dai *rdai)
472 {
473         int id = rsnd_mod_id(mod);
474
475         rsnd_mod_bset(mod, SRC_ROUTE_CTRL, (1 << id), (1 << id));
476
477         return rsnd_src_start(mod, rdai);
478 }
479
480 static int rsnd_src_stop_gen1(struct rsnd_mod *mod,
481                               struct rsnd_dai *rdai)
482 {
483         int id = rsnd_mod_id(mod);
484
485         rsnd_mod_bset(mod, SRC_ROUTE_CTRL, (1 << id), 0);
486
487         return rsnd_src_stop(mod, rdai);
488 }
489
490 static struct rsnd_mod_ops rsnd_src_gen1_ops = {
491         .name   = SRC_NAME,
492         .probe  = rsnd_src_probe_gen1,
493         .init   = rsnd_src_init_gen1,
494         .quit   = rsnd_src_quit,
495         .start  = rsnd_src_start_gen1,
496         .stop   = rsnd_src_stop_gen1,
497 };
498
499 /*
500  *              Gen2 functions
501  */
502 static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod,
503                                           struct rsnd_dai *rdai)
504 {
505         struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
506         struct device *dev = rsnd_priv_to_dev(priv);
507         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
508         struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
509         struct rsnd_src *src = rsnd_mod_to_src(mod);
510         uint ratio;
511         int ret;
512
513         /* 6 - 1/6 are very enough ratio for SRC_BSDSR */
514         if (!rsnd_src_convert_rate(src))
515                 ratio = 0;
516         else if (rsnd_src_convert_rate(src) > runtime->rate)
517                 ratio = 100 * rsnd_src_convert_rate(src) / runtime->rate;
518         else
519                 ratio = 100 * runtime->rate / rsnd_src_convert_rate(src);
520
521         if (ratio > 600) {
522                 dev_err(dev, "FSO/FSI ratio error\n");
523                 return -EINVAL;
524         }
525
526         ret = rsnd_src_set_convert_rate(mod, rdai);
527         if (ret < 0)
528                 return ret;
529
530         rsnd_mod_write(mod, SRC_SRCCR, 0x00011110);
531
532         switch (rsnd_mod_id(mod)) {
533         case 5:
534         case 6:
535         case 7:
536         case 8:
537                 rsnd_mod_write(mod, SRC_BSDSR, 0x02400000);
538                 break;
539         default:
540                 rsnd_mod_write(mod, SRC_BSDSR, 0x01800000);
541                 break;
542         }
543
544         rsnd_mod_write(mod, SRC_BSISR, 0x00100060);
545
546         return 0;
547 }
548
549 static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod,
550                                             struct rsnd_dai *rdai)
551 {
552         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
553         struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
554         struct rsnd_src *src = rsnd_mod_to_src(mod);
555         u32 convert_rate = rsnd_src_convert_rate(src);
556         int ret;
557
558         if (convert_rate)
559                 ret = rsnd_adg_set_convert_clk_gen2(mod, rdai, io,
560                                                     runtime->rate,
561                                                     convert_rate);
562         else
563                 ret = rsnd_adg_set_convert_timing_gen2(mod, rdai, io);
564
565         return ret;
566 }
567
568 static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
569                                struct rsnd_dai *rdai)
570 {
571         struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
572         struct rsnd_src *src = rsnd_mod_to_src(mod);
573         struct device *dev = rsnd_priv_to_dev(priv);
574         int ret;
575
576         ret = rsnd_dma_init(priv,
577                             rsnd_mod_to_dma(mod),
578                             rsnd_info_is_playback(priv, src),
579                             src->info->dma_id);
580         if (ret < 0)
581                 dev_err(dev, "SRC DMA failed\n");
582
583         dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod));
584
585         return ret;
586 }
587
588 static int rsnd_src_remove_gen2(struct rsnd_mod *mod,
589                                 struct rsnd_dai *rdai)
590 {
591         rsnd_dma_quit(rsnd_mod_to_priv(mod), rsnd_mod_to_dma(mod));
592
593         return 0;
594 }
595
596 static int rsnd_src_init_gen2(struct rsnd_mod *mod,
597                               struct rsnd_dai *rdai)
598 {
599         int ret;
600
601         ret = rsnd_src_init(mod, rdai);
602         if (ret < 0)
603                 return ret;
604
605         ret = rsnd_src_set_convert_rate_gen2(mod, rdai);
606         if (ret < 0)
607                 return ret;
608
609         ret = rsnd_src_set_convert_timing_gen2(mod, rdai);
610         if (ret < 0)
611                 return ret;
612
613         return 0;
614 }
615
616 static int rsnd_src_start_gen2(struct rsnd_mod *mod,
617                                struct rsnd_dai *rdai)
618 {
619         struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
620         struct rsnd_src *src = rsnd_mod_to_src(mod);
621         u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11;
622
623         rsnd_dma_start(rsnd_mod_to_dma(&src->mod));
624
625         rsnd_mod_write(mod, SRC_CTRL, val);
626
627         return rsnd_src_start(mod, rdai);
628 }
629
630 static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
631                               struct rsnd_dai *rdai)
632 {
633         struct rsnd_src *src = rsnd_mod_to_src(mod);
634
635         rsnd_mod_write(mod, SRC_CTRL, 0);
636
637         rsnd_dma_stop(rsnd_mod_to_dma(&src->mod));
638
639         return rsnd_src_stop(mod, rdai);
640 }
641
642 static struct rsnd_mod_ops rsnd_src_gen2_ops = {
643         .name   = SRC_NAME,
644         .probe  = rsnd_src_probe_gen2,
645         .remove = rsnd_src_remove_gen2,
646         .init   = rsnd_src_init_gen2,
647         .quit   = rsnd_src_quit,
648         .start  = rsnd_src_start_gen2,
649         .stop   = rsnd_src_stop_gen2,
650 };
651
652 struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id)
653 {
654         if (WARN_ON(id < 0 || id >= rsnd_src_nr(priv)))
655                 id = 0;
656
657         return &((struct rsnd_src *)(priv->src) + id)->mod;
658 }
659
660 static void rsnd_of_parse_src(struct platform_device *pdev,
661                               const struct rsnd_of_data *of_data,
662                               struct rsnd_priv *priv)
663 {
664         struct device_node *src_node;
665         struct rcar_snd_info *info = rsnd_priv_to_info(priv);
666         struct rsnd_src_platform_info *src_info;
667         struct device *dev = &pdev->dev;
668         int nr;
669
670         if (!of_data)
671                 return;
672
673         src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
674         if (!src_node)
675                 return;
676
677         nr = of_get_child_count(src_node);
678         if (!nr)
679                 goto rsnd_of_parse_src_end;
680
681         src_info = devm_kzalloc(dev,
682                                 sizeof(struct rsnd_src_platform_info) * nr,
683                                 GFP_KERNEL);
684         if (!src_info) {
685                 dev_err(dev, "src info allocation error\n");
686                 goto rsnd_of_parse_src_end;
687         }
688
689         info->src_info          = src_info;
690         info->src_info_nr       = nr;
691
692 rsnd_of_parse_src_end:
693         of_node_put(src_node);
694 }
695
696 int rsnd_src_probe(struct platform_device *pdev,
697                    const struct rsnd_of_data *of_data,
698                    struct rsnd_priv *priv)
699 {
700         struct rcar_snd_info *info = rsnd_priv_to_info(priv);
701         struct device *dev = rsnd_priv_to_dev(priv);
702         struct rsnd_src *src;
703         struct rsnd_mod_ops *ops;
704         struct clk *clk;
705         char name[RSND_SRC_NAME_SIZE];
706         int i, nr;
707
708         ops = NULL;
709         if (rsnd_is_gen1(priv))
710                 ops = &rsnd_src_gen1_ops;
711         if (rsnd_is_gen2(priv))
712                 ops = &rsnd_src_gen2_ops;
713         if (!ops) {
714                 dev_err(dev, "unknown Generation\n");
715                 return -EIO;
716         }
717
718         rsnd_of_parse_src(pdev, of_data, priv);
719
720         /*
721          * init SRC
722          */
723         nr      = info->src_info_nr;
724         if (!nr)
725                 return 0;
726
727         src     = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
728         if (!src) {
729                 dev_err(dev, "SRC allocate failed\n");
730                 return -ENOMEM;
731         }
732
733         priv->src_nr    = nr;
734         priv->src       = src;
735
736         for_each_rsnd_src(src, priv, i) {
737                 snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
738                          SRC_NAME, i);
739
740                 clk = devm_clk_get(dev, name);
741                 if (IS_ERR(clk))
742                         return PTR_ERR(clk);
743
744                 src->info = &info->src_info[i];
745                 src->clk = clk;
746
747                 rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i);
748
749                 dev_dbg(dev, "SRC%d probed\n", i);
750         }
751
752         return 0;
753 }