Skip to contentSkip to conversation

microblaze: Fix microblaze-generic config file

PATCH New Michal Simek 3 participants 10 messages Aug 2, 2010 – Dec 3, 2010

Subsystems (3)
lore
Share & tools
lore

Michal Simek

author maintainer
#0 lore raw

PATCH 1/4 microblaze: Fix microblaze-generic config file

1. Fix preprocessor statements
2. Clean coding style

---
 include/configs/microblaze-generic.h |  227 ++++++++++++++++++----------------
 1 files changed, 123 insertions(+), 104 deletions(-)
include/configs/microblaze-generic.h +123 -104
index 28cee47..9301a6b 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2007-2008 Michal Simek
+ * (C) Copyright 2007-2010 Michal Simek
  *
  * Michal SIMEK <[email protected]>
  *
@@ -27,31 +27,33 @@
 
 #include "../board/xilinx/microblaze-generic/xparameters.h"
 
-#define	CONFIG_MICROBLAZE	1	/* MicroBlaze CPU */
+/* MicroBlaze CPU */
+#define	CONFIG_MICROBLAZE	1
 #define	MICROBLAZE_V5		1
 
 /* uart */
 #ifdef XILINX_UARTLITE_BASEADDR
-	#define	CONFIG_XILINX_UARTLITE
-	#define	CONFIG_SERIAL_BASE	XILINX_UARTLITE_BASEADDR
-	#define	CONFIG_BAUDRATE		XILINX_UARTLITE_BAUDRATE
-	#define	CONFIG_SYS_BAUDRATE_TABLE	{ CONFIG_BAUDRATE }
-	#define CONSOLE_ARG	"console=console=ttyUL0,115200\0"
+# define CONFIG_XILINX_UARTLITE
+# define CONFIG_SERIAL_BASE	XILINX_UARTLITE_BASEADDR
+# define CONFIG_BAUDRATE	XILINX_UARTLITE_BAUDRATE
+# define CONFIG_SYS_BAUDRATE_TABLE	{ CONFIG_BAUDRATE }
+# define CONSOLE_ARG	"console=console=ttyUL0,115200\0"
 #elif XILINX_UART16550_BASEADDR
-	#define CONFIG_SYS_NS16550	1
-	#define CONFIG_SYS_NS16550_SERIAL
-	#define CONFIG_SYS_NS16550_REG_SIZE	-4
-	#define CONFIG_CONS_INDEX	1
-	#define CONFIG_SYS_NS16550_COM1	(XILINX_UART16550_BASEADDR + 0x1000 + 0x3)
-	#define CONFIG_SYS_NS16550_CLK	XILINX_UART16550_CLOCK_HZ
-	#define	CONFIG_BAUDRATE		115200
-
-	/* The following table includes the supported baudrates */
-	#define CONFIG_SYS_BAUDRATE_TABLE  \
-		{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
-	#define CONSOLE_ARG	"console=console=ttyS0,115200\0"
+# define CONFIG_SYS_NS16550		1
+# define CONFIG_SYS_NS16550_SERIAL
+# define CONFIG_SYS_NS16550_REG_SIZE	-4
+# define CONFIG_CONS_INDEX		1
+# define CONFIG_SYS_NS16550_COM1 \
+			(XILINX_UART16550_BASEADDR + 0x1000 + 0x3)
+# define CONFIG_SYS_NS16550_CLK	XILINX_UART16550_CLOCK_HZ
+# define CONFIG_BAUDRATE	115200
+
+/* The following table includes the supported baudrates */
+# define CONFIG_SYS_BAUDRATE_TABLE \
+	{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
+# define CONSOLE_ARG	"console=console=ttyS0,115200\0"
 #else
-	#error Undefined uart
+# error Undefined uart
 #endif
 
 /* setting reset address */
@@ -59,41 +61,41 @@
 
 /* ethernet */
 #ifdef XILINX_EMACLITE_BASEADDR
-	#define CONFIG_XILINX_EMACLITE	1
-	#define CONFIG_SYS_ENET
+# define CONFIG_XILINX_EMACLITE		1
+# define CONFIG_SYS_ENET
 #elif XILINX_LLTEMAC_BASEADDR
-	#define CONFIG_XILINX_LL_TEMAC	1
-	#define CONFIG_SYS_ENET
+# define CONFIG_XILINX_LL_TEMAC		1
+# define CONFIG_SYS_ENET
 #endif
 
 #undef ET_DEBUG
 
 /* gpio */
 #ifdef XILINX_GPIO_BASEADDR
-	#define	CONFIG_SYS_GPIO_0		1
-	#define	CONFIG_SYS_GPIO_0_ADDR		XILINX_GPIO_BASEADDR
+# define CONFIG_SYS_GPIO_0		1
+# define CONFIG_SYS_GPIO_0_ADDR		XILINX_GPIO_BASEADDR
 #endif
 
 /* interrupt controller */
 #ifdef XILINX_INTC_BASEADDR
-	#define	CONFIG_SYS_INTC_0		1
-	#define	CONFIG_SYS_INTC_0_ADDR		XILINX_INTC_BASEADDR
-	#define	CONFIG_SYS_INTC_0_NUM		XILINX_INTC_NUM_INTR_INPUTS
+# define CONFIG_SYS_INTC_0		1
+# define CONFIG_SYS_INTC_0_ADDR		XILINX_INTC_BASEADDR
+# define CONFIG_SYS_INTC_0_NUM		XILINX_INTC_NUM_INTR_INPUTS
 #endif
 
 /* timer */
 #ifdef XILINX_TIMER_BASEADDR
-	#if (XILINX_TIMER_IRQ != -1)
-		#define	CONFIG_SYS_TIMER_0		1
-		#define	CONFIG_SYS_TIMER_0_ADDR	XILINX_TIMER_BASEADDR
-		#define	CONFIG_SYS_TIMER_0_IRQ		XILINX_TIMER_IRQ
-		#define	FREQUENCE		XILINX_CLOCK_FREQ
-		#define	CONFIG_SYS_TIMER_0_PRELOAD	( FREQUENCE/1000 )
-	#endif
+# if (XILINX_TIMER_IRQ != -1)
+#  define CONFIG_SYS_TIMER_0		1
+#  define CONFIG_SYS_TIMER_0_ADDR	XILINX_TIMER_BASEADDR
+#  define CONFIG_SYS_TIMER_0_IRQ	XILINX_TIMER_IRQ
+#  define FREQUENCE	XILINX_CLOCK_FREQ
+#  define CONFIG_SYS_TIMER_0_PRELOAD	( FREQUENCE/1000 )
+# endif
 #elif XILINX_CLOCK_FREQ
-	#define	CONFIG_XILINX_CLOCK_FREQ	XILINX_CLOCK_FREQ
+# define CONFIG_XILINX_CLOCK_FREQ	XILINX_CLOCK_FREQ
 #else
-	#error BAD CLOCK FREQ
+# error BAD CLOCK FREQ
 #endif
 /* FSL */
 /* #define	CONFIG_SYS_FSL_2 */
@@ -135,15 +137,20 @@
 /* global pointer */
 #define	CONFIG_SYS_GBL_DATA_SIZE	128 /* size of global data */
 /* start of global data */
-#define	CONFIG_SYS_GBL_DATA_OFFSET	(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE - CONFIG_SYS_GBL_DATA_SIZE)
+#define	CONFIG_SYS_GBL_DATA_OFFSET \
+	(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE \
+				- CONFIG_SYS_GBL_DATA_SIZE)
 
 /* monitor code */
-#define	SIZE			0x40000
+#define	SIZE				0x40000
 #define	CONFIG_SYS_MONITOR_LEN		(SIZE - CONFIG_SYS_GBL_DATA_SIZE)
-#define	CONFIG_SYS_MONITOR_BASE	(CONFIG_SYS_GBL_DATA_OFFSET - CONFIG_SYS_MONITOR_LEN)
-#define	CONFIG_SYS_MONITOR_END		(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
+#define	CONFIG_SYS_MONITOR_BASE	\
+			(CONFIG_SYS_GBL_DATA_OFFSET - CONFIG_SYS_MONITOR_LEN)
+#define	CONFIG_SYS_MONITOR_END \
+			(CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
 #define	CONFIG_SYS_MALLOC_LEN		SIZE
-#define	CONFIG_SYS_MALLOC_BASE		(CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN)
+#define	CONFIG_SYS_MALLOC_BASE \
+			(CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN)
 
 /* stack */
 #define	CONFIG_SYS_INIT_SP_OFFSET	CONFIG_SYS_MALLOC_BASE
@@ -152,55 +159,62 @@
 #define	FLASH
 
 #ifdef FLASH
-	#define	CONFIG_SYS_FLASH_BASE		XILINX_FLASH_START
-	#define	CONFIG_SYS_FLASH_SIZE		XILINX_FLASH_SIZE
-	#define	CONFIG_SYS_FLASH_CFI		1
-	#define	CONFIG_FLASH_CFI_DRIVER	1
-	#define	CONFIG_SYS_FLASH_EMPTY_INFO	1	/* ?empty sector */
-	#define	CONFIG_SYS_MAX_FLASH_BANKS	1	/* max number of memory banks */
-	#define	CONFIG_SYS_MAX_FLASH_SECT	512	/* max number of sectors on one chip */
-	#define	CONFIG_SYS_FLASH_PROTECTION		/* hardware flash protection */
-
-	#ifdef	RAMENV
-		#define	CONFIG_ENV_IS_NOWHERE	1
-		#define	CONFIG_ENV_SIZE		0x1000
-		#define	CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
-
-	#else	/* !RAMENV */
-		#define	CONFIG_ENV_IS_IN_FLASH	1
-		#define	CONFIG_ENV_SECT_SIZE	0x20000	/* 128K(one sector) for env */
-		#define	CONFIG_ENV_ADDR		(CONFIG_SYS_FLASH_BASE + (2 * CONFIG_ENV_SECT_SIZE))
-		#define	CONFIG_ENV_SIZE		0x20000
-	#endif /* !RAMBOOT */
+# define CONFIG_SYS_FLASH_BASE		XILINX_FLASH_START
+# define CONFIG_SYS_FLASH_SIZE		XILINX_FLASH_SIZE
+# define CONFIG_SYS_FLASH_CFI		1
+# define CONFIG_FLASH_CFI_DRIVER	1
+/* ?empty sector */
+# define CONFIG_SYS_FLASH_EMPTY_INFO	1
+/* max number of memory banks */
+# define CONFIG_SYS_MAX_FLASH_BANKS	1
+/* max number of sectors on one chip */
+# define CONFIG_SYS_MAX_FLASH_SECT	512
+/* hardware flash protection */
+# define CONFIG_SYS_FLASH_PROTECTION
+
+# ifdef	RAMENV
+#  define CONFIG_ENV_IS_NOWHERE	1
+#  define CONFIG_ENV_SIZE	0x1000
+#  define CONFIG_ENV_ADDR	(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
+
+# else	/* !RAMENV */
+#  define CONFIG_ENV_IS_IN_FLASH	1
+/* 128K(one sector) for env */
+#  define CONFIG_ENV_SECT_SIZE	0x20000
+#  define CONFIG_ENV_ADDR \
+			(CONFIG_SYS_FLASH_BASE + (2 * CONFIG_ENV_SECT_SIZE))
+#  define CONFIG_ENV_SIZE	0x20000
+# endif /* !RAMBOOT */
 #else /* !FLASH */
-	/* ENV in RAM */
-	#define	CONFIG_SYS_NO_FLASH		1
-	#define	CONFIG_ENV_IS_NOWHERE	1
-	#define	CONFIG_ENV_SIZE		0x1000
-	#define	CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
-	#define	CONFIG_SYS_FLASH_PROTECTION		/* hardware flash protection */
+/* ENV in RAM */
+# define CONFIG_SYS_NO_FLASH	1
+# define CONFIG_ENV_IS_NOWHERE	1
+# define CONFIG_ENV_SIZE	0x1000
+# define CONFIG_ENV_ADDR	(CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SIZE)
+/* hardware flash protection */
+# define CONFIG_SYS_FLASH_PROTECTION
 #endif /* !FLASH */
 
 /* system ace */
 #ifdef XILINX_SYSACE_BASEADDR
-	#define	CONFIG_SYSTEMACE
-	/* #define DEBUG_SYSTEMACE */
-	#define	SYSTEMACE_CONFIG_FPGA
-	#define	CONFIG_SYS_SYSTEMACE_BASE	XILINX_SYSACE_BASEADDR
-	#define	CONFIG_SYS_SYSTEMACE_WIDTH	XILINX_SYSACE_MEM_WIDTH
-	#define	CONFIG_DOS_PARTITION
+# define CONFIG_SYSTEMACE
+/* #define DEBUG_SYSTEMACE */
+# define SYSTEMACE_CONFIG_FPGA
+# define CONFIG_SYS_SYSTEMACE_BASE	XILINX_SYSACE_BASEADDR
+# define CONFIG_SYS_SYSTEMACE_WIDTH	XILINX_SYSACE_MEM_WIDTH
+# define CONFIG_DOS_PARTITION
 #endif
 
 #if defined(XILINX_USE_ICACHE)
-	#define CONFIG_ICACHE
+# define CONFIG_ICACHE
 #else
-	#undef CONFIG_ICACHE
+# undef CONFIG_ICACHE
 #endif
 
 #if defined(XILINX_USE_DCACHE)
-	#define CONFIG_DCACHE
+# define CONFIG_DCACHE
 #else
-	#undef CONFIG_DCACHE
+# undef CONFIG_DCACHE
 #endif
 
 /*
@@ -222,37 +236,37 @@
 #define CONFIG_CMD_ECHO
 
 #if defined(CONFIG_DCACHE) || defined(CONFIG_ICACHE)
-	#define CONFIG_CMD_CACHE
+# define CONFIG_CMD_CACHE
 #else
-	#undef CONFIG_CMD_CACHE
+# undef CONFIG_CMD_CACHE
 #endif
 
 #ifndef CONFIG_SYS_ENET
-	#undef CONFIG_CMD_NET
+# undef CONFIG_CMD_NET
 #else
-	#define CONFIG_CMD_PING
-	#define CONFIG_CMD_DHCP
+# define CONFIG_CMD_PING
+# define CONFIG_CMD_DHCP
 #endif
 
 #if defined(CONFIG_SYSTEMACE)
-	#define CONFIG_CMD_EXT2
-	#define CONFIG_CMD_FAT
+# define CONFIG_CMD_EXT2
+# define CONFIG_CMD_FAT
 #endif
 
 #if defined(FLASH)
-	#define CONFIG_CMD_ECHO
-	#define CONFIG_CMD_FLASH
-	#define CONFIG_CMD_IMLS
-	#define CONFIG_CMD_JFFS2
-
-	#if !defined(RAMENV)
-		#define CONFIG_CMD_SAVEENV
-		#define CONFIG_CMD_SAVES
-	#endif
+# define CONFIG_CMD_ECHO
+# define CONFIG_CMD_FLASH
+# define CONFIG_CMD_IMLS
+# define CONFIG_CMD_JFFS2
+
+# if !defined(RAMENV)
+#  define CONFIG_CMD_SAVEENV
+#  define CONFIG_CMD_SAVES
+# endif
 #else
-	#undef CONFIG_CMD_IMLS
-	#undef CONFIG_CMD_FLASH
-	#undef CONFIG_CMD_JFFS2
+# undef CONFIG_CMD_IMLS
+# undef CONFIG_CMD_FLASH
+# undef CONFIG_CMD_JFFS2
 #endif
 
 #if defined(CONFIG_CMD_JFFS2)
@@ -270,11 +284,16 @@
 
 /* Miscellaneous configurable options */
 #define	CONFIG_SYS_PROMPT	"U-Boot-mONStR> "
-#define	CONFIG_SYS_CBSIZE	512	/* size of console buffer */
-#define	CONFIG_SYS_PBSIZE	(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16) /* print buffer size */
-#define	CONFIG_SYS_MAXARGS	15	/* max number of command args */
+/* size of console buffer */
+#define	CONFIG_SYS_CBSIZE	512
+ /* print buffer size */
+#define	CONFIG_SYS_PBSIZE \
+		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+/* max number of command args */
+#define	CONFIG_SYS_MAXARGS	15
 #define	CONFIG_SYS_LONGHELP
-#define	CONFIG_SYS_LOAD_ADDR	XILINX_RAM_START /* default load address */
+/* default load address */
+#define	CONFIG_SYS_LOAD_ADDR	XILINX_RAM_START
 
 #define	CONFIG_BOOTDELAY	-1	/* -1 disables auto-boot */
 #define	CONFIG_BOOTARGS		"root=romfs"
@@ -291,7 +310,7 @@
 
 #define	CONFIG_PREBOOT	"echo U-BOOT for ${hostname};setenv preboot;echo"
 
-#define	CONFIG_EXTRA_ENV_SETTINGS	"unlock=yes\0" /* hardware flash protection */\
+#define	CONFIG_EXTRA_ENV_SETTINGS	"unlock=yes\0" \
 					"nor0=flash-0\0"\
 					"mtdparts=mtdparts=flash-0:"\
 					"256k(u-boot),256k(env),3m(kernel),"\
@@ -302,7 +321,7 @@
 /* Use the HUSH parser */
 #define CONFIG_SYS_HUSH_PARSER
 #ifdef CONFIG_SYS_HUSH_PARSER
-#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+# define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
 #endif
 
 #endif	/* __CONFIG_H */
Signature · 1 line
1.5.5.6
author maintainer
#1 lore raw

PATCH 2/4 net: Move Emaclite to NET_MULTI

Emaclite was using old net api that's why
this patch move emaclite to NET_MULTI api.

---
 drivers/net/xilinx_emaclite.c |   84 +++++++++++++++++++++++------------------
 include/netdev.h              |    1 +
 2 files changed, 48 insertions(+), 37 deletions(-)
drivers/net/xilinx_emaclite.c +47 -37
index 0820daa..f460525 100644
@@ -26,6 +26,7 @@
 #include <common.h>
 #include <net.h>
 #include <config.h>
+#include <malloc.h>
 #include <asm/io.h>
 
 #undef DEBUG
@@ -63,26 +64,19 @@
 #define XEL_RSR_RECV_IE_MASK		0x00000008UL
 
 typedef struct {
-	unsigned int baseaddress;	/* Base address for device (IPIF) */
-	unsigned int nexttxbuffertouse;	/* Next TX buffer to write to */
-	unsigned int nextrxbuffertouse;	/* Next RX buffer to read from */
-	unsigned char deviceid;		/* Unique ID of device - for future */
+	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;
 
 static u32 etherrxbuff[PKTSIZE_ALIGN/4]; /* Receive buffer */
 
-/* hardcoded MAC address for the Xilinx EMAC Core when env is nowhere*/
-#ifdef CONFIG_ENV_IS_NOWHERE
-static u8 emacaddr[ENET_ADDR_LENGTH] = { 0x00, 0x0a, 0x35, 0x00, 0x22, 0x01 };
-#else
-static u8 emacaddr[ENET_ADDR_LENGTH];
-#endif
-
-void xemaclite_alignedread (u32 * srcptr, void *destptr, unsigned bytecount)
+static void xemaclite_alignedread (u32 *srcptr, void *destptr, u32 bytecount)
 {
-	unsigned int i;
+	u32 i;
 	u32 alignbuffer;
 	u32 *to32ptr;
 	u32 *from32ptr;
@@ -107,9 +101,9 @@ void xemaclite_alignedread (u32 * srcptr, void *destptr, unsigned bytecount)
 	}
 }
 
-void xemaclite_alignedwrite (void *srcptr, u32 destptr, unsigned bytecount)
+static void xemaclite_alignedwrite (void *srcptr, u32 destptr, u32 bytecount)
 {
-	unsigned i;
+	u32 i;
 	u32 alignbuffer;
 	u32 *to32ptr = (u32 *) destptr;
 	u32 *from32ptr;
@@ -134,23 +128,16 @@ void xemaclite_alignedwrite (void *srcptr, u32 destptr, unsigned bytecount)
 	*to32ptr++ = alignbuffer;
 }
 
-void eth_halt (void)
+static void emaclite_halt(struct eth_device *dev)
 {
 	debug ("eth_halt\n");
 }
 
-int eth_init (bd_t * bis)
+static int emaclite_init(struct eth_device *dev, bd_t *bis)
 {
-	uchar enetaddr[6];
-
 	debug ("EmacLite Initialization Started\n");
 	memset (&emaclite, 0, sizeof (xemaclite));
-	emaclite.baseaddress = XILINX_EMACLITE_BASEADDR;
-
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
-		memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
-		eth_setenv_enetaddr("ethaddr", enetaddr);
-	}
+	emaclite.baseaddress = dev->iobase;
 
 /*
  * TX - TX_PING & TX_PONG initialization
@@ -158,7 +145,7 @@ int eth_init (bd_t * bis)
 	/* Restart PING TX */
 	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
 	/* Copy MAC address */
-	xemaclite_alignedwrite (enetaddr,
+	xemaclite_alignedwrite (dev->enetaddr,
 		emaclite.baseaddress, ENET_ADDR_LENGTH);
 	/* Set the length */
 	out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);
@@ -171,7 +158,7 @@ int eth_init (bd_t * bis)
 #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 (enetaddr, emaclite.baseaddress +
+	xemaclite_alignedwrite (dev->enetaddr, emaclite.baseaddress +
 		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,
@@ -194,7 +181,7 @@ int eth_init (bd_t * bis)
 	return 0;
 }
 
-int xemaclite_txbufferavailable (xemaclite * instanceptr)
+static int xemaclite_txbufferavailable (xemaclite *instanceptr)
 {
 	u32 reg;
 	u32 txpingbusy;
@@ -216,12 +203,12 @@ int xemaclite_txbufferavailable (xemaclite * instanceptr)
 	return (!(txpingbusy && txpongbusy));
 }
 
-int eth_send (volatile void *ptr, int len) {
-
-	unsigned int reg;
-	unsigned int baseaddress;
+static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)
+{
+	u32 reg;
+	u32 baseaddress;
 
-	unsigned maxtry = 1000;
+	u32 maxtry = 1000;
 
 	if (len > ENET_MAX_MTU)
 		len = ENET_MAX_MTU;
@@ -293,11 +280,11 @@ int eth_send (volatile void *ptr, int len) {
 	return 0;
 }
 
-int eth_rx (void)
+static int emaclite_recv(struct eth_device *dev)
 {
-	unsigned int length;
-	unsigned int reg;
-	unsigned int baseaddress;
+	u32 length;
+	u32 reg;
+	u32 baseaddress;
 
 	baseaddress = emaclite.baseaddress + emaclite.nextrxbuffertouse;
 	reg = in_be32 (baseaddress + XEL_RSR_OFFSET);
@@ -353,3 +340,26 @@ int eth_rx (void)
 	return 1;
 
 }
+
+int xilinx_emaclite_initialize (bd_t *bis)
+{
+	struct eth_device *dev;
+
+	dev = malloc(sizeof(*dev));
+	if (dev == NULL)
+		hang();
+
+	memset(dev, 0, sizeof(*dev));
+	sprintf(dev->name, "Xilinx Emaclite");
+
+	dev->iobase = XILINX_EMACLITE_BASEADDR;
+	dev->priv = 0;
+	dev->init = emaclite_init;
+	dev->halt = emaclite_halt;
+	dev->send = emaclite_send;
+	dev->recv = emaclite_recv;
+
+	eth_register(dev);
+
+	return 0;
+}
include/netdev.h +1 -0
index 94eedfe..979fb57 100644
@@ -88,6 +88,7 @@ int tsi108_eth_initialize(bd_t *bis);
 int uec_initialize(int index);
 int uec_standard_init(bd_t *bis);
 int uli526x_initialize(bd_t *bis);
+int xilinx_emaclite_initialize (bd_t *bis);
 int sh_eth_initialize(bd_t *bis);
 int dm9000_initialize(bd_t *bis);
 
Signature · 1 line
1.5.5.6
author maintainer
#2 lore raw

PATCH 2/4 net: Move Emaclite to NET_MULTI

Quoted 4 lines · Michal Simek

Emaclite was using old net api that's why
this patch move emaclite to NET_MULTI api.

Ben: any comment on this patch?

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
author maintainer
#3 lore raw

PATCH 3/4 microblaze: Add support for NET_MULTI api

In reply to Michal Simek

Microblaze hasn't supported NET_MULTI support.

---
 arch/microblaze/lib/board.c                        |   12 ++++++++++--
 .../xilinx/microblaze-generic/microblaze-generic.c |   13 +++++++++++++
 include/configs/microblaze-generic.h               |    2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
arch/microblaze/lib/board.c +10 -2
index 3ff5c17..0ce040e 100644
@@ -31,6 +31,7 @@
 #include <version.h>
 #include <watchdog.h>
 #include <stdio_dev.h>
+#include <net.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -42,6 +43,7 @@ extern int gpio_init (void);
 #ifdef CONFIG_SYS_INTC_0
 extern int interrupts_init (void);
 #endif
+
 #if defined(CONFIG_CMD_NET)
 extern int eth_init (bd_t * bis);
 #endif
@@ -165,8 +167,14 @@ void board_init (void)
 
 #if defined(CONFIG_CMD_NET)
 	/* IP Address */
-	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-	eth_init (bd);
+	bd->bi_ip_addr = getenv_IPaddr("ipaddr");
+
+	printf("Net:   ");
+	eth_initialize(gd->bd);
+
+	uchar enetaddr[6];
+	eth_getenv_enetaddr("ethaddr", enetaddr);
+	printf("MAC:   %pM\n", enetaddr);
 #endif
 
 	/* main_loop */
board/xilinx/microblaze-generic/microblaze-generic.c +13 -0
index 838f131..5a218b7 100644
@@ -27,6 +27,7 @@
 
 #include <common.h>
 #include <config.h>
+#include <netdev.h>
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 
@@ -66,3 +67,15 @@ int fsl_init2 (void) {
 	return 0;
 }
 #endif
+
+int board_eth_init(bd_t *bis)
+{
+	/*
+	 * This board either has PCI NICs or uses the CPU's TSECs
+	 * pci_eth_init() will return 0 if no NICs found, so in that case
+	 * returning -1 will force cpu_eth_init() to be called.
+	 */
+#ifdef CONFIG_XILINX_EMACLITE
+	return xilinx_emaclite_initialize(bis);
+#endif
+}
include/configs/microblaze-generic.h +2 -0
index 9301a6b..c30cc4c 100644
@@ -243,9 +243,11 @@
 
 #ifndef CONFIG_SYS_ENET
 # undef CONFIG_CMD_NET
+# undef CONFIG_NET_MULTI
 #else
 # define CONFIG_CMD_PING
 # define CONFIG_CMD_DHCP
+# define CONFIG_NET_MULTI
 #endif
 
 #if defined(CONFIG_SYSTEMACE)
Signature · 1 line
1.5.5.6
author maintainer
#4 lore raw

PATCH 4/4 net: Add LL TEMAC driver to u-boot

Add Xilinx LL Temac driver to u-boot.

---
 .../xilinx/microblaze-generic/microblaze-generic.c |    3 +
 drivers/net/Makefile                               |    1 +
 drivers/net/xilinx_ll_temac.c                      |  561 ++++++++++++++++++++
 include/netdev.h                                   |    1 +
 4 files changed, 566 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/xilinx_ll_temac.c
board/xilinx/microblaze-generic/microblaze-generic.c +3 -0
index 5a218b7..5bb3fb4 100644
@@ -78,4 +78,7 @@ int board_eth_init(bd_t *bis)
 #ifdef CONFIG_XILINX_EMACLITE
 	return xilinx_emaclite_initialize(bis);
 #endif
+#ifdef CONFIG_XILINX_LL_TEMAC
+	return xilinx_ll_temac_initialize(bis);
+#endif
 }
drivers/net/Makefile +1 -0
index 218eeff..93f9c28 100644
@@ -78,6 +78,7 @@ COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
 COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o
 COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
+COBJS-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/net/xilinx_ll_temac.c new file +561 -0

561 lines not on this page · raw message

include/netdev.h +1 -0
index 979fb57..a486d0b 100644
@@ -89,6 +89,7 @@ int uec_initialize(int index);
 int uec_standard_init(bd_t *bis);
 int uli526x_initialize(bd_t *bis);
 int xilinx_emaclite_initialize (bd_t *bis);
+int xilinx_ll_temac_initialize(bd_t *bis);
 int sh_eth_initialize(bd_t *bis);
 int dm9000_initialize(bd_t *bis);
 
Signature · 1 line
1.5.5.6
author maintainer
#5 lore raw

PATCH 4/4 net: Add LL TEMAC driver to u-boot

Quoted 3 lines · Michal Simek

Add Xilinx LL Temac driver to u-boot.

Ben: any comment on this patch?

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
#6 lore raw

PATCH 4/4 net: Add LL TEMAC driver to u-boot

In reply to Michal Simek

Dear Michal Simek,

sorry for the long delay. We're still lacking a (new) network custodian...

Review line 2

Quoted 7 lines · In message <[email protected]> you wrote:

Add Xilinx LL Temac driver to u-boot.

+++ b/drivers/net/xilinx_ll_temac.c

(quoted diff) +2 -0
@@ -0,0 +1,561 @@
+/*
+ *

Drop blank line.

drivers/net/xilinx_ll_temac.c line 11

Quoted 2 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+ * Copyright (C) 2008 - 2009 Michal Simek <[email protected]>
+ * June 2008 Microblaze optimalization, FIFO mode support

2009? Not 2010 ?

drivers/net/xilinx_ll_temac.c line 71

Quoted 12 lines
drivers/net/xilinx_ll_temac.c new file +12 -0
+/* XPS_LL_TEMAC direct registers definition */
+#define TEMAC_RAF0		(dev->iobase + 0x00)
+#define TEMAC_TPF0		(dev->iobase + 0x04)
+#define TEMAC_IFGP0		(dev->iobase + 0x08)
+#define TEMAC_IS0		(dev->iobase + 0x0c)
+#define TEMAC_IP0		(dev->iobase + 0x10)
+#define TEMAC_IE0		(dev->iobase + 0x14)
+
+#define TEMAC_MSW0		(dev->iobase + 0x20)
+#define TEMAC_LSW0		(dev->iobase + 0x24)
+#define TEMAC_CTL0		(dev->iobase + 0x28)
+#define TEMAC_RDY0		(dev->iobase + 0x2c)

Please use a C struct to describe the register layout.

Quoted 8 lines
drivers/net/xilinx_ll_temac.c new file +8 -0
+/* XPS_LL_TEMAC indirect registers offset definition */
+
+#define RCW0	0x200
+#define RCW1	0x240
+#define TC	0x280
+#define FCC	0x2c0
+#define EMMC	0x300
+#define PHYC	0x320

drivers/net/xilinx_ll_temac.c line 95

Quoted 10 lines
drivers/net/xilinx_ll_temac.c new file +10 -0
+#define MC	0x340
+#define UAW0	0x380
+#define UAW1	0x384
+#define MAW0	0x388
+#define MAW1	0x38c
+#define AFM	0x390
+#define TIS	0x3a0
+#define TIE	0x3a4
+#define MIIMWD	0x3b0
+#define MIIMAI	0x3b4

Ditto.

drivers/net/xilinx_ll_temac.c line 174

Quoted 6 lines
drivers/net/xilinx_ll_temac.c new file +6 -0
+	out_be32((u32 *)TEMAC_LSW0, phy_data);
+	out_be32((u32 *)TEMAC_CTL0, CNTLREG_WRITE_ENABLE_MASK | MIIMWD);
+	out_be32((u32 *)TEMAC_LSW0, (phy_addr << 5) | (reg_addr));
+	out_be32((u32 *)TEMAC_CTL0, \
+			CNTLREG_WRITE_ENABLE_MASK | MIIMAI | (emac << 10));
+	while (!(in_be32((u32 *)TEMAC_RDY0) & XTE_RSE_MIIM_WR_MASK))

The need to have all these casts should ring some alarm bell to you. Please use a proper C struct instead.

drivers/net/xilinx_ll_temac.c line 196

Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+	out_be32((u32 *)TEMAC_LSW0, reg_data);
+	out_be32((u32 *)TEMAC_CTL0, \
+			CNTLREG_WRITE_ENABLE_MASK | (emac << 10) | reg_offset);

Drop the backslash.

drivers/net/xilinx_ll_temac.c line 223

Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+		debug ("%d: 0x%x ", j, result);
+	}
+	debug ("\n");

No spaces between function name and '('. Please fix globally. Consider running your patch through checkpatch...

drivers/net/xilinx_ll_temac.c line 243

Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+	while (retries-- &&
+		((xps_ll_temac_hostif_get(dev, 0, phy_addr, 1) & 0x24) == 0x24))
+		;

Bad indentation.

Quoted 1 line
drivers/net/xilinx_ll_temac.c new file +1 -0
+	if (i == 0x7c0a3) {

...

drivers/net/xilinx_ll_temac.c line 274

Quoted 1 line
drivers/net/xilinx_ll_temac.c new file +1 -0
+	if (i == 0x1410cc2) {

Please use self-explaining symbolic names for these magic numbers, and/or add sufficient comments what these mean.

drivers/net/xilinx_ll_temac.c line 374

Quoted 5 lines
drivers/net/xilinx_ll_temac.c new file +5 -0
+static void debugll(int count)
+{
+	printf ("%d fifo isr 0x%08x, fifo_ier 0x%08x, fifo_rdfr 0x%08x, "
+		"fifo_rdfo 0x%08x fifo_rlr 0x%08x\n", count, ll_fifo->isr, \
+		ll_fifo->ier, ll_fifo->rdfr, ll_fifo->rdfo, ll_fifo->rlf);

Drop the backslash. Please check & fix globally.

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
What can it profit a man to gain the whole world and to come  to  his
property with a gastric ulcer, a blown prostate, and bifocals?
                                     -- John Steinbeck, _Cannery Row_
author maintainer
#7 lore raw

PATCH 4/4 net: Add LL TEMAC driver to u-boot

Dear Wolfgang,

Quoted 8 lines · Wolfgang Denk

Dear Michal Simek,

sorry for the long delay. We're still lacking a (new) network custodian...

Quoted 2 lines · In message <[email protected]> you wrote:

Add Xilinx LL Temac driver to u-boot.

Quoted 7 lines

Review line 2

Quoted 5 lines

+++ b/drivers/net/xilinx_ll_temac.c

(quoted diff) +2 -0
@@ -0,0 +1,561 @@
+/*
+ *

Drop blank line.

done

Quoted 5 lines

drivers/net/xilinx_ll_temac.c line 11

Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+ * Copyright (C) 2008 - 2009 Michal Simek <[email protected]>
+ * June 2008 Microblaze optimalization, FIFO mode support

2009? Not 2010 ?

done

Quoted 16 lines
Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+/* XPS_LL_TEMAC direct registers definition */
+#define TEMAC_RAF0		(dev->iobase + 0x00)

drivers/net/xilinx_ll_temac.c line 71

Quoted 10 lines
drivers/net/xilinx_ll_temac.c new file +10 -0
+#define TEMAC_TPF0		(dev->iobase + 0x04)
+#define TEMAC_IFGP0		(dev->iobase + 0x08)
+#define TEMAC_IS0		(dev->iobase + 0x0c)
+#define TEMAC_IP0		(dev->iobase + 0x10)
+#define TEMAC_IE0		(dev->iobase + 0x14)
+
+#define TEMAC_MSW0		(dev->iobase + 0x20)
+#define TEMAC_LSW0		(dev->iobase + 0x24)
+#define TEMAC_CTL0		(dev->iobase + 0x28)
+#define TEMAC_RDY0		(dev->iobase + 0x2c)

Please use a C struct to describe the register layout.

not fixed.

Quoted 4 lines

drivers/net/xilinx_ll_temac.c line 80

Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+/* XPS_LL_TEMAC indirect registers offset definition */
+
+#define RCW0	0x200

not used

Quoted 3 lines

drivers/net/xilinx_ll_temac.c line 83

Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+#define RCW1	0x240
+#define TC	0x280
+#define FCC	0x2c0

not used

Quoted 2 lines

drivers/net/xilinx_ll_temac.c line 85

Quoted 2 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+#define EMMC	0x300
+#define PHYC	0x320

not used

Quoted 4 lines

drivers/net/xilinx_ll_temac.c line 89

Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +4 -0
+#define MC	0x340
+#define UAW0	0x380
+#define UAW1	0x384
+#define MAW0	0x388

not used

Quoted 1 line

drivers/net/xilinx_ll_temac.c line 90

Quoted 1 line
drivers/net/xilinx_ll_temac.c new file +1 -0
+#define MAW1	0x38c

not used

Quoted 2 lines

drivers/net/xilinx_ll_temac.c line 92

Quoted 2 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+#define AFM	0x390
+#define TIS	0x3a0

not used

Quoted 1 line

drivers/net/xilinx_ll_temac.c line 93

Quoted 1 line
drivers/net/xilinx_ll_temac.c new file +1 -0
+#define TIE	0x3a4

not used

Quoted 4 lines

drivers/net/xilinx_ll_temac.c line 95

Quoted 2 lines
drivers/net/xilinx_ll_temac.c new file +2 -0
+#define MIIMWD	0x3b0
+#define MIIMAI	0x3b4

Ditto.

They are offset for indirect accesses that's why should be just values.

Quoted 11 lines

drivers/net/xilinx_ll_temac.c line 174

Quoted 8 lines
drivers/net/xilinx_ll_temac.c new file +6 -0
+	out_be32((u32 *)TEMAC_LSW0, phy_data);
+	out_be32((u32 *)TEMAC_CTL0, CNTLREG_WRITE_ENABLE_MASK | MIIMWD);
+	out_be32((u32 *)TEMAC_LSW0, (phy_addr << 5) | (reg_addr));
+	out_be32((u32 *)TEMAC_CTL0, \
+			CNTLREG_WRITE_ENABLE_MASK | MIIMAI | (emac << 10));
+	while (!(in_be32((u32 *)TEMAC_RDY0) & XTE_RSE_MIIM_WR_MASK))

The need to have all these casts should ring some alarm bell to you. Please use a proper C struct instead.

sure.

Quoted 6 lines

drivers/net/xilinx_ll_temac.c line 196

Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+	out_be32((u32 *)TEMAC_LSW0, reg_data);
+	out_be32((u32 *)TEMAC_CTL0, \
+			CNTLREG_WRITE_ENABLE_MASK | (emac << 10) | reg_offset);

Drop the backslash.

done

Quoted 7 lines

drivers/net/xilinx_ll_temac.c line 223

Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+		debug ("%d: 0x%x ", j, result);
+	}
+	debug ("\n");

No spaces between function name and '('. Please fix globally. Consider running your patch through checkpatch...

done

Quoted 6 lines

drivers/net/xilinx_ll_temac.c line 243

Quoted 4 lines
drivers/net/xilinx_ll_temac.c new file +3 -0
+	while (retries-- &&
+		((xps_ll_temac_hostif_get(dev, 0, phy_addr, 1) & 0x24) == 0x24))
+		;

Bad indentation.

done.

Quoted 8 lines
Quoted 3 lines
drivers/net/xilinx_ll_temac.c new file +1 -0
+	if (i == 0x7c0a3) {

...

drivers/net/xilinx_ll_temac.c line 274

Quoted 1 line
drivers/net/xilinx_ll_temac.c new file +1 -0
+	if (i == 0x1410cc2) {

Please use self-explaining symbolic names for these magic numbers, and/or add sufficient comments what these mean.

There is option which I prefer which is phy lib.

Quoted 8 lines

drivers/net/xilinx_ll_temac.c line 374

Quoted 6 lines
drivers/net/xilinx_ll_temac.c new file +5 -0
+static void debugll(int count)
+{
+	printf ("%d fifo isr 0x%08x, fifo_ier 0x%08x, fifo_rdfr 0x%08x, "
+		"fifo_rdfo 0x%08x fifo_rlr 0x%08x\n", count, ll_fifo->isr, \
+		ll_fifo->ier, ll_fifo->rdfr, ll_fifo->rdfo, ll_fifo->rlf);

Drop the backslash. Please check & fix globally.

done.

Quoted 1 line

I have fixed some simple issues which you reported but not everything. (microblaze custodian tree)

I am still not convince that I even would like to push this driver mainline and keep responsibility for it.

The next thing is that there is missing phy lib support which will be good to use.

Microblaze systems are slightly moving to new AXI bus where will be different eth IP core which will require new u-boot driver. Not sure if will be based on this ll_temac driver.

Stephan: If you are willing to fix issues which Wolfgang reported, I am happy to test them.

Best regards,
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
#8 lore raw

PATCH 2/4 net: Move Emaclite to NET_MULTI

In reply to Michal Simek

Hi Michal,

Sorry for the delay in reviewing

Quoted 103 lines · Michal Simek

Emaclite was using old net api that's why
this patch move emaclite to NET_MULTI api.

---
  drivers/net/xilinx_emaclite.c |   84 +++++++++++++++++++++++------------------
  include/netdev.h              |    1 +
  2 files changed, 48 insertions(+), 37 deletions(-)
drivers/net/xilinx_emaclite.c +13 -26
index 0820daa..f460525 100644
@@ -26,6 +26,7 @@
  #include<common.h>
  #include<net.h>
  #include<config.h>
+#include<malloc.h>
  #include<asm/io.h>
 
  #undef DEBUG
@@ -63,26 +64,19 @@
  #define XEL_RSR_RECV_IE_MASK		0x00000008UL
 
  typedef struct {
-	unsigned int baseaddress;	/* Base address for device (IPIF) */
-	unsigned int nexttxbuffertouse;	/* Next TX buffer to write to */
-	unsigned int nextrxbuffertouse;	/* Next RX buffer to read from */
-	unsigned char deviceid;		/* Unique ID of device - for future */
+	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;
 
  static u32 etherrxbuff[PKTSIZE_ALIGN/4]; /* Receive buffer */
 
-/* hardcoded MAC address for the Xilinx EMAC Core when env is nowhere*/
-#ifdef CONFIG_ENV_IS_NOWHERE
-static u8 emacaddr[ENET_ADDR_LENGTH] = { 0x00, 0x0a, 0x35, 0x00, 0x22, 0x01 };
-#else
-static u8 emacaddr[ENET_ADDR_LENGTH];
-#endif
-
-void xemaclite_alignedread (u32 * srcptr, void *destptr, unsigned bytecount)
+static void xemaclite_alignedread (u32 *srcptr, void *destptr, u32 bytecount)
  {
-	unsigned int i;
+	u32 i;
  	u32 alignbuffer;
  	u32 *to32ptr;
  	u32 *from32ptr;
@@ -107,9 +101,9 @@ void xemaclite_alignedread (u32 * srcptr, void *destptr, unsigned bytecount)
  	}
  }
 
-void xemaclite_alignedwrite (void *srcptr, u32 destptr, unsigned bytecount)
+static void xemaclite_alignedwrite (void *srcptr, u32 destptr, u32 bytecount)
  {
-	unsigned i;
+	u32 i;
  	u32 alignbuffer;
  	u32 *to32ptr = (u32 *) destptr;
  	u32 *from32ptr;
@@ -134,23 +128,16 @@ void xemaclite_alignedwrite (void *srcptr, u32 destptr, unsigned bytecount)
  	*to32ptr++ = alignbuffer;
  }
 
-void eth_halt (void)
+static void emaclite_halt(struct eth_device *dev)
  {
  	debug ("eth_halt\n");
  }
 
-int eth_init (bd_t * bis)
+static int emaclite_init(struct eth_device *dev, bd_t *bis)
  {
-	uchar enetaddr[6];
-
  	debug ("EmacLite Initialization Started\n");
  	memset (&emaclite, 0, sizeof (xemaclite));
-	emaclite.baseaddress = XILINX_EMACLITE_BASEADDR;
-
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
-		memcpy(enetaddr, emacaddr, ENET_ADDR_LENGTH);
-		eth_setenv_enetaddr("ethaddr", enetaddr);
-	}
+	emaclite.baseaddress = dev->iobase;
 
  /*
   * TX - TX_PING&  TX_PONG initialization
@@ -158,7 +145,7 @@ int eth_init (bd_t * bis)
  	/* Restart PING TX */
  	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
  	/* Copy MAC address */
-	xemaclite_alignedwrite (enetaddr,
+	xemaclite_alignedwrite (dev->enetaddr,
  		emaclite.baseaddress, ENET_ADDR_LENGTH);
  	/* Set the length */
  	out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);

drivers/net/xilinx_emaclite.c int eth_init (bd_t * bis) · line 163

Quoted 7 lines
drivers/net/xilinx_emaclite.c +1 -1
@@ -171,7 +158,7 @@ int eth_init (bd_t * bis)
  #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 (enetaddr, emaclite.baseaddress +
+	xemaclite_alignedwrite (dev->enetaddr, emaclite.baseaddress +
  		XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH);
  	out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET, ENET_ADDR_LENGTH);

Please consider moving this stuff to a separate function. If you bind it to dev->write_hwaddr(), programming will occur at initialization time.

Quoted 51 lines
drivers/net/xilinx_emaclite.c +13 -10
  	out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET,
@@ -194,7 +181,7 @@ int eth_init (bd_t * bis)
  	return 0;
  }
 
-int xemaclite_txbufferavailable (xemaclite * instanceptr)
+static int xemaclite_txbufferavailable (xemaclite *instanceptr)
  {
  	u32 reg;
  	u32 txpingbusy;
@@ -216,12 +203,12 @@ int xemaclite_txbufferavailable (xemaclite * instanceptr)
  	return (!(txpingbusy&&  txpongbusy));
  }
 
-int eth_send (volatile void *ptr, int len) {
-
-	unsigned int reg;
-	unsigned int baseaddress;
+static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)
+{
+	u32 reg;
+	u32 baseaddress;
 
-	unsigned maxtry = 1000;
+	u32 maxtry = 1000;
 
  	if (len>  ENET_MAX_MTU)
  		len = ENET_MAX_MTU;
@@ -293,11 +280,11 @@ int eth_send (volatile void *ptr, int len) {
  	return 0;
  }
 
-int eth_rx (void)
+static int emaclite_recv(struct eth_device *dev)
  {
-	unsigned int length;
-	unsigned int reg;
-	unsigned int baseaddress;
+	u32 length;
+	u32 reg;
+	u32 baseaddress;
 
  	baseaddress = emaclite.baseaddress + emaclite.nextrxbuffertouse;
  	reg = in_be32 (baseaddress + XEL_RSR_OFFSET);
@@ -353,3 +340,26 @@ int eth_rx (void)
  	return 1;
 
  }
+
+int xilinx_emaclite_initialize (bd_t *bis)
+{

drivers/net/xilinx_emaclite.c int eth_rx (void) · line 355

Quoted 10 lines
drivers/net/xilinx_emaclite.c +10 -0
+	struct eth_device *dev;
+
+	dev = malloc(sizeof(*dev));
+	if (dev == NULL)
+		hang();
+
+	memset(dev, 0, sizeof(*dev));
+	sprintf(dev->name, "Xilinx Emaclite");
+
+	dev->iobase = XILINX_EMACLITE_BASEADDR;

Can you pass this in as a parameter instead? You don't seem to use 'bis', so it's not necessary

Quoted 15 lines
drivers/net/xilinx_emaclite.c +10 -0
+	dev->priv = 0;
+	dev->init = emaclite_init;
+	dev->halt = emaclite_halt;
+	dev->send = emaclite_send;
+	dev->recv = emaclite_recv;
+
+	eth_register(dev);
+
+	return 0;
+}
include/netdev.h +0 -0
index 94eedfe..979fb57 100644

include/netdev.h int tsi108_eth_initialize(bd_t *bis); · line 93

Quoted 6 lines
include/netdev.h +1 -0
@@ -88,6 +88,7 @@ int tsi108_eth_initialize(bd_t *bis);
  int uec_initialize(int index);
  int uec_standard_init(bd_t *bis);
  int uli526x_initialize(bd_t *bis);
+int xilinx_emaclite_initialize (bd_t *bis);
  int sh_eth_initialize(bd_t *bis);
  int dm9000_initialize(bd_t *bis);

regards,
Ben

author maintainer
#9 lore raw

PATCH 2/4 net: Move Emaclite to NET_MULTI

Hi Ben,

Quoted 18 lines · Ben Warren

Hi Michal,

Sorry for the delay in reviewing

Quoted 13 lines · Michal Simek

Emaclite was using old net api that's why
this patch move emaclite to NET_MULTI api.

---
  drivers/net/xilinx_emaclite.c |   84
+++++++++++++++++++++++------------------
  include/netdev.h              |    1 +
  2 files changed, 48 insertions(+), 37 deletions(-)
drivers/net/xilinx_emaclite.c +0 -0
index 0820daa..f460525 100644

...

Quoted 15 lines
Quoted 15 lines

* TX - TX_PING& TX_PONG initialization

drivers/net/xilinx_emaclite.c +1 -1
@@ -158,7 +145,7 @@ int eth_init (bd_t * bis)
      /* Restart PING TX */
      out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET, 0);
      /* Copy MAC address */
-    xemaclite_alignedwrite (enetaddr,
+    xemaclite_alignedwrite (dev->enetaddr,
          emaclite.baseaddress, ENET_ADDR_LENGTH);
      /* Set the length */
      out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET,

ENET_ADDR_LENGTH);

drivers/net/xilinx_emaclite.c +0 -0
@@ -171,7 +158,7 @@ int eth_init (bd_t * bis)
  #ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
      /* The same operation with PONG TX */
      out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET +
Quoted 8 lines
Quoted 6 lines
drivers/net/xilinx_emaclite.c +1 -1
 XEL_BUFFER_OFFSET, 0);
-    xemaclite_alignedwrite (enetaddr, emaclite.baseaddress +
+    xemaclite_alignedwrite (dev->enetaddr, emaclite.baseaddress +
          XEL_BUFFER_OFFSET, ENET_ADDR_LENGTH);
      out_be32 (emaclite.baseaddress + XEL_TPLR_OFFSET,

ENET_ADDR_LENGTH);

Please consider moving this stuff to a separate function. If you bind it to dev->write_hwaddr(), programming will occur at initialization time.

I consider it. This driver is well tested. We are using it for a long time that's why I prefer to keep it as is. I would look at it when I have free time.

...

Quoted 7 lines
Quoted 7 lines
drivers/net/xilinx_emaclite.c +7 -0
+
+int xilinx_emaclite_initialize (bd_t *bis)
+{
+    struct eth_device *dev;
+
+    dev = malloc(sizeof(*dev));
+    if (dev == NULL)
Quoted 8 lines

drivers/net/xilinx_emaclite.c int eth_rx (void) · line 355

Quoted 6 lines
drivers/net/xilinx_emaclite.c +6 -0
+        hang();
+
+    memset(dev, 0, sizeof(*dev));
+    sprintf(dev->name, "Xilinx Emaclite");
+
+    dev->iobase = XILINX_EMACLITE_BASEADDR;

Can you pass this in as a parameter instead? You don't seem to use 'bis', so it's not necessary

I did it. version 2 will contain this change.

I am going to send v2. Please review it. I am also sending second patch with little endian support.

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