e1000: Fix wrong microwire EEPROM state initialization
commit9651ac55e5de0e1534d898316cc851af6ffc4334
authorIzumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Sat, 10 Jul 2010 14:03:45 +0000 (10 23:03 +0900)
committerAurelien Jarno <aurelien@aurel32.net>
Thu, 22 Jul 2010 03:52:10 +0000 (22 05:52 +0200)
tree8c923d16d67f34d9f8d385f5465927f069372a36
parent3c638d0690a0b21c6acef7ce3132f821d8c1e25d
e1000: Fix wrong microwire EEPROM state initialization

This change fixes initialization of e1000's microwire EEPROM internal
state values so that qemu's e1000 emulation works on NetBSD,
which doesn't use Intel's em driver but has its own wm driver
for the Intel i8254x Gigabit Ethernet.

Previously set_eecd() function in e1000.c clears EEPROM internal state
values on SK rising edge during CS==L, but according to FM93C06 EEPROM
(which is MicroWire compatible) data sheet, EEPROM internal status
should be cleared on CS rise edge regardless of SK input:
 "... a rising edge on this (CS) signal is required to reset the internal
  state-machine to accept a new cycle .."
and nothing should be changed during CS (chip select) is inactive.

Intel's em driver seems to explicitly raise SK output after CS is negated
in em_standby_eeprom() so many other OSes that use Intel's driver
don't have this problem even on the previous e1000.c implementation,
but I can't find any articles that say the MICROWIRE or EEPROM spec
requires such sequence, and actually hardware works fine without it
(i.e. real i82540EM has been working on NetBSD).

This fix also changes initialization to clear each state value in
struct eecd_state individually rather than using memset() against
the whole structre. The old_eecd member stores the last SK and CS
signal levels and it should be preserved even after reset of internal
EEPROM state to detect next signal edges for proper EEPROM emulation.

Signed-off-by: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
hw/e1000.c