Changeset 3651 for trunk/coreboot-v2
- Timestamp:
- 10/12/08 16:40:23 (3 months ago)
- Location:
- trunk/coreboot-v2/src/southbridge/via/vt8237r
- Files:
-
- 6 modified
-
chip.h (modified) (1 diff)
-
vt8237_ctrl.c (modified) (5 diffs)
-
vt8237r.c (modified) (1 diff)
-
vt8237r_early_smbus.c (modified) (8 diffs)
-
vt8237r_lpc.c (modified) (11 diffs)
-
vt8237r_sata.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/coreboot-v2/src/southbridge/via/vt8237r/chip.h
r3052 r3651 54 54 int ide1_enable:1; 55 55 56 /* 1 = 80-pin cable */56 /* 1 = 80-pin cable, 0 = 40-pin cable */ 57 57 int ide0_80pin_cable:1; 58 58 int ide1_80pin_cable:1; -
trunk/coreboot-v2/src/southbridge/via/vt8237r/vt8237_ctrl.c
r3567 r3651 29 29 { 30 30 u8 regm, regm2, regm3; 31 32 31 device_t devfun3; 33 32 34 33 devfun3 = dev_find_device(PCI_VENDOR_ID_VIA, 35 PCI_DEVICE_ID_VIA_K8T890CE_3, 0); 34 PCI_DEVICE_ID_VIA_K8T890CE_3, 0); 35 if (!devfun3) 36 devfun3 = dev_find_device(PCI_VENDOR_ID_VIA, 37 PCI_DEVICE_ID_VIA_K8M890CE_3, 0); 38 if (!devfun3) 39 die("Unknown NB"); 36 40 37 if (!devfun3) 38 devfun3 = dev_find_device(PCI_VENDOR_ID_VIA, 39 PCI_DEVICE_ID_VIA_K8M890CE_3, 0); 40 41 if (!devfun3) 42 die("Unknown NB"); 43 44 /* CPU to PCI Flow Control 1 & 2, just fill in recommended */ 41 /* CPU to PCI Flow Control 1 & 2, just fill in recommended. */ 45 42 pci_write_config8(dev, 0x70, 0xc2); 46 43 pci_write_config8(dev, 0x71, 0xc8); … … 55 52 pci_write_config8(dev, 0x78, 0x01); 56 53 /* APIC on HT */ 57 pci_write_config8(dev, 0x7c, 0x77); //maybe Enable LDT APIC Mode bit3 set to 1 54 /* Maybe Enable LDT APIC Mode bit3 set to 1 */ 55 pci_write_config8(dev, 0x7c, 0x77); 58 56 59 57 /* WARNING: Need to copy some registers from NB (D0F3) to SB (D11F7). */ … … 90 88 * NB V-Link Receiving Strobe Delay 0xb7 0x02 0x02 0x61 0x01 91 89 * NB V-Link Compensation Control bit4,0 (b5,b6) 0xb4 0x10 0x10 0x11 0x11 92 * SB V-Link Strobe Drive Control 0xb9 0x00 0xa5 0x98 0x9890 * SB V-Link Strobe Drive Control 0xb9 0x00 0xa5 0x98 0x98 93 91 * SB V-Link Data drive Control???? 0xba 0x00 0xbb 0x77 0x77 94 92 * SB V-Link Receive Strobe Delay???? 0xbb 0x04 0x11 0x11 0x11 … … 97 95 * V-Link CKG Control 0xb1 0x05 0x05 0x01 0x03 98 96 */ 99 100 97 static void vt8237s_vlink_init(struct device *dev) 101 98 { 102 99 u8 reg; 103 104 100 device_t devfun7; 105 101 106 102 devfun7 = dev_find_device(PCI_VENDOR_ID_VIA, 107 PCI_DEVICE_ID_VIA_K8T890CE_7, 0); 108 103 PCI_DEVICE_ID_VIA_K8T890CE_7, 0); 109 104 if (!devfun7) 110 105 devfun7 = dev_find_device(PCI_VENDOR_ID_VIA, 111 PCI_DEVICE_ID_VIA_K8M890CE_7, 0); 112 113 /* no pairing NB found */ 106 PCI_DEVICE_ID_VIA_K8M890CE_7, 0); 107 /* No pairing NB was found. */ 114 108 if (!devfun7) 115 109 return; … … 133 127 pci_write_config8(dev, 0xbb, 0x89); 134 128 135 136 129 reg = pci_read_config8(dev, 0xbd); 137 130 reg |= 0x3; 138 131 pci_write_config8(dev, 0xbd, reg); 139 132 140 /* Program V-link 8X 8bit full duplex, parity disabled FIXME*/133 /* Program V-link 8X 8bit full duplex, parity disabled. FIXME. */ 141 134 pci_write_config8(dev, 0x48, 0x13); 142 135 } 143 136 144 static void ctrl_enable(struct device *dev) {145 146 /* enable the 0:13 and 0:13.1*/137 static void ctrl_enable(struct device *dev) 138 { 139 /* Enable the 0:13 and 0:13.1. */ 147 140 /* FIXME */ 148 141 pci_write_config8(dev, 0x4f, 0x43); 149 142 } 150 143 151 152 144 extern void dump_south(device_t dev); 153 145 154 static void ctrl_init(struct device *dev) { 146 static void ctrl_init(struct device *dev) 147 { 148 /* 149 * TODO: Fix some ordering issue for V-link set Rx77[6] and 150 * PCI1_Rx4F[0] should to 1. 151 * FIXME DO you need? 152 */ 155 153 156 /* TODO: Fix some ordering issue fo V-link set Rx77[6] and PCI1_Rx4F[0] 157 should to 1 FIXME DO you need?*/ 158 159 /* VT8237R specific configuration other SB are done in their own directories */ 160 /* add A version */ 154 /* 155 * VT8237R specific configuration. Other SB are done in their own 156 * directories. TODO: Add A version. 157 */ 161 158 device_t devsb = dev_find_device(PCI_VENDOR_ID_VIA, 162 PCI_DEVICE_ID_VIA_VT8237S_LPC, 0);159 PCI_DEVICE_ID_VIA_VT8237S_LPC, 0); 163 160 if (devsb) { 164 /* FIXME: Skip v-link setup for now */165 // vt8237s_vlink_init(dev);161 /* FIXME: Skip v-link setup for now. */ 162 // vt8237s_vlink_init(dev); 166 163 } 167 164 168 /* configure PCI1 and copy mirror registers from D0F3*/165 /* Configure PCI1 and copy mirror registers from D0F3. */ 169 166 vt8237_cfg(dev); 170 167 dump_south(dev); -
trunk/coreboot-v2/src/southbridge/via/vt8237r/vt8237r.c
r3556 r3651 64 64 for (i = 0; i < 256; i += 16) { 65 65 printk_debug("%02x: ", i); 66 for (j = 0; j < 16; j++) {66 for (j = 0; j < 16; j++) 67 67 printk_debug("%02x ", pci_read_config8(dev, i + j)); 68 }69 68 printk_debug("\n"); 70 69 } -
trunk/coreboot-v2/src/southbridge/via/vt8237r/vt8237r_early_smbus.c
r3567 r3651 129 129 return val; 130 130 } 131 /** 132 * Enable the smbus on vt8237r-based systems 131 132 /** 133 * Enable the SMBus on VT8237R-based systems. 133 134 */ 134 135 void enable_smbus(void) … … 137 138 138 139 /* Power management controller */ 139 140 140 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 141 141 PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); 142 143 142 if (dev == PCI_DEV_INVALID) { 144 143 /* Power management controller */ 145 144 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 146 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);145 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0); 147 146 if (dev == PCI_DEV_INVALID) 148 147 die("Power management controller not found\r\n"); 149 148 } 150 149 151 /* 7 = SMBus Clock from RTC 32.768KHz 150 /* 151 * 7 = SMBus Clock from RTC 32.768KHz 152 152 * 5 = Internal PLL reset from susp 153 153 */ … … 202 202 */ 203 203 for (i = 0; (i < SMBUS_TIMEOUT && ((result < SPD_MEMORY_TYPE_SDRAM) || 204 (result > SPD_MEMORY_TYPE_SDRAM_DDR3))); i++) {204 (result > SPD_MEMORY_TYPE_SDRAM_DDR3))); i++) { 205 205 206 206 if (current_slot > ram_slots) … … 219 219 } 220 220 221 /* fixme better separate the NB and SB, will done once it works*/222 223 void vt8237_sb_enable_fid_vid(void) {224 device_t dev; 225 device_t dev ctl;221 /* FIXME: Better separate the NB and SB, will be done once it works. */ 222 223 void vt8237_sb_enable_fid_vid(void) 224 { 225 device_t dev, devctl; 226 226 227 227 /* Power management controller */ 228 228 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 229 229 PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); 230 231 230 if (dev == PCI_DEV_INVALID) { 232 /* Power management controller */231 /* Power management controller */ 233 232 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 234 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);233 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0); 235 234 if (dev == PCI_DEV_INVALID) 236 235 return; 237 236 238 237 devctl = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 239 PCI_DEVICE_ID_VIA_VT8237_VLINK), 0);238 PCI_DEVICE_ID_VIA_VT8237_VLINK), 0); 240 239 if (devctl == PCI_DEV_INVALID) 241 240 return; 242 241 242 /* TODO: Why is this an extra block? */ 243 243 { 244 u8 tmp; 245 tmp = pci_read_config8(devctl, 0xec); 246 print_debug("EC is "); 247 print_debug_hex8(tmp); 248 print_debug(" E5 is "); 249 tmp = pci_read_config8(dev, 0xe5); 250 print_debug_hex8(tmp); 251 244 u8 tmp; 245 tmp = pci_read_config8(devctl, 0xec); 246 print_debug("EC is "); 247 print_debug_hex8(tmp); 248 print_debug(" E5 is "); 249 tmp = pci_read_config8(dev, 0xe5); 250 print_debug_hex8(tmp); 252 251 } 252 253 253 /* Set ACPI base address to I/O VT8237R_ACPI_IO_BASE. */ 254 254 pci_write_config16(dev, 0x88, VT8237R_ACPI_IO_BASE | 0x1); 255 255 256 /* Enable ACPI accessm RTC signal gated with PSON. */ 256 257 pci_write_config8(dev, 0x81, 0x84); 257 /* Allow SLP# signal to assert LDTSTOP_L. 258 259 /* 260 * Allow SLP# signal to assert LDTSTOP_L. 258 261 * Will work for C3 and for FID/VID change. 259 262 */ 260 263 261 /* fixme */ 262 outb(0xff, VT8237R_ACPI_IO_BASE + 0x50); //fixme maybe not needed 263 264 // outb(0x4, VT8237R_ACPI_IO_BASE + 0x50); //fixme maybe not needed 265 266 /* it seems for AMD LDTSTP is connected not to SLP anymore */ 267 /* enable 0: DPSLP# / DPRSTP# / VRDSLP */ 268 269 /* Enable SATA LED, VR timer = 100us 270 * Enable DPSLP# / DPRSTP# / VRDSLP - WARNING LDTSTP connetcs to some of those pins! (and not to SLP as on R ver) 264 /* FIXME */ 265 outb(0xff, VT8237R_ACPI_IO_BASE + 0x50); /* Maybe unneeded? */ 266 // outb(0x4, VT8237R_ACPI_IO_BASE + 0x50); /* Maybe unneeded? */ 267 268 /* It seems for AMD LDTSTP is connected not to SLP anymore. */ 269 /* Enable 0: DPSLP# / DPRSTP# / VRDSLP */ 270 271 /* 272 * Enable SATA LED, VR timer = 100us. 273 * Enable DPSLP# / DPRSTP# / VRDSLP - WARNING LDTSTP connetcs 274 * to some of those pins! (and not to SLP as on R ver). 271 275 */ 272 //fixme273 pci_write_config8(dev, 0xe5, 0x69); 274 275 /* REQ5 as PCI request input - should be together with INTE-INTH.276 * Fast VR timer disable - need for LDTSTP signal277 */276 pci_write_config8(dev, 0xe5, 0x69); /* FIXME */ 277 278 /* 279 * REQ5 as PCI request input - should be together with 280 * INTE-INTH. Fast VR timer disable - need for LDTSTP signal. 281 */ 278 282 pci_write_config8(dev, 0xe4, 0xa5); 279 280 /* reduce further the STPCLK/LDTSTP signal to 5us */ 281 283 284 /* Reduce further the STPCLK/LDTSTP signal to 5us. */ 282 285 pci_write_config8(dev, 0xec, 0x4); 283 /* Host Bus Power Management Control, maybe not needed */ 286 287 /* Host Bus Power Management Control, maybe not needed. */ 284 288 pci_write_config8(dev, 0x8c, 0x5); 285 289 286 /* so the chip knows we are on AMD*/290 /* So the chip knows we are on AMD. */ 287 291 pci_write_config8(devctl, 0x7c, 0x77); 288 292 289 293 devctl = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 290 0x2336), 0);294 0x2336), 0); 291 295 if (devctl == PCI_DEV_INVALID) 292 296 return; 293 /* Enable C2NOW delay to PSTATECTL VID / FID Change Delay to P-State Control */ 297 298 /* 299 * Enable C2NOW delay to PSTATECTL VID / FID Change Delay 300 * to P-State Control. 301 */ 294 302 pci_write_config8(devctl, 0xa6, 0x83); 295 303 296 //return; //FIXME fall through some revs have it old way 297 } 304 // return; // FIXME: Fall through some revs have it old way. 305 } 306 298 307 /* Set ACPI base address to I/O VT8237R_ACPI_IO_BASE. */ 299 308 pci_write_config16(dev, 0x88, VT8237R_ACPI_IO_BASE | 0x1); 309 300 310 /* Enable ACPI accessm RTC signal gated with PSON. */ 301 311 pci_write_config8(dev, 0x81, 0x84); 302 /* Allow SLP# signal to assert LDTSTOP_L. 312 313 /* 314 * Allow SLP# signal to assert LDTSTOP_L. 303 315 * Will work for C3 and for FID/VID change. 304 316 */ … … 313 325 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 314 326 PCI_DEVICE_ID_VIA_VT8237R_LPC), 0); 315 316 327 if (dev == PCI_DEV_INVALID) { 317 /* Power management controller */328 /* Power management controller */ 318 329 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 319 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0);330 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0); 320 331 if (dev == PCI_DEV_INVALID) 321 332 return; 322 333 } 323 334 324 /* ROM decode last 1MB FFC00000 - FFFFFFFF */335 /* ROM decode last 1MB FFC00000 - FFFFFFFF. */ 325 336 pci_write_config8(dev, 0x41, 0x7f); 326 337 } 327 338 328 void vt8237_early_spi_init(void) { 339 void vt8237_early_spi_init(void) 340 { 329 341 device_t dev; 330 342 volatile u16 *spireg; 331 343 u32 tmp; 332 344 333 /* Bus Control and Power Management */345 /* Bus Control and Power Management */ 334 346 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 335 347 PCI_DEVICE_ID_VIA_VT8237S_LPC), 0); … … 338 350 die("SB not found\r\n"); 339 351 340 /* put SPI base 20 d0 fe*/352 /* Put SPI base 20 d0 fe. */ 341 353 tmp = pci_read_config32(dev, 0xbc); 342 pci_write_config32(dev, 0xbc, (VT8237S_SPI_MEM_BASE >> 8) | (tmp & 0xFF000000)); 343 344 /* set SPI clock to 33MHz */ 354 pci_write_config32(dev, 0xbc, 355 (VT8237S_SPI_MEM_BASE >> 8) | (tmp & 0xFF000000)); 356 357 /* Set SPI clock to 33MHz. */ 345 358 spireg = (u16 *) (VT8237S_SPI_MEM_BASE + 0x6c); 346 (*spireg) &= 0xff00; 347 } 348 349 /* offset 0x58 359 (*spireg) &= 0xff00; 360 } 361 362 /* 363 * Offset 0x58: 350 364 * 31:20 reserved 351 365 * 19:16 4 bit position in shadow EEPROM 352 366 * 15:0 data to write 353 367 * 354 * offset 0x5c368 * Offset 0x5c: 355 369 * 31:28 reserved 356 370 * 27 ERDBG - enable read from 0x5c 357 371 * 26 reserved 358 372 * 25 SEELD 359 * 24 SEEPR - write 1 when done updating, wait until SEELD is set to 1, sticky 373 * 24 SEEPR - write 1 when done updating, wait until SEELD is 374 * set to 1, sticky 360 375 * cleared by reset, if it is 1 writing is disabled 361 376 * 19:16 4 bit position in shadow EEPROM 362 377 * 15:0 data from shadow EEPROM 363 378 * 364 * after PCIRESET SEELD and SEEPR must be 1 and 1365 */366 367 /* 1 = needs PCI reset, 0 don't reset, network initialized */368 369 /* fixme maybe close the debug register after use? */379 * After PCIRESET SEELD and SEEPR must be 1 and 1. 380 */ 381 382 /* 1 = needs PCI reset, 0 don't reset, network initialized. */ 383 384 /* FIXME: Maybe close the debug register after use? */ 370 385 371 386 #define LAN_TIMEOUT 0x7FFFFFFF 372 387 373 int vt8237_early_network_init(struct vt8237_network_rom *rom) { 388 int vt8237_early_network_init(struct vt8237_network_rom *rom) 389 { 374 390 struct vt8237_network_rom n; 375 int loops;391 int i, loops; 376 392 device_t dev; 377 393 u32 tmp; … … 379 395 u16 *rom_write; 380 396 unsigned int checksum; 381 int i;382 397 383 398 /* Network adapter */ 384 399 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, 385 400 PCI_DEVICE_ID_VIA_8233_7), 0); 386 387 401 if (dev == PCI_DEV_INVALID) { 388 print_err("Network is disabled, please enable\n");389 return 0;402 print_err("Network is disabled, please enable\n"); 403 return 0; 390 404 } 391 405 392 406 tmp = pci_read_config32(dev, 0x5c); 393 /* enable ERDBG */ 394 tmp |= 0x08000000; 407 tmp |= 0x08000000; /* Enable ERDBG. */ 395 408 pci_write_config32(dev, 0x5c, tmp); 396 409 397 410 status = ((pci_read_config32(dev, 0x5c) >> 24) & 0x3); 398 399 if (status == 3) { 400 /* network controller OK, EEPROM loaded */ 401 return 0; 402 } 403 411 412 /* Network controller OK, EEPROM loaded. */ 413 if (status == 3) 414 return 0; 415 404 416 if (rom == NULL) { 405 print_err("No configurationdata specified, using default MAC!\n");417 print_err("No config data specified, using default MAC!\n"); 406 418 n.mac_address[0] = 0x0; 407 419 n.mac_address[1] = 0x0; … … 432 444 rom = &n; 433 445 } 434 446 435 447 rom_write = (u16 *) rom; 436 448 checksum = 0; 437 /* write all data except checksum and second to last byte*/438 tmp &= 0xff000000; /* leave reserved bits in*/449 /* Write all data except checksum and second to last byte. */ 450 tmp &= 0xff000000; /* Leave reserved bits in. */ 439 451 for (i = 0; i < 15; i++) { 440 452 pci_write_config32(dev, 0x58, tmp | (i << 16) | rom_write[i]); 441 /* lame code fixme*/453 /* Lame code FIXME */ 442 454 checksum += rom_write[i] & 0xff; 443 / /checksum %= 256;455 /* checksum %= 256; */ 444 456 checksum += (rom_write[i] >> 8) & 0xff; 445 / /checksum %= 256;446 } 447 457 /* checksum %= 256; */ 458 } 459 448 460 checksum += (rom_write[15] & 0xff); 449 461 checksum = ~(checksum & 0xff); 450 462 tmp |= (((checksum & 0xff) << 8) | rom_write[15]); 451 463 452 /* write last byte and checksum*/453 pci_write_config32(dev, 0x58, (15 << 16) | tmp);454 464 /* Write last byte and checksum. */ 465 pci_write_config32(dev, 0x58, (15 << 16) | tmp); 466 455 467 tmp = pci_read_config32(dev, 0x5c); 456 pci_write_config32(dev, 0x5c, tmp | 0x01000000); /* toggle SEEPR*/457 468 pci_write_config32(dev, 0x5c, tmp | 0x01000000); /* Toggle SEEPR. */ 469 458 470 /* Yes, this is a mess, but it's the easiest way to do it. */ 459 while ( (((pci_read_config32(dev, 0x5c) >> 25) & 1) == 0)460 && (loops < LAN_TIMEOUT)) 471 while ((((pci_read_config32(dev, 0x5c) >> 25) & 1) == 0) 472 && (loops < LAN_TIMEOUT)) { 461 473 ++loops; 474 } 462 475 463 476 if (loops >= LAN_TIMEOUT) { 464 print_err("Timout - LAN controller did not accept configuration\n");465 return 0;466 } 467 468 /* we are done, config will be used after PCIRST#*/477 print_err("Timeout - LAN controller didn't accept config\n"); 478 return 0; 479 } 480 481 /* We are done, config will be used after PCIRST#. */ 469 482 return 1; 470 483 } -
trunk/coreboot-v2/src/southbridge/via/vt8237r/vt8237r_lpc.c
r3567 r3651 55 55 /* IO-APIC virtual wire mode configuration. */ 56 56 /* mask, trigger, polarity, destination, delivery, vector */ 57 {0, ENABLED | TRIGGER_EDGE | POLARITY_HIGH | PHYSICAL_DEST |58 ExtINT, NONE},57 {0, ENABLED | TRIGGER_EDGE | POLARITY_HIGH | PHYSICAL_DEST | 58 ExtINT, NONE}, { 59 59 {1, DISABLED, NONE}, 60 60 {2, DISABLED, NONE}, … … 168 168 pci_write_config8(dev, 0x93, 0x88); 169 169 170 /* 7 = SMBus clock from RTC 32.768KHz 170 /* 171 * 7 = SMBus clock from RTC 32.768KHz 171 172 * 5 = Internal PLL reset from susp 172 173 * 2 = GPO2 is GPIO … … 174 175 pci_write_config8(dev, 0x94, 0xa4); 175 176 176 /* 7 = stp to sust delay 1msec 177 /* 178 * 7 = stp to sust delay 1msec 177 179 * 6 = SUSST# Deasserted Before PWRGD for STD 178 180 * 4 = PWRGOOD reset on VT8237A/S … … 217 219 /* SCI is generated for RTC/pwrBtn/slpBtn. */ 218 220 outw(0x001, VT8237R_ACPI_IO_BASE + 0x04); 219 220 } 221 222 223 static void vt8237r_init(struct device *dev) { 221 } 222 223 static void vt8237r_init(struct device *dev) 224 { 224 225 u8 enables; 225
