diff options
author | Manuel Lauss <manuel.lauss@googlemail.com> | 2009-10-19 10:10:59 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-10-19 11:12:31 -0400 |
commit | 8d567b6b441bfcc20e8cbebc0dc376b2e280cd88 (patch) | |
tree | de34b3c4107a81990922df87311459978af6e87f /sound/soc/au1x | |
parent | e697cd410a0c3aaea697c9915837e99933d8935b (diff) |
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.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index efe2afd4fe24..2a06a9c548af 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, | |||
75 | AC97_CDC(pscdata)); | 75 | AC97_CDC(pscdata)); |
76 | au_sync(); | 76 | au_sync(); |
77 | 77 | ||
78 | tmo = 2000; | 78 | tmo = 20; |
79 | while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)) | 79 | do { |
80 | && --tmo) | 80 | udelay(21); |
81 | udelay(2); | 81 | if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) |
82 | break; | ||
83 | } while (--tmo); | ||
82 | 84 | ||
83 | data = au_readl(AC97_CDC(pscdata)); | 85 | data = au_readl(AC97_CDC(pscdata)); |
84 | 86 | ||
@@ -114,10 +116,12 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
114 | AC97_CDC(pscdata)); | 116 | AC97_CDC(pscdata)); |
115 | au_sync(); | 117 | au_sync(); |
116 | 118 | ||
117 | tmo = 2000; | 119 | tmo = 20; |
118 | while ((!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)) | 120 | do { |
119 | && --tmo) | 121 | udelay(21); |
120 | udelay(2); | 122 | if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) |
123 | break; | ||
124 | } while (--tmo); | ||
121 | 125 | ||
122 | au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); | 126 | au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); |
123 | au_sync(); | 127 | au_sync(); |
@@ -200,7 +204,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, | |||
200 | /* FIXME */ | 204 | /* FIXME */ |
201 | struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; | 205 | struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; |
202 | unsigned long r, ro, stat; | 206 | unsigned long r, ro, stat; |
203 | int chans, stype = SUBSTREAM_TYPE(substream); | 207 | int chans, t, stype = SUBSTREAM_TYPE(substream); |
204 | 208 | ||
205 | chans = params_channels(params); | 209 | chans = params_channels(params); |
206 | 210 | ||
@@ -242,8 +246,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, | |||
242 | au_sync(); | 246 | au_sync(); |
243 | 247 | ||
244 | /* ...wait for it... */ | 248 | /* ...wait for it... */ |
245 | while (au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) | 249 | t = 100; |
246 | asm volatile ("nop"); | 250 | while ((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t) |
251 | msleep(1); | ||
252 | |||
253 | if (!t) | ||
254 | printk(KERN_ERR "PSC-AC97: can't disable!\n"); | ||
247 | 255 | ||
248 | /* ...write config... */ | 256 | /* ...write config... */ |
249 | au_writel(r, AC97_CFG(pscdata)); | 257 | au_writel(r, AC97_CFG(pscdata)); |
@@ -254,8 +262,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, | |||
254 | au_sync(); | 262 | au_sync(); |
255 | 263 | ||
256 | /* ...and wait for ready bit */ | 264 | /* ...and wait for ready bit */ |
257 | while (!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) | 265 | t = 100; |
258 | asm volatile ("nop"); | 266 | while ((!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t) |
267 | msleep(1); | ||
268 | |||
269 | if (!t) | ||
270 | printk(KERN_ERR "PSC-AC97: can't enable!\n"); | ||
259 | 271 | ||
260 | mutex_unlock(&pscdata->lock); | 272 | mutex_unlock(&pscdata->lock); |
261 | 273 | ||