Use common GPL-header format in CK804 files, add missing ones (trivial).
[coreboot.git] / src / southbridge / nvidia / ck804 / ck804_early_smbus.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2004 Tyan Computer
5  * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include "ck804_smbus.h"
22
23 #define SMBUS_IO_BASE 0x1000
24
25 static void enable_smbus(void)
26 {
27         device_t dev;
28         dev = pci_locate_device(PCI_ID(0x10de, 0x0052), 0);
29         if (dev == PCI_DEV_INVALID)
30                 die("SMBus controller not found\n");
31
32         print_debug("SMBus controller enabled\n");
33
34         /* Set SMBus I/O base. */
35         pci_write_config32(dev, 0x20, SMBUS_IO_BASE | 1);
36
37         /* Set SMBus I/O space enable. */
38         pci_write_config16(dev, 0x4, 0x01);
39
40         /* Clear any lingering errors, so the transaction will run. */
41         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
42 }
43
44 static int smbus_read_byte(unsigned device, unsigned address)
45 {
46         return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
47 }
48
49 static inline int smbus_write_byte(unsigned device, unsigned address,
50                             unsigned char val)
51 {
52         return do_smbus_write_byte(SMBUS_IO_BASE, device, address, val);
53 }