1 #include "amd8111_smbus.h"
3 #define SMBUS_IO_BASE 0x0f00
5 static void enable_smbus(void)
10 dev = pci_locate_device(PCI_ID(0x1022, 0x746b), 0);
11 if (dev == PCI_DEV_INVALID) {
12 die("SMBUS controller not found\n");
15 pci_write_config32(dev, 0x58, SMBUS_IO_BASE | 1);
16 enable = pci_read_config8(dev, 0x41);
17 pci_write_config8(dev, 0x41, enable | (1 << 7));
19 /* check that we can see the smbus controller I/O. */
20 if (inw(SMBUS_IO_BASE)==0xFF){
21 die("SMBUS controller I/O not found\n");
24 /* clear any lingering errors, so the transaction will run */
25 outw(inw(SMBUS_IO_BASE + SMBGSTATUS), SMBUS_IO_BASE + SMBGSTATUS);
26 print_spew("SMBus controller enabled\n");
29 static inline int smbus_recv_byte(unsigned device)
31 return do_smbus_recv_byte(SMBUS_IO_BASE, device);
34 static inline int smbus_send_byte(unsigned device, unsigned char val)
36 return do_smbus_send_byte(SMBUS_IO_BASE, device, val);
39 static inline int smbus_read_byte(unsigned device, unsigned address)
41 return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
44 static inline int smbus_write_byte(unsigned device, unsigned address, unsigned char val)
46 return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);