6661993324f98fec56edb61769d22ed78d75a5fd
[coreboot.git] / src / southbridge / intel / i82801ax / i82801ax_smbus.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2005 Yinghai Lu <yinghailu@gmail.com>
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 <stdint.h>
22 #include <smbus.h>
23 #include <pci.h>
24 #include <arch/io.h>
25 #include "i82801ax.h"
26 #include "i82801_smbus.h"
27
28 static int smbus_read_byte(struct bus *bus, device_t dev, u8 address)
29 {
30         unsigned device;        /* TODO: u16? */
31         struct resource *res;
32
33         device = dev->path.i2c.device;
34         res = find_resource(bus->dev, 0x20);
35
36         return do_smbus_read_byte(res->base, device, address);
37 }
38
39 static struct smbus_bus_operations lops_smbus_bus = {
40         .read_byte      = smbus_read_byte,
41 };
42
43 static const struct device_operations smbus_ops = {
44         .read_resources         = pci_dev_read_resources,
45         .set_resources          = pci_dev_set_resources,
46         .enable_resources       = pci_dev_enable_resources,
47         .init                   = 0,
48         .scan_bus               = scan_static_bus,
49         .enable                 = i82801er_enable,
50         .ops_smbus_bus          = &lops_smbus_bus,
51 };
52
53 /* 82801AA (ICH) */
54 static const struct pci_driver i82801aa_smb __pci_driver = {
55         .ops    = &smbus_ops,
56         .vendor = PCI_VENDOR_ID_INTEL,
57         .device = PCI_DEVICE_ID_INTEL_82801AA_SMB,
58 };
59
60 /* 82801AB (ICH0) */
61 static const struct pci_driver i82801ab_smb __pci_driver = {
62         .ops    = &smbus_ops,
63         .vendor = PCI_VENDOR_ID_INTEL,
64         .device = PCI_DEVICE_ID_INTEL_82801AB_SMB,
65 };
66