Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 2 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 3 | #include <stdint.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Kyösti Mälkki | 8a41f4b | 2019-02-08 18:14:34 +0200 | [diff] [blame] | 5 | #include <device/pci.h> |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 6 | #include <device/pci_ids.h> |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 7 | #include <device/pci_def.h> |
Kyösti Mälkki | 1cae454 | 2020-01-06 12:31:34 +0200 | [diff] [blame] | 8 | #include <device/smbus_host.h> |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 9 | #include "i82371eb.h" |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 10 | |
Kyösti Mälkki | 7a95575 | 2020-01-07 12:18:24 +0200 | [diff] [blame] | 11 | void i82371eb_early_init(void) |
| 12 | { |
| 13 | enable_smbus(); |
| 14 | enable_pm(); |
| 15 | } |
| 16 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 17 | uintptr_t smbus_base(void) |
| 18 | { |
| 19 | return SMBUS_IO_BASE; |
| 20 | } |
| 21 | |
| 22 | int smbus_enable_iobar(uintptr_t base) |
Richard Smith | cb8eab4 | 2006-07-24 04:25:47 +0000 | [diff] [blame] | 23 | { |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 24 | u8 reg8; |
| 25 | u16 reg16; |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 26 | |
Uwe Hermann | 115c5b9 | 2010-10-09 17:00:18 +0000 | [diff] [blame] | 27 | /* Get the SMBus/PM device of the 82371AB/EB/MB. */ |
Elyes Haouas | 5996eea | 2022-02-15 22:07:22 +0100 | [diff] [blame^] | 28 | const pci_devfn_t dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 447aafe | 2007-11-29 01:44:43 +0000 | [diff] [blame] | 29 | PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0); |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 30 | |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 31 | /* Set the SMBus I/O base. */ |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 32 | pci_write_config32(dev, SMBBA, base | 1); |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 33 | |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 34 | /* Enable the SMBus controller host interface. */ |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 35 | reg8 = pci_read_config8(dev, SMBHSTCFG); |
| 36 | reg8 |= SMB_HST_EN; |
| 37 | pci_write_config8(dev, SMBHSTCFG, reg8); |
| 38 | |
| 39 | /* Enable access to the SMBus I/O space. */ |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame] | 40 | reg16 = pci_read_config16(dev, PCI_COMMAND); |
Uwe Hermann | 9da69f8 | 2007-11-30 02:08:26 +0000 | [diff] [blame] | 41 | reg16 |= PCI_COMMAND_IO; |
Uwe Hermann | 56a9125 | 2007-06-03 16:57:27 +0000 | [diff] [blame] | 42 | pci_write_config16(dev, PCI_COMMAND, reg16); |
Uwe Hermann | 1410c2d | 2007-05-29 10:37:52 +0000 | [diff] [blame] | 43 | |
Kyösti Mälkki | f555a58 | 2020-01-06 19:41:42 +0200 | [diff] [blame] | 44 | return 0; |
Richard Smith | d7088c4 | 2006-07-30 00:23:20 +0000 | [diff] [blame] | 45 | } |