2b59a7798886ad925c4f687c6ba37af3e069262a
[coreboot.git] / src / southbridge / nvidia / ck804 / ck804_early_smbus.c
1 /*
2  * Copyright 2004 Tyan Computer
3  *  by yhlu@tyan.com
4  */
5
6 #include "ck804_smbus.h"
7
8 #define SMBUS_IO_BASE 0x1000
9
10 static void enable_smbus(void)
11 {
12         device_t dev;
13         dev = pci_locate_device(PCI_ID(0x10de, 0x0052), 0);
14         if (dev == PCI_DEV_INVALID)
15                 die("SMBus controller not found\n");
16
17         print_debug("SMBus controller enabled\n");
18
19         /* Set SMBus I/O base. */
20         pci_write_config32(dev, 0x20, SMBUS_IO_BASE | 1);
21
22         /* Set SMBus I/O space enable. */
23         pci_write_config16(dev, 0x4, 0x01);
24
25         /* Clear any lingering errors, so the transaction will run. */
26         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
27 }
28
29 static int smbus_read_byte(unsigned device, unsigned address)
30 {
31         return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
32 }
33
34 static inline int smbus_write_byte(unsigned device, unsigned address,
35                             unsigned char val)
36 {
37         return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);
38 }