summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-cs42888.c
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@freescale.com>2017-09-01 13:40:23 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit9bfd88127507067356b2f6261e188c7c5d7a378e (patch)
treed8d23c93471297bd56a7e39c5bae2e4f2901afbd /sound/soc/fsl/imx-cs42888.c
parent487c0761bdcc13f71267d32043bde5e51bee8163 (diff)
MLK-16350-3: ASoC: imx-cs42888: fix clock rate issue
The rate returned by clk_get_rate in probe function is not correct, for the power domain in that time may be closed, kernel get 0 rate from scfw, so move the clk_get_rate to hw_params, in that time, the power domain should be enabled Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Diffstat (limited to 'sound/soc/fsl/imx-cs42888.c')
-rw-r--r--sound/soc/fsl/imx-cs42888.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sound/soc/fsl/imx-cs42888.c b/sound/soc/fsl/imx-cs42888.c
index 1e4a80579741..c70606e6905d 100644
--- a/sound/soc/fsl/imx-cs42888.c
+++ b/sound/soc/fsl/imx-cs42888.c
@@ -32,6 +32,7 @@
#define SUPPORT_RATE_NUM 10
struct imx_priv {
+ struct clk *codec_clk;
unsigned int mclk_freq;
struct platform_device *pdev;
struct platform_device *asrc_pdev;
@@ -59,6 +60,8 @@ static int imx_cs42888_surround_hw_params(struct snd_pcm_substream *substream,
int ret = 0;
+ priv->mclk_freq = clk_get_rate(priv->codec_clk);
+
if (priv->is_codec_master) {
/* TDM is not supported by codec in master mode */
if (enable_tdm) {
@@ -151,7 +154,9 @@ static int imx_cs42888_surround_startup(struct snd_pcm_substream *substream)
static u32 support_rates[SUPPORT_RATE_NUM];
int ret;
- if (priv->mclk_freq == 24576000) {
+ priv->mclk_freq = clk_get_rate(priv->codec_clk);
+
+ if (priv->mclk_freq % 24576000 == 0) {
support_rates[0] = 48000;
support_rates[1] = 96000;
support_rates[2] = 192000;
@@ -282,7 +287,6 @@ static int imx_cs42888_probe(struct platform_device *pdev)
struct platform_device *asrc_pdev = NULL;
struct i2c_client *codec_dev;
struct imx_priv *priv = &card_priv;
- struct clk *codec_clk = NULL;
int ret;
u32 width;
@@ -353,13 +357,12 @@ static int imx_cs42888_probe(struct platform_device *pdev)
priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE;
}
- codec_clk = devm_clk_get(&codec_dev->dev, NULL);
- if (IS_ERR(codec_clk)) {
- ret = PTR_ERR(codec_clk);
+ priv->codec_clk = devm_clk_get(&codec_dev->dev, NULL);
+ if (IS_ERR(priv->codec_clk)) {
+ ret = PTR_ERR(priv->codec_clk);
dev_err(&codec_dev->dev, "failed to get codec clk: %d\n", ret);
goto fail;
}
- priv->mclk_freq = clk_get_rate(codec_clk);
priv->is_codec_master = false;
if (of_property_read_bool(pdev->dev.of_node, "codec-master"))