Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 4 | #include <device/pci_def.h> |
Kyösti Mälkki | 1cae454 | 2020-01-06 12:31:34 +0200 | [diff] [blame] | 5 | #include <device/smbus_host.h> |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 6 | #include "i82801gx.h" |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 7 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 8 | uintptr_t smbus_base(void) |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 9 | { |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 10 | return SMBUS_IO_BASE; |
| 11 | } |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 12 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 13 | int smbus_enable_iobar(uintptr_t base) |
| 14 | { |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 15 | /* Set the SMBus device statically. */ |
Elyes HAOUAS | eb00e87 | 2020-04-06 09:38:38 +0200 | [diff] [blame] | 16 | const pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 17 | |
| 18 | /* Check to make sure we've got the right device. */ |
Elyes HAOUAS | ae22fe2 | 2020-05-21 09:04:16 +0200 | [diff] [blame] | 19 | if (pci_read_config16(dev, PCI_DEVICE_ID) != 0x27da) |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 20 | return -1; |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 21 | |
| 22 | /* Set SMBus I/O base. */ |
Elyes HAOUAS | 92646ea | 2020-04-04 13:43:03 +0200 | [diff] [blame] | 23 | pci_write_config32(dev, SMB_BASE, base | PCI_BASE_ADDRESS_SPACE_IO); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 24 | |
| 25 | /* Set SMBus enable. */ |
| 26 | pci_write_config8(dev, HOSTC, HST_EN); |
| 27 | |
| 28 | /* Set SMBus I/O space enable. */ |
| 29 | pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO); |
| 30 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 31 | return 0; |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 32 | } |