blob: de16717416de9954aed0e866a7b3924faebe0830 [file] [log] [blame]
Uwe Hermann1410c2d2007-05-29 10:37:52 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Uwe Hermann1410c2d2007-05-29 10:37:52 +00003 *
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 Hermann1410c2d2007-05-29 10:37:52 +000015 */
16
Uwe Hermann9da69f82007-11-30 02:08:26 +000017#include <stdint.h>
Uwe Hermann115c5b92010-10-09 17:00:18 +000018#include <arch/io.h>
Uwe Hermann1410c2d2007-05-29 10:37:52 +000019#include <device/pci_ids.h>
Uwe Hermann115c5b92010-10-09 17:00:18 +000020#include <device/pci_def.h>
Arthur Heymans16fe7902017-04-12 17:01:31 +020021#include <southbridge/intel/common/smbus.h>
Uwe Hermann1410c2d2007-05-29 10:37:52 +000022#include "i82371eb.h"
Richard Smithcb8eab42006-07-24 04:25:47 +000023
Uwe Hermann115c5b92010-10-09 17:00:18 +000024void enable_smbus(void)
Richard Smithcb8eab42006-07-24 04:25:47 +000025{
Antonello Dettorif068a732016-09-03 10:45:33 +020026 pci_devfn_t dev;
Uwe Hermann9da69f82007-11-30 02:08:26 +000027 u8 reg8;
28 u16 reg16;
Uwe Hermann1410c2d2007-05-29 10:37:52 +000029
Uwe Hermann115c5b92010-10-09 17:00:18 +000030 /* Get the SMBus/PM device of the 82371AB/EB/MB. */
Uwe Hermann1410c2d2007-05-29 10:37:52 +000031 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_INTEL,
Uwe Hermann447aafe2007-11-29 01:44:43 +000032 PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0);
Uwe Hermann1410c2d2007-05-29 10:37:52 +000033
Uwe Hermann1410c2d2007-05-29 10:37:52 +000034 /* Set the SMBus I/O base. */
35 pci_write_config32(dev, SMBBA, SMBUS_IO_BASE | 1);
36
Uwe Hermann9da69f82007-11-30 02:08:26 +000037 /* Enable the SMBus controller host interface. */
Uwe Hermann1410c2d2007-05-29 10:37:52 +000038 reg8 = pci_read_config8(dev, SMBHSTCFG);
39 reg8 |= SMB_HST_EN;
40 pci_write_config8(dev, SMBHSTCFG, reg8);
41
42 /* Enable access to the SMBus I/O space. */
Uwe Hermann56a91252007-06-03 16:57:27 +000043 reg16 = pci_read_config16(dev, PCI_COMMAND);
Uwe Hermann9da69f82007-11-30 02:08:26 +000044 reg16 |= PCI_COMMAND_IO;
Uwe Hermann56a91252007-06-03 16:57:27 +000045 pci_write_config16(dev, PCI_COMMAND, reg16);
Uwe Hermann1410c2d2007-05-29 10:37:52 +000046
47 /* Clear any lingering errors, so the transaction will run. */
Arthur Heymans16fe7902017-04-12 17:01:31 +020048 outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
Richard Smithd7088c42006-07-30 00:23:20 +000049}
50
Uwe Hermann115c5b92010-10-09 17:00:18 +000051int smbus_read_byte(u8 device, u8 address)
Richard Smithd7088c42006-07-30 00:23:20 +000052{
53 return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
54}