ASoC: rsnd: rsnd_mod controls clock
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 15 Jan 2015 08:03:22 +0000 (08:03 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 15 Jan 2015 11:37:48 +0000 (11:37 +0000)
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>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c

index d9c81cda09f7483a2eb6c6b79851904f0fffd13c..766bd4ce439bb3d01877230739e5a26d195ae6df 100644 (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;
 }
 
 /*
index 5380a4827ba79ecb88bcaeb411bc6465aecb3019..77cb0089047188ec2269db121bb8d4a434c157e8 100644 (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);
        }
index ff191cfbdcf62409258b4eba3e4eeab39fd94119..d8c31170b491e59eb31b2b6ab9fbed9e0833f72e 100644 (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);
index 648b35e7effce6fe84c8b0897fabc07982c840c0..6a3fd8dce1c37d08927c88e22bbb2fa0fdb1e887 100644 (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);
        }
index df10585dd3251a759eb1d6dfe5d0c749f14749c1..a55b96399adae055e55fe95cee3344cabb5d7d03 100644 (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);
        }