sb/intel/common/smbus: Use proper delay instruction

Use udelay() over reading port 80h to delay CPU operation.

Since SMBUS runs at 100Khz a typical operation takes about
200usec or more to complete. Using udelay(1) doesn't delay
the boot for too long.

TEST=Booted on Lenovo X220. No additional boot delay was found.

Change-Id: Ied745927b1c54b53d7450b8e0c0a03d648a3ebba
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88810
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Rudolph 2025-08-17 14:51:14 +02:00 committed by Matt DeVillier
commit 8509798006

View file

@ -2,6 +2,7 @@
#include <arch/io.h>
#include <console/console.h>
#include <delay.h>
#include <device/smbus_def.h>
#include <device/smbus_host.h>
#include <types.h>
@ -66,11 +67,6 @@
#define BLOCK_WRITE (1 << 0)
#define BLOCK_I2C (1 << 1)
static void smbus_delay(void)
{
inb(0x80);
}
static void host_outb(uintptr_t base, u8 reg, u8 value)
{
outb(value, base + reg);
@ -142,7 +138,7 @@ static int setup_command(uintptr_t base, u8 ctrl, u8 xmitadd)
u8 host_busy;
do {
smbus_delay();
udelay(1);
host_busy = host_inb(base, SMBHSTSTAT) & SMBHSTSTS_HOST_BUSY;
} while (--loops && host_busy);
@ -172,7 +168,7 @@ static int execute_command(uintptr_t base)
/* Poll for it to start. */
do {
smbus_delay();
udelay(1);
/* If we poll too slow, we could miss HOST_BUSY flag
* set and detect INTR or x_ERR flags instead here.
@ -194,7 +190,7 @@ static int complete_command(uintptr_t base)
u8 status;
do {
smbus_delay();
udelay(1);
status = host_inb(base, SMBHSTSTAT);
} while (--loops && !host_completed(status));