Lines Matching +full:wait +full:- +full:retry +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Charles Eidsness <charles@cooper-street.com>
23 #include <asm/mach-au1x00/au1000.h>
57 /* how often to retry failed codec register reads/writes */
74 return __raw_readl(ctx->mmio + reg); in RD()
79 __raw_writel(v, ctx->mmio + reg); in WR()
87 unsigned int tmo, retry; in au1xac97c_ac97_read() local
91 retry = AC97_RW_RETRIES; in au1xac97c_ac97_read()
93 mutex_lock(&ctx->lock); in au1xac97c_ac97_read()
96 while ((RD(ctx, AC97_STATUS) & STAT_CP) && --tmo) in au1xac97c_ac97_read()
97 udelay(21); /* wait an ac97 frame time */ in au1xac97c_ac97_read()
105 /* stupid errata: data is only valid for 21us, so in au1xac97c_ac97_read()
109 while ((RD(ctx, AC97_STATUS) & STAT_CP) && --tmo) in au1xac97c_ac97_read()
117 mutex_unlock(&ctx->lock); in au1xac97c_ac97_read()
118 } while (--retry && !tmo); in au1xac97c_ac97_read()
120 pr_debug("AC97RD %04x %04lx %d\n", r, data, retry); in au1xac97c_ac97_read()
122 return retry ? data & 0xffff : 0xffff; in au1xac97c_ac97_read()
129 unsigned int tmo, retry; in au1xac97c_ac97_write() local
131 retry = AC97_RW_RETRIES; in au1xac97c_ac97_write()
133 mutex_lock(&ctx->lock); in au1xac97c_ac97_write()
135 for (tmo = 5; (RD(ctx, AC97_STATUS) & STAT_CP) && tmo; tmo--) in au1xac97c_ac97_write()
144 for (tmo = 10; (RD(ctx, AC97_STATUS) & STAT_CP) && tmo; tmo--) in au1xac97c_ac97_write()
149 mutex_unlock(&ctx->lock); in au1xac97c_ac97_write()
150 } while (--retry && !tmo); in au1xac97c_ac97_write()
152 pr_debug("AC97WR %04x %04x %d\n", r, v, retry); in au1xac97c_ac97_write()
159 WR(ctx, AC97_CONFIG, ctx->cfg | CFG_SG | CFG_SN); in au1xac97c_ac97_warm_reset()
161 WR(ctx, AC97_CONFIG, ctx->cfg | CFG_SG); in au1xac97c_ac97_warm_reset()
162 WR(ctx, AC97_CONFIG, ctx->cfg); in au1xac97c_ac97_warm_reset()
170 WR(ctx, AC97_CONFIG, ctx->cfg | CFG_RS); in au1xac97c_ac97_cold_reset()
172 WR(ctx, AC97_CONFIG, ctx->cfg); in au1xac97c_ac97_cold_reset()
174 /* wait for codec ready */ in au1xac97c_ac97_cold_reset()
176 while (((RD(ctx, AC97_STATUS) & STAT_RD) == 0) && --i) in au1xac97c_ac97_cold_reset()
194 snd_soc_dai_set_dma_data(dai, substream, &ctx->dmaids[0]); in alchemy_ac97c_startup()
200 return ac97c_workdata ? 0 : -ENODEV; in au1xac97c_dai_probe()
209 .name = "alchemy-ac97c",
236 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); in au1xac97c_drvprobe()
238 return -ENOMEM; in au1xac97c_drvprobe()
240 mutex_init(&ctx->lock); in au1xac97c_drvprobe()
244 return -ENODEV; in au1xac97c_drvprobe()
246 if (!devm_request_mem_region(&pdev->dev, iores->start, in au1xac97c_drvprobe()
248 pdev->name)) in au1xac97c_drvprobe()
249 return -EBUSY; in au1xac97c_drvprobe()
251 ctx->mmio = devm_ioremap(&pdev->dev, iores->start, in au1xac97c_drvprobe()
253 if (!ctx->mmio) in au1xac97c_drvprobe()
254 return -EBUSY; in au1xac97c_drvprobe()
258 return -EBUSY; in au1xac97c_drvprobe()
259 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; in au1xac97c_drvprobe()
263 return -EBUSY; in au1xac97c_drvprobe()
264 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; in au1xac97c_drvprobe()
270 ctx->cfg = CFG_RC(3) | CFG_XS(3); in au1xac97c_drvprobe()
271 WR(ctx, AC97_CONFIG, ctx->cfg); in au1xac97c_drvprobe()
279 ret = snd_soc_register_component(&pdev->dev, &au1xac97c_component, in au1xac97c_drvprobe()
292 snd_soc_unregister_component(&pdev->dev); in au1xac97c_drvremove()
315 WR(ctx, AC97_CONFIG, ctx->cfg); in au1xac97c_drvresume()
335 .name = "alchemy-ac97c",