xilinx_emaclite.c ping-pong fix
Subsystems (2)
PATCH 1/1 xilinx_emaclite.c ping-pong fix
--- drivers/net/xilinx_emaclite.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/xilinx_emaclite.c +0 -0
@@ -138,7 +138,9 @@ static int emaclite_init(struct eth_device *dev, bd_t *b=
is)
=09debug ("EmacLite Initialization Started\n");
=09memset (&emaclite, 0, sizeof (xemaclite)); =09emaclite.baseaddress =3D dev->iobase;
-
+ =20
+ emaclite.nexttxbuffertouse =3D 0;
+ emaclite.nextrxbuffertouse =3D 0;
/*
* TX - TX_PING & TX_PONG initialization
*/
@@ -155,12 +157,13 @@ static int emaclite_init(struct eth_device *dev, bd_t = *bis)
=09while ((in_be32 (emaclite.baseaddress + XEL_TSR_OFFSET) & =09=09XEL_TSR_PROG_MAC_ADDR) !=3D 0) ;
=20
-#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
+#ifdef XILINX_EMACLITE_TX_PING_PONG
=09/* The same operation with PONG TX */
=09out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); =09xemaclite_alignedwrite (dev->enetaddr, emaclite.baseaddress + =09=09XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH);
-=09out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
+=09out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET + XEL_BUFFER_OFFSET,=20 + ENET_ADDR_LENGTH);
=09out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, =09=09XEL_TSR_PROG_MAC_ADDR);
=09while ((in_be32 (emaclite.baseaddress + XEL_TSR_OFFSET +
@@ -172,7 +175,7 @@ static int emaclite_init(struct eth_device *dev, bd_t *b= is)
*/
=09/* Write out the value to flush the RX buffer */
=09out_be32 (emaclite.baseaddress + XEL_RSR_OFFSET, XEL_RSR_RECV_IE_MASK);
-#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
+#ifdef XILINX_EMACLITE_RX_PING_PONG
=09out_be32 (emaclite.baseaddress + XEL_RSR_OFFSET + XEL_BUFFER_OFFSET, =09=09XEL_RSR_RECV_IE_MASK);
#endif
@@ -222,7 +225,7 @@ static int emaclite_send (struct eth_device *dev, volati= le void *ptr, int len)
=09=09printf ("Error: Timeout waiting for ethernet TX buffer\n"); =09=09/* Restart PING TX */
=09=09out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
-#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
+#ifdef XILINX_EMACLITE_TX_PING_PONG
=09=09out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + =09=09XEL_BUFFER_OFFSET, 0);
#endif
@@ -238,7 +241,7 @@ static int emaclite_send (struct eth_device *dev, volati= le void *ptr, int len)
=09=09&& ((in_be32 ((baseaddress) + XEL_TSR_OFFSET)
=09=09=09& XEL_TSR_XMIT_ACTIVE_MASK) =3D=3D 0)) {
=20
-#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
+#ifdef XILINX_EMACLITE_TX_PING_PONG
=09=09emaclite.nexttxbuffertouse ^=3D XEL_BUFFER_OFFSET;
#endif
=09=09debug ("Send packet from 0x%x\n", baseaddress);
@@ -254,7 +257,7 @@ static int emaclite_send (struct eth_device *dev, volati= le void *ptr, int len)
=09=09out_be32 (baseaddress + XEL_TSR_OFFSET, reg);
=09=09return 1;
=09}
-#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
+#ifdef XILINX_EMACLITE_TX_PING_PONG
=09/* Switch to second buffer */
=09baseaddress ^=3D XEL_BUFFER_OFFSET;
=09/* Determine if the expected buffer address is empty */
@@ -290,11 +293,11 @@ static int emaclite_recv(struct eth_device *dev)
=09reg =3D in_be32 (baseaddress + XEL_RSR_OFFSET);
=09debug ("Testing data at address 0x%x\n", baseaddress);
=09if ((reg & XEL_RSR_RECV_DONE_MASK) =3D=3D XEL_RSR_RECV_DONE_MASK) {
-#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
+#ifdef XILINX_EMACLITE_RX_PING_PONG
=09=09emaclite.nextrxbuffertouse ^=3D XEL_BUFFER_OFFSET;
#endif
=09} else {
-#ifndef CONFIG_XILINX_EMACLITE_RX_PING_PONG
+#ifndef XILINX_EMACLITE_RX_PING_PONG
=09=09debug ("No data was available - address 0x%x\n", baseaddress); =09=09return 0;
#else
--=20
1.7.2.5
--=_57hwwwf7zdkf--