eepro100: Support byte/word read/write access to MDI control register

MDI control is a 32 bit register, but may be read or written using
8 or 16 bit access. Data is latched when the MSB is written.

Add support for byte/word read/write access.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Stefan Weil 2011-04-30 22:40:11 +02:00 committed by Michael S. Tsirkin
parent 27a05006e0
commit 0113f48df6

View File

@ -1193,8 +1193,9 @@ static uint32_t eepro100_read_mdi(EEPRO100State * s)
return val; return val;
} }
static void eepro100_write_mdi(EEPRO100State * s, uint32_t val) static void eepro100_write_mdi(EEPRO100State *s)
{ {
uint32_t val = e100_read_reg4(s, SCBCtrlMDI);
uint8_t raiseint = (val & BIT(29)) >> 29; uint8_t raiseint = (val & BIT(29)) >> 29;
uint8_t opcode = (val & BITS(27, 26)) >> 26; uint8_t opcode = (val & BITS(27, 26)) >> 26;
uint8_t phy = (val & BITS(25, 21)) >> 21; uint8_t phy = (val & BITS(25, 21)) >> 21;
@ -1370,6 +1371,13 @@ static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
case SCBeeprom: case SCBeeprom:
val = eepro100_read_eeprom(s); val = eepro100_read_eeprom(s);
break; break;
case SCBCtrlMDI:
case SCBCtrlMDI + 1:
case SCBCtrlMDI + 2:
case SCBCtrlMDI + 3:
val = (uint8_t)(eepro100_read_mdi(s) >> (8 * (addr & 3)));
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
break;
case SCBpmdr: /* Power Management Driver Register */ case SCBpmdr: /* Power Management Driver Register */
val = 0; val = 0;
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val)); TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
@ -1402,6 +1410,11 @@ static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
val = eepro100_read_eeprom(s); val = eepro100_read_eeprom(s);
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val)); TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
break; break;
case SCBCtrlMDI:
case SCBCtrlMDI + 2:
val = (uint16_t)(eepro100_read_mdi(s) >> (8 * (addr & 3)));
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
break;
default: default:
logout("addr=%s val=0x%04x\n", regname(addr), val); logout("addr=%s val=0x%04x\n", regname(addr), val);
missing("unknown word read"); missing("unknown word read");
@ -1488,6 +1501,15 @@ static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val)
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val)); TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
eepro100_write_eeprom(s->eeprom, val); eepro100_write_eeprom(s->eeprom, val);
break; break;
case SCBCtrlMDI:
case SCBCtrlMDI + 1:
case SCBCtrlMDI + 2:
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
break;
case SCBCtrlMDI + 3:
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
eepro100_write_mdi(s);
break;
default: default:
logout("addr=%s val=0x%02x\n", regname(addr), val); logout("addr=%s val=0x%02x\n", regname(addr), val);
missing("unknown byte write"); missing("unknown byte write");
@ -1527,6 +1549,13 @@ static void eepro100_write2(EEPRO100State * s, uint32_t addr, uint16_t val)
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val)); TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
eepro100_write_eeprom(s->eeprom, val); eepro100_write_eeprom(s->eeprom, val);
break; break;
case SCBCtrlMDI:
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
break;
case SCBCtrlMDI + 2:
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
eepro100_write_mdi(s);
break;
default: default:
logout("addr=%s val=0x%04x\n", regname(addr), val); logout("addr=%s val=0x%04x\n", regname(addr), val);
missing("unknown word write"); missing("unknown word write");
@ -1548,7 +1577,8 @@ static void eepro100_write4(EEPRO100State * s, uint32_t addr, uint32_t val)
eepro100_write_port(s); eepro100_write_port(s);
break; break;
case SCBCtrlMDI: case SCBCtrlMDI:
eepro100_write_mdi(s, val); TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
eepro100_write_mdi(s);
break; break;
default: default:
logout("addr=%s val=0x%08x\n", regname(addr), val); logout("addr=%s val=0x%08x\n", regname(addr), val);