Commit fe65e8bf authored by Alexander Potashev's avatar Alexander Potashev

RT77090. kinetis eth: Fix receiving of Ethernet packets

The Ethernet module of the MCU requires that the RDAR register is set
only after a while after the RDSR register is set; i.e. the RDAR
register should not be set immediately after RDSR during initialization
of the Ethernet module.
  1. If we write to the ENET_RDAR register immediately after initializing
the ENET_RDSR register, the incoming packets can _never_ be received.
  2. If we make the MCU wait for 10us before writing to ENET_RDAR, the
incoming packets are _always_ received correctly.
  3. If we perform a few instructions (about 10 of them) between setting
RDSR and RDAR, then the problem manifests randomly from time to time.

In order to fix the bug, we add a 10us delay just before writing
to the RDAR register.

Things just work in Freescale MQX and in Linux, because there is a lot
of other initialization code between the RDAR and RDSR register are set,
so this other initialization code serves as a delay.
parent ae1cc580
......@@ -527,6 +527,16 @@ int fec_init(struct eth_device *dev, bd_t * bd)
/* Now enable the transmit and receive processing */
fecp->ecr |= FEC_ECR_ETHER_EN;
/*
* A delay is required between we set RDSR and RDAR. If there is no such
* delay, then the Ethernet module becomes unable to receive packets.
*
* In Freescale MQX and in Linux things just work because there is a lot
* other initialization code between the RDAR and the RDSR register
* are being set, so this other initialization code serves as a delay.
*/
udelay(10);
/* And last, try to fill Rx Buffer Descriptors */
fecp->rdar = 0x01000000; /* Descriptor polling active */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment