blob: 7d8503bb7dd3e7573d00eaec1ca7f957374e01aa [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01002
Elyes HAOUAS25d20d32020-04-06 09:12:50 +02003#include <device/pci_ids.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01005#include <device/pci_def.h>
Kyösti Mälkki1cae4542020-01-06 12:31:34 +02006#include <device/smbus_host.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01007#include "pch.h"
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01008
Kyösti Mälkkif555a582020-01-06 19:41:42 +02009uintptr_t smbus_base(void)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010010{
Kyösti Mälkkif555a582020-01-06 19:41:42 +020011 return SMBUS_IO_BASE;
12}
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010013
Kyösti Mälkkif555a582020-01-06 19:41:42 +020014int smbus_enable_iobar(uintptr_t base)
15{
Vladimir Serbinenko888d5592013-11-13 17:53:38 +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);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010018
19 /* Check to make sure we've got the right device. */
Elyes HAOUAS25d20d32020-04-06 09:12:50 +020020 if (pci_read_config16(dev, PCI_VENDOR_ID) != PCI_VENDOR_ID_INTEL)
Kyösti Mälkkif555a582020-01-06 19:41:42 +020021 return -1;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +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);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +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;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010034}