Commit 53233e40 authored by Shengjiu Wang's avatar Shengjiu Wang Committed by Mark Brown

ASoC: fsl_sai: Correct the clock source for mclk0

On VF610, mclk0 = bus_clk;
On i.MX6SX/6UL/6ULL/7D, mclk0 = mclk1;
On i.MX7ULP, mclk0 = bus_clk;
On i.MX8QM/8QXP, mclk0 = bus_clk;
On i.MX8MQ/8MN/8MM/8MP, mclk0 = bus_clk;

So add variable mclk0_is_mclk1 in fsl_sai_soc_data to
distinguish these platforms.
Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/1605768038-4582-1-git-send-email-shengjiu.wang@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 61349f0f
...@@ -359,7 +359,14 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) ...@@ -359,7 +359,14 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)
if (sai->is_slave_mode) if (sai->is_slave_mode)
return 0; return 0;
for (id = 0; id < FSL_SAI_MCLK_MAX; id++) { /*
* There is no point in polling MCLK0 if it is identical to MCLK1.
* And given that MQS use case has to use MCLK1 though two clocks
* are the same, we simply skip MCLK0 and start to find from MCLK1.
*/
id = sai->soc_data->mclk0_is_mclk1 ? 1 : 0;
for (; id < FSL_SAI_MCLK_MAX; id++) {
clk_rate = clk_get_rate(sai->mclk_clk[id]); clk_rate = clk_get_rate(sai->mclk_clk[id]);
if (!clk_rate) if (!clk_rate)
continue; continue;
...@@ -1040,7 +1047,6 @@ static int fsl_sai_probe(struct platform_device *pdev) ...@@ -1040,7 +1047,6 @@ static int fsl_sai_probe(struct platform_device *pdev)
sai->bus_clk = NULL; sai->bus_clk = NULL;
} }
sai->mclk_clk[0] = sai->bus_clk;
for (i = 1; i < FSL_SAI_MCLK_MAX; i++) { for (i = 1; i < FSL_SAI_MCLK_MAX; i++) {
sprintf(tmp, "mclk%d", i); sprintf(tmp, "mclk%d", i);
sai->mclk_clk[i] = devm_clk_get(&pdev->dev, tmp); sai->mclk_clk[i] = devm_clk_get(&pdev->dev, tmp);
...@@ -1051,6 +1057,11 @@ static int fsl_sai_probe(struct platform_device *pdev) ...@@ -1051,6 +1057,11 @@ static int fsl_sai_probe(struct platform_device *pdev)
} }
} }
if (sai->soc_data->mclk0_is_mclk1)
sai->mclk_clk[0] = sai->mclk_clk[1];
else
sai->mclk_clk[0] = sai->bus_clk;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) if (irq < 0)
return irq; return irq;
...@@ -1165,6 +1176,7 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = { ...@@ -1165,6 +1176,7 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
.use_edma = false, .use_edma = false,
.fifo_depth = 32, .fifo_depth = 32,
.reg_offset = 0, .reg_offset = 0,
.mclk0_is_mclk1 = false,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
...@@ -1172,6 +1184,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { ...@@ -1172,6 +1184,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
.use_edma = false, .use_edma = false,
.fifo_depth = 32, .fifo_depth = 32,
.reg_offset = 0, .reg_offset = 0,
.mclk0_is_mclk1 = true,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
...@@ -1179,6 +1192,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { ...@@ -1179,6 +1192,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
.use_edma = false, .use_edma = false,
.fifo_depth = 16, .fifo_depth = 16,
.reg_offset = 8, .reg_offset = 8,
.mclk0_is_mclk1 = false,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
...@@ -1186,6 +1200,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { ...@@ -1186,6 +1200,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
.use_edma = false, .use_edma = false,
.fifo_depth = 128, .fifo_depth = 128,
.reg_offset = 8, .reg_offset = 8,
.mclk0_is_mclk1 = false,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
...@@ -1193,6 +1208,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { ...@@ -1193,6 +1208,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
.use_edma = true, .use_edma = true,
.fifo_depth = 64, .fifo_depth = 64,
.reg_offset = 0, .reg_offset = 0,
.mclk0_is_mclk1 = false,
}; };
static const struct of_device_id fsl_sai_ids[] = { static const struct of_device_id fsl_sai_ids[] = {
......
...@@ -219,6 +219,7 @@ ...@@ -219,6 +219,7 @@
struct fsl_sai_soc_data { struct fsl_sai_soc_data {
bool use_imx_pcm; bool use_imx_pcm;
bool use_edma; bool use_edma;
bool mclk0_is_mclk1;
unsigned int fifo_depth; unsigned int fifo_depth;
unsigned int reg_offset; unsigned int reg_offset;
}; };
......
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