2007-05-29 12:37:52 +02:00
|
|
|
/*
|
2008-01-18 11:35:56 +01:00
|
|
|
* This file is part of the coreboot project.
|
2007-05-29 12:37:52 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2007-11-30 03:08:26 +01:00
|
|
|
#include <stdint.h>
|
2010-10-09 19:00:18 +02:00
|
|
|
#include <arch/io.h>
|
|
|
|
#include <arch/romcc_io.h>
|
|
|
|
#include <console/console.h>
|
2007-05-29 12:37:52 +02:00
|
|
|
#include <device/pci_ids.h>
|
2010-10-09 19:00:18 +02:00
|
|
|
#include <device/pci_def.h>
|
2007-05-29 12:37:52 +02:00
|
|
|
#include "i82371eb.h"
|
2010-12-08 06:42:47 +01:00
|
|
|
#include "smbus.h"
|
2006-07-24 06:25:47 +02:00
|
|
|
|
2010-10-09 19:00:18 +02:00
|
|
|
void enable_smbus(void)
|
2006-07-24 06:25:47 +02:00
|
|
|
{
|
|
|
|
device_t dev;
|
2007-11-30 03:08:26 +01:00
|
|
|
u8 reg8;
|
|
|
|
u16 reg16;
|
2007-05-29 12:37:52 +02:00
|
|
|
|
2010-10-09 19:00:18 +02:00
|
|
|
/* Get the SMBus/PM device of the 82371AB/EB/MB. */
|
2007-05-29 12:37:52 +02:00
|
|
|
dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_INTEL,
|
2007-11-29 02:44:43 +01:00
|
|
|
PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0);
|
2007-05-29 12:37:52 +02:00
|
|
|
|
|
|
|
/* Set the SMBus I/O base. */
|
|
|
|
pci_write_config32(dev, SMBBA, SMBUS_IO_BASE | 1);
|
2006-07-24 06:25:47 +02:00
|
|
|
|
2007-11-30 03:08:26 +01:00
|
|
|
/* Enable the SMBus controller host interface. */
|
2007-05-29 12:37:52 +02:00
|
|
|
reg8 = pci_read_config8(dev, SMBHSTCFG);
|
|
|
|
reg8 |= SMB_HST_EN;
|
|
|
|
pci_write_config8(dev, SMBHSTCFG, reg8);
|
2006-07-24 06:25:47 +02:00
|
|
|
|
2007-05-29 12:37:52 +02:00
|
|
|
/* Enable access to the SMBus I/O space. */
|
2007-06-03 18:57:27 +02:00
|
|
|
reg16 = pci_read_config16(dev, PCI_COMMAND);
|
2007-11-30 03:08:26 +01:00
|
|
|
reg16 |= PCI_COMMAND_IO;
|
2007-06-03 18:57:27 +02:00
|
|
|
pci_write_config16(dev, PCI_COMMAND, reg16);
|
2006-07-30 02:23:20 +02:00
|
|
|
|
2007-05-29 12:37:52 +02:00
|
|
|
/* Clear any lingering errors, so the transaction will run. */
|
|
|
|
outb(inb(SMBUS_IO_BASE + SMBHST_STATUS), SMBUS_IO_BASE + SMBHST_STATUS);
|
2006-07-30 02:23:20 +02:00
|
|
|
}
|
|
|
|
|
2010-10-09 19:00:18 +02:00
|
|
|
int smbus_read_byte(u8 device, u8 address)
|
2006-07-30 02:23:20 +02:00
|
|
|
{
|
2007-05-29 12:37:52 +02:00
|
|
|
return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
|
2006-07-30 02:23:20 +02:00
|
|
|
}
|