ftgmac100: Improve software reset

The software reset of the MAC needs a finer granularity. Some settings
in MACCR are kept.

Cc: Frederic Konrad <konrad.frederic@yahoo.fr>
Fixes: bd44300d1a ("net: add FTGMAC100 support")
Message-Id: <20200819100956.2216690-16-clg@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
Cédric Le Goater 2020-09-01 14:21:50 +02:00
parent c2ab73fcbe
commit e0059c8883

View File

@ -649,10 +649,8 @@ static uint32_t ftgmac100_rxpoll(FTGMAC100State *s)
return cnt / div[speed];
}
static void ftgmac100_reset(DeviceState *d)
static void ftgmac100_do_reset(FTGMAC100State *s, bool sw_reset)
{
FTGMAC100State *s = FTGMAC100(d);
/* Reset the FTGMAC100 */
s->isr = 0;
s->ier = 0;
@ -671,7 +669,12 @@ static void ftgmac100_reset(DeviceState *d)
s->fear1 = 0;
s->tpafcr = 0xf1;
s->maccr = 0;
if (sw_reset) {
s->maccr &= FTGMAC100_MACCR_GIGA_MODE | FTGMAC100_MACCR_FAST_MODE;
} else {
s->maccr = 0;
}
s->phycr = 0;
s->phydata = 0;
s->fcr = 0x400;
@ -680,6 +683,11 @@ static void ftgmac100_reset(DeviceState *d)
phy_reset(s);
}
static void ftgmac100_reset(DeviceState *d)
{
ftgmac100_do_reset(FTGMAC100(d), false);
}
static uint64_t ftgmac100_read(void *opaque, hwaddr addr, unsigned size)
{
FTGMAC100State *s = FTGMAC100(opaque);
@ -824,7 +832,7 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
case FTGMAC100_MACCR: /* MAC Device control */
s->maccr = value;
if (value & FTGMAC100_MACCR_SW_RST) {
ftgmac100_reset(DEVICE(s));
ftgmac100_do_reset(s, true);
}
if (ftgmac100_can_receive(qemu_get_queue(s->nic))) {