Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 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 <stdint.h> |
| 22 | #include <smbus.h> |
| 23 | #include <pci.h> |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 24 | #include <pci_ids.h> |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 25 | #include <arch/io.h> |
| 26 | #include "i82801gx.h" |
| 27 | #include "i82801_smbus.h" |
| 28 | |
| 29 | static int smbus_read_byte(struct bus *bus, device_t dev, u8 address) |
| 30 | { |
| 31 | u16 device; |
| 32 | struct resource *res; |
| 33 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame^] | 34 | device = dev->path.i2c.device; |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 35 | res = find_resource(bus->dev, 0x20); |
| 36 | |
| 37 | return do_smbus_read_byte(res->base, device, address); |
| 38 | } |
| 39 | |
| 40 | static struct smbus_bus_operations lops_smbus_bus = { |
| 41 | .read_byte = smbus_read_byte, |
| 42 | }; |
| 43 | |
| 44 | static 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) */ |
| 55 | static const struct pci_driver i82801gx_smbus __pci_driver = { |
| 56 | .ops = &smbus_ops, |
| 57 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 58 | .device = 0x27da, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 59 | }; |