sb/intel/common: Declare common smbus_base() and enable_smbus()

This avoids including platform-specific headers with different
filenames from common code.

Change-Id: Idf9893e55949d63f3ceca2249e618d0f81320321
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38232
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Kyösti Mälkki
2020-01-06 19:41:42 +02:00
committed by Patrick Georgi
parent 542fa6de38
commit f555a58abc
27 changed files with 111 additions and 85 deletions

View File

@@ -18,6 +18,7 @@
#include <cf9_reset.h>
#include <ip_checksum.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include <southbridge/intel/common/gpio.h>
#include <southbridge/intel/common/pmbase.h>
#include <southbridge/intel/common/rcba.h>

View File

@@ -15,26 +15,27 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include "pch.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Check to make sure we've got the right device. */
if (pci_read_config16(dev, 0x0) != 0x8086) {
die("SMBus controller not found!");
}
if (pci_read_config16(dev, 0x0) != 0x8086)
return -1;
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -42,9 +43,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -62,7 +62,6 @@ int pch_silicon_type(void);
int pch_silicon_supported(int type, int rev);
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue);
void enable_smbus(void);
void enable_usb_bar(void);
#if ENV_ROMSTAGE

View File

@@ -15,7 +15,6 @@
*/
#include <stdint.h>
#include <console/console.h>
#include <device/pci_ops.h>
#include <device/pci.h>
#include <device/pci_ids.h>
@@ -29,7 +28,12 @@ void i82371eb_early_init(void)
enable_pm();
}
void enable_smbus(void)
uintptr_t smbus_base(void)
{
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
pci_devfn_t dev;
u8 reg8;
@@ -40,7 +44,7 @@ void enable_smbus(void)
PCI_DEVICE_ID_INTEL_82371AB_SMB_ACPI), 0);
/* Set the SMBus I/O base. */
pci_write_config32(dev, SMBBA, SMBUS_IO_BASE | 1);
pci_write_config32(dev, SMBBA, base | 1);
/* Enable the SMBus controller host interface. */
reg8 = pci_read_config8(dev, SMBHSTCFG);
@@ -52,9 +56,7 @@ void enable_smbus(void)
reg16 |= PCI_COMMAND_IO;
pci_write_config16(dev, PCI_COMMAND, reg16);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled\n");
return 0;
}
int smbus_read_byte(u8 device, u8 address)

View File

@@ -19,7 +19,6 @@
#if !defined(__ACPI__)
void enable_smbus(void);
void enable_pm(void);
void i82371eb_early_init(void);

View File

@@ -16,9 +16,7 @@
#include <device/pci_ops.h>
#include <device/pci_def.h>
#include <console/console.h>
#include <device/smbus_host.h>
#include "i82801dx.h"
void i82801dx_early_init(void)
@@ -26,20 +24,23 @@ void i82801dx_early_init(void)
enable_smbus();
}
void enable_smbus(void)
uintptr_t smbus_base(void)
{
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* set smbus iobase */
pci_write_config32(dev, 0x20, SMBUS_IO_BASE | 1);
pci_write_config32(dev, 0x20, base | 1);
/* Set smbus enable */
pci_write_config8(dev, 0x40, 0x01);
/* Set smbus iospace enable */
pci_write_config16(dev, 0x4, 0x01);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -36,7 +36,6 @@
void i82801dx_enable(struct device *dev);
void i82801dx_early_init(void);
void enable_smbus(void);
int smbus_read_byte(unsigned int device, unsigned int address);
void aseg_smm_lock(void);

View File

@@ -14,6 +14,7 @@
#include <stdint.h>
#include <console/console.h>
#include <device/pci_ops.h>
#include <device/smbus_host.h>
#include <southbridge/intel/common/gpio.h>
#include <southbridge/intel/common/pmbase.h>
#include "i82801gx.h"

View File

@@ -15,25 +15,27 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include "i82801gx.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Check to make sure we've got the right device. */
if (pci_read_config16(dev, 0x2) != 0x27da)
die("SMBus controller not found!");
return -1;
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -41,9 +43,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -37,7 +37,6 @@
#include <device/device.h>
void i82801gx_enable(struct device *dev);
void enable_smbus(void);
void i82801gx_lpc_setup(void);
void i82801gx_setup_bars(void);
void i82801gx_early_init(void);

View File

@@ -16,6 +16,7 @@
#include <arch/io.h>
#include <device/pci_ops.h>
#include <device/smbus_host.h>
#include "i82801ix.h"
#include "chip.h"

View File

@@ -16,26 +16,28 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <device/smbus_host.h>
#include "i82801ix.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Check to make sure we've got the right device. */
if (pci_read_config16(dev, 0x2) != PCI_DEVICE_ID_INTEL_82801IB_SMB)
die("SMBus controller not found!");
return -1;
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -43,9 +45,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -208,7 +208,6 @@ static inline int lpc_is_mobile(const u16 devid)
void aseg_smm_lock(void);
void enable_smbus(void);
void i82801ix_early_init(void);
void i82801ix_lpc_decode(void);
void i82801ix_dmi_setup(void);

View File

@@ -14,6 +14,7 @@
#include <console/console.h>
#include <device/pci_ops.h>
#include <device/smbus_host.h>
#include <southbridge/intel/common/gpio.h>
#include <southbridge/intel/common/pmbase.h>
#include "i82801jx.h"

View File

@@ -16,21 +16,23 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include "i82801jx.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -38,9 +40,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -225,7 +225,6 @@ static inline int lpc_is_mobile(const u16 devid)
}
#define LPC_IS_MOBILE(dev) lpc_is_mobile(pci_read_config16(dev, PCI_DEVICE_ID))
void enable_smbus(void);
#if ENV_ROMSTAGE
int smbus_read_byte(unsigned int device, unsigned int address);
int i2c_eeprom_read(unsigned int device, unsigned int cmd, unsigned int bytes,

View File

@@ -18,6 +18,7 @@
#include <stdint.h>
#include <device/pci_ops.h>
#include <device/smbus_host.h>
#include <northbridge/intel/nehalem/nehalem.h>
#include <southbridge/intel/ibexpeak/pch.h>
#include <southbridge/intel/common/gpio.h>

View File

@@ -15,26 +15,27 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include "pch.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Check to make sure we've got the right device. */
if (pci_read_config16(dev, 0x0) != 0x8086) {
die("SMBus controller not found!");
}
if (pci_read_config16(dev, 0x0) != 0x8086)
return -1;
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -42,9 +43,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -52,7 +52,6 @@
#define DEBUG_PERIODIC_SMIS 0
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue);
void enable_smbus(void);
void enable_usb_bar(void);
#if ENV_ROMSTAGE

View File

@@ -19,6 +19,7 @@
#include <device/pci_ops.h>
#include <device/device.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include <southbridge/intel/common/pmclib.h>
#include <elog.h>
#include "pch.h"

View File

@@ -15,26 +15,27 @@
*/
#include <device/pci_ops.h>
#include <console/console.h>
#include <device/pci_def.h>
#include <device/smbus_host.h>
#include "pch.h"
void enable_smbus(void)
uintptr_t smbus_base(void)
{
pci_devfn_t dev;
return SMBUS_IO_BASE;
}
int smbus_enable_iobar(uintptr_t base)
{
/* Set the SMBus device statically. */
dev = PCI_DEV(0x0, 0x1f, 0x3);
pci_devfn_t dev = PCI_DEV(0x0, 0x1f, 0x3);
/* Check to make sure we've got the right device. */
if (pci_read_config16(dev, 0x0) != 0x8086) {
die("SMBus controller not found!");
}
if (pci_read_config16(dev, 0x0) != 0x8086)
return -1;
/* Set SMBus I/O base. */
pci_write_config32(dev, SMB_BASE,
SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
base | PCI_BASE_ADDRESS_SPACE_IO);
/* Set SMBus enable. */
pci_write_config8(dev, HOSTC, HST_EN);
@@ -42,9 +43,7 @@ void enable_smbus(void)
/* Set SMBus I/O space enable. */
pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
smbus_host_reset(SMBUS_IO_BASE);
printk(BIOS_DEBUG, "SMBus controller enabled.\n");
return 0;
}
int smbus_read_byte(unsigned int device, unsigned int address)

View File

@@ -174,7 +174,6 @@ void pch_log_state(void);
void acpi_create_intel_hpet(acpi_hpet_t * hpet);
void acpi_create_serialio_ssdt(acpi_header_t *ssdt);
void enable_smbus(void);
#if ENV_ROMSTAGE
int smbus_read_byte(unsigned int device, unsigned int address);