ASoC: fsl_sai: Do not set MCTL_MCLK_EN based on the number of registers
Subsystems (3)
Fabio Estevam
reviewerRFC 1/1 ASoC: fsl_sai: Do not set MCTL_MCLK_EN based on the number of registers
From: Fabio Estevam <[email protected]>
Since commit ff87d619ac18 ("ASoC: fsl_sai: Enable MCTL_MCLK_EN bit for master mode") Andreas reports that on an i.MX8MP-based system where MCLK needs to be an input, the MCLK pin is actually an output, despite not having the 'fsl,sai-mclk-direction-output' property present in the devicetree.
This commit explains the following:
"On i.MX8MM, the MCTL_MCLK_EN bit it is not only the gate for MCLK output to PAD, but also the gate bit between root clock and SAI module, So it is need to be enabled for master mode, otherwise there is no bclk generated."
Currently, the decision of using MCTL_MCLK_EN as a clock gate is based on the number of SAI registers present on a platform.
This is fragile as it causes issues on i.MX8MP, for example.
Fix the problem by introducing a new boolean mclk_en_gates_clock member in the fsl_sai_soc_data structure that indicates that the MCTL_MCLK_EN bit also acts as a gate between the root clock and the SAI block.
This allows i.MX8MM to turn on FSL_SAI_MCTL_MCLK_EN as intended and other SoCs such as i.MX8MP can still use MCLK as input.
---
Hi Shengjiu,
Is imx8mm the only SoC that needs mclk_en_gates_clock = true?
What about imx8mn and imx93?
sound/soc/fsl/fsl_sai.c | 12 +++++++++++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-)
sound/soc/fsl/fsl_sai.c +11 -1
@@ -507,7 +507,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) savediv / 2 - 1); } -if (sai->soc_data->max_register >=FSL_SAI_MCTL ) { +if (sai->soc_data->mclk_en_gates_clock) {/* SAI is in master mode at this point, so enable MCLK */ regmap_update_bits (sai->regmap,FSL_SAI_MCTL ,FSL_SAI_MCTL_MCLK_EN ,FSL_SAI_MCTL_MCLK_EN );
@@ -1513,6 +1513,7 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .reg_offset = 0, .mclk0_is_mclk1 = false, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RMR, };
@@ -1524,6 +1525,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .reg_offset = 0, .mclk0_is_mclk1 = true, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RMR, };
@@ -1535,6 +1537,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { .reg_offset = 8, .mclk0_is_mclk1 = false, .flags = PMQOS_CPU_LATENCY, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RMR, };
@@ -1546,6 +1549,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { .reg_offset = 8, .mclk0_is_mclk1 = false, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RMR, };
@@ -1557,6 +1561,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { .reg_offset = 0, .mclk0_is_mclk1 = false, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RMR, };
@@ -1568,6 +1573,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mm_data = { .mclk0_is_mclk1 = false, .pins = 8, .flags = 0, + .mclk_en_gates_clock = true, .max_register = FSL_SAI_MCTL, };
@@ -1579,6 +1585,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mn_data = { .mclk0_is_mclk1 = false, .pins = 8, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_MDIV, };
@@ -1590,6 +1597,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mp_data = { .mclk0_is_mclk1 = false, .pins = 8, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_MDIV, .mclk_with_tere = true, };
@@ -1602,6 +1610,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8ulp_data = { .mclk0_is_mclk1 = false, .pins = 4, .flags = PMQOS_CPU_LATENCY, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_RTCAP, };
@@ -1613,6 +1622,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx93_data = { .mclk0_is_mclk1 = false, .pins = 4, .flags = 0, + .mclk_en_gates_clock = false, .max_register = FSL_SAI_MCTL, .max_burst = {8, 8}, };
sound/soc/fsl/fsl_sai.h +1 -0
@@ -232,6 +232,7 @@ struct fsl_sai_soc_data {bool use_edma;bool mclk0_is_mclk1;bool mclk_with_tere; +bool mclk_en_gates_clock;unsigned int fifo_depth;unsigned int pins;unsigned int reg_offset;
Signature · 1 line
2.34.1
Fabio Estevam
reviewerHi Shengjiu,
Quoted 9 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Since commit
ff87d619ac18("ASoC:fsl_sai: EnableMCTL_MCLK_ENbit for master mode") Andreas reports that on an i.MX8MP-based system where MCLK needs to be an input, the MCLK pin is actually an output, despite not having the 'fsl,sai-mclk-direction-output' property present in the devicetree.
Quoted 6 lines
This commit explains the following:
"On i.MX8MM, the
MCTL_MCLK_ENbit it is not only the gate for MCLK output to PAD, but also the gate bit between root clock and SAI module, So it is need to be enabled for master mode, otherwise there is no bclk generated."
As far as I can see, the i.MX8MM Reference Manual only talks about this bit controlling the MCLK direction.
Is there any documentation that explains this clock gate control functionality?
Quoted 33 lines
Currently, the decision of using
MCTL_MCLK_ENas a clock gate is based on the number of SAI registers present on a platform.This is fragile as it causes issues on i.MX8MP, for example.
Fix the problem by introducing a new boolean
mclk_en_gates_clockmember in thefsl_sai_soc_datastructure that indicates that theMCTL_MCLK_ENbit also acts as a gate between the root clock and the SAI block.This allows i.MX8MM to turn on
FSL_SAI_MCTL_MCLK_ENas intended and other SoCs such as i.MX8MP can still use MCLK as input.Fixes ff87d619ac18 ("ASoC: fsl_sai: Enable MCTL_MCLK_EN bit for master mode")Reported-by Andreas Henriksson <[email protected]>Signed-off-by Fabio Estevam <[email protected]>Signed-off-by Fabio Estevam <[email protected]>---
Hi Shengjiu,Is imx8mm the only SoC that needs
mclk_en_gates_clock= true?What about imx8mn and imx93?
sound/soc/fsl/fsl_sai.c | 12 +++++++++++- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-)sound/soc/fsl/fsl_sai.c +0
-0
sound/soc/fsl/fsl_sai.c static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) · line 513
Quoted 8 lines
sound/soc/fsl/fsl_sai.c +1
-1@@ -507,7 +507,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq) savediv / 2 - 1); } -if (sai->soc_data->max_register >=FSL_SAI_MCTL ) { +if (sai->soc_data->mclk_en_gates_clock) {/* SAI is in master mode at this point, so enable MCLK */ regmap_update_bits (sai->regmap,FSL_SAI_MCTL ,FSL_SAI_MCTL_MCLK_EN ,FSL_SAI_MCTL_MCLK_EN );
Also, why is FSL_SAI_MCTL_MCLK_EN set in two places (here and inside probe)?