aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/mxs/mxs-saif.c
diff options
context:
space:
mode:
authorDong Aisheng <b29396@freescale.com>2011-08-21 11:45:40 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-08-22 18:33:49 -0400
commitbbe8ff5e25afd4d06c8a8bad009aca5f0d0c22ef (patch)
treeaca8b98790f77bbfaa1a1087813b3e003c7d8efe /sound/soc/mxs/mxs-saif.c
parent09d930ae5198fbb67b86d3d058ad82211f469a46 (diff)
ASoC: mxs-saif: clear clk gate first before register setting
Saif needs clear clk gate first before writing registers or the write will not success. The original xx_get_mclk function clear clk gate after mclk setting that may cause the former mclk setting unwork, then the real output mclk maybe inaccurate. Placing the clear before setting mclk to avoid such an issue. We also have to clear clk gate in startup instead of in prepare function. Signed-off-by: Dong Aisheng <b29396@freescale.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/mxs/mxs-saif.c')
-rw-r--r--sound/soc/mxs/mxs-saif.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index 0b3adaec9f4c..530017f7d14a 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -187,16 +187,20 @@ int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
187 if (!saif) 187 if (!saif)
188 return -EINVAL; 188 return -EINVAL;
189 189
190 /* Clear Reset */
191 __raw_writel(BM_SAIF_CTRL_SFTRST,
192 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
193
194 /* FIXME: need clear clk gate for register r/w */
195 __raw_writel(BM_SAIF_CTRL_CLKGATE,
196 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
197
190 stat = __raw_readl(saif->base + SAIF_STAT); 198 stat = __raw_readl(saif->base + SAIF_STAT);
191 if (stat & BM_SAIF_STAT_BUSY) { 199 if (stat & BM_SAIF_STAT_BUSY) {
192 dev_err(saif->dev, "error: busy\n"); 200 dev_err(saif->dev, "error: busy\n");
193 return -EBUSY; 201 return -EBUSY;
194 } 202 }
195 203
196 /* Clear Reset */
197 __raw_writel(BM_SAIF_CTRL_SFTRST,
198 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
199
200 saif->mclk_in_use = 1; 204 saif->mclk_in_use = 1;
201 ret = mxs_saif_set_clk(saif, mclk, rate); 205 ret = mxs_saif_set_clk(saif, mclk, rate);
202 if (ret) 206 if (ret)
@@ -207,8 +211,6 @@ int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
207 return ret; 211 return ret;
208 212
209 /* enable MCLK output */ 213 /* enable MCLK output */
210 __raw_writel(BM_SAIF_CTRL_CLKGATE,
211 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
212 __raw_writel(BM_SAIF_CTRL_RUN, 214 __raw_writel(BM_SAIF_CTRL_RUN,
213 saif->base + SAIF_CTRL + MXS_SET_ADDR); 215 saif->base + SAIF_CTRL + MXS_SET_ADDR);
214 216
@@ -303,6 +305,10 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream,
303 __raw_writel(BM_SAIF_CTRL_SFTRST, 305 __raw_writel(BM_SAIF_CTRL_SFTRST,
304 saif->base + SAIF_CTRL + MXS_CLR_ADDR); 306 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
305 307
308 /* clear clock gate */
309 __raw_writel(BM_SAIF_CTRL_CLKGATE,
310 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
311
306 return 0; 312 return 0;
307} 313}
308 314
@@ -379,10 +385,6 @@ static int mxs_saif_prepare(struct snd_pcm_substream *substream,
379{ 385{
380 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); 386 struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);
381 387
382 /* clear clock gate */
383 __raw_writel(BM_SAIF_CTRL_CLKGATE,
384 saif->base + SAIF_CTRL + MXS_CLR_ADDR);
385
386 /* enable FIFO error irqs */ 388 /* enable FIFO error irqs */
387 __raw_writel(BM_SAIF_CTRL_FIFO_ERROR_IRQ_EN, 389 __raw_writel(BM_SAIF_CTRL_FIFO_ERROR_IRQ_EN,
388 saif->base + SAIF_CTRL + MXS_SET_ADDR); 390 saif->base + SAIF_CTRL + MXS_SET_ADDR);