1 // SPDX-License-Identifier: GPL-2.0
3 // Renesas R-Car SRU/SCU/SSIU/SSI support
5 // Copyright (C) 2013 Renesas Solutions Corp.
6 // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
9 // Kuninori Morimoto <morimoto.kuninori@renesas.com>
12 * Renesas R-Car sound device structure
16 * SRU : Sound Routing Unit
17 * - SRC : Sampling Rate Converter
19 * - CTU : Channel Count Conversion Unit
21 * - DVC : Digital Volume and Mute Function
22 * - SSI : Serial Sound Interface
26 * SCU : Sampling Rate Converter Unit
27 * - SRC : Sampling Rate Converter
29 * - CTU : Channel Count Conversion Unit
31 * - DVC : Digital Volume and Mute Function
32 * SSIU : Serial Sound Interface Unit
33 * - SSI : Serial Sound Interface
41 * | ** this depends on Gen1/Gen2
45 * | ** these depend on data path
46 * | ** gen and platform data control it
50 * | +- playback -> [mod] -> [mod] -> [mod] -> ...
53 * | +- capture -> [mod] -> [mod] -> [mod] -> ...
57 * | +- playback -> [mod] -> [mod] -> [mod] -> ...
60 * | +- capture -> [mod] -> [mod] -> [mod] -> ...
63 * | ** these control ssi
72 * | ** these control src
82 * for_each_rsnd_dai(xx, priv, xx)
83 * rdai[0] => rdai[1] => rdai[2] => ...
85 * for_each_rsnd_mod(xx, rdai, xx)
86 * [mod] => [mod] => [mod] => ...
88 * rsnd_dai_call(xxx, fn )
89 * [mod]->fn() -> [mod]->fn() -> [mod]->fn()...
94 * you can enable below define if you don't need
95 * DAI status debug message when debugging
96 * see rsnd_dbg_dai_call()
98 * #define RSND_DEBUG_NO_DAI_CALL 1
101 #include <linux/pm_runtime.h>
104 #define RSND_RATES SNDRV_PCM_RATE_8000_192000
105 #define RSND_FMTS (SNDRV_PCM_FMTBIT_S8 |\
106 SNDRV_PCM_FMTBIT_S16_LE |\
107 SNDRV_PCM_FMTBIT_S24_LE)
109 static const struct of_device_id rsnd_of_match[] = {
110 { .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 },
111 { .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 },
112 { .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 },
113 /* Special Handling */
114 { .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) },
117 MODULE_DEVICE_TABLE(of, rsnd_of_match);
122 void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type)
124 if (mod->type != type) {
125 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
126 struct device *dev = rsnd_priv_to_dev(priv);
128 dev_warn(dev, "%s is not your expected module\n",
133 struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
134 struct rsnd_mod *mod)
136 if (!mod || !mod->ops || !mod->ops->dma_req)
139 return mod->ops->dma_req(io, mod);
142 #define MOD_NAME_NUM 5
143 #define MOD_NAME_SIZE 16
144 char *rsnd_mod_name(struct rsnd_mod *mod)
146 static char names[MOD_NAME_NUM][MOD_NAME_SIZE];
148 char *name = names[num];
151 if (num >= MOD_NAME_NUM)
155 * Let's use same char to avoid pointlessness memory
156 * Thus, rsnd_mod_name() should be used immediately
159 if ((mod)->ops->id_sub) {
160 snprintf(name, MOD_NAME_SIZE, "%s[%d%d]",
163 rsnd_mod_id_sub(mod));
165 snprintf(name, MOD_NAME_SIZE, "%s[%d]",
173 u32 *rsnd_mod_get_status(struct rsnd_mod *mod,
174 struct rsnd_dai_stream *io,
175 enum rsnd_mod_type type)
180 int rsnd_mod_id_raw(struct rsnd_mod *mod)
185 int rsnd_mod_id(struct rsnd_mod *mod)
188 return (mod)->ops->id(mod);
190 return rsnd_mod_id_raw(mod);
193 int rsnd_mod_id_sub(struct rsnd_mod *mod)
195 if ((mod)->ops->id_sub)
196 return (mod)->ops->id_sub(mod);
201 int rsnd_mod_init(struct rsnd_priv *priv,
202 struct rsnd_mod *mod,
203 struct rsnd_mod_ops *ops,
205 enum rsnd_mod_type type,
208 int ret = clk_prepare(clk);
222 void rsnd_mod_quit(struct rsnd_mod *mod)
224 clk_unprepare(mod->clk);
228 void rsnd_mod_interrupt(struct rsnd_mod *mod,
229 void (*callback)(struct rsnd_mod *mod,
230 struct rsnd_dai_stream *io))
232 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
233 struct rsnd_dai_stream *io;
234 struct rsnd_dai *rdai;
237 for_each_rsnd_dai(rdai, priv, i) {
238 io = &rdai->playback;
239 if (mod == io->mod[mod->type])
243 if (mod == io->mod[mod->type])
248 int rsnd_io_is_working(struct rsnd_dai_stream *io)
250 /* see rsnd_dai_stream_init/quit() */
252 return snd_pcm_running(io->substream);
257 int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io,
258 struct snd_pcm_hw_params *params)
260 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
263 * params will be added when refine
265 * __rsnd_soc_hw_rule_rate()
266 * __rsnd_soc_hw_rule_channels()
269 return params_channels(params);
271 return runtime->channels;
274 int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io,
275 struct snd_pcm_hw_params *params)
277 int chan = rsnd_runtime_channel_original_with_params(io, params);
278 struct rsnd_mod *ctu_mod = rsnd_io_to_mod_ctu(io);
281 u32 converted_chan = rsnd_io_converted_chan(io);
286 * converted_chan will be used for CTU,
288 * User shouldn't use CTU with TDM Split mode.
290 if (rsnd_runtime_is_tdm_split(io)) {
291 struct device *dev = rsnd_priv_to_dev(rsnd_io_to_priv(io));
293 dev_err(dev, "CTU and TDM Split should be used\n");
297 return converted_chan;
303 int rsnd_channel_normalization(int chan)
305 if ((chan > 8) || (chan < 0))
308 /* TDM Extend Mode needs 8ch */
315 int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io,
316 struct snd_pcm_hw_params *params)
318 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
319 int chan = rsnd_io_is_play(io) ?
320 rsnd_runtime_channel_after_ctu_with_params(io, params) :
321 rsnd_runtime_channel_original_with_params(io, params);
324 if (rsnd_runtime_is_multi_ssi(io))
325 chan /= rsnd_rdai_ssi_lane_get(rdai);
327 return rsnd_channel_normalization(chan);
330 int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io)
332 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
333 int lane = rsnd_rdai_ssi_lane_get(rdai);
334 int chan = rsnd_io_is_play(io) ?
335 rsnd_runtime_channel_after_ctu(io) :
336 rsnd_runtime_channel_original(io);
338 return (chan > 2) && (lane > 1);
341 int rsnd_runtime_is_tdm(struct rsnd_dai_stream *io)
343 return rsnd_runtime_channel_for_ssi(io) >= 6;
346 int rsnd_runtime_is_tdm_split(struct rsnd_dai_stream *io)
348 return !!rsnd_flags_has(io, RSND_STREAM_TDM_SPLIT);
354 u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
356 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
357 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
358 struct device *dev = rsnd_priv_to_dev(priv);
360 switch (snd_pcm_format_width(runtime->format)) {
369 dev_warn(dev, "not supported sample bits\n");
377 u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io)
379 struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io);
380 struct rsnd_mod *target;
381 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
384 * *Hardware* L/R and *Software* L/R are inverted for 16bit data.
388 * We need to care about inversion timing to control
389 * Playback/Capture correctly.
390 * The point is [DVC] needs *Hardware* L/R, [MEM] needs *Software* L/R
392 * sL/R : software L/R
393 * hL/R : hardware L/R
394 * (*) : conversion timing
397 * sL/R (*) hL/R hL/R hL/R hL/R hL/R
398 * [MEM] -> [SRC] -> [DVC] -> [CMD] -> [SSIU] -> [SSI] -> codec
401 * hL/R hL/R hL/R hL/R hL/R (*) sL/R
402 * codec -> [SSI] -> [SSIU] -> [SRC] -> [DVC] -> [CMD] -> [MEM]
404 if (rsnd_io_is_play(io)) {
405 struct rsnd_mod *src = rsnd_io_to_mod_src(io);
407 target = src ? src : ssiu;
409 struct rsnd_mod *cmd = rsnd_io_to_mod_cmd(io);
411 target = cmd ? cmd : ssiu;
414 /* Non target mod or non 16bit needs normal DALIGN */
415 if ((snd_pcm_format_width(runtime->format) != 16) ||
418 /* Target mod needs inverted DALIGN when 16bit */
423 u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
425 enum rsnd_mod_type playback_mods[] = {
430 enum rsnd_mod_type capture_mods[] = {
435 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
436 struct rsnd_mod *tmod = NULL;
437 enum rsnd_mod_type *mods =
438 rsnd_io_is_play(io) ?
439 playback_mods : capture_mods;
443 * This is needed for 24bit data
444 * We need to shift 8bit
446 * Linux 24bit data is located as 0x00******
447 * HW 24bit data is located as 0x******00
450 if (snd_pcm_format_width(runtime->format) != 24)
453 for (i = 0; i < ARRAY_SIZE(playback_mods); i++) {
454 tmod = rsnd_io_to_mod(io, mods[i]);
462 if (rsnd_io_is_play(io))
463 return (0 << 20) | /* shift to Left */
464 (8 << 16); /* 8bit */
466 return (1 << 20) | /* shift to Right */
467 (8 << 16); /* 8bit */
473 struct rsnd_mod *rsnd_mod_next(int *iterator,
474 struct rsnd_dai_stream *io,
475 enum rsnd_mod_type *array,
478 struct rsnd_mod *mod;
479 enum rsnd_mod_type type;
480 int max = array ? array_size : RSND_MOD_MAX;
482 for (; *iterator < max; (*iterator)++) {
483 type = (array) ? array[*iterator] : *iterator;
484 mod = rsnd_io_to_mod(io, type);
492 static enum rsnd_mod_type rsnd_mod_sequence[][RSND_MOD_MAX] = {
526 static int rsnd_status_update(u32 *status,
527 int shift, int add, int timing)
529 u32 mask = 0xF << shift;
530 u8 val = (*status >> shift) & 0xF;
531 u8 next_val = (val + add) & 0xF;
532 int func_call = (val == timing);
534 if (next_val == 0xF) /* underflow case */
537 *status = (*status & ~mask) + (next_val << shift);
542 #define rsnd_dai_call(fn, io, param...) \
544 struct device *dev = rsnd_priv_to_dev(rsnd_io_to_priv(io)); \
545 struct rsnd_mod *mod; \
546 int is_play = rsnd_io_is_play(io); \
548 enum rsnd_mod_type *types = rsnd_mod_sequence[is_play]; \
549 for_each_rsnd_mod_arrays(i, mod, io, types, RSND_MOD_MAX) { \
551 u32 *status = mod->ops->get_status(mod, io, types[i]); \
552 int func_call = rsnd_status_update(status, \
553 __rsnd_mod_shift_##fn, \
554 __rsnd_mod_add_##fn, \
555 __rsnd_mod_call_##fn); \
556 rsnd_dbg_dai_call(dev, "%s\t0x%08x %s\n", \
557 rsnd_mod_name(mod), *status, \
558 (func_call && (mod)->ops->fn) ? #fn : ""); \
559 if (func_call && (mod)->ops->fn) \
560 tmp = (mod)->ops->fn(mod, io, param); \
561 if (tmp && (tmp != -EPROBE_DEFER)) \
562 dev_err(dev, "%s : %s error %d\n", \
563 rsnd_mod_name(mod), #fn, tmp); \
569 int rsnd_dai_connect(struct rsnd_mod *mod,
570 struct rsnd_dai_stream *io,
571 enum rsnd_mod_type type)
573 struct rsnd_priv *priv;
579 if (io->mod[type] == mod)
585 priv = rsnd_mod_to_priv(mod);
586 dev = rsnd_priv_to_dev(priv);
590 dev_dbg(dev, "%s is connected to io (%s)\n",
592 rsnd_io_is_play(io) ? "Playback" : "Capture");
597 static void rsnd_dai_disconnect(struct rsnd_mod *mod,
598 struct rsnd_dai_stream *io,
599 enum rsnd_mod_type type)
601 io->mod[type] = NULL;
604 int rsnd_rdai_channels_ctrl(struct rsnd_dai *rdai,
607 if (max_channels > 0)
608 rdai->max_channels = max_channels;
610 return rdai->max_channels;
613 int rsnd_rdai_ssi_lane_ctrl(struct rsnd_dai *rdai,
617 rdai->ssi_lane = ssi_lane;
619 return rdai->ssi_lane;
622 int rsnd_rdai_width_ctrl(struct rsnd_dai *rdai, int width)
625 rdai->chan_width = width;
627 return rdai->chan_width;
630 struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id)
632 if ((id < 0) || (id >= rsnd_rdai_nr(priv)))
635 return priv->rdai + id;
638 static struct snd_soc_dai_driver
639 *rsnd_daidrv_get(struct rsnd_priv *priv, int id)
641 if ((id < 0) || (id >= rsnd_rdai_nr(priv)))
644 return priv->daidrv + id;
647 #define rsnd_dai_to_priv(dai) snd_soc_dai_get_drvdata(dai)
648 static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai)
650 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
652 return rsnd_rdai_get(priv, dai->id);
656 * rsnd_soc_dai functions
658 void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io)
660 struct snd_pcm_substream *substream = io->substream;
663 * this function should be called...
665 * - if rsnd_dai_pointer_update() returns true
666 * - without spin lock
669 snd_pcm_period_elapsed(substream);
672 static void rsnd_dai_stream_init(struct rsnd_dai_stream *io,
673 struct snd_pcm_substream *substream)
675 io->substream = substream;
678 static void rsnd_dai_stream_quit(struct rsnd_dai_stream *io)
680 io->substream = NULL;
684 struct snd_soc_dai *rsnd_substream_to_dai(struct snd_pcm_substream *substream)
686 struct snd_soc_pcm_runtime *rtd = substream->private_data;
692 struct rsnd_dai_stream *rsnd_rdai_to_io(struct rsnd_dai *rdai,
693 struct snd_pcm_substream *substream)
695 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
696 return &rdai->playback;
698 return &rdai->capture;
701 static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
702 struct snd_soc_dai *dai)
704 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
705 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
706 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
710 spin_lock_irqsave(&priv->lock, flags);
713 case SNDRV_PCM_TRIGGER_START:
714 case SNDRV_PCM_TRIGGER_RESUME:
715 ret = rsnd_dai_call(init, io, priv);
717 goto dai_trigger_end;
719 ret = rsnd_dai_call(start, io, priv);
721 goto dai_trigger_end;
723 ret = rsnd_dai_call(irq, io, priv, 1);
725 goto dai_trigger_end;
728 case SNDRV_PCM_TRIGGER_STOP:
729 case SNDRV_PCM_TRIGGER_SUSPEND:
730 ret = rsnd_dai_call(irq, io, priv, 0);
732 ret |= rsnd_dai_call(stop, io, priv);
734 ret |= rsnd_dai_call(quit, io, priv);
742 spin_unlock_irqrestore(&priv->lock, flags);
747 static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
749 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
751 /* set master/slave audio interface */
752 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
753 case SND_SOC_DAIFMT_CBM_CFM:
754 rdai->clk_master = 0;
756 case SND_SOC_DAIFMT_CBS_CFS:
757 rdai->clk_master = 1; /* codec is slave, cpu is master */
764 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
765 case SND_SOC_DAIFMT_I2S:
767 rdai->data_alignment = 0;
768 rdai->frm_clk_inv = 0;
770 case SND_SOC_DAIFMT_LEFT_J:
771 case SND_SOC_DAIFMT_DSP_B:
773 rdai->data_alignment = 0;
774 rdai->frm_clk_inv = 1;
776 case SND_SOC_DAIFMT_RIGHT_J:
778 rdai->data_alignment = 1;
779 rdai->frm_clk_inv = 1;
781 case SND_SOC_DAIFMT_DSP_A:
783 rdai->data_alignment = 0;
784 rdai->frm_clk_inv = 1;
788 /* set clock inversion */
789 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
790 case SND_SOC_DAIFMT_NB_IF:
791 rdai->frm_clk_inv = !rdai->frm_clk_inv;
793 case SND_SOC_DAIFMT_IB_NF:
794 rdai->bit_clk_inv = !rdai->bit_clk_inv;
796 case SND_SOC_DAIFMT_IB_IF:
797 rdai->bit_clk_inv = !rdai->bit_clk_inv;
798 rdai->frm_clk_inv = !rdai->frm_clk_inv;
800 case SND_SOC_DAIFMT_NB_NF:
808 static int rsnd_soc_set_dai_tdm_slot(struct snd_soc_dai *dai,
809 u32 tx_mask, u32 rx_mask,
810 int slots, int slot_width)
812 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
813 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
814 struct device *dev = rsnd_priv_to_dev(priv);
816 switch (slot_width) {
831 /* TDM Extend Mode */
832 rsnd_rdai_channels_set(rdai, slots);
833 rsnd_rdai_ssi_lane_set(rdai, 1);
834 rsnd_rdai_width_set(rdai, slot_width);
837 dev_err(dev, "unsupported TDM slots (%d)\n", slots);
844 static unsigned int rsnd_soc_hw_channels_list[] = {
848 static unsigned int rsnd_soc_hw_rate_list[] = {
863 static int rsnd_soc_hw_rule(struct rsnd_dai *rdai,
864 unsigned int *list, int list_num,
865 struct snd_interval *baseline, struct snd_interval *iv)
867 struct snd_interval p;
871 snd_interval_any(&p);
875 for (i = 0; i < list_num; i++) {
877 if (!snd_interval_test(iv, list[i]))
880 rate = rsnd_ssi_clk_query(rdai,
881 baseline->min, list[i], NULL);
883 p.min = min(p.min, list[i]);
884 p.max = max(p.max, list[i]);
887 rate = rsnd_ssi_clk_query(rdai,
888 baseline->max, list[i], NULL);
890 p.min = min(p.min, list[i]);
891 p.max = max(p.max, list[i]);
895 return snd_interval_refine(iv, &p);
898 static int rsnd_soc_hw_rule_rate(struct snd_pcm_hw_params *params,
899 struct snd_pcm_hw_rule *rule)
901 struct snd_interval *ic_ = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
902 struct snd_interval *ir = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
903 struct snd_interval ic;
904 struct rsnd_dai_stream *io = rule->private;
905 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
908 * possible sampling rate limitation is same as
909 * 2ch if it supports multi ssi
910 * and same as 8ch if TDM 6ch (see rsnd_ssi_config_init())
914 ic.max = rsnd_runtime_channel_for_ssi_with_params(io, params);
916 return rsnd_soc_hw_rule(rdai, rsnd_soc_hw_rate_list,
917 ARRAY_SIZE(rsnd_soc_hw_rate_list),
921 static int rsnd_soc_hw_rule_channels(struct snd_pcm_hw_params *params,
922 struct snd_pcm_hw_rule *rule)
924 struct snd_interval *ic_ = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
925 struct snd_interval *ir = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
926 struct snd_interval ic;
927 struct rsnd_dai_stream *io = rule->private;
928 struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
931 * possible sampling rate limitation is same as
932 * 2ch if it supports multi ssi
933 * and same as 8ch if TDM 6ch (see rsnd_ssi_config_init())
937 ic.max = rsnd_runtime_channel_for_ssi_with_params(io, params);
939 return rsnd_soc_hw_rule(rdai, rsnd_soc_hw_channels_list,
940 ARRAY_SIZE(rsnd_soc_hw_channels_list),
944 static const struct snd_pcm_hardware rsnd_pcm_hardware = {
945 .info = SNDRV_PCM_INFO_INTERLEAVED |
946 SNDRV_PCM_INFO_MMAP |
947 SNDRV_PCM_INFO_MMAP_VALID,
948 .buffer_bytes_max = 64 * 1024,
949 .period_bytes_min = 32,
950 .period_bytes_max = 8192,
956 static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream,
957 struct snd_soc_dai *dai)
959 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
960 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
961 struct snd_pcm_hw_constraint_list *constraint = &rdai->constraint;
962 struct snd_pcm_runtime *runtime = substream->runtime;
963 unsigned int max_channels = rsnd_rdai_channels_get(rdai);
966 rsnd_dai_stream_init(io, substream);
970 * It depends on Platform design
972 constraint->list = rsnd_soc_hw_channels_list;
973 constraint->count = 0;
974 constraint->mask = 0;
976 for (i = 0; i < ARRAY_SIZE(rsnd_soc_hw_channels_list); i++) {
977 if (rsnd_soc_hw_channels_list[i] > max_channels)
979 constraint->count = i + 1;
982 snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware);
984 snd_pcm_hw_constraint_list(runtime, 0,
985 SNDRV_PCM_HW_PARAM_CHANNELS, constraint);
987 snd_pcm_hw_constraint_integer(runtime,
988 SNDRV_PCM_HW_PARAM_PERIODS);
991 * Sampling Rate / Channel Limitation
992 * It depends on Clock Master Mode
994 if (rsnd_rdai_is_clk_master(rdai)) {
995 int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
997 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
998 rsnd_soc_hw_rule_rate,
999 is_play ? &rdai->playback : &rdai->capture,
1000 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
1001 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1002 rsnd_soc_hw_rule_channels,
1003 is_play ? &rdai->playback : &rdai->capture,
1004 SNDRV_PCM_HW_PARAM_RATE, -1);
1010 static void rsnd_soc_dai_shutdown(struct snd_pcm_substream *substream,
1011 struct snd_soc_dai *dai)
1013 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1014 struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
1015 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
1018 * call rsnd_dai_call without spinlock
1020 rsnd_dai_call(cleanup, io, priv);
1022 rsnd_dai_stream_quit(io);
1025 static int rsnd_soc_dai_prepare(struct snd_pcm_substream *substream,
1026 struct snd_soc_dai *dai)
1028 struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
1029 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1030 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
1032 return rsnd_dai_call(prepare, io, priv);
1035 static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
1036 .startup = rsnd_soc_dai_startup,
1037 .shutdown = rsnd_soc_dai_shutdown,
1038 .trigger = rsnd_soc_dai_trigger,
1039 .set_fmt = rsnd_soc_dai_set_fmt,
1040 .set_tdm_slot = rsnd_soc_set_dai_tdm_slot,
1041 .prepare = rsnd_soc_dai_prepare,
1044 static void rsnd_parse_tdm_split_mode(struct rsnd_priv *priv,
1045 struct rsnd_dai_stream *io,
1046 struct device_node *dai_np)
1048 struct device *dev = rsnd_priv_to_dev(priv);
1049 struct device_node *ssiu_np = rsnd_ssiu_of_node(priv);
1050 struct device_node *np;
1051 int is_play = rsnd_io_is_play(io);
1058 * This driver assumes that it is TDM Split mode
1059 * if it includes ssiu node
1062 struct device_node *node = is_play ?
1063 of_parse_phandle(dai_np, "playback", i) :
1064 of_parse_phandle(dai_np, "capture", i);
1070 for_each_child_of_node(ssiu_np, np) {
1072 rsnd_flags_set(io, RSND_STREAM_TDM_SPLIT);
1073 dev_dbg(dev, "%s is part of TDM Split\n", io->name);
1081 static void rsnd_parse_connect_simple(struct rsnd_priv *priv,
1082 struct rsnd_dai_stream *io,
1083 struct device_node *dai_np)
1085 if (!rsnd_io_to_mod_ssi(io))
1088 rsnd_parse_tdm_split_mode(priv, io, dai_np);
1091 static void rsnd_parse_connect_graph(struct rsnd_priv *priv,
1092 struct rsnd_dai_stream *io,
1093 struct device_node *endpoint)
1095 struct device *dev = rsnd_priv_to_dev(priv);
1096 struct device_node *remote_node = of_graph_get_remote_port_parent(endpoint);
1098 if (!rsnd_io_to_mod_ssi(io))
1102 if (strstr(remote_node->full_name, "hdmi@fead0000")) {
1103 rsnd_flags_set(io, RSND_STREAM_HDMI0);
1104 dev_dbg(dev, "%s connected to HDMI0\n", io->name);
1108 if (strstr(remote_node->full_name, "hdmi@feae0000")) {
1109 rsnd_flags_set(io, RSND_STREAM_HDMI1);
1110 dev_dbg(dev, "%s connected to HDMI1\n", io->name);
1113 rsnd_parse_tdm_split_mode(priv, io, endpoint);
1116 void rsnd_parse_connect_common(struct rsnd_dai *rdai,
1117 struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id),
1118 struct device_node *node,
1119 struct device_node *playback,
1120 struct device_node *capture)
1122 struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
1123 struct device_node *np;
1124 struct rsnd_mod *mod;
1131 for_each_child_of_node(node, np) {
1132 mod = mod_get(priv, i);
1134 rsnd_dai_connect(mod, &rdai->playback, mod->type);
1136 rsnd_dai_connect(mod, &rdai->capture, mod->type);
1143 static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv,
1146 struct device *dev = rsnd_priv_to_dev(priv);
1147 struct device_node *np = dev->of_node;
1148 struct device_node *dai_node;
1149 struct device_node *ret;
1154 * parse both previous dai (= rcar_sound,dai), and
1155 * graph dai (= ports/port)
1157 dai_node = of_get_child_by_name(np, RSND_NODE_DAI);
1160 goto of_node_compatible;
1165 dai_node = of_graph_get_next_endpoint(np, NULL);
1174 of_node_put(dai_node);
1180 #define PREALLOC_BUFFER (32 * 1024)
1181 #define PREALLOC_BUFFER_MAX (32 * 1024)
1183 static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
1184 struct rsnd_dai_stream *io,
1187 struct rsnd_priv *priv = rsnd_io_to_priv(io);
1188 struct device *dev = rsnd_priv_to_dev(priv);
1189 struct snd_pcm_substream *substream;
1192 * use Audio-DMAC dev if we can use IPMMU
1194 * rsnd_dmaen_attach()
1199 for (substream = rtd->pcm->streams[stream].substream;
1201 substream = substream->next) {
1202 snd_pcm_lib_preallocate_pages(substream,
1205 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1211 static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd,
1212 struct snd_soc_dai *dai)
1214 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1217 ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd);
1221 ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd);
1225 ret = rsnd_preallocate_pages(rtd, &rdai->playback,
1226 SNDRV_PCM_STREAM_PLAYBACK);
1230 ret = rsnd_preallocate_pages(rtd, &rdai->capture,
1231 SNDRV_PCM_STREAM_CAPTURE);
1238 static void __rsnd_dai_probe(struct rsnd_priv *priv,
1239 struct device_node *dai_np,
1242 struct device_node *playback, *capture;
1243 struct rsnd_dai_stream *io_playback;
1244 struct rsnd_dai_stream *io_capture;
1245 struct snd_soc_dai_driver *drv;
1246 struct rsnd_dai *rdai;
1247 struct device *dev = rsnd_priv_to_dev(priv);
1250 rdai = rsnd_rdai_get(priv, dai_i);
1251 drv = rsnd_daidrv_get(priv, dai_i);
1252 io_playback = &rdai->playback;
1253 io_capture = &rdai->capture;
1255 snprintf(rdai->name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", dai_i);
1258 drv->name = rdai->name;
1259 drv->ops = &rsnd_soc_dai_ops;
1260 drv->pcm_new = rsnd_pcm_new;
1262 snprintf(io_playback->name, RSND_DAI_NAME_SIZE,
1263 "DAI%d Playback", dai_i);
1264 drv->playback.rates = RSND_RATES;
1265 drv->playback.formats = RSND_FMTS;
1266 drv->playback.channels_min = 2;
1267 drv->playback.channels_max = 8;
1268 drv->playback.stream_name = io_playback->name;
1270 snprintf(io_capture->name, RSND_DAI_NAME_SIZE,
1271 "DAI%d Capture", dai_i);
1272 drv->capture.rates = RSND_RATES;
1273 drv->capture.formats = RSND_FMTS;
1274 drv->capture.channels_min = 2;
1275 drv->capture.channels_max = 8;
1276 drv->capture.stream_name = io_capture->name;
1278 io_playback->rdai = rdai;
1279 io_capture->rdai = rdai;
1280 rsnd_rdai_channels_set(rdai, 2); /* default 2ch */
1281 rsnd_rdai_ssi_lane_set(rdai, 1); /* default 1lane */
1282 rsnd_rdai_width_set(rdai, 32); /* default 32bit width */
1284 for (io_i = 0;; io_i++) {
1285 playback = of_parse_phandle(dai_np, "playback", io_i);
1286 capture = of_parse_phandle(dai_np, "capture", io_i);
1288 if (!playback && !capture)
1291 rsnd_parse_connect_ssi(rdai, playback, capture);
1292 rsnd_parse_connect_ssiu(rdai, playback, capture);
1293 rsnd_parse_connect_src(rdai, playback, capture);
1294 rsnd_parse_connect_ctu(rdai, playback, capture);
1295 rsnd_parse_connect_mix(rdai, playback, capture);
1296 rsnd_parse_connect_dvc(rdai, playback, capture);
1298 of_node_put(playback);
1299 of_node_put(capture);
1302 if (rsnd_ssi_is_pin_sharing(io_capture) ||
1303 rsnd_ssi_is_pin_sharing(io_playback)) {
1304 /* should have symmetric_rates if pin sharing */
1305 drv->symmetric_rates = 1;
1308 dev_dbg(dev, "%s (%s/%s)\n", rdai->name,
1309 rsnd_io_to_mod_ssi(io_playback) ? "play" : " -- ",
1310 rsnd_io_to_mod_ssi(io_capture) ? "capture" : " -- ");
1313 static int rsnd_dai_probe(struct rsnd_priv *priv)
1315 struct device_node *dai_node;
1316 struct device_node *dai_np;
1317 struct snd_soc_dai_driver *rdrv;
1318 struct device *dev = rsnd_priv_to_dev(priv);
1319 struct rsnd_dai *rdai;
1324 dai_node = rsnd_dai_of_node(priv, &is_graph);
1326 nr = of_graph_get_endpoint_count(dai_node);
1328 nr = of_get_child_count(dai_node);
1333 rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL);
1334 rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL);
1339 priv->daidrv = rdrv;
1347 for_each_endpoint_of_node(dai_node, dai_np) {
1348 __rsnd_dai_probe(priv, dai_np, dai_i);
1349 if (rsnd_is_gen3(priv)) {
1350 struct rsnd_dai *rdai = rsnd_rdai_get(priv, dai_i);
1352 rsnd_parse_connect_graph(priv, &rdai->playback, dai_np);
1353 rsnd_parse_connect_graph(priv, &rdai->capture, dai_np);
1358 for_each_child_of_node(dai_node, dai_np) {
1359 __rsnd_dai_probe(priv, dai_np, dai_i);
1360 if (rsnd_is_gen3(priv)) {
1361 struct rsnd_dai *rdai = rsnd_rdai_get(priv, dai_i);
1363 rsnd_parse_connect_simple(priv, &rdai->playback, dai_np);
1364 rsnd_parse_connect_simple(priv, &rdai->capture, dai_np);
1376 static int rsnd_hw_params(struct snd_pcm_substream *substream,
1377 struct snd_pcm_hw_params *hw_params)
1379 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
1380 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1381 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
1382 struct snd_soc_pcm_runtime *fe = substream->private_data;
1386 * rsnd assumes that it might be used under DPCM if user want to use
1387 * channel / rate convert. Then, rsnd should be FE.
1388 * And then, this function will be called *after* BE settings.
1389 * this means, each BE already has fixuped hw_params.
1391 * dpcm_fe_dai_hw_params()
1392 * dpcm_be_dai_hw_params()
1394 io->converted_rate = 0;
1395 io->converted_chan = 0;
1396 if (fe->dai_link->dynamic) {
1397 struct rsnd_priv *priv = rsnd_io_to_priv(io);
1398 struct device *dev = rsnd_priv_to_dev(priv);
1399 struct snd_soc_dpcm *dpcm;
1400 struct snd_pcm_hw_params *be_params;
1401 int stream = substream->stream;
1403 for_each_dpcm_be(fe, stream, dpcm) {
1404 be_params = &dpcm->hw_params;
1405 if (params_channels(hw_params) != params_channels(be_params))
1406 io->converted_chan = params_channels(be_params);
1407 if (params_rate(hw_params) != params_rate(be_params))
1408 io->converted_rate = params_rate(be_params);
1410 if (io->converted_chan)
1411 dev_dbg(dev, "convert channels = %d\n", io->converted_chan);
1412 if (io->converted_rate)
1413 dev_dbg(dev, "convert rate = %d\n", io->converted_rate);
1416 ret = rsnd_dai_call(hw_params, io, substream, hw_params);
1420 return snd_pcm_lib_malloc_pages(substream,
1421 params_buffer_bytes(hw_params));
1424 static int rsnd_hw_free(struct snd_pcm_substream *substream)
1426 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
1427 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1428 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
1431 ret = rsnd_dai_call(hw_free, io, substream);
1435 return snd_pcm_lib_free_pages(substream);
1438 static snd_pcm_uframes_t rsnd_pointer(struct snd_pcm_substream *substream)
1440 struct snd_soc_dai *dai = rsnd_substream_to_dai(substream);
1441 struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
1442 struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
1443 snd_pcm_uframes_t pointer = 0;
1445 rsnd_dai_call(pointer, io, &pointer);
1450 static const struct snd_pcm_ops rsnd_pcm_ops = {
1451 .ioctl = snd_pcm_lib_ioctl,
1452 .hw_params = rsnd_hw_params,
1453 .hw_free = rsnd_hw_free,
1454 .pointer = rsnd_pointer,
1460 static int rsnd_kctrl_info(struct snd_kcontrol *kctrl,
1461 struct snd_ctl_elem_info *uinfo)
1463 struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl);
1466 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1467 uinfo->count = cfg->size;
1468 uinfo->value.enumerated.items = cfg->max;
1469 if (uinfo->value.enumerated.item >= cfg->max)
1470 uinfo->value.enumerated.item = cfg->max - 1;
1471 strlcpy(uinfo->value.enumerated.name,
1472 cfg->texts[uinfo->value.enumerated.item],
1473 sizeof(uinfo->value.enumerated.name));
1475 uinfo->count = cfg->size;
1476 uinfo->value.integer.min = 0;
1477 uinfo->value.integer.max = cfg->max;
1478 uinfo->type = (cfg->max == 1) ?
1479 SNDRV_CTL_ELEM_TYPE_BOOLEAN :
1480 SNDRV_CTL_ELEM_TYPE_INTEGER;
1486 static int rsnd_kctrl_get(struct snd_kcontrol *kctrl,
1487 struct snd_ctl_elem_value *uc)
1489 struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl);
1492 for (i = 0; i < cfg->size; i++)
1494 uc->value.enumerated.item[i] = cfg->val[i];
1496 uc->value.integer.value[i] = cfg->val[i];
1501 static int rsnd_kctrl_put(struct snd_kcontrol *kctrl,
1502 struct snd_ctl_elem_value *uc)
1504 struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl);
1507 if (!cfg->accept(cfg->io))
1510 for (i = 0; i < cfg->size; i++) {
1512 change |= (uc->value.enumerated.item[i] != cfg->val[i]);
1513 cfg->val[i] = uc->value.enumerated.item[i];
1515 change |= (uc->value.integer.value[i] != cfg->val[i]);
1516 cfg->val[i] = uc->value.integer.value[i];
1520 if (change && cfg->update)
1521 cfg->update(cfg->io, cfg->mod);
1526 int rsnd_kctrl_accept_anytime(struct rsnd_dai_stream *io)
1531 int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io)
1533 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
1534 struct rsnd_priv *priv = rsnd_io_to_priv(io);
1535 struct device *dev = rsnd_priv_to_dev(priv);
1538 dev_warn(dev, "Can't update kctrl when idle\n");
1545 struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg)
1547 cfg->cfg.val = cfg->val;
1552 struct rsnd_kctrl_cfg *rsnd_kctrl_init_s(struct rsnd_kctrl_cfg_s *cfg)
1554 cfg->cfg.val = &cfg->val;
1559 const char * const volume_ramp_rate[] = {
1560 "128 dB/1 step", /* 00000 */
1561 "64 dB/1 step", /* 00001 */
1562 "32 dB/1 step", /* 00010 */
1563 "16 dB/1 step", /* 00011 */
1564 "8 dB/1 step", /* 00100 */
1565 "4 dB/1 step", /* 00101 */
1566 "2 dB/1 step", /* 00110 */
1567 "1 dB/1 step", /* 00111 */
1568 "0.5 dB/1 step", /* 01000 */
1569 "0.25 dB/1 step", /* 01001 */
1570 "0.125 dB/1 step", /* 01010 = VOLUME_RAMP_MAX_MIX */
1571 "0.125 dB/2 steps", /* 01011 */
1572 "0.125 dB/4 steps", /* 01100 */
1573 "0.125 dB/8 steps", /* 01101 */
1574 "0.125 dB/16 steps", /* 01110 */
1575 "0.125 dB/32 steps", /* 01111 */
1576 "0.125 dB/64 steps", /* 10000 */
1577 "0.125 dB/128 steps", /* 10001 */
1578 "0.125 dB/256 steps", /* 10010 */
1579 "0.125 dB/512 steps", /* 10011 */
1580 "0.125 dB/1024 steps", /* 10100 */
1581 "0.125 dB/2048 steps", /* 10101 */
1582 "0.125 dB/4096 steps", /* 10110 */
1583 "0.125 dB/8192 steps", /* 10111 = VOLUME_RAMP_MAX_DVC */
1586 int rsnd_kctrl_new(struct rsnd_mod *mod,
1587 struct rsnd_dai_stream *io,
1588 struct snd_soc_pcm_runtime *rtd,
1589 const unsigned char *name,
1590 int (*accept)(struct rsnd_dai_stream *io),
1591 void (*update)(struct rsnd_dai_stream *io,
1592 struct rsnd_mod *mod),
1593 struct rsnd_kctrl_cfg *cfg,
1594 const char * const *texts,
1598 struct snd_card *card = rtd->card->snd_card;
1599 struct snd_kcontrol *kctrl;
1600 struct snd_kcontrol_new knew = {
1601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1603 .info = rsnd_kctrl_info,
1605 .get = rsnd_kctrl_get,
1606 .put = rsnd_kctrl_put,
1611 * 1) Avoid duplicate register for DVC with MIX case
1612 * 2) Allow duplicate register for MIX
1613 * 3) re-register if card was rebinded
1615 list_for_each_entry(kctrl, &card->controls, list) {
1616 struct rsnd_kctrl_cfg *c = kctrl->private_data;
1622 if (size > RSND_MAX_CHANNELS)
1625 kctrl = snd_ctl_new1(&knew, cfg);
1629 ret = snd_ctl_add(card, kctrl);
1636 cfg->accept = accept;
1637 cfg->update = update;
1649 static const struct snd_soc_component_driver rsnd_soc_component = {
1650 .ops = &rsnd_pcm_ops,
1654 static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv,
1655 struct rsnd_dai_stream *io)
1659 ret = rsnd_dai_call(probe, io, priv);
1660 if (ret == -EAGAIN) {
1661 struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io);
1662 struct rsnd_mod *mod;
1666 * Fallback to PIO mode
1670 * call "remove" for SSI/SRC/DVC
1671 * SSI will be switch to PIO mode if it was DMA mode
1674 * rsnd_ssi_fallback()
1676 rsnd_dai_call(remove, io, priv);
1679 * remove all mod from io
1680 * and, re connect ssi
1682 for_each_rsnd_mod(i, mod, io)
1683 rsnd_dai_disconnect(mod, io, i);
1684 rsnd_dai_connect(ssi_mod, io, RSND_MOD_SSI);
1689 rsnd_dai_call(fallback, io, priv);
1693 * DAI has SSI which is PIO mode only now.
1695 ret = rsnd_dai_call(probe, io, priv);
1704 static int rsnd_probe(struct platform_device *pdev)
1706 struct rsnd_priv *priv;
1707 struct device *dev = &pdev->dev;
1708 struct rsnd_dai *rdai;
1709 int (*probe_func[])(struct rsnd_priv *priv) = {
1727 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
1732 priv->flags = (unsigned long)of_device_get_match_data(dev);
1733 spin_lock_init(&priv->lock);
1738 for (i = 0; i < ARRAY_SIZE(probe_func); i++) {
1739 ret = probe_func[i](priv);
1744 for_each_rsnd_dai(rdai, priv, i) {
1745 ret = rsnd_rdai_continuance_probe(priv, &rdai->playback);
1747 goto exit_snd_probe;
1749 ret = rsnd_rdai_continuance_probe(priv, &rdai->capture);
1751 goto exit_snd_probe;
1754 dev_set_drvdata(dev, priv);
1759 ret = devm_snd_soc_register_component(dev, &rsnd_soc_component,
1760 priv->daidrv, rsnd_rdai_nr(priv));
1762 dev_err(dev, "cannot snd dai register\n");
1763 goto exit_snd_probe;
1766 pm_runtime_enable(dev);
1768 dev_info(dev, "probed\n");
1772 for_each_rsnd_dai(rdai, priv, i) {
1773 rsnd_dai_call(remove, &rdai->playback, priv);
1774 rsnd_dai_call(remove, &rdai->capture, priv);
1778 * adg is very special mod which can't use rsnd_dai_call(remove),
1779 * and it registers ADG clock on probe.
1780 * It should be unregister if probe failed.
1781 * Mainly it is assuming -EPROBE_DEFER case
1783 rsnd_adg_remove(priv);
1788 static int rsnd_remove(struct platform_device *pdev)
1790 struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
1791 struct rsnd_dai *rdai;
1792 void (*remove_func[])(struct rsnd_priv *priv) = {
1804 snd_soc_disconnect_sync(&pdev->dev);
1806 pm_runtime_disable(&pdev->dev);
1808 for_each_rsnd_dai(rdai, priv, i) {
1809 ret |= rsnd_dai_call(remove, &rdai->playback, priv);
1810 ret |= rsnd_dai_call(remove, &rdai->capture, priv);
1813 for (i = 0; i < ARRAY_SIZE(remove_func); i++)
1814 remove_func[i](priv);
1819 static int __maybe_unused rsnd_suspend(struct device *dev)
1821 struct rsnd_priv *priv = dev_get_drvdata(dev);
1823 rsnd_adg_clk_disable(priv);
1828 static int __maybe_unused rsnd_resume(struct device *dev)
1830 struct rsnd_priv *priv = dev_get_drvdata(dev);
1832 rsnd_adg_clk_enable(priv);
1837 static const struct dev_pm_ops rsnd_pm_ops = {
1838 SET_SYSTEM_SLEEP_PM_OPS(rsnd_suspend, rsnd_resume)
1841 static struct platform_driver rsnd_driver = {
1843 .name = "rcar_sound",
1845 .of_match_table = rsnd_of_match,
1847 .probe = rsnd_probe,
1848 .remove = rsnd_remove,
1850 module_platform_driver(rsnd_driver);
1852 MODULE_LICENSE("GPL v2");
1853 MODULE_DESCRIPTION("Renesas R-Car audio driver");
1854 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
1855 MODULE_ALIAS("platform:rcar-pcm-audio");