diff options
author | Jörg Krause <jk@lintech.de> | 2017-01-13 15:44:27 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-01-17 13:19:36 -0500 |
commit | bcb8c270829a639b8b838809d7c2b540e65f4e01 (patch) | |
tree | b0b0de3f797ab5efe4e3a5b6ef4ced3f9036b3d6 | |
parent | b25658ed7d24cd8b1f9a72148e80e216b6a0c17a (diff) |
ASoC: mxs-saif: fix setting master base rate
The SAIF base oversample rates are either 512*fs or 384*fs. An additional
divider exists within the SAIF to generate sub-multiples of these two base
rates if MCLK is required by the codec.
* The sub-rates for the 512x base rate are: 256x, 128x, 64x, and 32x.
* The sub-rates for the 384x base rate are: 192x, 96x, and 48x.
Setting the base rate depending on the modulo operation with 32 and 48
give wrong results for some mclk.
If mclk=18.432MHz both modulo operations results in 0. As testing the
result with 32 is done first, a wrong base rate of 512*fs is set instead
of the correct 384*fs.
Fix this by setting the base rate depending on the calculated sub-rate.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/mxs/mxs-saif.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 9012a2036131..b42f301c6b96 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c | |||
@@ -119,23 +119,33 @@ static int mxs_saif_set_clk(struct mxs_saif *saif, | |||
119 | * Set SAIF clock | 119 | * Set SAIF clock |
120 | * | 120 | * |
121 | * The SAIF clock should be either 384*fs or 512*fs. | 121 | * The SAIF clock should be either 384*fs or 512*fs. |
122 | * If MCLK is used, the SAIF clk ratio need to match mclk ratio. | 122 | * If MCLK is used, the SAIF clk ratio needs to match mclk ratio. |
123 | * For 32x mclk, set saif clk as 512*fs. | 123 | * For 256x, 128x, 64x, and 32x sub-rates, set saif clk as 512*fs. |
124 | * For 48x mclk, set saif clk as 384*fs. | 124 | * For 192x, 96x, and 48x sub-rates, set saif clk as 384*fs. |
125 | * | 125 | * |
126 | * If MCLK is not used, we just set saif clk to 512*fs. | 126 | * If MCLK is not used, we just set saif clk to 512*fs. |
127 | */ | 127 | */ |
128 | clk_prepare_enable(master_saif->clk); | 128 | clk_prepare_enable(master_saif->clk); |
129 | 129 | ||
130 | if (master_saif->mclk_in_use) { | 130 | if (master_saif->mclk_in_use) { |
131 | if (mclk % 32 == 0) { | 131 | switch (mclk / rate) { |
132 | case 32: | ||
133 | case 64: | ||
134 | case 128: | ||
135 | case 256: | ||
136 | case 512: | ||
132 | scr &= ~BM_SAIF_CTRL_BITCLK_BASE_RATE; | 137 | scr &= ~BM_SAIF_CTRL_BITCLK_BASE_RATE; |
133 | ret = clk_set_rate(master_saif->clk, 512 * rate); | 138 | ret = clk_set_rate(master_saif->clk, 512 * rate); |
134 | } else if (mclk % 48 == 0) { | 139 | break; |
140 | case 48: | ||
141 | case 96: | ||
142 | case 192: | ||
143 | case 384: | ||
135 | scr |= BM_SAIF_CTRL_BITCLK_BASE_RATE; | 144 | scr |= BM_SAIF_CTRL_BITCLK_BASE_RATE; |
136 | ret = clk_set_rate(master_saif->clk, 384 * rate); | 145 | ret = clk_set_rate(master_saif->clk, 384 * rate); |
137 | } else { | 146 | break; |
138 | /* SAIF MCLK should be either 32x or 48x */ | 147 | default: |
148 | /* SAIF MCLK should be a sub-rate of 512x or 384x */ | ||
139 | clk_disable_unprepare(master_saif->clk); | 149 | clk_disable_unprepare(master_saif->clk); |
140 | return -EINVAL; | 150 | return -EINVAL; |
141 | } | 151 | } |