Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 2 | |
Angel Pons | 90e9f54 | 2020-06-01 19:31:53 +0200 | [diff] [blame] | 3 | #include <device/pci_def.h> |
Elyes HAOUAS | 25d20d3 | 2020-04-06 09:12:50 +0200 | [diff] [blame] | 4 | #include <device/pci_ids.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Kyösti Mälkki | 1cae454 | 2020-01-06 12:31:34 +0200 | [diff] [blame] | 6 | #include <device/smbus_host.h> |
Angel Pons | 90e9f54 | 2020-06-01 19:31:53 +0200 | [diff] [blame] | 7 | #include "early_smbus.h" |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 8 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 9 | uintptr_t smbus_base(void) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 10 | { |
Angel Pons | b21bffa | 2020-07-03 01:02:28 +0200 | [diff] [blame] | 11 | return CONFIG_FIXED_SMBUS_IO_BASE; |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 12 | } |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 13 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 14 | int smbus_enable_iobar(uintptr_t base) |
| 15 | { |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 16 | /* Set the SMBus device statically. */ |
Angel Pons | 90e9f54 | 2020-06-01 19:31:53 +0200 | [diff] [blame] | 17 | const pci_devfn_t dev = PCI_DEV_SMBUS; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 18 | |
| 19 | /* Check to make sure we've got the right device. */ |
Elyes HAOUAS | 25d20d3 | 2020-04-06 09:12:50 +0200 | [diff] [blame] | 20 | if (pci_read_config16(dev, PCI_VENDOR_ID) != PCI_VENDOR_ID_INTEL) |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 21 | return -1; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 22 | |
| 23 | /* Set SMBus I/O base. */ |
Angel Pons | 90e9f54 | 2020-06-01 19:31:53 +0200 | [diff] [blame] | 24 | pci_write_config32(dev, SMB_BASE, base | PCI_BASE_ADDRESS_SPACE_IO); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 25 | |
| 26 | /* Set SMBus enable. */ |
| 27 | pci_write_config8(dev, HOSTC, HST_EN); |
| 28 | |
| 29 | /* Set SMBus I/O space enable. */ |
| 30 | pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO); |
| 31 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 32 | return 0; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 33 | } |