blob: 556fe1a107f59dd3daba3dbeb9e1045269e9bfb5 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgie72a8a32012-11-06 11:05:09 +01002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01004#include <device/pci_def.h>
Felix Singer7f8b0cd82019-11-10 11:04:08 +01005#include <device/pci_ids.h>
Kyösti Mälkki1cae4542020-01-06 12:31:34 +02006#include <device/smbus_host.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01007#include "i82801ix.h"
Patrick Georgie72a8a32012-11-06 11:05:09 +01008
Kyösti Mälkkif555a582020-01-06 19:41:42 +02009uintptr_t smbus_base(void)
Patrick Georgie72a8a32012-11-06 11:05:09 +010010{
Kyösti Mälkkif555a582020-01-06 19:41:42 +020011 return SMBUS_IO_BASE;
12}
Patrick Georgie72a8a32012-11-06 11:05:09 +010013
Kyösti Mälkkif555a582020-01-06 19:41:42 +020014int smbus_enable_iobar(uintptr_t base)
15{
Patrick Georgie72a8a32012-11-06 11:05:09 +010016 /* Set the SMBus device statically. */
Kyösti Mälkkif555a582020-01-06 19:41:42 +020017 pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
Patrick Georgie72a8a32012-11-06 11:05:09 +010018
19 /* Check to make sure we've got the right device. */
Felix Singer7f8b0cd82019-11-10 11:04:08 +010020 if (pci_read_config16(dev, 0x2) != PCI_DEVICE_ID_INTEL_82801IB_SMB)
Kyösti Mälkkif555a582020-01-06 19:41:42 +020021 return -1;
Patrick Georgie72a8a32012-11-06 11:05:09 +010022
23 /* Set SMBus I/O base. */
24 pci_write_config32(dev, SMB_BASE,
Kyösti Mälkkif555a582020-01-06 19:41:42 +020025 base | PCI_BASE_ADDRESS_SPACE_IO);
Patrick Georgie72a8a32012-11-06 11:05:09 +010026
27 /* Set SMBus enable. */
28 pci_write_config8(dev, HOSTC, HST_EN);
29
30 /* Set SMBus I/O space enable. */
31 pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
32
Kyösti Mälkkif555a582020-01-06 19:41:42 +020033 return 0;
Patrick Georgie72a8a32012-11-06 11:05:09 +010034}
35
Martin Rothff744bf2019-10-23 21:46:03 -060036int smbus_read_byte(unsigned int device, unsigned int address)
Patrick Georgie72a8a32012-11-06 11:05:09 +010037{
38 return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
39}