ASoC: samsung: i2s: Move core clk to the driver common data structure
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Tue, 12 Feb 2019 18:03:25 +0000 (19:03 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 13 Feb 2019 11:46:08 +0000 (11:46 +0000)
The core clock is also common for both CPU DAIs so move it to
the driver's private data structure.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/samsung/i2s.c

index 29bcfca20572d9f9698c2cb186c91520100d6b77..159c19fdb6625e588cc705882fce58afa013efb8 100644 (file)
@@ -71,8 +71,6 @@ struct i2s_dai {
         * 0 indicates CPU driver is free to choose any value.
         */
        unsigned rfs, bfs;
-       /* I2S Controller's core clock */
-       struct clk *clk;
        /* Clock for generating I2S signals */
        struct clk *op_clk;
        /* Pointer to the Primary_Fifo if this is Sec_Fifo, NULL otherwise */
@@ -117,6 +115,9 @@ struct samsung_i2s_priv {
        struct snd_soc_dai_driver *dai_drv;
        int num_dais;
 
+       /* The I2S controller's core clock */
+       struct clk *clk;
+
        /* The clock provider's data */
        struct clk *clk_table[3];
        struct clk_onecell_data clk_data;
@@ -1205,6 +1206,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
 #ifdef CONFIG_PM
 static int i2s_runtime_suspend(struct device *dev)
 {
+       struct samsung_i2s_priv *priv = dev_get_drvdata(dev);
        struct i2s_dai *i2s = samsung_i2s_get_pri_dai(dev);
 
        i2s->suspend_i2smod = readl(i2s->addr + I2SMOD);
@@ -1213,24 +1215,25 @@ static int i2s_runtime_suspend(struct device *dev)
 
        if (i2s->op_clk)
                clk_disable_unprepare(i2s->op_clk);
-       clk_disable_unprepare(i2s->clk);
+       clk_disable_unprepare(priv->clk);
 
        return 0;
 }
 
 static int i2s_runtime_resume(struct device *dev)
 {
+       struct samsung_i2s_priv *priv = dev_get_drvdata(dev);
        struct i2s_dai *i2s = samsung_i2s_get_pri_dai(dev);
        int ret;
 
-       ret = clk_prepare_enable(i2s->clk);
+       ret = clk_prepare_enable(priv->clk);
        if (ret)
                return ret;
 
        if (i2s->op_clk) {
                ret = clk_prepare_enable(i2s->op_clk);
                if (ret) {
-                       clk_disable_unprepare(i2s->clk);
+                       clk_disable_unprepare(priv->clk);
                        return ret;
                }
        }
@@ -1428,13 +1431,13 @@ static int samsung_i2s_probe(struct platform_device *pdev)
 
        regs_base = res->start;
 
-       pri_dai->clk = devm_clk_get(&pdev->dev, "iis");
-       if (IS_ERR(pri_dai->clk)) {
+       priv->clk = devm_clk_get(&pdev->dev, "iis");
+       if (IS_ERR(priv->clk)) {
                dev_err(&pdev->dev, "Failed to get iis clock\n");
-               return PTR_ERR(pri_dai->clk);
+               return PTR_ERR(priv->clk);
        }
 
-       ret = clk_prepare_enable(pri_dai->clk);
+       ret = clk_prepare_enable(priv->clk);
        if (ret != 0) {
                dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
                return ret;
@@ -1472,7 +1475,6 @@ static int samsung_i2s_probe(struct platform_device *pdev)
 
                sec_dai->dma_playback.addr_width = 4;
                sec_dai->addr = pri_dai->addr;
-               sec_dai->clk = pri_dai->clk;
                sec_dai->quirks = quirks;
                sec_dai->idma_playback.addr = idma_addr;
                sec_dai->pri_dai = pri_dai;
@@ -1519,7 +1521,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
 err_disable_pm:
        pm_runtime_disable(&pdev->dev);
 err_disable_clk:
-       clk_disable_unprepare(pri_dai->clk);
+       clk_disable_unprepare(priv->clk);
        i2s_delete_secondary_device(priv);
        return ret;
 }
@@ -1527,7 +1529,6 @@ err_disable_clk:
 static int samsung_i2s_remove(struct platform_device *pdev)
 {
        struct samsung_i2s_priv *priv = dev_get_drvdata(&pdev->dev);
-       struct i2s_dai *pri_dai = samsung_i2s_get_pri_dai(&pdev->dev);
 
        /* The secondary device has no driver data assigned */
        if (!priv)
@@ -1537,7 +1538,7 @@ static int samsung_i2s_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 
        i2s_unregister_clock_provider(priv);
-       clk_disable_unprepare(pri_dai->clk);
+       clk_disable_unprepare(priv->clk);
        pm_runtime_put_noidle(&pdev->dev);
        i2s_delete_secondary_device(priv);