]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - sound/soc/sh/rcar/src.c
Merge remote-tracking branch 'regulator/fix/max77802' into regulator-linus
[mirror_ubuntu-artful-kernel.git] / sound / soc / sh / rcar / src.c
CommitLineData
07539c1d 1/*
ba9c949f 2 * Renesas R-Car SRC support
07539c1d
KM
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
8aefda50
KM
13#define SRC_NAME "src"
14
cfcefe01
KM
15/* SRCx_STATUS */
16#define OUF_SRCO ((1 << 12) | (1 << 13))
17#define OUF_SRCI ((1 << 9) | (1 << 8))
18
19/* SCU_SYSTEM_STATUS0/1 */
20#define OUF_SRC(id) ((1 << (id + 16)) | (1 << id))
21
ba9c949f 22struct rsnd_src {
07539c1d 23 struct rsnd_mod mod;
940e9479 24 struct rsnd_mod *dma;
43cb6954
KM
25 struct rsnd_kctrl_cfg_s sen; /* sync convert enable */
26 struct rsnd_kctrl_cfg_s sync; /* sync convert */
3b7843ff 27 u32 convert_rate; /* sampling rate convert */
adf6a681 28 int irq;
07539c1d
KM
29};
30
ba9c949f 31#define RSND_SRC_NAME_SIZE 16
374a5281 32
adf6a681 33#define rsnd_src_get(priv, id) ((struct rsnd_src *)(priv->src) + id)
232c00b6 34#define rsnd_src_to_dma(src) ((src)->dma)
da599fd3 35#define rsnd_src_nr(priv) ((priv)->src_nr)
ab2049f9 36#define rsnd_src_sync_is_enabled(mod) (rsnd_mod_to_src(mod)->sen.val)
82e76ed3 37
ba9c949f
KM
38#define rsnd_mod_to_src(_mod) \
39 container_of((_mod), struct rsnd_src, mod)
39cf3c40 40
ba9c949f 41#define for_each_rsnd_src(pos, priv, i) \
39cf3c40 42 for ((i) = 0; \
ba9c949f
KM
43 ((i) < rsnd_src_nr(priv)) && \
44 ((pos) = (struct rsnd_src *)(priv)->src + i); \
39cf3c40
KM
45 i++)
46
47
ef749400
KM
48/*
49 * image of SRC (Sampling Rate Converter)
50 *
51 * 96kHz <-> +-----+ 48kHz +-----+ 48kHz +-------+
52 * 48kHz <-> | SRC | <------> | SSI | <-----> | codec |
53 * 44.1kHz <-> +-----+ +-----+ +-------+
54 * ...
55 *
56 */
374a5281 57
c926b746 58/*
ba9c949f 59 * src.c is caring...
c926b746
KM
60 *
61 * Gen1
62 *
63 * [mem] -> [SRU] -> [SSI]
64 * |--------|
65 *
66 * Gen2
67 *
ba9c949f 68 * [mem] -> [SRC] -> [SSIU] -> [SSI]
c926b746
KM
69 * |-----------------|
70 */
71
98efeeae 72static void rsnd_src_activation(struct rsnd_mod *mod)
379febfd
KM
73{
74 rsnd_mod_write(mod, SRC_SWRSR, 0);
75 rsnd_mod_write(mod, SRC_SWRSR, 1);
76}
77
475a361a
KM
78static void rsnd_src_halt(struct rsnd_mod *mod)
79{
80 rsnd_mod_write(mod, SRC_SRCIR, 1);
81 rsnd_mod_write(mod, SRC_SWRSR, 0);
82}
83
9b99e9a7
KM
84static struct dma_chan *rsnd_src_dma_req(struct rsnd_dai_stream *io,
85 struct rsnd_mod *mod)
72adc61f
KM
86{
87 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
72adc61f
KM
88 int is_play = rsnd_io_is_play(io);
89
90 return rsnd_dma_request_channel(rsnd_src_of_node(priv),
91 mod,
92 is_play ? "rx" : "tx");
93}
94
88c61cff 95static u32 rsnd_src_convert_rate(struct rsnd_dai_stream *io,
1a9be9ee 96 struct rsnd_mod *mod)
43cb6954 97{
43cb6954 98 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
1a9be9ee 99 struct rsnd_src *src = rsnd_mod_to_src(mod);
43cb6954
KM
100 u32 convert_rate;
101
102 if (!runtime)
103 return 0;
104
ab2049f9 105 if (!rsnd_src_sync_is_enabled(mod))
43cb6954
KM
106 return src->convert_rate;
107
108 convert_rate = src->sync.val;
109
110 if (!convert_rate)
111 convert_rate = src->convert_rate;
112
113 if (!convert_rate)
114 convert_rate = runtime->rate;
115
116 return convert_rate;
117}
118
cbf1494f
KM
119unsigned int rsnd_src_get_rate(struct rsnd_priv *priv,
120 struct rsnd_dai_stream *io,
121 int is_in)
1b7b08ef 122{
b1eac430 123 struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
cbf1494f 124 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
b1eac430 125 unsigned int rate = 0;
cbf1494f
KM
126 int is_play = rsnd_io_is_play(io);
127
128 /*
129 *
130 * Playback
131 * runtime_rate -> [SRC] -> convert_rate
132 *
133 * Capture
134 * convert_rate -> [SRC] -> runtime_rate
135 */
136
137 if (is_play == is_in)
138 return runtime->rate;
1b7b08ef 139
1a9be9ee
KM
140 /*
141 * return convert rate if SRC is used,
142 * otherwise, return runtime->rate as usual
143 */
144 if (src_mod)
145 rate = rsnd_src_convert_rate(io, src_mod);
1b7b08ef 146
1b7b08ef
KM
147 if (!rate)
148 rate = runtime->rate;
149
150 return rate;
151}
152
3b7843ff 153static int rsnd_src_hw_params(struct rsnd_mod *mod,
2c0fac19 154 struct rsnd_dai_stream *io,
3b7843ff
KM
155 struct snd_pcm_substream *substream,
156 struct snd_pcm_hw_params *fe_params)
157{
158 struct rsnd_src *src = rsnd_mod_to_src(mod);
159 struct snd_soc_pcm_runtime *fe = substream->private_data;
160
3b7843ff
KM
161 /*
162 * SRC assumes that it is used under DPCM if user want to use
163 * sampling rate convert. Then, SRC should be FE.
164 * And then, this function will be called *after* BE settings.
165 * this means, each BE already has fixuped hw_params.
166 * see
167 * dpcm_fe_dai_hw_params()
168 * dpcm_be_dai_hw_params()
169 */
fc99d23f 170 src->convert_rate = 0;
3b7843ff
KM
171 if (fe->dai_link->dynamic) {
172 int stream = substream->stream;
173 struct snd_soc_dpcm *dpcm;
174 struct snd_pcm_hw_params *be_params;
175
176 list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) {
177 be_params = &dpcm->hw_params;
178
179 if (params_rate(fe_params) != params_rate(be_params))
180 src->convert_rate = params_rate(be_params);
181 }
182 }
183
184 return 0;
185}
186
75916f65
KM
187static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io,
188 struct rsnd_mod *mod)
1b7b08ef 189{
75916f65
KM
190 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
191 struct device *dev = rsnd_priv_to_dev(priv);
192 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
90431eb4 193 int is_play = rsnd_io_is_play(io);
67923f77 194 int use_src = 0;
0102eed5 195 u32 fin, fout;
75916f65
KM
196 u32 ifscr, fsrate, adinr;
197 u32 cr, route;
198 u32 bsdsr, bsisr;
90431eb4 199 u32 i_busif, o_busif, tmp;
75916f65 200 uint ratio;
1b7b08ef 201
75916f65
KM
202 if (!runtime)
203 return;
43cb6954 204
0102eed5
KM
205 fin = rsnd_src_get_in_rate(priv, io);
206 fout = rsnd_src_get_out_rate(priv, io);
207
75916f65 208 /* 6 - 1/6 are very enough ratio for SRC_BSDSR */
0102eed5 209 if (fin == fout)
75916f65 210 ratio = 0;
0102eed5
KM
211 else if (fin > fout)
212 ratio = 100 * fin / fout;
75916f65 213 else
0102eed5 214 ratio = 100 * fout / fin;
1b7b08ef 215
75916f65
KM
216 if (ratio > 600) {
217 dev_err(dev, "FSO/FSI ratio error\n");
218 return;
219 }
1b7b08ef 220
67923f77
KM
221 use_src = (fin != fout) | rsnd_src_sync_is_enabled(mod);
222
75916f65
KM
223 /*
224 * SRC_ADINR
225 */
c45f7263 226 adinr = rsnd_get_adinr_bit(mod, io) |
eed76bb8 227 rsnd_runtime_channel_original(io);
1b7b08ef 228
75916f65
KM
229 /*
230 * SRC_IFSCR / SRC_IFSVR
231 */
232 ifscr = 0;
233 fsrate = 0;
67923f77 234 if (use_src) {
93ca33c9
HY
235 u64 n;
236
75916f65 237 ifscr = 1;
93ca33c9
HY
238 n = (u64)0x0400000 * fin;
239 do_div(n, fout);
240 fsrate = n;
75916f65 241 }
cfcefe01 242
75916f65
KM
243 /*
244 * SRC_SRCCR / SRC_ROUTE_MODE0
245 */
246 cr = 0x00011110;
247 route = 0x0;
67923f77 248 if (use_src) {
75916f65 249 route = 0x1;
3b7843ff 250
ab2049f9 251 if (rsnd_src_sync_is_enabled(mod)) {
75916f65
KM
252 cr |= 0x1;
253 route |= rsnd_io_is_play(io) ?
254 (0x1 << 24) : (0x1 << 25);
255 }
256 }
43cb6954 257
75916f65
KM
258 /*
259 * SRC_BSDSR / SRC_BSISR
260 */
261 switch (rsnd_mod_id(mod)) {
262 case 5:
263 case 6:
264 case 7:
265 case 8:
266 bsdsr = 0x02400000; /* 6 - 1/6 */
267 bsisr = 0x00100060; /* 6 - 1/6 */
268 break;
269 default:
270 bsdsr = 0x01800000; /* 6 - 1/6 */
271 bsisr = 0x00100060 ;/* 6 - 1/6 */
272 break;
273 }
1b7b08ef 274
90431eb4
KM
275 /* BUSIF_MODE */
276 tmp = rsnd_get_busif_shift(io, mod);
277 i_busif = ( is_play ? tmp : 0) | 1;
278 o_busif = (!is_play ? tmp : 0) | 1;
279
0fbab951
KM
280 rsnd_mod_write(mod, SRC_ROUTE_MODE0, route);
281
75916f65
KM
282 rsnd_mod_write(mod, SRC_SRCIR, 1); /* initialize */
283 rsnd_mod_write(mod, SRC_ADINR, adinr);
284 rsnd_mod_write(mod, SRC_IFSCR, ifscr);
285 rsnd_mod_write(mod, SRC_IFSVR, fsrate);
286 rsnd_mod_write(mod, SRC_SRCCR, cr);
287 rsnd_mod_write(mod, SRC_BSDSR, bsdsr);
288 rsnd_mod_write(mod, SRC_BSISR, bsisr);
289 rsnd_mod_write(mod, SRC_SRCIR, 0); /* cancel initialize */
1b7b08ef 290
90431eb4
KM
291 rsnd_mod_write(mod, SRC_I_BUSIF_MODE, i_busif);
292 rsnd_mod_write(mod, SRC_O_BUSIF_MODE, o_busif);
293
75916f65 294 rsnd_mod_write(mod, SRC_BUSIF_DALIGN, rsnd_get_dalign(mod, io));
1b7b08ef 295
0102eed5 296 rsnd_adg_set_src_timesel_gen2(mod, io, fin, fout);
1b7b08ef
KM
297}
298
b5b442ab
KM
299static int rsnd_src_irq(struct rsnd_mod *mod,
300 struct rsnd_dai_stream *io,
301 struct rsnd_priv *priv,
302 int enable)
cfcefe01
KM
303{
304 struct rsnd_src *src = rsnd_mod_to_src(mod);
305 u32 sys_int_val, int_val, sys_int_mask;
adf6a681 306 int irq = src->irq;
cfcefe01
KM
307 int id = rsnd_mod_id(mod);
308
309 sys_int_val =
310 sys_int_mask = OUF_SRC(id);
311 int_val = 0x3300;
312
313 /*
314 * IRQ is not supported on non-DT
315 * see
75916f65 316 * rsnd_src_probe_()
cfcefe01
KM
317 */
318 if ((irq <= 0) || !enable) {
319 sys_int_val = 0;
320 int_val = 0;
321 }
322
1a1bf58a
KM
323 /*
324 * WORKAROUND
325 *
ab2049f9 326 * ignore over flow error when rsnd_src_sync_is_enabled()
1a1bf58a 327 */
ab2049f9 328 if (rsnd_src_sync_is_enabled(mod))
1a1bf58a
KM
329 sys_int_val = sys_int_val & 0xffff;
330
cfcefe01
KM
331 rsnd_mod_write(mod, SRC_INT_ENABLE0, int_val);
332 rsnd_mod_bset(mod, SCU_SYS_INT_EN0, sys_int_mask, sys_int_val);
333 rsnd_mod_bset(mod, SCU_SYS_INT_EN1, sys_int_mask, sys_int_val);
b5b442ab
KM
334
335 return 0;
cfcefe01
KM
336}
337
8cc225f7 338static void rsnd_src_status_clear(struct rsnd_mod *mod)
cfcefe01
KM
339{
340 u32 val = OUF_SRC(rsnd_mod_id(mod));
341
42b197e7
KM
342 rsnd_mod_write(mod, SCU_SYS_STATUS0, val);
343 rsnd_mod_write(mod, SCU_SYS_STATUS1, val);
cfcefe01
KM
344}
345
6a25c8da 346static bool rsnd_src_error_occurred(struct rsnd_mod *mod)
cfcefe01 347{
1a1bf58a 348 u32 val0, val1;
cfcefe01
KM
349 bool ret = false;
350
1a1bf58a
KM
351 val0 = val1 = OUF_SRC(rsnd_mod_id(mod));
352
353 /*
354 * WORKAROUND
355 *
ab2049f9 356 * ignore over flow error when rsnd_src_sync_is_enabled()
1a1bf58a 357 */
ab2049f9 358 if (rsnd_src_sync_is_enabled(mod))
1a1bf58a
KM
359 val0 = val0 & 0xffff;
360
361 if ((rsnd_mod_read(mod, SCU_SYS_STATUS0) & val0) ||
6a25c8da 362 (rsnd_mod_read(mod, SCU_SYS_STATUS1) & val1))
cfcefe01 363 ret = true;
cfcefe01 364
cfcefe01
KM
365 return ret;
366}
367
75916f65
KM
368static int rsnd_src_start(struct rsnd_mod *mod,
369 struct rsnd_dai_stream *io,
370 struct rsnd_priv *priv)
cfcefe01 371{
1a1bf58a
KM
372 u32 val;
373
374 /*
375 * WORKAROUND
376 *
377 * Enable SRC output if you want to use sync convert together with DVC
378 */
ab2049f9 379 val = (rsnd_io_to_mod_dvc(io) && !rsnd_src_sync_is_enabled(mod)) ?
1a1bf58a 380 0x01 : 0x11;
cfcefe01
KM
381
382 rsnd_mod_write(mod, SRC_CTRL, val);
383
cfcefe01
KM
384 return 0;
385}
386
75916f65
KM
387static int rsnd_src_stop(struct rsnd_mod *mod,
388 struct rsnd_dai_stream *io,
389 struct rsnd_priv *priv)
cfcefe01 390{
31739a68 391 rsnd_mod_write(mod, SRC_CTRL, 0);
cfcefe01 392
75916f65
KM
393 return 0;
394}
395
396static int rsnd_src_init(struct rsnd_mod *mod,
397 struct rsnd_dai_stream *io,
398 struct rsnd_priv *priv)
399{
400 struct rsnd_src *src = rsnd_mod_to_src(mod);
cfcefe01 401
ef30da1c
KM
402 /* reset sync convert_rate */
403 src->sync.val = 0;
404
75916f65
KM
405 rsnd_mod_power_on(mod);
406
98efeeae 407 rsnd_src_activation(mod);
75916f65
KM
408
409 rsnd_src_set_convert_rate(io, mod);
410
8cc225f7 411 rsnd_src_status_clear(mod);
75916f65 412
75916f65 413 return 0;
cfcefe01
KM
414}
415
75916f65
KM
416static int rsnd_src_quit(struct rsnd_mod *mod,
417 struct rsnd_dai_stream *io,
418 struct rsnd_priv *priv)
b761bf27 419{
75916f65 420 struct rsnd_src *src = rsnd_mod_to_src(mod);
75916f65 421
475a361a
KM
422 rsnd_src_halt(mod);
423
75916f65
KM
424 rsnd_mod_power_off(mod);
425
75916f65
KM
426 /* reset sync convert_rate */
427 src->sync.val = 0;
428
429 return 0;
b761bf27
KM
430}
431
75916f65
KM
432static void __rsnd_src_interrupt(struct rsnd_mod *mod,
433 struct rsnd_dai_stream *io)
cfcefe01 434{
02299d98 435 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
6a25c8da 436 bool stop = false;
02299d98
KM
437
438 spin_lock(&priv->lock);
cfcefe01 439
02299d98 440 /* ignore all cases if not working */
d5bbe7de 441 if (!rsnd_io_is_working(io))
75916f65 442 goto rsnd_src_interrupt_out;
cfcefe01 443
6a25c8da
KM
444 if (rsnd_src_error_occurred(mod))
445 stop = true;
88c61cff 446
8cc225f7 447 rsnd_src_status_clear(mod);
75916f65 448rsnd_src_interrupt_out:
8cc225f7 449
02299d98 450 spin_unlock(&priv->lock);
6a25c8da
KM
451
452 if (stop)
453 snd_pcm_stop_xrun(io->substream);
88c61cff
KM
454}
455
75916f65 456static irqreturn_t rsnd_src_interrupt(int irq, void *data)
88c61cff
KM
457{
458 struct rsnd_mod *mod = data;
459
75916f65 460 rsnd_mod_interrupt(mod, __rsnd_src_interrupt);
cfcefe01
KM
461
462 return IRQ_HANDLED;
463}
464
75916f65
KM
465static int rsnd_src_probe_(struct rsnd_mod *mod,
466 struct rsnd_dai_stream *io,
467 struct rsnd_priv *priv)
76c6fb5c 468{
ba9c949f 469 struct rsnd_src *src = rsnd_mod_to_src(mod);
76c6fb5c 470 struct device *dev = rsnd_priv_to_dev(priv);
adf6a681 471 int irq = src->irq;
76c6fb5c 472 int ret;
76c6fb5c 473
cfcefe01
KM
474 if (irq > 0) {
475 /*
476 * IRQ is not supported on non-DT
477 * see
b5b442ab 478 * rsnd_src_irq()
cfcefe01
KM
479 */
480 ret = devm_request_irq(dev, irq,
75916f65 481 rsnd_src_interrupt,
cfcefe01
KM
482 IRQF_SHARED,
483 dev_name(dev), mod);
484 if (ret)
b543b52a 485 return ret;
cfcefe01
KM
486 }
487
b99305d2 488 ret = rsnd_dma_attach(io, mod, &src->dma);
8aefda50 489
76c6fb5c
KM
490 return ret;
491}
492
75916f65 493static int rsnd_src_pcm_new(struct rsnd_mod *mod,
2c0fac19 494 struct rsnd_dai_stream *io,
43cb6954
KM
495 struct snd_soc_pcm_runtime *rtd)
496{
43cb6954
KM
497 struct rsnd_src *src = rsnd_mod_to_src(mod);
498 int ret;
499
500 /*
501 * enable SRC sync convert if possible
502 */
503
7115cb91 504 /*
61a219fe
KM
505 * It can't use SRC Synchronous convert
506 * when Capture if it uses CMD
7115cb91 507 */
61a219fe 508 if (rsnd_io_to_mod_cmd(io) && !rsnd_io_is_play(io))
7115cb91
KM
509 return 0;
510
43cb6954
KM
511 /*
512 * enable sync convert
513 */
b65a7ccc 514 ret = rsnd_kctrl_new_s(mod, io, rtd,
43cb6954
KM
515 rsnd_io_is_play(io) ?
516 "SRC Out Rate Switch" :
517 "SRC In Rate Switch",
75916f65 518 rsnd_src_set_convert_rate,
43cb6954
KM
519 &src->sen, 1);
520 if (ret < 0)
521 return ret;
522
b65a7ccc 523 ret = rsnd_kctrl_new_s(mod, io, rtd,
43cb6954
KM
524 rsnd_io_is_play(io) ?
525 "SRC Out Rate" :
526 "SRC In Rate",
75916f65 527 rsnd_src_set_convert_rate,
43cb6954
KM
528 &src->sync, 192000);
529
530 return ret;
531}
532
75916f65 533static struct rsnd_mod_ops rsnd_src_ops = {
8aefda50 534 .name = SRC_NAME,
72adc61f 535 .dma_req = rsnd_src_dma_req,
75916f65
KM
536 .probe = rsnd_src_probe_,
537 .init = rsnd_src_init,
538 .quit = rsnd_src_quit,
539 .start = rsnd_src_start,
540 .stop = rsnd_src_stop,
b5b442ab 541 .irq = rsnd_src_irq,
3b7843ff 542 .hw_params = rsnd_src_hw_params,
75916f65 543 .pcm_new = rsnd_src_pcm_new,
629509c5
KM
544};
545
ba9c949f 546struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id)
07539c1d 547{
ba9c949f 548 if (WARN_ON(id < 0 || id >= rsnd_src_nr(priv)))
8b14719b 549 id = 0;
07539c1d 550
adf6a681 551 return rsnd_mod_get(rsnd_src_get(priv, id));
90e8e50f
KM
552}
553
2ea6b074 554int rsnd_src_probe(struct rsnd_priv *priv)
07539c1d 555{
adf6a681
KM
556 struct device_node *node;
557 struct device_node *np;
07539c1d 558 struct device *dev = rsnd_priv_to_dev(priv);
ba9c949f 559 struct rsnd_src *src;
ef749400 560 struct clk *clk;
ba9c949f 561 char name[RSND_SRC_NAME_SIZE];
2f78dd7f 562 int i, nr, ret;
07539c1d 563
e8e7b7bd
KM
564 /* This driver doesn't support Gen1 at this point */
565 if (rsnd_is_gen1(priv))
566 return 0;
033e7ed8 567
adf6a681
KM
568 node = rsnd_src_of_node(priv);
569 if (!node)
570 return 0; /* not used is not error */
90e8e50f 571
adf6a681
KM
572 nr = of_get_child_count(node);
573 if (!nr) {
574 ret = -EINVAL;
575 goto rsnd_src_probe_done;
576 }
389933d9 577
ba9c949f 578 src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
adf6a681
KM
579 if (!src) {
580 ret = -ENOMEM;
581 goto rsnd_src_probe_done;
582 }
07539c1d 583
ba9c949f
KM
584 priv->src_nr = nr;
585 priv->src = src;
07539c1d 586
adf6a681
KM
587 i = 0;
588 for_each_child_of_node(node, np) {
de196515
SS
589 if (!of_device_is_available(np))
590 goto skip;
591
adf6a681
KM
592 src = rsnd_src_get(priv, i);
593
8aefda50
KM
594 snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
595 SRC_NAME, i);
ef749400 596
adf6a681
KM
597 src->irq = irq_of_parse_and_map(np, 0);
598 if (!src->irq) {
599 ret = -EINVAL;
600 goto rsnd_src_probe_done;
601 }
ef749400 602
adf6a681
KM
603 clk = devm_clk_get(dev, name);
604 if (IS_ERR(clk)) {
605 ret = PTR_ERR(clk);
606 goto rsnd_src_probe_done;
607 }
07539c1d 608
e8e7b7bd 609 ret = rsnd_mod_init(priv, rsnd_mod_get(src),
5ba17b42
KM
610 &rsnd_src_ops, clk, rsnd_mod_get_status,
611 RSND_MOD_SRC, i);
2f78dd7f 612 if (ret)
adf6a681
KM
613 goto rsnd_src_probe_done;
614
de196515 615skip:
adf6a681 616 i++;
374a5281 617 }
07539c1d 618
adf6a681
KM
619 ret = 0;
620
621rsnd_src_probe_done:
622 of_node_put(node);
623
624 return ret;
07539c1d 625}
2f78dd7f 626
2ea6b074 627void rsnd_src_remove(struct rsnd_priv *priv)
2f78dd7f
KM
628{
629 struct rsnd_src *src;
630 int i;
631
632 for_each_rsnd_src(src, priv, i) {
b76e218a 633 rsnd_mod_quit(rsnd_mod_get(src));
2f78dd7f
KM
634 }
635}