1927 |
vortex_t *card = (vortex_t*)codec->private_data; |
vortex_t *card = (vortex_t*)codec->private_data; |
1928 |
unsigned long flags; |
unsigned long flags; |
1929 |
unsigned int lifeboat = 0; |
unsigned int lifeboat = 0; |
1930 |
|
unsigned long read_addr; |
1931 |
spin_lock_irqsave(&card->lock, flags); |
spin_lock_irqsave(&card->lock, flags); |
1932 |
|
|
1933 |
/* wait for transactions to clear */ |
/* wait for transactions to clear */ |
1934 |
while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) { |
while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) { |
1935 |
udelay(100); |
udelay(100); |
1936 |
if (lifeboat++ > POLL_COUNT) { |
if (lifeboat++ > POLL_COUNT) { |
1937 |
printk(KERN_ERR "vortex: ac97 codec busy\n"); |
printk(KERN_ERR "vortex: ac97 codec stuck busy\n"); |
1938 |
return; |
return; |
1939 |
} |
} |
1940 |
} |
} |
1944 |
((data << VORTEX_CODEC_DATSHIFT) & VORTEX_CODEC_DATMASK) | |
((data << VORTEX_CODEC_DATSHIFT) & VORTEX_CODEC_DATMASK) | |
1945 |
VORTEX_CODEC_WRITE); |
VORTEX_CODEC_WRITE); |
1946 |
|
|
1947 |
spin_unlock_irqrestore(&card->lock, flags); |
|
1948 |
|
/* this is necessary to flush the write */ |
1949 |
/* verify that the write succeeded */ |
while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) { |
1950 |
/* This isn't too happy... |
udelay(100); |
1951 |
if (vortex_codec_read(codec, addr) != data) |
if (lifeboat++ > POLL_COUNT) { |
1952 |
printk(KERN_ERR "vortex: ac97 codec write failed %x - %x\n", vortex_codec_read(codec, addr), data); |
printk(KERN_ERR "vortex: ac97 codec stuck busy\n"); |
1953 |
*/ |
return; |
1954 |
|
} |
1955 |
|
} |
1956 |
|
read_addr = ((addr << VORTEX_CODEC_ADDSHIFT) & VORTEX_CODEC_ADDMASK); |
1957 |
|
hwwrite(card->mmio, VORTEX_CODEC_IO, read_addr); |
1958 |
|
|
1959 |
vortex_codec_read(codec, addr); |
spin_unlock_irqrestore(&card->lock, flags); |
1960 |
} |
} |
1961 |
|
|
1962 |
unsigned short vortex_codec_read(ac97_t *codec, unsigned short addr) { |
unsigned short vortex_codec_read(ac97_t *codec, unsigned short addr) { |
1973 |
while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) { |
while (!(hwread(card->mmio, VORTEX_CODEC_CTRL) & 0x100)) { |
1974 |
udelay(100); |
udelay(100); |
1975 |
if (lifeboat++ > POLL_COUNT) { |
if (lifeboat++ > POLL_COUNT) { |
1976 |
printk(KERN_ERR "vortex: ac97 codec busy\n"); |
printk(KERN_ERR "vortex: ac97 codec stuck busy\n"); |
1977 |
return 0xffff; |
return 0xffff; |
1978 |
} |
} |
1979 |
} |
} |