From 850979800641a7ebab6d0f137bb6961755e23ba1 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sun, 17 Aug 2025 14:51:14 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/88810 Reviewed-by: Angel Pons Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) --- src/southbridge/intel/common/smbus.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/southbridge/intel/common/smbus.c b/src/southbridge/intel/common/smbus.c index 944e360a0f..57325f7063 100644 --- a/src/southbridge/intel/common/smbus.c +++ b/src/southbridge/intel/common/smbus.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -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));