Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Read one byte from the intel i2c, used for reading SPD on intel chipsets only. */
- unsigned char smb_read_byte_intel(uint32_t base, uint8_t adr, uint8_t cmd)
- {
- int l1, h1, l2, h2;
- unsigned long long t;
- outb(base + SMBHSTSTS, 0x1f); // reset SMBus Controller
- outb(base + SMBHSTDAT, 0xff);
- rdtsc(l1, h1);
- while ( inb(base + SMBHSTSTS) & 0x01) // wait until read
- {
- rdtsc(l2, h2);
- t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform.CPU.TSCFrequency / 100);
- if (t > 5)
- return 0xFF; // break after 5ms
- }
- outb(base + SMBHSTCMD, cmd);
- outb(base + SMBHSTADD, (adr << 1) | 0x01 );
- outb(base + SMBHSTCNT, 0x48 );
- rdtsc(l1, h1);
- while (!( inb(base + SMBHSTSTS) & 0x02)) // wait til command finished
- {
- rdtsc(l2, h2);
- t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform.CPU.TSCFrequency / 100);
- if (t > 5)
- return 0xFF; // break after 5ms
- }
- return inb(base + SMBHSTDAT);
- }
Add Comment
Please, Sign In to add comment