Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +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. |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> |
| 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. |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 17 | #include <stdint.h> |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 18 | #include <arch/io.h> |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 19 | #include <console/console.h> |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 20 | #include <device/pci_ids.h> |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 21 | #include <device/pci_def.h> |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 22 | #include "i82371eb.h" |
stepan | 836ae29 | 2010-12-08 05:42:47 +0000 | [diff] [blame] | 23 | #include "smbus.h" |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 24 | |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 25 | void enable_smbus(void) |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 26 | { |
| 27 | device_t dev; |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 28 | u8 reg8; |
| 29 | u16 reg16; |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 30 | |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 31 | /* Get the SMBus/PM device of the 82371AB/EB/MB. */ |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 32 | dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 447aafe | 2007-11-29 01:44:43 +0000 | [diff] [blame] | 33 | PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0); |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 34 | |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 35 | /* Set the SMBus I/O base. */ |
| 36 | pci_write_config32(dev, SMBBA, SMBUS_IO_BASE | 1); |
| 37 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 38 | /* Enable the SMBus controller host interface. */ |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 39 | reg8 = pci_read_config8(dev, SMBHSTCFG); |
| 40 | reg8 |= SMB_HST_EN; |
| 41 | pci_write_config8(dev, SMBHSTCFG, reg8); |
| 42 | |
| 43 | /* Enable access to the SMBus I/O space. */ |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame] | 44 | reg16 = pci_read_config16(dev, PCI_COMMAND); |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 45 | reg16 |= PCI_COMMAND_IO; |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame] | 46 | pci_write_config16(dev, PCI_COMMAND, reg16); |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 47 | |
| 48 | /* Clear any lingering errors, so the transaction will run. */ |
| 49 | outb(inb(SMBUS_IO_BASE + SMBHST_STATUS), SMBUS_IO_BASE + SMBHST_STATUS); |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 52 | int smbus_read_byte(u8 device, u8 address) |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame] | 53 | { |
| 54 | return do_smbus_read_byte(SMBUS_IO_BASE, device, address); |
| 55 | } |