Commit 512864c4 authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown

ASoC: codecs: tx-macro: move to individual clks from bulk

Using bulk clocks and referencing them individually using array index is
not great for readers.
So move them to individual clocks handling and also remove some unnecessary
error handling in the code.
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-6-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 43b647d9
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
...@@ -258,7 +259,11 @@ struct tx_macro { ...@@ -258,7 +259,11 @@ struct tx_macro {
unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS]; unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS];
unsigned long active_decimator[TX_MACRO_MAX_DAIS]; unsigned long active_decimator[TX_MACRO_MAX_DAIS];
struct regmap *regmap; struct regmap *regmap;
struct clk_bulk_data clks[TX_NUM_CLKS_MAX]; struct clk *mclk;
struct clk *npl;
struct clk *macro;
struct clk *dcodec;
struct clk *fsgen;
struct clk_hw hw; struct clk_hw hw;
bool dec_active[NUM_DECIMATORS]; bool dec_active[NUM_DECIMATORS];
bool reset_swr; bool reset_swr;
...@@ -1748,7 +1753,7 @@ static int tx_macro_register_mclk_output(struct tx_macro *tx) ...@@ -1748,7 +1753,7 @@ static int tx_macro_register_mclk_output(struct tx_macro *tx)
struct clk_init_data init; struct clk_init_data init;
int ret; int ret;
parent_clk_name = __clk_get_name(tx->clks[2].clk); parent_clk_name = __clk_get_name(tx->mclk);
init.name = clk_name; init.name = clk_name;
init.ops = &swclk_gate_ops; init.ops = &swclk_gate_ops;
...@@ -1787,17 +1792,25 @@ static int tx_macro_probe(struct platform_device *pdev) ...@@ -1787,17 +1792,25 @@ static int tx_macro_probe(struct platform_device *pdev)
if (!tx) if (!tx)
return -ENOMEM; return -ENOMEM;
tx->clks[0].id = "macro"; tx->macro = devm_clk_get_optional(dev, "macro");
tx->clks[1].id = "dcodec"; if (IS_ERR(tx->macro))
tx->clks[2].id = "mclk"; return PTR_ERR(tx->macro);
tx->clks[3].id = "npl";
tx->clks[4].id = "fsgen";
ret = devm_clk_bulk_get_optional(dev, TX_NUM_CLKS_MAX, tx->clks); tx->dcodec = devm_clk_get_optional(dev, "dcodec");
if (ret) { if (IS_ERR(tx->dcodec))
dev_err(dev, "Error getting RX Clocks (%d)\n", ret); return PTR_ERR(tx->dcodec);
return ret;
} tx->mclk = devm_clk_get(dev, "mclk");
if (IS_ERR(tx->mclk))
return PTR_ERR(tx->mclk);
tx->npl = devm_clk_get(dev, "npl");
if (IS_ERR(tx->npl))
return PTR_ERR(tx->npl);
tx->fsgen = devm_clk_get(dev, "fsgen");
if (IS_ERR(tx->fsgen))
return PTR_ERR(tx->fsgen);
base = devm_platform_ioremap_resource(pdev, 0); base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) if (IS_ERR(base))
...@@ -1827,26 +1840,52 @@ static int tx_macro_probe(struct platform_device *pdev) ...@@ -1827,26 +1840,52 @@ static int tx_macro_probe(struct platform_device *pdev)
tx->dev = dev; tx->dev = dev;
/* set MCLK and NPL rates */ /* set MCLK and NPL rates */
clk_set_rate(tx->clks[2].clk, MCLK_FREQ); clk_set_rate(tx->mclk, MCLK_FREQ);
clk_set_rate(tx->clks[3].clk, 2 * MCLK_FREQ); clk_set_rate(tx->npl, 2 * MCLK_FREQ);
ret = clk_bulk_prepare_enable(TX_NUM_CLKS_MAX, tx->clks); ret = clk_prepare_enable(tx->macro);
if (ret) if (ret)
return ret; goto err;
ret = clk_prepare_enable(tx->dcodec);
if (ret)
goto err_dcodec;
ret = clk_prepare_enable(tx->mclk);
if (ret)
goto err_mclk;
ret = clk_prepare_enable(tx->npl);
if (ret)
goto err_npl;
ret = clk_prepare_enable(tx->fsgen);
if (ret)
goto err_fsgen;
ret = tx_macro_register_mclk_output(tx); ret = tx_macro_register_mclk_output(tx);
if (ret) if (ret)
goto err; goto err_clkout;
ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv, ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv,
tx_macro_dai, tx_macro_dai,
ARRAY_SIZE(tx_macro_dai)); ARRAY_SIZE(tx_macro_dai));
if (ret) if (ret)
goto err; goto err_clkout;
return ret;
err:
clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks);
return 0;
err_clkout:
clk_disable_unprepare(tx->fsgen);
err_fsgen:
clk_disable_unprepare(tx->npl);
err_npl:
clk_disable_unprepare(tx->mclk);
err_mclk:
clk_disable_unprepare(tx->dcodec);
err_dcodec:
clk_disable_unprepare(tx->macro);
err:
return ret; return ret;
} }
...@@ -1854,7 +1893,11 @@ static int tx_macro_remove(struct platform_device *pdev) ...@@ -1854,7 +1893,11 @@ static int tx_macro_remove(struct platform_device *pdev)
{ {
struct tx_macro *tx = dev_get_drvdata(&pdev->dev); struct tx_macro *tx = dev_get_drvdata(&pdev->dev);
clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks); clk_disable_unprepare(tx->macro);
clk_disable_unprepare(tx->dcodec);
clk_disable_unprepare(tx->mclk);
clk_disable_unprepare(tx->npl);
clk_disable_unprepare(tx->fsgen);
return 0; return 0;
} }
......
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