sb/intel/common: Add smbus_set_slave_addr()
Change-Id: I7dddb61fab00e0f4f67d4eebee0cfe8dcd99f4ab
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38230
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/southbridge/intel/bd82x6x/pch.h b/src/southbridge/intel/bd82x6x/pch.h
index 089d458..5f353af 100644
--- a/src/southbridge/intel/bd82x6x/pch.h
+++ b/src/southbridge/intel/bd82x6x/pch.h
@@ -238,7 +238,6 @@
#define PCH_SMBUS_DEV PCI_DEV(0, 0x1f, 3)
#define SMB_BASE 0x20
#define HOSTC 0x40
-#define SMB_RCV_SLVA 0x09
/* HOSTC bits */
#define I2C_EN (1 << 2)
diff --git a/src/southbridge/intel/bd82x6x/smbus.c b/src/southbridge/intel/bd82x6x/smbus.c
index 0a9c175..b011c49 100644
--- a/src/southbridge/intel/bd82x6x/smbus.c
+++ b/src/southbridge/intel/bd82x6x/smbus.c
@@ -20,8 +20,6 @@
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
-#include <arch/io.h>
-#include <southbridge/intel/common/smbus.h>
#include <device/smbus_host.h>
#include "pch.h"
@@ -38,7 +36,7 @@
/* Set Receive Slave Address */
res = find_resource(dev, PCI_BASE_ADDRESS_4);
if (res)
- outb(SMBUS_SLAVE_ADDR, res->base + SMB_RCV_SLVA);
+ smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
}
static int lsmbus_read_byte(struct device *dev, u8 address)
diff --git a/src/southbridge/intel/common/smbus.c b/src/southbridge/intel/common/smbus.c
index f6805ad..d253ae7 100644
--- a/src/southbridge/intel/common/smbus.c
+++ b/src/southbridge/intel/common/smbus.c
@@ -101,6 +101,11 @@
host_and_or(base, SMBHSTSTAT, 0xff, 0);
}
+void smbus_set_slave_addr(uintptr_t base, u8 slave_address)
+{
+ host_outb(base, SMB_RCV_SLVA, slave_address);
+}
+
static int host_completed(u8 status)
{
if (status & SMBHSTSTS_HOST_BUSY)
diff --git a/src/southbridge/intel/common/smbus.h b/src/southbridge/intel/common/smbus.h
index 20443e1..e72203e4 100644
--- a/src/southbridge/intel/common/smbus.h
+++ b/src/southbridge/intel/common/smbus.h
@@ -32,4 +32,6 @@
#define SMBUS_PIN_CTL 0xf
#define SMBSLVCMD 0x11
+#define SMB_RCV_SLVA SMBTRNSADD
+
#endif
diff --git a/src/southbridge/intel/ibexpeak/pch.h b/src/southbridge/intel/ibexpeak/pch.h
index 5785ef1..529b7a2 100644
--- a/src/southbridge/intel/ibexpeak/pch.h
+++ b/src/southbridge/intel/ibexpeak/pch.h
@@ -232,7 +232,6 @@
#define PCH_SMBUS_DEV PCI_DEV(0, 0x1f, 3)
#define SMB_BASE 0x20
#define HOSTC 0x40
-#define SMB_RCV_SLVA 0x09
/* HOSTC bits */
#define I2C_EN (1 << 2)
diff --git a/src/southbridge/intel/ibexpeak/smbus.c b/src/southbridge/intel/ibexpeak/smbus.c
index 9168cff..accbe68 100644
--- a/src/southbridge/intel/ibexpeak/smbus.c
+++ b/src/southbridge/intel/ibexpeak/smbus.c
@@ -20,8 +20,6 @@
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
-#include <arch/io.h>
-#include <southbridge/intel/common/smbus.h>
#include <device/smbus_host.h>
#include "pch.h"
@@ -38,7 +36,7 @@
/* Set Receive Slave Address */
res = find_resource(dev, PCI_BASE_ADDRESS_4);
if (res)
- outb(SMBUS_SLAVE_ADDR, res->base + SMB_RCV_SLVA);
+ smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
}
static int lsmbus_read_byte(struct device *dev, u8 address)
diff --git a/src/southbridge/intel/lynxpoint/pch.h b/src/southbridge/intel/lynxpoint/pch.h
index d83dd17..71f42ea 100644
--- a/src/southbridge/intel/lynxpoint/pch.h
+++ b/src/southbridge/intel/lynxpoint/pch.h
@@ -440,7 +440,6 @@
#define PCH_SMBUS_DEV PCI_DEV(0, 0x1f, 3)
#define SMB_BASE 0x20
#define HOSTC 0x40
-#define SMB_RCV_SLVA 0x09
/* HOSTC bits */
#define I2C_EN (1 << 2)
diff --git a/src/southbridge/intel/lynxpoint/smbus.c b/src/southbridge/intel/lynxpoint/smbus.c
index 24beaf2..ff659b8 100644
--- a/src/southbridge/intel/lynxpoint/smbus.c
+++ b/src/southbridge/intel/lynxpoint/smbus.c
@@ -20,8 +20,6 @@
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
-#include <arch/io.h>
-#include <southbridge/intel/common/smbus.h>
#include <device/smbus_host.h>
#include "pch.h"
@@ -38,7 +36,7 @@
/* Set Receive Slave Address */
res = find_resource(dev, PCI_BASE_ADDRESS_4);
if (res)
- outb(SMBUS_SLAVE_ADDR, res->base + SMB_RCV_SLVA);
+ smbus_set_slave_addr(res->base, SMBUS_SLAVE_ADDR);
}
static int lsmbus_read_byte(struct device *dev, u8 address)