Guest User

Untitled

a guest
Dec 10th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /** Read one byte from the intel i2c, used for reading SPD on intel chipsets only. */
  2. unsigned char smb_read_byte_intel(uint32_t base, uint8_t adr, uint8_t cmd)
  3. {
  4. int l1, h1, l2, h2;
  5. unsigned long long t;
  6.  
  7. outb(base + SMBHSTSTS, 0x1f); // reset SMBus Controller
  8. outb(base + SMBHSTDAT, 0xff);
  9.  
  10. while( inb(base + SMBHSTSTS) & 0x01); // wait until ready
  11.  
  12. outb(base + SMBHSTCMD, cmd);
  13. outb(base + SMBHSTADD, (adr << 1) | 0x01 );
  14. outb(base + SMBHSTCNT, 0x48 );
  15.  
  16. rdtsc(l1, h1);
  17.  
  18. while (!( inb(base + SMBHSTSTS) & 0x02)) // wait til command finished
  19. {
  20. rdtsc(l2, h2);
  21. t = ((h2 - h1) * 0xffffffff + (l2 - l1)) / (Platform.CPU.TSCFrequency / 100);
  22. if (t > 5)
  23. break; // break after 5ms
  24. }
  25. return inb(base + SMBHSTDAT);
  26. }
Add Comment
Please, Sign In to add comment