Commit 3e53ac82 authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown

ASoC: qcom: make osr clock optional

Some LPASS integrations like on APQ8016 do not have OSR clk, so making
osr clk optional would allow such integrations to use lpass driver.
Tested-by: default avatarKenneth Westfield <kwestfie@codeaurora.org>
Acked-by: default avatarKenneth Westfield <kwestfie@codeaurora.org>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9a127cff
...@@ -33,6 +33,9 @@ static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -33,6 +33,9 @@ static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id,
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
int ret; int ret;
if (IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
return 0;
ret = clk_set_rate(drvdata->mi2s_osr_clk[dai->driver->id], freq); ret = clk_set_rate(drvdata->mi2s_osr_clk[dai->driver->id], freq);
if (ret) if (ret)
dev_err(dai->dev, "%s() error setting mi2s osrclk to %u: %d\n", dev_err(dai->dev, "%s() error setting mi2s osrclk to %u: %d\n",
...@@ -47,18 +50,23 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream, ...@@ -47,18 +50,23 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream,
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
int ret; int ret;
ret = clk_prepare_enable(drvdata->mi2s_osr_clk[dai->diver->id]); if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id])) {
if (ret) { ret = clk_prepare_enable(
dev_err(dai->dev, "%s() error in enabling mi2s osr clk: %d\n", drvdata->mi2s_osr_clk[dai->driver->id]);
__func__, ret); if (ret) {
return ret; dev_err(dai->dev, "%s() error in enabling mi2s osr clk: %d\n",
__func__, ret);
return ret;
}
} }
ret = clk_prepare_enable(drvdata->mi2s_bit_clk[dai->driver->id]); ret = clk_prepare_enable(drvdata->mi2s_bit_clk[dai->driver->id]);
if (ret) { if (ret) {
dev_err(dai->dev, "%s() error in enabling mi2s bit clk: %d\n", dev_err(dai->dev, "%s() error in enabling mi2s bit clk: %d\n",
__func__, ret); __func__, ret);
clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]); if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
clk_disable_unprepare(
drvdata->mi2s_osr_clk[dai->driver->id]);
return ret; return ret;
} }
...@@ -71,7 +79,9 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, ...@@ -71,7 +79,9 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream,
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]);
clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
} }
static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
...@@ -412,11 +422,10 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -412,11 +422,10 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
drvdata->mi2s_osr_clk[dai_id] = devm_clk_get(&pdev->dev, drvdata->mi2s_osr_clk[dai_id] = devm_clk_get(&pdev->dev,
clk_name); clk_name);
if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) { if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) {
dev_err(&pdev->dev, dev_warn(&pdev->dev,
"%s() error getting mi2s-osr-clk: %ld\n", "%s() error getting mi2s-osr-clk: %ld\n",
__func__, __func__,
PTR_ERR(drvdata->mi2s_osr_clk[dai_id])); PTR_ERR(drvdata->mi2s_osr_clk[dai_id]));
return PTR_ERR(drvdata->mi2s_osr_clk[dai_id]);
} }
if (variant->num_dai > 1) if (variant->num_dai > 1)
......
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