Skip to content

Commit 9b1ec31

Browse files
committed
[realtek] Ensure EEPROM writes reach chip before starting udelay()
On some systems, it appears to be possible for writes to the EEPROM registers to be delayed for long enough that the EEPROM's setup and hold times are violated, resulting in invalid data being read from the EEPROM. Fix by inserting a PCI read cycle immediately after writes to RTL_9346CR, to ensure that the write has completed before starting the udelay() used to time the SPI bus transitions. Reported-by: Gelip <mrgelip@gmail.com> Tested-by: Gelip <mrgelip@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent c6375a8 commit 9b1ec31

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/drivers/net/realtek.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static void realtek_spi_open_bit ( struct bit_basher *basher ) {
7474

7575
/* Enable EEPROM access */
7676
writeb ( RTL_9346CR_EEM_EEPROM, rtl->regs + RTL_9346CR );
77+
readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
7778
}
7879

7980
/**
@@ -87,6 +88,7 @@ static void realtek_spi_close_bit ( struct bit_basher *basher ) {
8788

8889
/* Disable EEPROM access */
8990
writeb ( RTL_9346CR_EEM_NORMAL, rtl->regs + RTL_9346CR );
91+
readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
9092
}
9193

9294
/**
@@ -129,6 +131,7 @@ static void realtek_spi_write_bit ( struct bit_basher *basher,
129131
reg &= ~mask;
130132
reg |= ( data & mask );
131133
writeb ( reg, rtl->regs + RTL_9346CR );
134+
readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
132135
DBG_ENABLE ( DBGLVL_IO );
133136
}
134137

0 commit comments

Comments
 (0)