first round name simplification. drop the <component>_ prefix.
[coreboot.git] / src / southbridge / amd / amd8111 / early_smbus.c
1 #include "amd8111_smbus.h"
2
3 #define SMBUS_IO_BASE 0x0f00
4
5 static void enable_smbus(void)
6 {
7         device_t dev;
8         uint8_t enable;
9
10         dev = pci_locate_device(PCI_ID(0x1022, 0x746b), 0);
11         if (dev == PCI_DEV_INVALID) {
12                 die("SMBUS controller not found\n");
13         }
14
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));
18
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");
22         }
23
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");
27 }
28
29 static inline int smbus_recv_byte(unsigned device)
30 {
31         return do_smbus_recv_byte(SMBUS_IO_BASE, device);
32 }
33
34 static inline int smbus_send_byte(unsigned device, unsigned char val)
35 {
36         return do_smbus_send_byte(SMBUS_IO_BASE, device, val);
37 }
38
39 static inline int smbus_read_byte(unsigned device, unsigned address)
40 {
41         return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
42 }
43
44 static inline int smbus_write_byte(unsigned device, unsigned address, unsigned char val)
45 {
46         return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);
47 }
48