Revision: linuxbios@linuxbios.org--devel/freebios--devel--2.0--patch-30
[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\r\n");
16         }
17         
18         print_debug("SMBus controller enabled\r\n");
19         /* set smbus iobase */
20         pci_write_config32(dev, 0x20, SMBUS_IO_BASE | 1);
21         /* Set smbus iospace enable */ 
22         pci_write_config16(dev, 0x4, 0x01);
23         /* clear any lingering errors, so the transaction will run */
24         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
25 }
26
27 static int smbus_read_byte(unsigned device, unsigned address)
28 {
29         return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
30 }
31 static int smbus_write_byte(unsigned device, unsigned address, unsigned char val)
32 {
33         return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);
34 }