2014-05-09 07:44:49 +07:00
|
|
|
/*
|
|
|
|
* Renesas R-Car DVC support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Renesas Solutions Corp.
|
|
|
|
* Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2016-03-10 12:29:21 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Playback Volume
|
|
|
|
* amixer set "DVC Out" 100%
|
|
|
|
*
|
|
|
|
* Capture Volume
|
|
|
|
* amixer set "DVC In" 100%
|
|
|
|
*
|
|
|
|
* Playback Mute
|
|
|
|
* amixer set "DVC Out Mute" on
|
|
|
|
*
|
|
|
|
* Capture Mute
|
|
|
|
* amixer set "DVC In Mute" on
|
|
|
|
*
|
|
|
|
* Volume Ramp
|
|
|
|
* amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps"
|
|
|
|
* amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
|
|
|
|
* amixer set "DVC Out Ramp" on
|
|
|
|
* aplay xxx.wav &
|
|
|
|
* amixer set "DVC Out" 80% // Volume Down
|
|
|
|
* amixer set "DVC Out" 100% // Volume Up
|
|
|
|
*/
|
|
|
|
|
2014-05-09 07:44:49 +07:00
|
|
|
#include "rsnd.h"
|
|
|
|
|
|
|
|
#define RSND_DVC_NAME_SIZE 16
|
2014-05-23 13:25:43 +07:00
|
|
|
|
|
|
|
#define DVC_NAME "dvc"
|
|
|
|
|
2014-05-09 07:44:49 +07:00
|
|
|
struct rsnd_dvc {
|
|
|
|
struct rsnd_mod mod;
|
2014-11-27 15:06:14 +07:00
|
|
|
struct rsnd_kctrl_cfg_m volume;
|
|
|
|
struct rsnd_kctrl_cfg_m mute;
|
|
|
|
struct rsnd_kctrl_cfg_s ren; /* Ramp Enable */
|
|
|
|
struct rsnd_kctrl_cfg_s rup; /* Ramp Rate Up */
|
|
|
|
struct rsnd_kctrl_cfg_s rdown; /* Ramp Rate Down */
|
2014-05-09 07:44:49 +07:00
|
|
|
};
|
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
#define rsnd_dvc_get(priv, id) ((struct rsnd_dvc *)(priv->dvc) + id)
|
2015-07-15 14:11:02 +07:00
|
|
|
#define rsnd_dvc_nr(priv) ((priv)->dvc_nr)
|
2015-02-20 17:30:41 +07:00
|
|
|
|
2014-05-09 07:44:49 +07:00
|
|
|
#define rsnd_mod_to_dvc(_mod) \
|
|
|
|
container_of((_mod), struct rsnd_dvc, mod)
|
|
|
|
|
|
|
|
#define for_each_rsnd_dvc(pos, priv, i) \
|
|
|
|
for ((i) = 0; \
|
|
|
|
((i) < rsnd_dvc_nr(priv)) && \
|
|
|
|
((pos) = (struct rsnd_dvc *)(priv)->dvc + i); \
|
|
|
|
i++)
|
|
|
|
|
2015-03-24 17:47:43 +07:00
|
|
|
static const char * const dvc_ramp_rate[] = {
|
2014-11-10 10:52:06 +07:00
|
|
|
"128 dB/1 step", /* 00000 */
|
|
|
|
"64 dB/1 step", /* 00001 */
|
|
|
|
"32 dB/1 step", /* 00010 */
|
|
|
|
"16 dB/1 step", /* 00011 */
|
|
|
|
"8 dB/1 step", /* 00100 */
|
|
|
|
"4 dB/1 step", /* 00101 */
|
|
|
|
"2 dB/1 step", /* 00110 */
|
|
|
|
"1 dB/1 step", /* 00111 */
|
|
|
|
"0.5 dB/1 step", /* 01000 */
|
|
|
|
"0.25 dB/1 step", /* 01001 */
|
|
|
|
"0.125 dB/1 step", /* 01010 */
|
|
|
|
"0.125 dB/2 steps", /* 01011 */
|
|
|
|
"0.125 dB/4 steps", /* 01100 */
|
|
|
|
"0.125 dB/8 steps", /* 01101 */
|
|
|
|
"0.125 dB/16 steps", /* 01110 */
|
|
|
|
"0.125 dB/32 steps", /* 01111 */
|
|
|
|
"0.125 dB/64 steps", /* 10000 */
|
|
|
|
"0.125 dB/128 steps", /* 10001 */
|
|
|
|
"0.125 dB/256 steps", /* 10010 */
|
|
|
|
"0.125 dB/512 steps", /* 10011 */
|
|
|
|
"0.125 dB/1024 steps", /* 10100 */
|
|
|
|
"0.125 dB/2048 steps", /* 10101 */
|
|
|
|
"0.125 dB/4096 steps", /* 10110 */
|
|
|
|
"0.125 dB/8192 steps", /* 10111 */
|
|
|
|
};
|
|
|
|
|
2015-11-30 15:51:15 +07:00
|
|
|
static void rsnd_dvc_activation(struct rsnd_mod *mod)
|
2015-07-15 14:12:00 +07:00
|
|
|
{
|
|
|
|
rsnd_mod_write(mod, DVC_SWRSR, 0);
|
|
|
|
rsnd_mod_write(mod, DVC_SWRSR, 1);
|
|
|
|
}
|
|
|
|
|
2015-11-30 15:52:21 +07:00
|
|
|
static void rsnd_dvc_halt(struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
rsnd_mod_write(mod, DVC_DVUIR, 1);
|
|
|
|
rsnd_mod_write(mod, DVC_SWRSR, 0);
|
|
|
|
}
|
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
#define rsnd_dvc_get_vrpdr(dvc) (dvc->rup.val << 8 | dvc->rdown.val)
|
|
|
|
#define rsnd_dvc_get_vrdbr(dvc) (0x3ff - (dvc->volume.val[0] >> 13))
|
2015-07-15 14:13:29 +07:00
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
static void rsnd_dvc_volume_parameter(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
2014-05-09 07:44:49 +07:00
|
|
|
{
|
|
|
|
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
2016-02-18 15:13:13 +07:00
|
|
|
u32 val[RSND_MAX_CHANNELS];
|
2014-05-09 07:44:49 +07:00
|
|
|
int i;
|
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
/* Enable Ramp */
|
|
|
|
if (dvc->ren.val)
|
2016-02-18 15:13:13 +07:00
|
|
|
for (i = 0; i < RSND_MAX_CHANNELS; i++)
|
2015-11-04 15:44:12 +07:00
|
|
|
val[i] = dvc->volume.cfg.max;
|
|
|
|
else
|
2016-02-18 15:13:13 +07:00
|
|
|
for (i = 0; i < RSND_MAX_CHANNELS; i++)
|
2015-11-04 15:44:12 +07:00
|
|
|
val[i] = dvc->volume.val[i];
|
2014-05-09 07:44:49 +07:00
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
/* Enable Digital Volume */
|
|
|
|
rsnd_mod_write(mod, DVC_VOL0R, val[0]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL1R, val[1]);
|
2015-11-30 15:53:44 +07:00
|
|
|
rsnd_mod_write(mod, DVC_VOL2R, val[2]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL3R, val[3]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL4R, val[4]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL5R, val[5]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL6R, val[6]);
|
|
|
|
rsnd_mod_write(mod, DVC_VOL7R, val[7]);
|
2015-11-04 15:44:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsnd_dvc_volume_init(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
2015-11-30 15:49:33 +07:00
|
|
|
u32 adinr = 0;
|
2015-11-04 15:44:12 +07:00
|
|
|
u32 dvucr = 0;
|
|
|
|
u32 vrctr = 0;
|
|
|
|
u32 vrpdr = 0;
|
|
|
|
u32 vrdbr = 0;
|
|
|
|
|
2015-11-30 15:49:33 +07:00
|
|
|
adinr = rsnd_get_adinr_bit(mod, io) |
|
2016-02-25 12:54:58 +07:00
|
|
|
rsnd_runtime_channel_after_ctu(io);
|
2015-11-30 15:49:33 +07:00
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
/* Enable Digital Volume, Zero Cross Mute Mode */
|
|
|
|
dvucr |= 0x101;
|
ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
We need to Enable/Disable DVC_DVUER register if we set
DVCp_ZCMCR, DVCp_VRCTR, DVCp_VRPDR, DVCp_VRDBR,
DVCp_VOL0R, DVCp_VOL1R, DVCp_VOL2R, DVCp_VOL3R,
DVCp_VOL4R, DVCp_VOL5R, DVCp_VOL6R, DVCp_VOL7R
and, these are controlled under rsnd_dvc_volume_update().
This patch moves DVC_DVUER settings to it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-05 11:27:18 +07:00
|
|
|
|
2014-11-10 10:52:06 +07:00
|
|
|
/* Enable Ramp */
|
|
|
|
if (dvc->ren.val) {
|
|
|
|
dvucr |= 0x10;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME !!
|
|
|
|
* use scale-downed Digital Volume
|
|
|
|
* as Volume Ramp
|
|
|
|
* 7F FFFF -> 3FF
|
|
|
|
*/
|
2015-11-04 15:44:12 +07:00
|
|
|
vrctr = 0xff;
|
|
|
|
vrpdr = rsnd_dvc_get_vrpdr(dvc);
|
|
|
|
vrdbr = rsnd_dvc_get_vrdbr(dvc);
|
2014-11-10 10:52:06 +07:00
|
|
|
}
|
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
/* Initialize operation */
|
|
|
|
rsnd_mod_write(mod, DVC_DVUIR, 1);
|
|
|
|
|
|
|
|
/* General Information */
|
2015-11-30 15:49:33 +07:00
|
|
|
rsnd_mod_write(mod, DVC_ADINR, adinr);
|
2015-11-04 15:44:12 +07:00
|
|
|
rsnd_mod_write(mod, DVC_DVUCR, dvucr);
|
|
|
|
|
|
|
|
/* Volume Ramp Parameter */
|
|
|
|
rsnd_mod_write(mod, DVC_VRCTR, vrctr);
|
|
|
|
rsnd_mod_write(mod, DVC_VRPDR, vrpdr);
|
|
|
|
rsnd_mod_write(mod, DVC_VRDBR, vrdbr);
|
|
|
|
|
|
|
|
/* Digital Volume Function Parameter */
|
|
|
|
rsnd_dvc_volume_parameter(io, mod);
|
|
|
|
|
|
|
|
/* cancel operation */
|
|
|
|
rsnd_mod_write(mod, DVC_DVUIR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rsnd_dvc_volume_update(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
|
|
|
{
|
|
|
|
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
|
|
|
u32 zcmcr = 0;
|
|
|
|
u32 vrpdr = 0;
|
|
|
|
u32 vrdbr = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < dvc->mute.cfg.size; i++)
|
|
|
|
zcmcr |= (!!dvc->mute.cfg.val[i]) << i;
|
2014-08-01 17:10:55 +07:00
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
if (dvc->ren.val) {
|
|
|
|
vrpdr = rsnd_dvc_get_vrpdr(dvc);
|
|
|
|
vrdbr = rsnd_dvc_get_vrdbr(dvc);
|
2014-11-05 11:26:53 +07:00
|
|
|
}
|
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
/* Disable DVC Register access */
|
|
|
|
rsnd_mod_write(mod, DVC_DVUER, 0);
|
|
|
|
|
|
|
|
/* Zero Cross Mute Function */
|
|
|
|
rsnd_mod_write(mod, DVC_ZCMCR, zcmcr);
|
|
|
|
|
|
|
|
/* Volume Ramp Function */
|
|
|
|
rsnd_mod_write(mod, DVC_VRPDR, vrpdr);
|
|
|
|
rsnd_mod_write(mod, DVC_VRDBR, vrdbr);
|
|
|
|
/* add DVC_VRWTR here */
|
|
|
|
|
|
|
|
/* Digital Volume Function Parameter */
|
|
|
|
rsnd_dvc_volume_parameter(io, mod);
|
ASoC: rsnd: move DVC_DVUER settings under rsnd_dvc_volume_update()
We need to Enable/Disable DVC_DVUER register if we set
DVCp_ZCMCR, DVCp_VRCTR, DVCp_VRPDR, DVCp_VRDBR,
DVCp_VOL0R, DVCp_VOL1R, DVCp_VOL2R, DVCp_VOL3R,
DVCp_VOL4R, DVCp_VOL5R, DVCp_VOL6R, DVCp_VOL7R
and, these are controlled under rsnd_dvc_volume_update().
This patch moves DVC_DVUER settings to it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-05 11:27:18 +07:00
|
|
|
|
|
|
|
/* Enable DVC Register access */
|
|
|
|
rsnd_mod_write(mod, DVC_DVUER, 1);
|
2014-05-09 07:44:49 +07:00
|
|
|
}
|
|
|
|
|
2015-10-26 15:43:21 +07:00
|
|
|
static int rsnd_dvc_probe_(struct rsnd_mod *mod,
|
|
|
|
struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_priv *priv)
|
|
|
|
{
|
|
|
|
return rsnd_cmd_attach(io, rsnd_mod_id(mod));
|
|
|
|
}
|
|
|
|
|
2015-07-15 14:13:10 +07:00
|
|
|
static int rsnd_dvc_init(struct rsnd_mod *mod,
|
2015-06-15 13:25:20 +07:00
|
|
|
struct rsnd_dai_stream *io,
|
2015-01-15 15:07:47 +07:00
|
|
|
struct rsnd_priv *priv)
|
2014-05-09 07:44:49 +07:00
|
|
|
{
|
2015-10-22 10:15:04 +07:00
|
|
|
rsnd_mod_power_on(mod);
|
2014-05-09 07:44:49 +07:00
|
|
|
|
2015-11-30 15:51:15 +07:00
|
|
|
rsnd_dvc_activation(mod);
|
2015-07-15 14:12:00 +07:00
|
|
|
|
2015-11-04 15:44:12 +07:00
|
|
|
rsnd_dvc_volume_init(io, mod);
|
2014-05-09 07:44:49 +07:00
|
|
|
|
2015-07-15 14:13:10 +07:00
|
|
|
rsnd_dvc_volume_update(io, mod);
|
2014-05-09 07:44:49 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsnd_dvc_quit(struct rsnd_mod *mod,
|
2015-06-15 13:25:20 +07:00
|
|
|
struct rsnd_dai_stream *io,
|
2015-01-15 15:07:47 +07:00
|
|
|
struct rsnd_priv *priv)
|
2014-05-09 07:44:49 +07:00
|
|
|
{
|
2015-11-30 15:52:21 +07:00
|
|
|
rsnd_dvc_halt(mod);
|
|
|
|
|
2015-10-22 10:15:04 +07:00
|
|
|
rsnd_mod_power_off(mod);
|
2014-05-09 07:44:49 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-01 17:10:47 +07:00
|
|
|
static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
|
2015-06-15 13:25:20 +07:00
|
|
|
struct rsnd_dai_stream *io,
|
2014-08-01 17:10:47 +07:00
|
|
|
struct snd_soc_pcm_runtime *rtd)
|
|
|
|
{
|
|
|
|
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
|
2015-01-15 15:06:49 +07:00
|
|
|
int is_play = rsnd_io_is_play(io);
|
2015-12-17 09:57:27 +07:00
|
|
|
int slots = rsnd_get_slot(io);
|
2014-08-01 17:10:47 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Volume */
|
2015-06-15 13:27:28 +07:00
|
|
|
ret = rsnd_kctrl_new_m(mod, io, rtd,
|
2015-01-15 15:06:49 +07:00
|
|
|
is_play ?
|
2014-08-01 17:10:47 +07:00
|
|
|
"DVC Out Playback Volume" : "DVC In Capture Volume",
|
2014-11-27 15:06:14 +07:00
|
|
|
rsnd_dvc_volume_update,
|
2015-11-30 15:53:44 +07:00
|
|
|
&dvc->volume, slots,
|
|
|
|
0x00800000 - 1);
|
2014-08-01 17:10:47 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2014-08-01 17:10:55 +07:00
|
|
|
/* Mute */
|
2015-06-15 13:27:28 +07:00
|
|
|
ret = rsnd_kctrl_new_m(mod, io, rtd,
|
2015-01-15 15:06:49 +07:00
|
|
|
is_play ?
|
2014-08-01 17:10:55 +07:00
|
|
|
"DVC Out Mute Switch" : "DVC In Mute Switch",
|
2014-11-27 15:06:14 +07:00
|
|
|
rsnd_dvc_volume_update,
|
2015-11-30 15:53:44 +07:00
|
|
|
&dvc->mute, slots,
|
|
|
|
1);
|
2014-08-01 17:10:55 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2014-11-10 10:52:06 +07:00
|
|
|
/* Ramp */
|
2015-06-15 13:27:28 +07:00
|
|
|
ret = rsnd_kctrl_new_s(mod, io, rtd,
|
2015-01-15 15:06:49 +07:00
|
|
|
is_play ?
|
2014-11-10 10:52:06 +07:00
|
|
|
"DVC Out Ramp Switch" : "DVC In Ramp Switch",
|
2014-11-27 15:06:14 +07:00
|
|
|
rsnd_dvc_volume_update,
|
2014-11-10 10:52:06 +07:00
|
|
|
&dvc->ren, 1);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2015-06-15 13:27:28 +07:00
|
|
|
ret = rsnd_kctrl_new_e(mod, io, rtd,
|
2015-01-15 15:06:49 +07:00
|
|
|
is_play ?
|
2014-11-10 10:52:06 +07:00
|
|
|
"DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate",
|
2014-11-27 15:06:14 +07:00
|
|
|
rsnd_dvc_volume_update,
|
2017-04-06 14:25:13 +07:00
|
|
|
&dvc->rup,
|
|
|
|
dvc_ramp_rate);
|
2014-11-10 10:52:06 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2015-06-15 13:27:28 +07:00
|
|
|
ret = rsnd_kctrl_new_e(mod, io, rtd,
|
2015-01-15 15:06:49 +07:00
|
|
|
is_play ?
|
2014-11-10 10:52:06 +07:00
|
|
|
"DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate",
|
2014-11-27 15:06:14 +07:00
|
|
|
rsnd_dvc_volume_update,
|
2017-04-06 14:25:13 +07:00
|
|
|
&dvc->rdown,
|
|
|
|
dvc_ramp_rate);
|
2014-11-10 10:52:06 +07:00
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2014-08-01 17:10:47 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-15 13:26:25 +07:00
|
|
|
static struct dma_chan *rsnd_dvc_dma_req(struct rsnd_dai_stream *io,
|
|
|
|
struct rsnd_mod *mod)
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
{
|
|
|
|
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
|
|
|
|
|
|
|
|
return rsnd_dma_request_channel(rsnd_dvc_of_node(priv),
|
|
|
|
mod, "tx");
|
|
|
|
}
|
|
|
|
|
2014-05-09 07:44:49 +07:00
|
|
|
static struct rsnd_mod_ops rsnd_dvc_ops = {
|
2014-05-23 13:25:43 +07:00
|
|
|
.name = DVC_NAME,
|
ASoC: rsnd: 1st DMAC dma-names cares subnode
Renesas R-Car sound (= rsnd) needs 2 DMAC which are called as
Audio DMAC (= 1st DMAC) and Audio DMAC peri peri (2nd DMAC).
And rsnd had assumed that 1st / 2nd DMACs are implemented as DMAEngine.
But, in result of DMA ML discussion, 2nd DMAC was concluded that it is
not a general purpose DMAC (2nd DMAC is for Device to Device inside
sound system). Additionally, current DMAEngine can't support Device to
Device, and we don't have correct DT bindings for it at this point.
So the easiest solution for it is that move it from DMAEngine to rsnd
driver.
dma-names on DT was implemented as no difference between 1st / 2nd
DMAC's, since rsnd had assumed that both DMACs are implemented as
DMAEngine. That style was "src_dst". But now, 2nd DMAC was implemented
as non DMAEngine, and it doesn't need dma-names anymore. So, this
dma-names rule is no longer needed.
And additionally, dma-names was assumed that it has all
(= SSI/SSIU/SRC/DVC) nodes under sound node.
In upstream code, no SoC/platform is supporting DMA for rsnd driver yet.
This means there is no compatible issue if this patch changes
dma-names's rule of DT.
This patch assumes dma-names for 1st DMAC are tx/rx base, and listed
in each SSI/SRC/DVC subnode
ex)
rcar_sound,dvc {
dvc0: dvc@0 {
dmas = <&audma0 0xbc>;
dma-names = "tx";
};
...
rcar_sound,src {
src0: src@0 {
...
dmas = <&audma0 0x85>, <&audma1 0x9a>;
dma-names = "rx", "tx";
};
...
rcar_sound,ssi {
ssi0: ssi@0 {
...
dmas = <&audma0 0x01>, <&audma1 0x02>, <&audma0 0x15>, <&audma1 0x16>;
dma-names = "rx", "tx", "rxu", "txu";
};
...
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-02-20 17:31:23 +07:00
|
|
|
.dma_req = rsnd_dvc_dma_req,
|
2015-10-26 15:43:21 +07:00
|
|
|
.probe = rsnd_dvc_probe_,
|
2014-05-09 07:44:49 +07:00
|
|
|
.init = rsnd_dvc_init,
|
|
|
|
.quit = rsnd_dvc_quit,
|
|
|
|
.pcm_new = rsnd_dvc_pcm_new,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id)
|
|
|
|
{
|
|
|
|
if (WARN_ON(id < 0 || id >= rsnd_dvc_nr(priv)))
|
|
|
|
id = 0;
|
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
return rsnd_mod_get(rsnd_dvc_get(priv, id));
|
2014-06-23 07:59:28 +07:00
|
|
|
}
|
|
|
|
|
2015-11-10 12:14:12 +07:00
|
|
|
int rsnd_dvc_probe(struct rsnd_priv *priv)
|
2014-05-09 07:44:49 +07:00
|
|
|
{
|
2015-11-10 12:12:50 +07:00
|
|
|
struct device_node *node;
|
|
|
|
struct device_node *np;
|
2014-05-09 07:44:49 +07:00
|
|
|
struct device *dev = rsnd_priv_to_dev(priv);
|
|
|
|
struct rsnd_dvc *dvc;
|
|
|
|
struct clk *clk;
|
|
|
|
char name[RSND_DVC_NAME_SIZE];
|
2015-03-26 11:02:09 +07:00
|
|
|
int i, nr, ret;
|
2014-05-09 07:44:49 +07:00
|
|
|
|
|
|
|
/* This driver doesn't support Gen1 at this point */
|
2015-10-15 10:25:28 +07:00
|
|
|
if (rsnd_is_gen1(priv))
|
|
|
|
return 0;
|
2014-05-09 07:44:49 +07:00
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
node = rsnd_dvc_of_node(priv);
|
|
|
|
if (!node)
|
|
|
|
return 0; /* not used is not error */
|
2015-07-15 14:15:47 +07:00
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
nr = of_get_child_count(node);
|
|
|
|
if (!nr) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto rsnd_dvc_probe_done;
|
|
|
|
}
|
2015-07-15 14:15:47 +07:00
|
|
|
|
2014-05-09 07:44:49 +07:00
|
|
|
dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL);
|
2015-11-10 12:12:50 +07:00
|
|
|
if (!dvc) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto rsnd_dvc_probe_done;
|
|
|
|
}
|
2014-05-09 07:44:49 +07:00
|
|
|
|
|
|
|
priv->dvc_nr = nr;
|
|
|
|
priv->dvc = dvc;
|
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
i = 0;
|
2015-12-14 19:05:17 +07:00
|
|
|
ret = 0;
|
2015-11-10 12:12:50 +07:00
|
|
|
for_each_child_of_node(node, np) {
|
|
|
|
dvc = rsnd_dvc_get(priv, i);
|
|
|
|
|
2014-05-23 13:25:43 +07:00
|
|
|
snprintf(name, RSND_DVC_NAME_SIZE, "%s.%d",
|
|
|
|
DVC_NAME, i);
|
2014-05-09 07:44:49 +07:00
|
|
|
|
|
|
|
clk = devm_clk_get(dev, name);
|
2015-11-10 12:12:50 +07:00
|
|
|
if (IS_ERR(clk)) {
|
|
|
|
ret = PTR_ERR(clk);
|
|
|
|
goto rsnd_dvc_probe_done;
|
|
|
|
}
|
2014-05-09 07:44:49 +07:00
|
|
|
|
2015-09-10 14:02:21 +07:00
|
|
|
ret = rsnd_mod_init(priv, rsnd_mod_get(dvc), &rsnd_dvc_ops,
|
2016-01-21 08:58:07 +07:00
|
|
|
clk, rsnd_mod_get_status, RSND_MOD_DVC, i);
|
2015-03-26 11:02:09 +07:00
|
|
|
if (ret)
|
2015-11-10 12:12:50 +07:00
|
|
|
goto rsnd_dvc_probe_done;
|
|
|
|
|
|
|
|
i++;
|
2014-05-09 07:44:49 +07:00
|
|
|
}
|
|
|
|
|
2015-11-10 12:12:50 +07:00
|
|
|
rsnd_dvc_probe_done:
|
|
|
|
of_node_put(node);
|
|
|
|
|
|
|
|
return ret;
|
2014-05-09 07:44:49 +07:00
|
|
|
}
|
2015-03-26 11:02:09 +07:00
|
|
|
|
2015-11-10 12:14:12 +07:00
|
|
|
void rsnd_dvc_remove(struct rsnd_priv *priv)
|
2015-03-26 11:02:09 +07:00
|
|
|
{
|
|
|
|
struct rsnd_dvc *dvc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_rsnd_dvc(dvc, priv, i) {
|
2015-09-10 14:02:21 +07:00
|
|
|
rsnd_mod_quit(rsnd_mod_get(dvc));
|
2015-03-26 11:02:09 +07:00
|
|
|
}
|
|
|
|
}
|