blob: bc14cc39f207bad128a04b63004f82f833756456 [file] [log] [blame]
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00001/*
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 <stdint.h>
22#include <smbus.h>
23#include <pci.h>
Uwe Hermannbddc6932008-10-29 13:51:31 +000024#include <pci_ids.h>
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000025#include <arch/io.h>
26#include "i82801gx.h"
27#include "i82801_smbus.h"
28
29static int smbus_read_byte(struct bus *bus, device_t dev, u8 address)
30{
31 u16 device;
32 struct resource *res;
33
Stefan Reinauer2b34db82009-02-28 20:10:20 +000034 device = dev->path.i2c.device;
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000035 res = find_resource(bus->dev, 0x20);
36
37 return do_smbus_read_byte(res->base, device, address);
38}
39
40static struct smbus_bus_operations lops_smbus_bus = {
41 .read_byte = smbus_read_byte,
42};
43
44static struct device_operations smbus_ops = {
45 .read_resources = pci_dev_read_resources,
46 .set_resources = pci_dev_set_resources,
47 .enable_resources = pci_dev_enable_resources,
48 .init = 0,
49 .scan_bus = scan_static_bus,
50 .enable = i82801gx_enable,
51 .ops_smbus_bus = &lops_smbus_bus,
52};
53
54/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
55static const struct pci_driver i82801gx_smbus __pci_driver = {
56 .ops = &smbus_ops,
57 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000058 .device = 0x27da,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000059};