Commit b5d015e6 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mark Brown

ASoC: samsung: i2s: Move core clk to the driver common data structure

The core clock is also common for both CPU DAIs so move it to
the driver's private data structure.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 64aba9bc
...@@ -71,8 +71,6 @@ struct i2s_dai { ...@@ -71,8 +71,6 @@ struct i2s_dai {
* 0 indicates CPU driver is free to choose any value. * 0 indicates CPU driver is free to choose any value.
*/ */
unsigned rfs, bfs; unsigned rfs, bfs;
/* I2S Controller's core clock */
struct clk *clk;
/* Clock for generating I2S signals */ /* Clock for generating I2S signals */
struct clk *op_clk; struct clk *op_clk;
/* Pointer to the Primary_Fifo if this is Sec_Fifo, NULL otherwise */ /* Pointer to the Primary_Fifo if this is Sec_Fifo, NULL otherwise */
...@@ -117,6 +115,9 @@ struct samsung_i2s_priv { ...@@ -117,6 +115,9 @@ struct samsung_i2s_priv {
struct snd_soc_dai_driver *dai_drv; struct snd_soc_dai_driver *dai_drv;
int num_dais; int num_dais;
/* The I2S controller's core clock */
struct clk *clk;
/* The clock provider's data */ /* The clock provider's data */
struct clk *clk_table[3]; struct clk *clk_table[3];
struct clk_onecell_data clk_data; struct clk_onecell_data clk_data;
...@@ -1205,6 +1206,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, ...@@ -1205,6 +1206,7 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2s_runtime_suspend(struct device *dev) 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); struct i2s_dai *i2s = samsung_i2s_get_pri_dai(dev);
i2s->suspend_i2smod = readl(i2s->addr + I2SMOD); i2s->suspend_i2smod = readl(i2s->addr + I2SMOD);
...@@ -1213,24 +1215,25 @@ static int i2s_runtime_suspend(struct device *dev) ...@@ -1213,24 +1215,25 @@ static int i2s_runtime_suspend(struct device *dev)
if (i2s->op_clk) if (i2s->op_clk)
clk_disable_unprepare(i2s->op_clk); clk_disable_unprepare(i2s->op_clk);
clk_disable_unprepare(i2s->clk); clk_disable_unprepare(priv->clk);
return 0; return 0;
} }
static int i2s_runtime_resume(struct device *dev) 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); struct i2s_dai *i2s = samsung_i2s_get_pri_dai(dev);
int ret; int ret;
ret = clk_prepare_enable(i2s->clk); ret = clk_prepare_enable(priv->clk);
if (ret) if (ret)
return ret; return ret;
if (i2s->op_clk) { if (i2s->op_clk) {
ret = clk_prepare_enable(i2s->op_clk); ret = clk_prepare_enable(i2s->op_clk);
if (ret) { if (ret) {
clk_disable_unprepare(i2s->clk); clk_disable_unprepare(priv->clk);
return ret; return ret;
} }
} }
...@@ -1428,13 +1431,13 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1428,13 +1431,13 @@ static int samsung_i2s_probe(struct platform_device *pdev)
regs_base = res->start; regs_base = res->start;
pri_dai->clk = devm_clk_get(&pdev->dev, "iis"); priv->clk = devm_clk_get(&pdev->dev, "iis");
if (IS_ERR(pri_dai->clk)) { if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "Failed to get iis clock\n"); 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) { if (ret != 0) {
dev_err(&pdev->dev, "failed to enable clock: %d\n", ret); dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
return ret; return ret;
...@@ -1472,7 +1475,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1472,7 +1475,6 @@ static int samsung_i2s_probe(struct platform_device *pdev)
sec_dai->dma_playback.addr_width = 4; sec_dai->dma_playback.addr_width = 4;
sec_dai->addr = pri_dai->addr; sec_dai->addr = pri_dai->addr;
sec_dai->clk = pri_dai->clk;
sec_dai->quirks = quirks; sec_dai->quirks = quirks;
sec_dai->idma_playback.addr = idma_addr; sec_dai->idma_playback.addr = idma_addr;
sec_dai->pri_dai = pri_dai; sec_dai->pri_dai = pri_dai;
...@@ -1519,7 +1521,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1519,7 +1521,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
err_disable_pm: err_disable_pm:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err_disable_clk: err_disable_clk:
clk_disable_unprepare(pri_dai->clk); clk_disable_unprepare(priv->clk);
i2s_delete_secondary_device(priv); i2s_delete_secondary_device(priv);
return ret; return ret;
} }
...@@ -1527,7 +1529,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) ...@@ -1527,7 +1529,6 @@ static int samsung_i2s_probe(struct platform_device *pdev)
static int samsung_i2s_remove(struct platform_device *pdev) static int samsung_i2s_remove(struct platform_device *pdev)
{ {
struct samsung_i2s_priv *priv = dev_get_drvdata(&pdev->dev); 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 */ /* The secondary device has no driver data assigned */
if (!priv) if (!priv)
...@@ -1537,7 +1538,7 @@ static int samsung_i2s_remove(struct platform_device *pdev) ...@@ -1537,7 +1538,7 @@ static int samsung_i2s_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
i2s_unregister_clock_provider(priv); i2s_unregister_clock_provider(priv);
clk_disable_unprepare(pri_dai->clk); clk_disable_unprepare(priv->clk);
pm_runtime_put_noidle(&pdev->dev); pm_runtime_put_noidle(&pdev->dev);
i2s_delete_secondary_device(priv); i2s_delete_secondary_device(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment