Commit 8d567b6b authored by Manuel Lauss's avatar Manuel Lauss Committed by Mark Brown

ASoC: au1x: psc-ac97: reorganize timeouts

Codec read/write functions: wait 21us between the pokings of hardware.
Add timeouts to unbounded loops waiting for bits to change.
Signed-off-by: default avatarManuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent e697cd41
...@@ -75,10 +75,12 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, ...@@ -75,10 +75,12 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
AC97_CDC(pscdata)); AC97_CDC(pscdata));
au_sync(); au_sync();
tmo = 2000; tmo = 20;
while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)) do {
&& --tmo) udelay(21);
udelay(2); if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
break;
} while (--tmo);
data = au_readl(AC97_CDC(pscdata)); data = au_readl(AC97_CDC(pscdata));
...@@ -114,10 +116,12 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, ...@@ -114,10 +116,12 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
AC97_CDC(pscdata)); AC97_CDC(pscdata));
au_sync(); au_sync();
tmo = 2000; tmo = 20;
while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)) do {
&& --tmo) udelay(21);
udelay(2); if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
break;
} while (--tmo);
au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
au_sync(); au_sync();
...@@ -200,7 +204,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, ...@@ -200,7 +204,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
/* FIXME */ /* FIXME */
struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
unsigned long r, ro, stat; unsigned long r, ro, stat;
int chans, stype = SUBSTREAM_TYPE(substream); int chans, t, stype = SUBSTREAM_TYPE(substream);
chans = params_channels(params); chans = params_channels(params);
...@@ -242,8 +246,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, ...@@ -242,8 +246,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
au_sync(); au_sync();
/* ...wait for it... */ /* ...wait for it... */
while (au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) t = 100;
asm volatile ("nop"); while ((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t)
msleep(1);
if (!t)
printk(KERN_ERR "PSC-AC97: can't disable!\n");
/* ...write config... */ /* ...write config... */
au_writel(r, AC97_CFG(pscdata)); au_writel(r, AC97_CFG(pscdata));
...@@ -254,8 +262,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, ...@@ -254,8 +262,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
au_sync(); au_sync();
/* ...and wait for ready bit */ /* ...and wait for ready bit */
while (!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) t = 100;
asm volatile ("nop"); while ((!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t)
msleep(1);
if (!t)
printk(KERN_ERR "PSC-AC97: can't enable!\n");
mutex_unlock(&pscdata->lock); mutex_unlock(&pscdata->lock);
......
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