net: emaclite: Change driver name and add address
Subsystems (2)
PATCH 1/8 net: emaclite: Change driver name and add address
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.
--- drivers/net/xilinx_emaclite.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/xilinx_emaclite.c +1 -1
@@ -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 ;
Signature · 1 line
1.5.5.6
PATCH 2/8 net: emaclite: Remove deviceid property
Cleanup structure.
--- drivers/net/xilinx_emaclite.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/net/xilinx_emaclite.c +0 -1
@@ -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;
Signature · 1 line
1.5.5.6
PATCH 3/8 net: emaclite: Use calloc instead of malloc
Simplify driver logic and clear eth_device structure in one command.
--- drivers/net/xilinx_emaclite.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/xilinx_emaclite.c +1 -2
@@ -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;
Signature · 1 line
1.5.5.6
PATCH 4/8 net: emaclite: Remove baseaddress from xemaclite
Use dev->iobase instead of baseaddress.
--- drivers/net/xilinx_emaclite.c | 34 ++++++++++++++++------------------ 1 files changed, 16 insertions(+), 18 deletions(-)
drivers/net/xilinx_emaclite.c +16 -18
@@ -64,7 +64,6 @@#define XEL_RSR_RECV_IE_MASK 0x00000008ULtypedef 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 ) {
Signature · 1 line
1.5.5.6
PATCH 5/8 net: emaclite: Use dynamic allocation
Every emaclite instance use own setting.
--- drivers/net/xilinx_emaclite.c | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-)
drivers/net/xilinx_emaclite.c +23 -16
@@ -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;
Signature · 1 line
1.5.5.6
PATCH 6/8 net: emaclite: Setup RX/TX ping pong for every instance
Setup RX/TX ping-pong buffer for every emaclite IP separately. The next patch move initialization directly to board code.
--- drivers/net/xilinx_emaclite.c | 122 +++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 54 deletions(-)
drivers/net/xilinx_emaclite.c +68 -54
@@ -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;
Signature · 1 line
1.5.5.6
PATCH 7/8 net: emaclite: Free allocated space for device
Free allocated space for device when allocating
failed for private data.
--- drivers/net/xilinx_emaclite.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/xilinx_emaclite.c +3 -1
@@ -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;
Signature · 1 line
1.5.5.6
PATCH 8/8 net: emaclite: Move RX/TX ping pong initialization to board
Init RX/TX ping pong directly in boards not in the driver.
--- .../xilinx/microblaze-generic/microblaze-generic.c | 11 ++++++++++- drivers/net/xilinx_emaclite.c | 10 +++------- include/netdev.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +10 -1
@@ -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 }
drivers/net/xilinx_emaclite.c +3 -7
@@ -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);
include/netdev.h +1 -1
@@ -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);
Signature · 1 line
1.5.5.6
PATCH 7/8 net: emaclite: Free allocated space for device
In reply to Michal Simekdrivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize (bd_t *bis, int · line 362
Quoted 11 lines · On Friday, August 26, 2011 08:47:22 Michal Simek wrote:
drivers/net/xilinx_emaclite.c +3
-1@@ -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
PATCH 7/8 net: emaclite: Free allocated space for device
Quoted 6 lines · Mike Frysinger
Quoted 5 lines · On Friday, August 26, 2011 08:47:22 Michal Simek wrote:
drivers/net/xilinx_emaclite.c +0
-0@@ -356,8 +356,10 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) return -1;
Quoted 9 lines
drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize (bd_t *bis, int base_addr) · line 362
Quoted 6 lines
drivers/net/xilinx_emaclite.c +3
-1emaclite =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
Signature · 4 lines
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
PATCH 5/8 net: emaclite: Use dynamic allocation
In reply to Michal Simekdrivers/net/xilinx_emaclite.c static int emaclite_recv(struct eth_device *dev) · line 353
Quoted 7 lines · On Friday, August 26, 2011 08:47:20 Michal Simek wrote:
drivers/net/xilinx_emaclite.c +3
-0dev =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
PATCH 4/8 net: emaclite: Remove baseaddress from xemaclite
In reply to Michal SimekDear Michal Simek,
Quoted 3 lines · In message <[email protected]> you wrote:
Use
dev->iobaseinstead of baseaddress.Signed-off-by Michal Simek <[email protected]>
...
Quoted 6 lines
drivers/net/xilinx_emaclite.c +2
-2-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 );
drivers/net/xilinx_emaclite.c static int emaclite_init(struct eth_device *dev, bd_t *bis) · line 153
Quoted 10 lines
drivers/net/xilinx_emaclite.c +3
-3/* 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
Signature · 6 lines
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
PATCH 1/8 net: emaclite: Change driver name and add address
In reply to Michal Simekdrivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize (bd_t *bis, int base_addr) · line 353
Quoted 2 lines · On Friday, August 26, 2011 08:47:16 Michal Simek wrote:
drivers/net/xilinx_emaclite.c +1
-1-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
PATCH 1/8 net: emaclite: Change driver name and add address
Quoted 5 lines · Mike Frysinger
drivers/net/xilinx_emaclite.c int xilinx_emaclite_initialize (bd_t *bis, int base_addr) · line 353
Quoted 2 lines · On Friday, August 26, 2011 08:47:16 Michal Simek wrote:
drivers/net/xilinx_emaclite.c +1
-1-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.
Quoted 3 lines
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
Signature · 4 lines
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