Commit fa68e002 authored by Jassi's avatar Jassi Committed by Mark Brown

ASoC: S3C lrsync function made to work with IRQs disabled.

s3c2412_snd_lrsync() maybe reached with IRQs disabled and if LRCLK
is dead due to improper initialization of CPU or CODEC, the system
gets stuck in the loop because jiffies may never get updated.
Implemented counter based wait mechanism for atleast the same
timeout period.
Signed-off-by: default avatarJassi <jassi.brar@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 3eef08ba
...@@ -230,6 +230,8 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) ...@@ -230,6 +230,8 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on)
pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
} }
#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
/* /*
* Wait for the LR signal to allow synchronisation to the L/R clock * Wait for the LR signal to allow synchronisation to the L/R clock
* from the codec. May only be needed for slave mode. * from the codec. May only be needed for slave mode.
...@@ -237,19 +239,21 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) ...@@ -237,19 +239,21 @@ static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on)
static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s) static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s)
{ {
u32 iiscon; u32 iiscon;
unsigned long timeout = jiffies + msecs_to_jiffies(5); unsigned long loops = msecs_to_loops(5);
pr_debug("Entered %s\n", __func__); pr_debug("Entered %s\n", __func__);
while (1) { while (--loops) {
iiscon = readl(i2s->regs + S3C2412_IISCON); iiscon = readl(i2s->regs + S3C2412_IISCON);
if (iiscon & S3C2412_IISCON_LRINDEX) if (iiscon & S3C2412_IISCON_LRINDEX)
break; break;
if (timeout < jiffies) { cpu_relax();
printk(KERN_ERR "%s: timeout\n", __func__); }
return -ETIMEDOUT;
} if (!loops) {
printk(KERN_ERR "%s: timeout\n", __func__);
return -ETIMEDOUT;
} }
return 0; return 0;
......
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