summaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2009-10-19 16:10:59 +0200
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-10-19 16:12:31 +0100
commit8d567b6b441bfcc20e8cbebc0dc376b2e280cd88 (patch)
treede34b3c4107a81990922df87311459978af6e87f /sound/soc/au1x
parente697cd410a0c3aaea697c9915837e99933d8935b (diff)
downloadop-kernel-dev-8d567b6b441bfcc20e8cbebc0dc376b2e280cd88.zip
op-kernel-dev-8d567b6b441bfcc20e8cbebc0dc376b2e280cd88.tar.gz
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: Manuel Lauss <manuel.lauss@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/au1x')
-rw-r--r--sound/soc/au1x/psc-ac97.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c
index efe2afd..2a06a9c 100644
--- a/sound/soc/au1x/psc-ac97.c
+++ b/sound/soc/au1x/psc-ac97.c
@@ -75,10 +75,12 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
AC97_CDC(pscdata));
au_sync();
- tmo = 2000;
- while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD))
- && --tmo)
- udelay(2);
+ tmo = 20;
+ do {
+ udelay(21);
+ if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
+ break;
+ } while (--tmo);
data = au_readl(AC97_CDC(pscdata));
@@ -114,10 +116,12 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
AC97_CDC(pscdata));
au_sync();
- tmo = 2000;
- while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD))
- && --tmo)
- udelay(2);
+ tmo = 20;
+ do {
+ udelay(21);
+ if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
+ break;
+ } while (--tmo);
au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
au_sync();
@@ -200,7 +204,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
/* FIXME */
struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
unsigned long r, ro, stat;
- int chans, stype = SUBSTREAM_TYPE(substream);
+ int chans, t, stype = SUBSTREAM_TYPE(substream);
chans = params_channels(params);
@@ -242,8 +246,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
au_sync();
/* ...wait for it... */
- while (au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)
- asm volatile ("nop");
+ t = 100;
+ 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... */
au_writel(r, AC97_CFG(pscdata));
@@ -254,8 +262,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
au_sync();
/* ...and wait for ready bit */
- while (!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR))
- asm volatile ("nop");
+ t = 100;
+ 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);
OpenPOWER on IntegriCloud