[coreboot] r904 - coreboot-v3/southbridge/amd/sb600
svn at coreboot.org
svn at coreboot.org
Tue Oct 7 02:29:36 CEST 2008
Author: rminnich
Date: 2008-10-07 02:29:36 +0200 (Tue, 07 Oct 2008)
New Revision: 904
Modified:
coreboot-v3/southbridge/amd/sb600/hda.c
Log:
We shouldn't assume the presence of a working HDA codec, so put in
a reasonable timeout of 50usecs (timeout value borrowed from the kernel).
This makes SimNow work, since apparently though the codec is
present in Simnow, it is non functional.
Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>
Acked-by: Ronald G. Minnich <rminnich at gmail.com>
Modified: coreboot-v3/southbridge/amd/sb600/hda.c
===================================================================
--- coreboot-v3/southbridge/amd/sb600/hda.c 2008-10-06 23:31:18 UTC (rev 903)
+++ coreboot-v3/southbridge/amd/sb600/hda.c 2008-10-07 00:29:36 UTC (rev 904)
@@ -162,6 +162,32 @@
return sizeof(cim_verb_data) / sizeof(u32);
}
+static int wait_for_ready(u8 *base)
+{
+ int timeout = 50;
+ while(timeout--) {
+ u32 dword=readl(base + 0x68);
+ if (!(dword & 1))
+ return 0;
+ udelay(1);
+ }
+
+ return -1;
+}
+
+static int wait_for_valid(u8 *base)
+{
+ int timeout = 50;
+ while(timeout--) {
+ u32 dword = readl(base + 0x68);
+ if ((dword & 3) == 2)
+ return 0;
+ udelay(1);
+ }
+
+ return 1;
+}
+
static void codec_init(u8 * base, int addr)
{
u32 dword;
@@ -170,16 +196,14 @@
int i;
/* 1 */
- do {
- dword = readl(base + 0x68);
- } while (dword & 1);
+ if (wait_for_ready(base) == -1)
+ return;
dword = (addr << 28) | 0x000f0000;
writel(dword, base + 0x60);
- do {
- dword = readl(base + 0x68);
- } while ((dword & 3) != 2);
+ if (wait_for_valid(base) == -1)
+ return;
dword = readl(base + 0x64);
@@ -195,15 +219,13 @@
printk(BIOS_DEBUG, "verb_size: %d\n", verb_size);
/* 3 */
for (i = 0; i < verb_size; i++) {
- do {
- dword = readl(base + 0x68);
- } while (dword & 1);
+ if (wait_for_ready(base) == -1)
+ return;
writel(verb[i], base + 0x60);
- do {
- dword = readl(base + 0x68);
- } while ((dword & 3) != 2);
+ if (wait_for_valid(base) == -1)
+ return;
}
printk(BIOS_DEBUG, "verb loaded!\n");
}
More information about the coreboot
mailing list