Intel 82801ax/82801bx: Fix and hook up i82801xx_smbus.c.
[coreboot.git] / src / southbridge / intel / i82801bx / i82801bx_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 <device/smbus.h>
23 #include <device/pci.h>
24 #include <device/pci_ids.h>
25 #include <arch/io.h>
26 #include "i82801bx.h"
27 #include "i82801bx_smbus.h"
28
29 static int lsmbus_read_byte(device_t dev, u8 address)
30 {
31         u16 device;
32         struct resource *res;
33         struct bus *pbus;
34
35         device = dev->path.i2c.device;
36         pbus = get_pbus_smbus(dev);
37         res = find_resource(pbus->dev, 0x20);
38
39         return do_smbus_read_byte(res->base, device, address);
40 }
41
42 static struct smbus_bus_operations lops_smbus_bus = {
43         .read_byte      = lsmbus_read_byte,
44 };
45
46 static const struct device_operations smbus_ops = {
47         .read_resources         = pci_dev_read_resources,
48         .set_resources          = pci_dev_set_resources,
49         .enable_resources       = pci_dev_enable_resources,
50         .init                   = 0,
51         .scan_bus               = scan_static_bus,
52         .enable                 = i82801bx_enable,
53         .ops_smbus_bus          = &lops_smbus_bus,
54 };
55
56 /* 82801AA (ICH) */
57 static const struct pci_driver i82801aa_smb __pci_driver = {
58         .ops    = &smbus_ops,
59         .vendor = PCI_VENDOR_ID_INTEL,
60         .device = PCI_DEVICE_ID_INTEL_82801AA_SMB,
61 };
62
63 /* 82801AB (ICH0) */
64 static const struct pci_driver i82801ab_smb __pci_driver = {
65         .ops    = &smbus_ops,
66         .vendor = PCI_VENDOR_ID_INTEL,
67         .device = PCI_DEVICE_ID_INTEL_82801AB_SMB,
68 };
69
70 /* 82801BA/BAM (ICH2/ICH2-M) */
71 static const struct pci_driver i82801ba_smb __pci_driver = {
72         .ops    = &smbus_ops,
73         .vendor = PCI_VENDOR_ID_INTEL,
74         .device = PCI_DEVICE_ID_INTEL_82801BA_SMB,
75 };
76
77 /* 82801CA/CAM (ICH3-S/ICH3-M) */
78 static const struct pci_driver i82801ca_smb __pci_driver = {
79         .ops    = &smbus_ops,
80         .vendor = PCI_VENDOR_ID_INTEL,
81         .device = PCI_DEVICE_ID_INTEL_82801CA_SMB,
82 };
83
84 /* 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) */
85 static const struct pci_driver i82801db_smb __pci_driver = {
86         .ops    = &smbus_ops,
87         .vendor = PCI_VENDOR_ID_INTEL,
88         .device = PCI_DEVICE_ID_INTEL_82801DB_SMB,
89 };
90
91 /* 82801EB/ER (ICH5/ICH5R) */
92 static const struct pci_driver i82801eb_smb __pci_driver = {
93         .ops    = &smbus_ops,
94         .vendor = PCI_VENDOR_ID_INTEL,
95         .device = PCI_DEVICE_ID_INTEL_82801EB_SMB,
96 };
97
98 /* 82801FB/FR/FW/FRW/FBM (ICH6/ICH6R/ICH6W/ICH6RW/ICH6-M) */
99 static const struct pci_driver i82801fb_smb __pci_driver = {
100         .ops    = &smbus_ops,
101         .vendor = PCI_VENDOR_ID_INTEL,
102         .device = PCI_DEVICE_ID_INTEL_82801FB_SMB,
103 };
104
105 /* 82801E (C-ICH) */
106 static const struct pci_driver i82801e_smb __pci_driver = {
107         .ops    = &smbus_ops,
108         .vendor = PCI_VENDOR_ID_INTEL,
109         .device = PCI_DEVICE_ID_INTEL_82801E_SMB,
110 };