Support for the Intel ICH7 southbridge.
[coreboot.git] / src / southbridge / intel / i82801gx / i82801gx_early_smbus.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
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 <device/pci_ids.h>
22 #include "i82801gx.h"
23 #include "i82801gx_smbus.h"
24
25 static void enable_smbus(void)
26 {
27         device_t dev;
28
29         /* Set the SMBus device statically. */
30         dev = PCI_DEV(0x0, 0x1f, 0x3);
31
32         /* Check to make sure we've got the right device. */
33         if (pci_read_config16(dev, 0x2) != 0x27da) {
34                 die("SMBus controller not found!");
35         }
36
37         /* Set SMBus I/O base. */
38         pci_write_config32(dev, SMB_BASE,
39                            SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
40
41         /* Set SMBus enable. */
42         pci_write_config8(dev, HOSTC, HST_EN);
43
44         /* Set SMBus I/O space enable. */
45         pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
46
47         /* Disable interrupt generation. */
48         outb(0, SMBUS_IO_BASE + SMBHSTCTL);
49
50         /* Clear any lingering errors, so transactions can run. */
51         outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
52         print_debug("SMBus controller enabled.\r\n");
53 }
54
55 static inline int smbus_read_byte(unsigned device, unsigned address)
56 {
57         return do_smbus_read_byte(device, address);
58 }
59