* [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address @ 2011-08-26 12:47 Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 2/8] net: emaclite: Remove deviceid property Michal Simek 2011-08-26 19:24 ` [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Mike Frysinger 0 siblings, 2 replies; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Current xilinx emaclite use net multi registration but doesn't support several emaclites interfaces. Changing driver name with adding address to name is the first step how to distiguish several drivers. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 3c7c250..8d170a3 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -350,7 +350,7 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) return -1; memset(dev, 0, sizeof(*dev)); - sprintf(dev->name, "Xilinx_Emaclite"); + sprintf(dev->name, "Xelite.%x", base_addr); dev->iobase = base_addr; dev->priv = 0; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 2/8] net: emaclite: Remove deviceid property 2011-08-26 12:47 [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 3/8] net: emaclite: Use calloc instead of malloc Michal Simek 2011-08-26 19:24 ` [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Mike Frysinger 1 sibling, 1 reply; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Cleanup structure. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 8d170a3..2a5c5e1 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -67,7 +67,6 @@ typedef struct { u32 baseaddress; /* Base address for device (IPIF) */ u32 nexttxbuffertouse; /* Next TX buffer to write to */ u32 nextrxbuffertouse; /* Next RX buffer to read from */ - uchar deviceid; /* Unique ID of device - for future */ } xemaclite; static xemaclite emaclite; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 3/8] net: emaclite: Use calloc instead of malloc 2011-08-26 12:47 ` [U-Boot] [PATCH 2/8] net: emaclite: Remove deviceid property Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Michal Simek 0 siblings, 1 reply; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Simplify driver logic and clear eth_device structure in one command. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 2a5c5e1..28aab97 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -344,11 +344,10 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) { struct eth_device *dev; - dev = malloc(sizeof(*dev)); + dev = calloc(1, sizeof(*dev)); if (dev == NULL) return -1; - memset(dev, 0, sizeof(*dev)); sprintf(dev->name, "Xelite.%x", base_addr); dev->iobase = base_addr; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite 2011-08-26 12:47 ` [U-Boot] [PATCH 3/8] net: emaclite: Use calloc instead of malloc Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Michal Simek 2011-09-07 20:26 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Wolfgang Denk 0 siblings, 2 replies; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Use dev->iobase instead of baseaddress. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 28aab97..d71b3a5 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -64,7 +64,6 @@ #define XEL_RSR_RECV_IE_MASK 0x00000008UL typedef struct { - u32 baseaddress; /* Base address for device (IPIF) */ u32 nexttxbuffertouse; /* Next TX buffer to write to */ u32 nextrxbuffertouse; /* Next RX buffer to read from */ } xemaclite; @@ -136,33 +135,32 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis) { debug ("EmacLite Initialization Started\n"); memset (&emaclite, 0, sizeof (xemaclite)); - emaclite.baseaddress = dev->iobase; /* * TX - TX_PING & TX_PONG initialization */ /* Restart PING TX */ - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0); + out_be32 (dev->iobase + XEL_TSR_OFFSET, 0); /* Copy MAC address */ xemaclite_alignedwrite (dev->enetaddr, - emaclite.baseaddress, ENET_ADDR_LENGTH); + dev->iobase, ENET_ADDR_LENGTH); /* Set the length */ - out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); + out_be32 (dev->iobase + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); /* Update the MAC address in the EMAC Lite */ - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, XEL_TSR_PROG_MAC_ADDR); + out_be32 (dev->iobase + XEL_TSR_OFFSET, XEL_TSR_PROG_MAC_ADDR); /* Wait for EMAC Lite to finish with the MAC address update */ - while ((in_be32 (emaclite.baseaddress + XEL_TSR_OFFSET) & + while ((in_be32 (dev->iobase + XEL_TSR_OFFSET) & XEL_TSR_PROG_MAC_ADDR) != 0) ; #ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG /* The same operation with PONG TX */ - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); - xemaclite_alignedwrite (dev->enetaddr, emaclite.baseaddress + + out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); + xemaclite_alignedwrite (dev->enetaddr, dev->iobase + XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH); - out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, + out_be32 (dev->iobase + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); + out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, XEL_TSR_PROG_MAC_ADDR); - while ((in_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + + while ((in_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET) & XEL_TSR_PROG_MAC_ADDR) != 0) ; #endif @@ -170,9 +168,9 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis) * RX - RX_PING & RX_PONG initialization */ /* Write out the value to flush the RX buffer */ - out_be32 (emaclite.baseaddress + XEL_RSR_OFFSET, XEL_RSR_RECV_IE_MASK); + out_be32 (dev->iobase + XEL_RSR_OFFSET, XEL_RSR_RECV_IE_MASK); #ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - out_be32 (emaclite.baseaddress + XEL_RSR_OFFSET + XEL_BUFFER_OFFSET, + out_be32 (dev->iobase + XEL_RSR_OFFSET + XEL_BUFFER_OFFSET, XEL_RSR_RECV_IE_MASK); #endif @@ -220,16 +218,16 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) if (!maxtry) { printf ("Error: Timeout waiting for ethernet TX buffer\n"); /* Restart PING TX */ - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0); + out_be32 (dev->iobase + XEL_TSR_OFFSET, 0); #ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + + out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); #endif return -1; } /* Determine the expected TX buffer address */ - baseaddress = (emaclite.baseaddress + emaclite.nexttxbuffertouse); + baseaddress = (dev->iobase + emaclite.nexttxbuffertouse); /* Determine if the expected buffer address is empty */ reg = in_be32 (baseaddress + XEL_TSR_OFFSET); @@ -285,7 +283,7 @@ static int emaclite_recv(struct eth_device *dev) u32 reg; u32 baseaddress; - baseaddress = emaclite.baseaddress + emaclite.nextrxbuffertouse; + baseaddress = dev->iobase + emaclite.nextrxbuffertouse; reg = in_be32 (baseaddress + XEL_RSR_OFFSET); debug ("Testing data at address 0x%x\n", baseaddress); if ((reg & XEL_RSR_RECV_DONE_MASK) == XEL_RSR_RECV_DONE_MASK) { -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation 2011-08-26 12:47 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 6/8] net: emaclite: Setup RX/TX ping pong for every instance Michal Simek 2011-08-26 19:22 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Mike Frysinger 2011-09-07 20:26 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Wolfgang Denk 1 sibling, 2 replies; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Every emaclite instance use own setting. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index d71b3a5..b157c7f 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -63,12 +63,10 @@ /* Recv interrupt enable bit */ #define XEL_RSR_RECV_IE_MASK 0x00000008UL -typedef struct { +struct xemaclite { u32 nexttxbuffertouse; /* Next TX buffer to write to */ u32 nextrxbuffertouse; /* Next RX buffer to read from */ -} xemaclite; - -static xemaclite emaclite; +}; static u32 etherrxbuff[PKTSIZE_ALIGN/4]; /* Receive buffer */ @@ -134,7 +132,6 @@ static void emaclite_halt(struct eth_device *dev) static int emaclite_init(struct eth_device *dev, bd_t *bis) { debug ("EmacLite Initialization Started\n"); - memset (&emaclite, 0, sizeof (xemaclite)); /* * TX - TX_PING & TX_PONG initialization @@ -178,22 +175,24 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis) return 0; } -static int xemaclite_txbufferavailable (xemaclite *instanceptr) +static int xemaclite_txbufferavailable (struct eth_device *dev) { u32 reg; u32 txpingbusy; u32 txpongbusy; + struct xemaclite *emaclite = dev->priv; + /* * Read the other buffer register * and determine if the other buffer is available */ - reg = in_be32 (instanceptr->baseaddress + - instanceptr->nexttxbuffertouse + 0); + reg = in_be32 (dev->iobase + + emaclite->nexttxbuffertouse + 0); txpingbusy = ((reg & XEL_TSR_XMIT_BUSY_MASK) == XEL_TSR_XMIT_BUSY_MASK); - reg = in_be32 (instanceptr->baseaddress + - (instanceptr->nexttxbuffertouse ^ XEL_TSR_OFFSET) + 0); + reg = in_be32 (dev->iobase + + (emaclite->nexttxbuffertouse ^ XEL_TSR_OFFSET) + 0); txpongbusy = ((reg & XEL_TSR_XMIT_BUSY_MASK) == XEL_TSR_XMIT_BUSY_MASK); @@ -204,13 +203,14 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) { u32 reg; u32 baseaddress; + struct xemaclite *emaclite = dev->priv; u32 maxtry = 1000; if (len > ENET_MAX_MTU) len = ENET_MAX_MTU; - while (!xemaclite_txbufferavailable (&emaclite) && maxtry) { + while (!xemaclite_txbufferavailable(dev) && maxtry) { udelay (10); maxtry--; } @@ -227,7 +227,7 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) } /* Determine the expected TX buffer address */ - baseaddress = (dev->iobase + emaclite.nexttxbuffertouse); + baseaddress = (dev->iobase + emaclite->nexttxbuffertouse); /* Determine if the expected buffer address is empty */ reg = in_be32 (baseaddress + XEL_TSR_OFFSET); @@ -236,7 +236,7 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) & XEL_TSR_XMIT_ACTIVE_MASK) == 0)) { #ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - emaclite.nexttxbuffertouse ^= XEL_BUFFER_OFFSET; + emaclite->nexttxbuffertouse ^= XEL_BUFFER_OFFSET; #endif debug ("Send packet from 0x%x\n", baseaddress); /* Write the frame to the buffer */ @@ -282,13 +282,14 @@ static int emaclite_recv(struct eth_device *dev) u32 length; u32 reg; u32 baseaddress; + struct xemaclite *emaclite = dev->priv; - baseaddress = dev->iobase + emaclite.nextrxbuffertouse; + baseaddress = dev->iobase + emaclite->nextrxbuffertouse; reg = in_be32 (baseaddress + XEL_RSR_OFFSET); debug ("Testing data at address 0x%x\n", baseaddress); if ((reg & XEL_RSR_RECV_DONE_MASK) == XEL_RSR_RECV_DONE_MASK) { #ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - emaclite.nextrxbuffertouse ^= XEL_BUFFER_OFFSET; + emaclite->nextrxbuffertouse ^= XEL_BUFFER_OFFSET; #endif } else { #ifndef CONFIG_XILINX_EMACLITE_RX_PING_PONG @@ -341,15 +342,21 @@ static int emaclite_recv(struct eth_device *dev) int xilinx_emaclite_initialize (bd_t *bis, int base_addr) { struct eth_device *dev; + struct xemaclite *emaclite; dev = calloc(1, sizeof(*dev)); if (dev == NULL) return -1; + emaclite = calloc(1, sizeof(struct xemaclite)); + if (emaclite == NULL) + return -1; + + dev->priv = emaclite; + sprintf(dev->name, "Xelite.%x", base_addr); dev->iobase = base_addr; - dev->priv = 0; dev->init = emaclite_init; dev->halt = emaclite_halt; dev->send = emaclite_send; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 6/8] net: emaclite: Setup RX/TX ping pong for every instance 2011-08-26 12:47 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Michal Simek 2011-08-26 19:22 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Mike Frysinger 1 sibling, 1 reply; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Setup RX/TX ping-pong buffer for every emaclite IP separately. The next patch move initialization directly to board code. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 122 +++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 54 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index b157c7f..ac6c783 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -66,6 +66,8 @@ struct xemaclite { u32 nexttxbuffertouse; /* Next TX buffer to write to */ u32 nextrxbuffertouse; /* Next RX buffer to read from */ + u32 txpp; /* TX ping pong buffer */ + u32 rxpp; /* RX ping pong buffer */ }; static u32 etherrxbuff[PKTSIZE_ALIGN/4]; /* Receive buffer */ @@ -131,6 +133,7 @@ static void emaclite_halt(struct eth_device *dev) static int emaclite_init(struct eth_device *dev, bd_t *bis) { + struct xemaclite *emaclite = dev->priv; debug ("EmacLite Initialization Started\n"); /* @@ -149,27 +152,27 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis) while ((in_be32 (dev->iobase + XEL_TSR_OFFSET) & XEL_TSR_PROG_MAC_ADDR) != 0) ; -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - /* The same operation with PONG TX */ - out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); - xemaclite_alignedwrite (dev->enetaddr, dev->iobase + - XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH); - out_be32 (dev->iobase + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); - out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, - XEL_TSR_PROG_MAC_ADDR); - while ((in_be32 (dev->iobase + XEL_TSR_OFFSET + - XEL_BUFFER_OFFSET) & XEL_TSR_PROG_MAC_ADDR) != 0) ; -#endif + if (emaclite->txpp) { + /* The same operation with PONG TX */ + out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, 0); + xemaclite_alignedwrite (dev->enetaddr, dev->iobase + + XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH); + out_be32 (dev->iobase + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); + out_be32 (dev->iobase + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET, + XEL_TSR_PROG_MAC_ADDR); + while ((in_be32 (dev->iobase + XEL_TSR_OFFSET + + XEL_BUFFER_OFFSET) & XEL_TSR_PROG_MAC_ADDR) != 0) ; + } /* * RX - RX_PING & RX_PONG initialization */ /* Write out the value to flush the RX buffer */ out_be32 (dev->iobase + XEL_RSR_OFFSET, XEL_RSR_RECV_IE_MASK); -#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - out_be32 (dev->iobase + XEL_RSR_OFFSET + XEL_BUFFER_OFFSET, - XEL_RSR_RECV_IE_MASK); -#endif + + if (emaclite->rxpp) + out_be32 (dev->iobase + XEL_RSR_OFFSET + XEL_BUFFER_OFFSET, + XEL_RSR_RECV_IE_MASK); debug ("EmacLite Initialization complete\n"); return 0; @@ -219,10 +222,10 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) printf ("Error: Timeout waiting for ethernet TX buffer\n"); /* Restart PING TX */ out_be32 (dev->iobase + XEL_TSR_OFFSET, 0); -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - out_be32 (dev->iobase + XEL_TSR_OFFSET + - XEL_BUFFER_OFFSET, 0); -#endif + if (emaclite->txpp) { + out_be32 (dev->iobase + XEL_TSR_OFFSET + + XEL_BUFFER_OFFSET, 0); + } return -1; } @@ -235,9 +238,9 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) && ((in_be32 ((baseaddress) + XEL_TSR_OFFSET) & XEL_TSR_XMIT_ACTIVE_MASK) == 0)) { -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - emaclite->nexttxbuffertouse ^= XEL_BUFFER_OFFSET; -#endif + if (emaclite->txpp) + emaclite->nexttxbuffertouse ^= XEL_BUFFER_OFFSET; + debug ("Send packet from 0x%x\n", baseaddress); /* Write the frame to the buffer */ xemaclite_alignedwrite ((void *) ptr, baseaddress, len); @@ -251,28 +254,31 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) out_be32 (baseaddress + XEL_TSR_OFFSET, reg); return 0; } -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - /* Switch to second buffer */ - baseaddress ^= XEL_BUFFER_OFFSET; - /* Determine if the expected buffer address is empty */ - reg = in_be32 (baseaddress + XEL_TSR_OFFSET); - if (((reg & XEL_TSR_XMIT_BUSY_MASK) == 0) - && ((in_be32 ((baseaddress) + XEL_TSR_OFFSET) - & XEL_TSR_XMIT_ACTIVE_MASK) == 0)) { - debug ("Send packet from 0x%x\n", baseaddress); - /* Write the frame to the buffer */ - xemaclite_alignedwrite ((void *) ptr, baseaddress, len); - out_be32 (baseaddress + XEL_TPLR_OFFSET,(len & - (XEL_TPLR_LENGTH_MASK_HI | XEL_TPLR_LENGTH_MASK_LO))); + + if (emaclite->txpp) { + /* Switch to second buffer */ + baseaddress ^= XEL_BUFFER_OFFSET; + /* Determine if the expected buffer address is empty */ reg = in_be32 (baseaddress + XEL_TSR_OFFSET); - reg |= XEL_TSR_XMIT_BUSY_MASK; - if ((reg & XEL_TSR_XMIT_IE_MASK) != 0) { - reg |= XEL_TSR_XMIT_ACTIVE_MASK; + if (((reg & XEL_TSR_XMIT_BUSY_MASK) == 0) + && ((in_be32 ((baseaddress) + XEL_TSR_OFFSET) + & XEL_TSR_XMIT_ACTIVE_MASK) == 0)) { + debug ("Send packet from 0x%x\n", baseaddress); + /* Write the frame to the buffer */ + xemaclite_alignedwrite ((void *) ptr, baseaddress, len); + out_be32 (baseaddress + XEL_TPLR_OFFSET,(len & + (XEL_TPLR_LENGTH_MASK_HI | + XEL_TPLR_LENGTH_MASK_LO))); + reg = in_be32 (baseaddress + XEL_TSR_OFFSET); + reg |= XEL_TSR_XMIT_BUSY_MASK; + if ((reg & XEL_TSR_XMIT_IE_MASK) != 0) { + reg |= XEL_TSR_XMIT_ACTIVE_MASK; + } + out_be32 (baseaddress + XEL_TSR_OFFSET, reg); + return 0; } - out_be32 (baseaddress + XEL_TSR_OFFSET, reg); - return 0; } -#endif + puts ("Error while sending frame\n"); return -1; } @@ -288,23 +294,24 @@ static int emaclite_recv(struct eth_device *dev) reg = in_be32 (baseaddress + XEL_RSR_OFFSET); debug ("Testing data at address 0x%x\n", baseaddress); if ((reg & XEL_RSR_RECV_DONE_MASK) == XEL_RSR_RECV_DONE_MASK) { -#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - emaclite->nextrxbuffertouse ^= XEL_BUFFER_OFFSET; -#endif + if (emaclite->rxpp) + emaclite->nextrxbuffertouse ^= XEL_BUFFER_OFFSET; } else { -#ifndef CONFIG_XILINX_EMACLITE_RX_PING_PONG - debug ("No data was available - address 0x%x\n", baseaddress); - return 0; -#else - baseaddress ^= XEL_BUFFER_OFFSET; - reg = in_be32 (baseaddress + XEL_RSR_OFFSET); - if ((reg & XEL_RSR_RECV_DONE_MASK) != - XEL_RSR_RECV_DONE_MASK) { + + if (!emaclite->rxpp) { debug ("No data was available - address 0x%x\n", - baseaddress); + baseaddress); return 0; + } else { + baseaddress ^= XEL_BUFFER_OFFSET; + reg = in_be32 (baseaddress + XEL_RSR_OFFSET); + if ((reg & XEL_RSR_RECV_DONE_MASK) != + XEL_RSR_RECV_DONE_MASK) { + debug ("No data was available - address 0x%x\n", + baseaddress); + return 0; + } } -#endif } /* Get the length of the frame that arrived */ switch(((ntohl(in_be32 (baseaddress + XEL_RXBUFF_OFFSET + 0xC))) & @@ -354,6 +361,13 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) dev->priv = emaclite; +#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG + emaclite->txpp = 1; +#endif +#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG + emaclite->rxpp = 1; +#endif + sprintf(dev->name, "Xelite.%x", base_addr); dev->iobase = base_addr; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device 2011-08-26 12:47 ` [U-Boot] [PATCH 6/8] net: emaclite: Setup RX/TX ping pong for every instance Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 8/8] net: emaclite: Move RX/TX ping pong initialization to board Michal Simek 2011-08-26 19:25 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Mike Frysinger 0 siblings, 2 replies; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Free allocated space for device when allocating failed for private data. Signed-off-by: Michal Simek <monstr@monstr.eu> --- drivers/net/xilinx_emaclite.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index ac6c783..e0b6ce5 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -356,8 +356,10 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) return -1; emaclite = calloc(1, sizeof(struct xemaclite)); - if (emaclite == NULL) + if (emaclite == NULL) { + free(dev); return -1; + } dev->priv = emaclite; -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 8/8] net: emaclite: Move RX/TX ping pong initialization to board 2011-08-26 12:47 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Michal Simek @ 2011-08-26 12:47 ` Michal Simek 2011-08-26 19:25 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Mike Frysinger 1 sibling, 0 replies; 14+ messages in thread From: Michal Simek @ 2011-08-26 12:47 UTC (permalink / raw) To: u-boot Init RX/TX ping pong directly in boards not in the driver. Signed-off-by: Michal Simek <monstr@monstr.eu> --- .../xilinx/microblaze-generic/microblaze-generic.c | 11 ++++++++++- drivers/net/xilinx_emaclite.c | 10 +++------- include/netdev.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c index 183e4dc..1a6e568 100644 --- a/board/xilinx/microblaze-generic/microblaze-generic.c +++ b/board/xilinx/microblaze-generic/microblaze-generic.c @@ -77,6 +77,15 @@ int board_eth_init(bd_t *bis) * returning -1 will force cpu_eth_init() to be called. */ #ifdef CONFIG_XILINX_EMACLITE - return xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR); + u32 txpp = 0; + u32 rxpp = 0; +# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG + txpp = 1; +# endif +# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG + rxpp = 1; +# endif + return xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR, + txpp, rxpp); #endif } diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index e0b6ce5..cbf82d9 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -346,7 +346,7 @@ static int emaclite_recv(struct eth_device *dev) } -int xilinx_emaclite_initialize (bd_t *bis, int base_addr) +int xilinx_emaclite_initialize (bd_t *bis, int base_addr, int txpp, int rxpp) { struct eth_device *dev; struct xemaclite *emaclite; @@ -363,12 +363,8 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) dev->priv = emaclite; -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - emaclite->txpp = 1; -#endif -#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - emaclite->rxpp = 1; -#endif + emaclite->txpp = txpp; + emaclite->rxpp = rxpp; sprintf(dev->name, "Xelite.%x", base_addr); diff --git a/include/netdev.h b/include/netdev.h index 6f0a971..5abafbc 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -90,7 +90,7 @@ int smc91111_initialize(u8 dev_num, int base_addr); int tsi108_eth_initialize(bd_t *bis); int uec_standard_init(bd_t *bis); int uli526x_initialize(bd_t *bis); -int xilinx_emaclite_initialize (bd_t *bis, int base_addr); +int xilinx_emaclite_initialize (bd_t *bis, int base_addr, int txpp, int rxpp); int sh_eth_initialize(bd_t *bis); int dm9000_initialize(bd_t *bis); int fecmxc_initialize(bd_t *bis); -- 1.5.5.6 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device 2011-08-26 12:47 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 8/8] net: emaclite: Move RX/TX ping pong initialization to board Michal Simek @ 2011-08-26 19:25 ` Mike Frysinger 2011-08-29 5:50 ` Michal Simek 1 sibling, 1 reply; 14+ messages in thread From: Mike Frysinger @ 2011-08-26 19:25 UTC (permalink / raw) To: u-boot On Friday, August 26, 2011 08:47:22 Michal Simek wrote: > --- a/drivers/net/xilinx_emaclite.c > +++ b/drivers/net/xilinx_emaclite.c > @@ -356,8 +356,10 @@ int xilinx_emaclite_initialize (bd_t *bis, int > base_addr) return -1; > > emaclite = calloc(1, sizeof(struct xemaclite)); > - if (emaclite == NULL) > + if (emaclite == NULL) { > + free(dev); > return -1; > + } since this bug was introduced by your patch 5/8, please squash it into that rather than sending out a known buggy one -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20110826/d0510c9a/attachment.pgp ^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device 2011-08-26 19:25 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Mike Frysinger @ 2011-08-29 5:50 ` Michal Simek 0 siblings, 0 replies; 14+ messages in thread From: Michal Simek @ 2011-08-29 5:50 UTC (permalink / raw) To: u-boot Mike Frysinger wrote: > On Friday, August 26, 2011 08:47:22 Michal Simek wrote: >> --- a/drivers/net/xilinx_emaclite.c >> +++ b/drivers/net/xilinx_emaclite.c >> @@ -356,8 +356,10 @@ int xilinx_emaclite_initialize (bd_t *bis, int >> base_addr) return -1; >> >> emaclite = calloc(1, sizeof(struct xemaclite)); >> - if (emaclite == NULL) >> + if (emaclite == NULL) { >> + free(dev); >> return -1; >> + } > > since this bug was introduced by your patch 5/8, please squash it into that > rather than sending out a known buggy one aah. Good point. Thanks, Michal -- Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian ^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation 2011-08-26 12:47 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 6/8] net: emaclite: Setup RX/TX ping pong for every instance Michal Simek @ 2011-08-26 19:22 ` Mike Frysinger 1 sibling, 0 replies; 14+ messages in thread From: Mike Frysinger @ 2011-08-26 19:22 UTC (permalink / raw) To: u-boot On Friday, August 26, 2011 08:47:20 Michal Simek wrote: > dev = calloc(1, sizeof(*dev)); > if (dev == NULL) > return -1; > > + emaclite = calloc(1, sizeof(struct xemaclite)); > + if (emaclite == NULL) > + return -1; and you just leaked the dev alloc :) -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20110826/57baf421/attachment.pgp ^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite 2011-08-26 12:47 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Michal Simek @ 2011-09-07 20:26 ` Wolfgang Denk 1 sibling, 0 replies; 14+ messages in thread From: Wolfgang Denk @ 2011-09-07 20:26 UTC (permalink / raw) To: u-boot Dear Michal Simek, In message <1314362843-18214-4-git-send-email-monstr@monstr.eu> you wrote: > Use dev->iobase instead of baseaddress. > > Signed-off-by: Michal Simek <monstr@monstr.eu> ... > - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0); > + out_be32 (dev->iobase + XEL_TSR_OFFSET, 0); > /* Copy MAC address */ > xemaclite_alignedwrite (dev->enetaddr, > - emaclite.baseaddress, ENET_ADDR_LENGTH); > + dev->iobase, ENET_ADDR_LENGTH); > /* Set the length */ > - out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); > + out_be32 (dev->iobase + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH); > /* Update the MAC address in the EMAC Lite */ > - out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, XEL_TSR_PROG_MAC_ADDR); > + out_be32 (dev->iobase + XEL_TSR_OFFSET, XEL_TSR_PROG_MAC_ADDR); > /* Wait for EMAC Lite to finish with the MAC address update */ > - while ((in_be32 (emaclite.baseaddress + XEL_TSR_OFFSET) & > + while ((in_be32 (dev->iobase + XEL_TSR_OFFSET) & > XEL_TSR_PROG_MAC_ADDR) != 0) ; I'll accept this for now as you are not adding this code new, but please note that all this should be cleaned up and converted into C structs instead of base + offset. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is, however, a strange, musty smell in the air that reminds me of something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. - Larry Wall in Configure from the perl distribution ^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address 2011-08-26 12:47 [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 2/8] net: emaclite: Remove deviceid property Michal Simek @ 2011-08-26 19:24 ` Mike Frysinger 2011-08-29 5:49 ` Michal Simek 1 sibling, 1 reply; 14+ messages in thread From: Mike Frysinger @ 2011-08-26 19:24 UTC (permalink / raw) To: u-boot On Friday, August 26, 2011 08:47:16 Michal Simek wrote: > - sprintf(dev->name, "Xilinx_Emaclite"); > + sprintf(dev->name, "Xelite.%x", base_addr); you calculated this down to the byte huh ;). i see it uses the full 16. do we have to worry about people who specify the device in their envs ? i'm guessing not if the current driver only supports one instance. -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20110826/316f9181/attachment.pgp ^ permalink raw reply [flat|nested] 14+ messages in thread
* [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address 2011-08-26 19:24 ` [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Mike Frysinger @ 2011-08-29 5:49 ` Michal Simek 0 siblings, 0 replies; 14+ messages in thread From: Michal Simek @ 2011-08-29 5:49 UTC (permalink / raw) To: u-boot Mike Frysinger wrote: > On Friday, August 26, 2011 08:47:16 Michal Simek wrote: >> - sprintf(dev->name, "Xilinx_Emaclite"); >> + sprintf(dev->name, "Xelite.%x", base_addr); > > you calculated this down to the byte huh ;). i see it uses the full 16. Yes, I had to because eth_device has 16 chars array for it. > > do we have to worry about people who specify the device in their envs ? i'm > guessing not if the current driver only supports one instance. The whole point is to support several instances that's why I need to add base address to name and fit to 16 chars. Michal -- Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-09-07 20:26 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-26 12:47 [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 2/8] net: emaclite: Remove deviceid property Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 3/8] net: emaclite: Use calloc instead of malloc Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 6/8] net: emaclite: Setup RX/TX ping pong for every instance Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Michal Simek 2011-08-26 12:47 ` [U-Boot] [PATCH 8/8] net: emaclite: Move RX/TX ping pong initialization to board Michal Simek 2011-08-26 19:25 ` [U-Boot] [PATCH 7/8] net: emaclite: Free allocated space for device Mike Frysinger 2011-08-29 5:50 ` Michal Simek 2011-08-26 19:22 ` [U-Boot] [PATCH 5/8] net: emaclite: Use dynamic allocation Mike Frysinger 2011-09-07 20:26 ` [U-Boot] [PATCH 4/8] net: emaclite: Remove baseaddress from xemaclite Wolfgang Denk 2011-08-26 19:24 ` [U-Boot] [PATCH 1/8] net: emaclite: Change driver name and add address Mike Frysinger 2011-08-29 5:49 ` Michal Simek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox