Changeset 3640 for trunk/coreboot-v2
- Timestamp:
- 10/07/08 18:25:10 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/coreboot-v2/src/southbridge/amd/sb600/sb600_hda.c
r3589 r3640 26 26 #include <delay.h> 27 27 #include "sb600.h" 28 29 #define HDA_ICII_REG 0x68 30 #define HDA_ICII_BUSY (1 << 0) 31 #define HDA_ICII_VALID (1 << 1) 28 32 29 33 static int set_bits(u8 * port, u32 mask, u32 val) … … 161 165 } 162 166 167 /** 168 * Wait 50usec for for the codec to indicate it is ready 169 * no response would imply that the codec is non-operative 170 */ 171 172 static int wait_for_ready(u8 *base) 173 { 174 /* Use a 50 usec timeout - the Linux kernel uses the 175 * same duration */ 176 177 int timeout = 50; 178 179 while(timeout--) { 180 u32 dword=readl(base + HDA_ICII_REG); 181 if (!(dword & HDA_ICII_BUSY)) 182 return 0; 183 udelay(1); 184 } 185 186 return -1; 187 } 188 189 /** 190 * Wait 50usec for for the codec to indicate that it accepted 191 * the previous command. No response would imply that the code 192 * is non-operative 193 */ 194 195 static int wait_for_valid(u8 *base) 196 { 197 /* Use a 50 usec timeout - the Linux kernel uses the 198 * same duration */ 199 200 int timeout = 50; 201 while(timeout--) { 202 u32 dword = readl(base + HDA_ICII_REG); 203 if ((dword & (HDA_ICII_VALID | HDA_ICII_BUSY)) == 204 HDA_ICII_VALID) 205 return 0; 206 udelay(1); 207 } 208 209 return 1; 210 } 211 163 212 static void codec_init(u8 * base, int addr) 164 213 { … … 169 218 170 219 /* 1 */ 171 do { 172 dword = readl(base + 0x68); 173 } while (dword & 1); 220 if (wait_for_ready(base) == -1) 221 return; 174 222 175 223 dword = (addr << 28) | 0x000f0000; 176 224 writel(dword, base + 0x60); 177 225 178 do { 179 dword = readl(base + 0x68); 180 } while ((dword & 3) != 2); 226 if (wait_for_valid(base) == -1) 227 return; 181 228 182 229 dword = readl(base + 0x64); … … 194 241 /* 3 */ 195 242 for (i = 0; i < verb_size; i++) { 196 do { 197 dword = readl(base + 0x68); 198 } while (dword & 1); 243 if (wait_for_ready(base) == -1) 244 return; 199 245 200 246 writel(verb[i], base + 0x60); 201 247 202 do { 203 dword = readl(base + 0x68); 204 } while ((dword & 3) != 2); 248 if (wait_for_valid(base) == -1) 249 return; 205 250 } 206 251 printk_debug("verb loaded!\n");
