Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 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. |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 17 | #include <stdint.h> |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 18 | #include <device/smbus.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_ids.h> |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 21 | #include <arch/io.h> |
Stefan Reinauer | 138be83 | 2010-02-27 01:50:21 +0000 | [diff] [blame] | 22 | #include "i82801ax.h" |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 23 | #include "smbus.h" |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 24 | |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 25 | static int lsmbus_read_byte(device_t dev, u8 address) |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 26 | { |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 27 | u16 device; |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 28 | struct resource *res; |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 29 | struct bus *pbus; |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 30 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 31 | device = dev->path.i2c.device; |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 32 | pbus = get_pbus_smbus(dev); |
| 33 | res = find_resource(pbus->dev, 0x20); |
Uwe Hermann | dfb3c13 | 2007-06-19 22:47:11 +0000 | [diff] [blame] | 34 | |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 35 | return do_smbus_read_byte(res->base, device, address); |
| 36 | } |
| 37 | |
Stefan Reinauer | 069385f | 2009-05-26 12:58:00 +0000 | [diff] [blame] | 38 | static struct smbus_bus_operations lops_smbus_bus = { |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 39 | .read_byte = lsmbus_read_byte, |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 42 | static const struct device_operations smbus_ops = { |
Uwe Hermann | dfb3c13 | 2007-06-19 22:47:11 +0000 | [diff] [blame] | 43 | .read_resources = pci_dev_read_resources, |
| 44 | .set_resources = pci_dev_set_resources, |
| 45 | .enable_resources = pci_dev_enable_resources, |
| 46 | .init = 0, |
Kyösti Mälkki | d0e212c | 2015-02-26 20:47:47 +0200 | [diff] [blame] | 47 | .scan_bus = scan_smbus, |
Uwe Hermann | 3b8db81 | 2010-10-08 16:40:23 +0000 | [diff] [blame] | 48 | .enable = i82801ax_enable, |
Uwe Hermann | dfb3c13 | 2007-06-19 22:47:11 +0000 | [diff] [blame] | 49 | .ops_smbus_bus = &lops_smbus_bus, |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 52 | /* 82801AA (ICH) */ |
| 53 | static const struct pci_driver i82801aa_smb __pci_driver = { |
Uwe Hermann | dfb3c13 | 2007-06-19 22:47:11 +0000 | [diff] [blame] | 54 | .ops = &smbus_ops, |
| 55 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 56 | .device = PCI_DEVICE_ID_INTEL_82801AA_SMB, |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 59 | /* 82801AB (ICH0) */ |
| 60 | static const struct pci_driver i82801ab_smb __pci_driver = { |
Uwe Hermann | dfb3c13 | 2007-06-19 22:47:11 +0000 | [diff] [blame] | 61 | .ops = &smbus_ops, |
| 62 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | cce5040 | 2007-11-07 22:09:02 +0000 | [diff] [blame] | 63 | .device = PCI_DEVICE_ID_INTEL_82801AB_SMB, |
Corey Osgood | e99bd10 | 2007-06-14 06:10:57 +0000 | [diff] [blame] | 64 | }; |