ASoC: rsnd: rsnd_mod controls clock

Current rsnd driver's mod (= ssi/src/dvc) have each own clk,
but, these are needed to start/stop each mod.
This patch adds struct clk in rsnd_mod, and start/stop these
via rsnd_mod_hw_start/stop() macro

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2015-01-15 08:03:22 +00:00 committed by Mark Brown
parent 9d0e202f13
commit 8564295231
5 changed files with 16 additions and 18 deletions

View file

@ -152,6 +152,7 @@ char *rsnd_mod_dma_name(struct rsnd_mod *mod)
void rsnd_mod_init(struct rsnd_priv *priv,
struct rsnd_mod *mod,
struct rsnd_mod_ops *ops,
struct clk *clk,
enum rsnd_mod_type type,
int id)
{
@ -159,6 +160,7 @@ void rsnd_mod_init(struct rsnd_priv *priv,
mod->id = id;
mod->ops = ops;
mod->type = type;
mod->clk = clk;
}
/*

View file

@ -17,7 +17,6 @@
struct rsnd_dvc {
struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
struct rsnd_mod mod;
struct clk *clk;
struct rsnd_kctrl_cfg_m volume;
struct rsnd_kctrl_cfg_m mute;
struct rsnd_kctrl_cfg_s ren; /* Ramp Enable */
@ -132,7 +131,6 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
struct rsnd_dai *rdai)
{
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(dvc_mod);
struct rsnd_dai_stream *io = rsnd_mod_to_io(dvc_mod);
struct rsnd_priv *priv = rsnd_mod_to_priv(dvc_mod);
struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
@ -153,7 +151,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
return -EINVAL;
}
clk_prepare_enable(dvc->clk);
rsnd_mod_hw_start(dvc_mod);
/*
* fixme
@ -181,9 +179,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
static int rsnd_dvc_quit(struct rsnd_mod *mod,
struct rsnd_dai *rdai)
{
struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
clk_disable_unprepare(dvc->clk);
rsnd_mod_hw_stop(mod);
return 0;
}
@ -356,9 +352,9 @@ int rsnd_dvc_probe(struct platform_device *pdev,
return PTR_ERR(clk);
dvc->info = &info->dvc_info[i];
dvc->clk = clk;
rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, RSND_MOD_DVC, i);
rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops,
clk, RSND_MOD_DVC, i);
dev_dbg(dev, "CMD%d probed\n", i);
}

View file

@ -226,6 +226,7 @@ struct rsnd_mod {
struct rsnd_mod_ops *ops;
struct rsnd_dma dma;
struct rsnd_dai_stream *io;
struct clk *clk;
u32 status;
};
/*
@ -261,10 +262,13 @@ struct rsnd_mod {
#define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
#define rsnd_mod_to_io(mod) ((mod)->io)
#define rsnd_mod_id(mod) ((mod)->id)
#define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk)
#define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk)
void rsnd_mod_init(struct rsnd_priv *priv,
struct rsnd_mod *mod,
struct rsnd_mod_ops *ops,
struct clk *clk,
enum rsnd_mod_type type,
int id);
char *rsnd_mod_name(struct rsnd_mod *mod);

View file

@ -22,7 +22,6 @@
struct rsnd_src {
struct rsnd_src_platform_info *info; /* rcar_snd.h */
struct rsnd_mod mod;
struct clk *clk;
int err;
};
@ -286,7 +285,7 @@ static int rsnd_src_init(struct rsnd_mod *mod,
{
struct rsnd_src *src = rsnd_mod_to_src(mod);
clk_prepare_enable(src->clk);
rsnd_mod_hw_start(mod);
src->err = 0;
@ -306,7 +305,7 @@ static int rsnd_src_quit(struct rsnd_mod *mod,
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct device *dev = rsnd_priv_to_dev(priv);
clk_disable_unprepare(src->clk);
rsnd_mod_hw_stop(mod);
if (src->err)
dev_warn(dev, "src under/over flow err = %d\n", src->err);
@ -902,9 +901,8 @@ int rsnd_src_probe(struct platform_device *pdev,
return PTR_ERR(clk);
src->info = &info->src_info[i];
src->clk = clk;
rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i);
rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i);
dev_dbg(dev, "SRC%d probed\n", i);
}

View file

@ -60,7 +60,6 @@
#define SSI_NAME "ssi"
struct rsnd_ssi {
struct clk *clk;
struct rsnd_ssi_platform_info *info; /* rcar_snd.h */
struct rsnd_ssi *parent;
struct rsnd_mod mod;
@ -188,7 +187,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
u32 cr;
if (0 == ssi->usrcnt) {
clk_prepare_enable(ssi->clk);
rsnd_mod_hw_start(&ssi->mod);
if (rsnd_dai_is_clk_master(rdai)) {
if (rsnd_ssi_clk_from_parent(ssi))
@ -260,7 +259,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi,
rsnd_ssi_master_clk_stop(ssi);
}
clk_disable_unprepare(ssi->clk);
rsnd_mod_hw_stop(&ssi->mod);
}
dev_dbg(dev, "%s[%d] hw stopped\n",
@ -731,7 +730,6 @@ int rsnd_ssi_probe(struct platform_device *pdev,
return PTR_ERR(clk);
ssi->info = pinfo;
ssi->clk = clk;
ops = &rsnd_ssi_non_ops;
if (pinfo->dma_id > 0)
@ -739,7 +737,7 @@ int rsnd_ssi_probe(struct platform_device *pdev,
else if (rsnd_ssi_pio_available(ssi))
ops = &rsnd_ssi_pio_ops;
rsnd_mod_init(priv, &ssi->mod, ops, RSND_MOD_SSI, i);
rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i);
rsnd_ssi_parent_clk_setup(priv, ssi);
}