Skip to contentSkip to conversation

Network support for spear platform and spear1300 support

PATCH New Vipin KUMAR 5 participants 38 messages Apr 21, 2010 – Apr 26, 2010

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover Network support for spear platform and spear1300 support

The following set of patches contain
1. Network driver support for designware IP
2. FSMC(Flexible static memory controller) support for ST IP.
3. I2C driver support for designware IP
4. SMI driver support for ST IP
5. spear1300 SoC and board support
6. misc changes in spear platform and board related code
7. change_bit routine defined in bitops.h(similar to setbit and clearbit)
8. Fix for u-boot.img generation

FSMC, I2C, SMI drivers earlier existed with the names spr_i2c, spr_nand etc. These drivers have now been ported as generic IPs so that the code can be reused by other platforms using the same peripheral

Vipin Kumar (17):
u-boot.img file not created when srctree and objtree are different change_bit routine defined
SPEAr : SMI erase and write timeouts increased
SPEAr : Placing ethaddr write and read within CONFIG_CMD_NET SPEAr : Reducing the max RAM size to 128MB
SPEAr : Basic arch related support added for SPEAr SoCs SPEAr : Network driver support added
SPEAr : Network support configured for spear SoCs
SPEAr : macb driver support added for spear310 and spear320 SPEAr : FSMC driver support added
SPEAr : Configuring FSMC driver for NAND interface
SPEAr : i2c driver moved completely into drivers/i2c SPEAr : smi driver moved completely into drivers/mtd SPEAr : USBD driver support added
SPEAr : Basic spear1300 architecture support added
SPEAr : spear1300 SoC support added
SPEAr : Supporting various configurations for spear3xx and spear6xx
boards

 Makefile                                   |   24 +-
 arch/arm/cpu/arm926ejs/spear/Makefile      |    3 +-
 arch/arm/include/asm/arch-spear/hardware.h |   16 +-
 arch/arm/include/asm/arch-spear/spr_i2c.h  |  146 ----
 arch/arm/include/asm/arch-spear/spr_misc.h |    5 +
 arch/arm/include/asm/arch-spear/spr_nand.h |   57 --
 arch/arm/include/asm/arch-spear/spr_smi.h  |  115 ----
 arch/arm/include/asm/bitops.h              |   11 +-
 board/spear/common/Makefile                |   10 +-
 board/spear/common/spr_misc.c              |   23 +-
 board/spear/spear1300/Makefile             |   51 ++
 board/spear/spear1300/config.mk            |   28 +
 board/spear/spear1300/spear1300.c          |   89 +++
 board/spear/spear1300/spr_lowlevel_init.S  |   38 +
 board/spear/spear300/config.mk             |   11 -
 board/spear/spear300/spear300.c            |   11 +-
 board/spear/spear310/config.mk             |   11 -
 board/spear/spear310/spear310.c            |   18 +-
 board/spear/spear320/config.mk             |   11 -
 board/spear/spear320/spear320.c            |   15 +-
 board/spear/spear600/config.mk             |   11 -
 board/spear/spear600/spear600.c            |   11 +-
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++
 cpu/arm_cortexa8/spear13xx/Makefile        |   52 ++
 cpu/arm_cortexa8/spear13xx/cache.S         |  112 +++
 cpu/arm_cortexa8/spear13xx/cpu_info.c      |  105 +++
 cpu/arm_cortexa8/spear13xx/reset.c         |   47 ++
 cpu/arm_cortexa8/spear13xx/timer.c         |  136 ++++
 drivers/i2c/Makefile                       |    2 +-
 drivers/i2c/dw_i2c.c                       |  331 +++++++++
 drivers/i2c/dw_i2c.h                       |  146 ++++
 drivers/i2c/spr_i2c.c                      |  331 ---------
 drivers/mtd/Makefile                       |    2 +-
 drivers/mtd/nand/Makefile                  |    2 +-
 drivers/mtd/nand/fsmc_nand.c               |  363 ++++++++++
 drivers/mtd/nand/fsmc_nand.h               |  104 +++
 drivers/mtd/nand/spr_nand.c                |  124 ----
 drivers/mtd/spr_smi.c                      |  523 --------------
 drivers/mtd/st_smi.c                       |  523 ++++++++++++++
 drivers/mtd/st_smi.h                       |  115 ++++
 drivers/net/Makefile                       |    1 +
 drivers/net/dw_eth.c                       |  504 ++++++++++++++
 drivers/net/dw_eth.h                       |  281 ++++++++
 drivers/serial/usbtty.h                    |    4 +-
 drivers/usb/gadget/Makefile                |    2 +-
 drivers/usb/gadget/dw_udc.c                | 1014 ++++++++++++++++++++++++++++
 drivers/usb/gadget/spr_udc.c               |  998 ---------------------------
 include/asm-arm/arch-spear/clk.h           |   27 +
 include/asm-arm/arch-spear13xx/hardware.h  |   40 ++
 include/asm-arm/arch-spear13xx/spr_gpt.h   |   85 +++
 include/asm-arm/arch-spear13xx/spr_misc.h  |  317 +++++++++
 include/asm-arm/arch-spear13xx/sys_proto.h |   32 +
 include/configs/spear-common.h             |   27 +-
 include/configs/spear13xx.h                |  199 ++++++
 include/configs/spear3xx.h                 |   30 +
 include/configs/spear6xx.h                 |   13 +
 include/netdev.h                           |    1 +
 include/usb/dw_udc.h                       |  230 +++++++
 include/usb/spr_udc.h                      |  230 -------
 59 files changed, 5237 insertions(+), 2607 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_i2c.h
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_nand.h
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_smi.h
 create mode 100644 board/spear/spear1300/Makefile
 create mode 100644 board/spear/spear1300/config.mk
 create mode 100644 board/spear/spear1300/spear1300.c
 create mode 100644 board/spear/spear1300/spr_lowlevel_init.S
 create mode 100644 cpu/arm926ejs/spear/cpu_info.c
 create mode 100644 cpu/arm_cortexa8/spear13xx/Makefile
 create mode 100644 cpu/arm_cortexa8/spear13xx/cache.S
 create mode 100644 cpu/arm_cortexa8/spear13xx/cpu_info.c
 create mode 100755 cpu/arm_cortexa8/spear13xx/reset.c
 create mode 100644 cpu/arm_cortexa8/spear13xx/timer.c
 create mode 100644 drivers/i2c/dw_i2c.c
 create mode 100644 drivers/i2c/dw_i2c.h
 delete mode 100644 drivers/i2c/spr_i2c.c
 create mode 100755 drivers/mtd/nand/fsmc_nand.c
 create mode 100644 drivers/mtd/nand/fsmc_nand.h
 delete mode 100644 drivers/mtd/nand/spr_nand.c
 delete mode 100644 drivers/mtd/spr_smi.c
 create mode 100644 drivers/mtd/st_smi.c
 create mode 100644 drivers/mtd/st_smi.h
 create mode 100755 drivers/net/dw_eth.c
 create mode 100644 drivers/net/dw_eth.h
 create mode 100644 drivers/usb/gadget/dw_udc.c
 delete mode 100644 drivers/usb/gadget/spr_udc.c
 create mode 100644 include/asm-arm/arch-spear/clk.h
 create mode 100644 include/asm-arm/arch-spear13xx/hardware.h
 create mode 100755 include/asm-arm/arch-spear13xx/spr_gpt.h
 create mode 100755 include/asm-arm/arch-spear13xx/spr_misc.h
 create mode 100644 include/asm-arm/arch-spear13xx/sys_proto.h
 create mode 100644 include/configs/spear13xx.h
 create mode 100644 include/usb/dw_udc.h
 delete mode 100644 include/usb/spr_udc.h
#1 lore raw

PATCH 1/17 u-boot.img file not created when srctree and objtree are different

Adding ($obj) before tools/mkimage for u-boot.img file creation

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 0381c81..1b431a5 100644
@@ -317,7 +317,7 @@ $(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
 		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
 
 $(obj)u-boot.img:	$(obj)u-boot.bin
-		./tools/mkimage -A $(ARCH) -T firmware -C none \
+		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
 		-a $(TEXT_BASE) -e 0 \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/17 change_bit routine defined

change_bit routine is left implementation dependent until now. This routine is now defined for arm platforms in asm-arm/bitops.h

---
 arch/arm/include/asm/bitops.h |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
arch/arm/include/asm/bitops.h +9 -2
index 270f163..435857b 100644
@@ -29,8 +29,6 @@ extern void set_bit(int nr, volatile void * addr);
 
 extern void clear_bit(int nr, volatile void * addr);
 
-extern void change_bit(int nr, volatile void * addr);
-
 static inline void __change_bit(int nr, volatile void *addr)
 {
 	unsigned long mask = BIT_MASK(nr);
@@ -39,6 +37,15 @@ static inline void __change_bit(int nr, volatile void *addr)
 	*p ^= mask;
 }
 
+static inline void change_bit(int nr, volatile void *addr)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	__change_bit(nr, addr);
+	local_irq_restore(flags);
+}
+
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
 	unsigned long mask = BIT_MASK(nr);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/17 SPEAr : SMI erase and write timeouts increased

SMI driver fails because of low timeout values. Increasing the erase and write timeouts to 3 seconds

---
 arch/arm/include/asm/arch-spear/spr_smi.h |    6 +++---
 drivers/mtd/spr_smi.c                     |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/include/asm/arch-spear/spr_smi.h +3 -3
index 06df745..e2e5e8f 100644
@@ -108,8 +108,8 @@ struct flash_dev {
 	ushort sector_count;
 };
 
-#define SFLASH_PAGE_SIZE	0x100	/* flash page size */
-#define XFER_FINISH_TOUT	2	/* xfer finish timeout */
-#define WMODE_TOUT		2	/* write enable timeout */
+#define SFLASH_PAGE_SIZE	0x100		/* flash page size */
+#define XFER_FINISH_TOUT	(3 * CONFIG_SYS_HZ)
+#define WMODE_TOUT		(3 * CONFIG_SYS_HZ)
 
 #endif
drivers/mtd/spr_smi.c +4 -4
index 9a70a19..189ee6d 100644
@@ -60,11 +60,11 @@ static struct flash_dev flash_ids[] = {
  */
 static void smi_wait_xfer_finish(int timeout)
 {
-	while (timeout--) {
+	do {
 		if (readl(&smicntl->smi_sr) & TFF)
 			break;
 		udelay(1000);
-	}
+	} while (timeout--);
 }
 
 /*
@@ -215,11 +215,11 @@ static int smi_write_enable(int bank)
 	/* Restore the CTRL REG1 state */
 	writel(ctrlreg1, &smicntl->smi_cr1);
 
-	while (timeout--) {
+	do {
 		if (smi_read_sr(bank) & (1 << (bank + WM_SHIFT)))
 			break;
 		udelay(1000);
-	}
+	} while (timeout--);
 
 	if (timeout)
 		return 0;
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/17 SPEAr : Placing ethaddr write and read within CONFIG_CMD_NET

ethaddr can be optionally read from i2c memory. So, chip_config command supports reading/writing hw mac id into i2c memory. Placing this code within CONFIG_CMD_NET as this would only be needed when network interface is configured

---
 board/spear/common/spr_misc.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
board/spear/common/spr_misc.c +20 -3
index e356912..4af9436 100644
@@ -38,6 +38,10 @@
 DECLARE_GLOBAL_DATA_PTR;
 static struct chip_data chip_data;
 
+#if defined(CONFIG_CMD_NET)
+static int i2c_read_mac(uchar *buffer);
+#endif
+
 int dram_init(void)
 {
 	struct xloader_table *xloader_tb =
@@ -166,6 +170,7 @@ int spear_board_init(ulong mach_type)
 	return 0;
 }
 
+#if defined(CONFIG_CMD_NET)
 static int i2c_read_mac(uchar *buffer)
 {
 	u8 buf[2];
@@ -205,15 +210,20 @@ static int write_mac(uchar *mac)
 	puts("I2C EEPROM writing failed \n");
 	return -1;
 }
+#endif
 
 int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	void (*sram_setfreq) (unsigned int, unsigned int);
 	struct chip_data *chip = &chip_data;
-	unsigned char mac[6];
-	unsigned int reg, frequency;
+	unsigned int frequency;
+
+#if defined(CONFIG_CMD_NET)
+	unsigned int reg;
 	char *s, *e;
 	char i2c_mac[20];
+	unsigned char mac[6];
+#endif
 
 	if ((argc > 3) || (argc < 2)) {
 		cmd_usage(cmdtp);
@@ -244,6 +254,8 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		}
 
 		return 0;
+
+#if defined(CONFIG_CMD_NET)
 	} else if (!strcmp(argv[1], "ethaddr")) {
 
 		s = argv[2];
@@ -255,6 +267,7 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		write_mac(mac);
 
 		return 0;
+#endif
 	} else if (!strcmp(argv[1], "print")) {
 
 		if (chip->cpufreq == -1)
@@ -274,13 +287,14 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		else
 			printf("DDR Type    = Not Known\n");
 
+#if defined(CONFIG_CMD_NET)
 		if (!i2c_read_mac(mac)) {
 			sprintf(i2c_mac, "%pM", mac);
 			printf("Ethaddr (from i2c mem) = %s\n", i2c_mac);
 		} else {
 			printf("Ethaddr (from i2c mem) = Not set\n");
 		}
-
+#endif
 		printf("Xloader Rev = %s\n", chip->version);
 
 		return 0;
@@ -293,4 +307,7 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(chip_config, 3, 1, do_chip_config,
 	   "configure chip",
 	   "chip_config cpufreq/ddrfreq frequency\n"
+#if defined(CONFIG_CMD_NET)
+	   "chip_config ethaddr XX:XX:XX:XX:XX:XX\n"
+#endif
 	   "chip_config print");
Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/17 SPEAr : Reducing the max RAM size to 128MB

---
 include/configs/spear-common.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/configs/spear-common.h +1 -1
index cc52e39..b526558 100644
@@ -208,6 +208,6 @@
 /* Physical Memory Map */
 #define CONFIG_NR_DRAM_BANKS			1
 #define PHYS_SDRAM_1				0x00000000
-#define PHYS_SDRAM_1_MAXSIZE			0x40000000
+#define PHYS_SDRAM_1_MAXSIZE			0x08000000
 
 #endif
Signature · 1 line
1.6.0.2
#6 lore raw

PATCH 6/17 SPEAr : Basic arch related support added for SPEAr SoCs

Adding CONFIG_DISPLAY_CPUINFO and CONFIG_ARCH_CPU_INIT support for SPEAr3xx and SPEAr6xx SoCs

---
 arch/arm/cpu/arm926ejs/spear/Makefile      |    3 +-
 arch/arm/include/asm/arch-spear/spr_misc.h |    5 ++
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++++++++++++++++++++++++++++
 include/configs/spear-common.h             |    3 +-
 4 files changed, 85 insertions(+), 2 deletions(-)
 create mode 100644 cpu/arm926ejs/spear/cpu_info.c
arch/arm/cpu/arm926ejs/spear/Makefile +2 -1
index bf8dfa8..6fe30c8 100644
@@ -26,7 +26,8 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(SOC).a
 
 COBJS	:= reset.o \
-	   timer.o
+	   timer.o \
+	   cpu_info.o
 SOBJS	:=
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/include/asm/arch-spear/spr_misc.h +5 -0
index 8b96d9b..045d2bb 100644
@@ -126,5 +126,10 @@ struct misc_regs {
 
 /* PERIPH1_CLKEN, PERIPH1_RST value */
 #define MISC_USBDENB			0x01000000
+#define MISC_ETHENB			0x00800000
+#define MISC_SMIENB			0x00200000
+#define MISC_FSMCENB			0x00000200
+#define MISC_I2CENB			0x00000080
+#define MISC_UART0ENB			0x00000008
 
 #endif
cpu/arm926ejs/spear/cpu_info.c new file +76 -0

76 lines not on this page · raw message

include/configs/spear-common.h +2 -1
index b526558..68ba293 100644
@@ -47,7 +47,6 @@
 
 /* Timer, HZ specific defines */
 #define CONFIG_SYS_HZ				(1000)
-#define CONFIG_SYS_HZ_CLOCK			(8300000)
 
 /* Flash configuration */
 #if defined(CONFIG_FLASH_PNOR)
@@ -168,6 +167,8 @@
 #define CONFIG_ENV_SIZE				0x02000
 
 /* Miscellaneous configurable options */
+#define CONFIG_ARCH_CPU_INIT			1
+#define CONFIG_DISPLAY_CPUINFO			1
 #define CONFIG_BOOT_PARAMS_ADDR			0x00000100
 #define CONFIG_CMDLINE_TAG			1
 #define CONFIG_SETUP_MEMORY_TAGS		1
Signature · 1 line
1.6.0.2
#7 lore raw

PATCH 7/17 SPEAr : Network driver support added

Designware network driver support added.
This is a Synopsys ethernet controller

---
 drivers/net/Makefile |    1 +
 drivers/net/dw_eth.c |  504 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dw_eth.h |  281 ++++++++++++++++++++++++++++
 include/netdev.h     |    1 +
 4 files changed, 787 insertions(+), 0 deletions(-)
 create mode 100755 drivers/net/dw_eth.c
 create mode 100644 drivers/net/dw_eth.h
drivers/net/Makefile +1 -0
index 1ec0ba1..d03c353 100644
@@ -68,6 +68,7 @@ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
 COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
 COBJS-$(CONFIG_SMC91111) += smc91111.o
 COBJS-$(CONFIG_SMC911X) += smc911x.o
+COBJS-$(CONFIG_DW_ETH) += dw_eth.o
 COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
 COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 COBJS-$(CONFIG_TSEC_ENET) += tsec.o
drivers/net/dw_eth.c new file +504 -0

504 lines not on this page · raw message

drivers/net/dw_eth.h new file +281 -0

281 lines not on this page · raw message

include/netdev.h +1 -0
index 1dd80f0..460889c 100644
@@ -79,6 +79,7 @@ int scc_initialize(bd_t *bis);
 int skge_initialize(bd_t *bis);
 int smc911x_initialize(u8 dev_num, int base_addr);
 int smc91111_initialize(u8 dev_num, int base_addr);
+int dw_mii_initialize(u32 id, ulong base_addr);
 int tsi108_eth_initialize(bd_t *bis);
 int uec_initialize(int index);
 int uec_standard_init(bd_t *bis);
Signature · 1 line
1.6.0.2
#8 lore raw

PATCH 8/17 SPEAr : Network support configured for spear SoCs

---
 arch/arm/include/asm/arch-spear/hardware.h |    1 +
 board/spear/spear300/spear300.c            |    6 ++++++
 board/spear/spear310/spear310.c            |    6 ++++++
 board/spear/spear320/spear320.c            |    6 ++++++
 board/spear/spear600/spear600.c            |    6 ++++++
 include/configs/spear-common.h             |   10 ++++++++--
 include/configs/spear3xx.h                 |    3 +++
 7 files changed, 36 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-spear/hardware.h +1 -0
index 818f36c..39d64b6 100644
@@ -31,6 +31,7 @@
 #define CONFIG_SPEAR_SYSCNTLBASE		(0xFCA00000)
 #define CONFIG_SPEAR_TIMERBASE			(0xFC800000)
 #define CONFIG_SPEAR_MISCBASE			(0xFCA80000)
+#define CONFIG_SPEAR_ETHBASE			(0xE0800000)
 
 #define CONFIG_SYS_NAND_CLE			(1 << 16)
 #define CONFIG_SYS_NAND_ALE			(1 << 17)
board/spear/spear300/spear300.c +6 -0
index 60ee544..e58792a 100644
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
@@ -56,3 +57,8 @@ int board_nand_init(struct nand_chip *nand)
 
 	return -1;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+}
board/spear/spear310/spear310.c +6 -0
index 03dfe16..e8a6552 100644
@@ -23,6 +23,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
@@ -57,3 +58,8 @@ int board_nand_init(struct nand_chip *nand)
 
 	return -1;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+}
board/spear/spear320/spear320.c +6 -0
index 2ba2dbb..72bc9a5 100644
@@ -23,6 +23,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
@@ -57,3 +58,8 @@ int board_nand_init(struct nand_chip *nand)
 
 	return -1;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+}
board/spear/spear600/spear600.c +6 -0
index eef9a37..b93151e 100644
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <netdev.h>
 #include <nand.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
@@ -51,3 +52,8 @@ int board_nand_init(struct nand_chip *nand)
 
 	return -1;
 }
+
+int board_eth_init(bd_t *bis)
+{
+	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+}
include/configs/spear-common.h +8 -2
index 68ba293..e7905b1 100644
@@ -27,6 +27,11 @@
  * Common configurations used for both spear3xx as well as spear6xx
  */
 
+/* Ethernet driver configuration */
+#define CONFIG_DW_ETH
+#define CONFIG_NET_MULTI
+#define CONFIG_PHY_RESET_DELAY			(10000)		/* in usec */
+
 /* USBD driver configuration */
 #define CONFIG_SPEARUDC
 #define CONFIG_USB_DEVICE
@@ -98,11 +103,12 @@
 #define CONFIG_CMD_MEMORY
 #define CONFIG_CMD_RUN
 #define CONFIG_CMD_SAVES
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
 
 /* This must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <config_cmd_default.h>
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
 
 /*
  * Default Environment Varible definitions
include/configs/spear3xx.h +3 -0
index 0248aba..f077213 100644
@@ -41,6 +41,9 @@
 
 #include <configs/spear-common.h>
 
+/* Ethernet driver configuration */
+#define CONFIG_DW_ALTDESC			1
+
 /* Serial Configuration (PL011) */
 #define CONFIG_SYS_SERIAL0			0xD0000000
 
Signature · 1 line
1.6.0.2
#9 lore raw

PATCH 9/17 SPEAr : macb driver support added for spear310 and spear320

---
 arch/arm/include/asm/arch-spear/hardware.h |    7 +++++++
 board/spear/spear310/spear310.c            |    9 ++++++++-
 board/spear/spear320/spear320.c            |    6 +++++-
 include/asm-arm/arch-spear/clk.h           |   27 +++++++++++++++++++++++++++
 include/configs/spear3xx.h                 |   13 +++++++++++++
 5 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 include/asm-arm/arch-spear/clk.h
arch/arm/include/asm/arch-spear/hardware.h +7 -0
index 39d64b6..9f1e154 100644
@@ -56,6 +56,11 @@
 #define CONFIG_SPEAR_EMIBASE			(0x4F000000)
 #define CONFIG_SPEAR_RASBASE			(0xB4000000)
 
+#define CONFIG_SYS_MACB0_BASE			(0xB0000000)
+#define CONFIG_SYS_MACB1_BASE			(0xB0800000)
+#define CONFIG_SYS_MACB2_BASE			(0xB1000000)
+#define CONFIG_SYS_MACB3_BASE			(0xB1800000)
+
 #elif defined(CONFIG_SPEAR320)
 #define CONFIG_SYS_I2C_BASE			(0xD0180000)
 #define CONFIG_SPEAR_FSMCBASE			(0x4C000000)
@@ -63,5 +68,7 @@
 #define CONFIG_SPEAR_EMIBASE			(0x40000000)
 #define CONFIG_SPEAR_RASBASE			(0xB3000000)
 
+#define CONFIG_SYS_MACB0_BASE			(0xAA000000)
+
 #endif
 #endif /* _ASM_ARCH_HARDWARE_H */
board/spear/spear310/spear310.c +8 -1
index e8a6552..1207709 100644
@@ -61,5 +61,12 @@ int board_nand_init(struct nand_chip *nand)
 
 int board_eth_init(bd_t *bis)
 {
-	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+	dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+
+	macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, CONFIG_MACB0_PHY);
+	macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE, CONFIG_MACB1_PHY);
+	macb_eth_initialize(2, (void *)CONFIG_SYS_MACB2_BASE, CONFIG_MACB2_PHY);
+	macb_eth_initialize(3, (void *)CONFIG_SYS_MACB3_BASE, CONFIG_MACB3_PHY);
+
+	return 0;
 }
board/spear/spear320/spear320.c +5 -1
index 72bc9a5..efc9a99 100644
@@ -61,5 +61,9 @@ int board_nand_init(struct nand_chip *nand)
 
 int board_eth_init(bd_t *bis)
 {
-	return dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+	dw_mii_initialize(0, CONFIG_SPEAR_ETHBASE);
+
+	macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE, CONFIG_MACB0_PHY);
+
+	return 0;
 }
include/asm-arm/arch-spear/clk.h new file +27 -0
new file mode 100644
index 0000000..343c6ce
@@ -0,0 +1,27 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, STMicroelectronics, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+static inline unsigned long get_macb_pclk_rate(unsigned int dev_id)
+{
+	return 83000000;
+}
include/configs/spear3xx.h +13 -0
index f077213..c53f3cc 100644
@@ -44,6 +44,19 @@
 /* Ethernet driver configuration */
 #define CONFIG_DW_ALTDESC			1
 
+#if defined(CONFIG_SPEAR310)
+#define CONFIG_MACB				1
+#define CONFIG_MACB0_PHY			0x01
+#define CONFIG_MACB1_PHY			0x03
+#define CONFIG_MACB2_PHY			0x05
+#define CONFIG_MACB3_PHY			0x07
+
+#elif defined(CONFIG_SPEAR320)
+#define CONFIG_MACB				1
+#define CONFIG_MACB0_PHY			0x01
+
+#endif
+
 /* Serial Configuration (PL011) */
 #define CONFIG_SYS_SERIAL0			0xD0000000
 
Signature · 1 line
1.6.0.2
#10 lore raw

PATCH 10/17 SPEAr : FSMC driver support added

Flexible static memory controller is an IP which controls the access to NAND chips along with many other memory device chips eg NOR, SRAM. This is an ST peripheral. This patch adds the driver support for FSMC controller interfacing with NAND memory.

---
 drivers/mtd/nand/Makefile    |    1 +
 drivers/mtd/nand/fsmc_nand.c |  363 ++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/fsmc_nand.h |  104 ++++++++++++
 3 files changed, 468 insertions(+), 0 deletions(-)
 create mode 100755 drivers/mtd/nand/fsmc_nand.c
 create mode 100644 drivers/mtd/nand/fsmc_nand.h
drivers/mtd/nand/Makefile +1 -0
index 28f27da..4c6b54f 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_DRIVER_NAND_BFIN) += bfin_nand.o
 COBJS-$(CONFIG_NAND_DAVINCI) += davinci_nand.o
 COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
+COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
 COBJS-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o
drivers/mtd/nand/fsmc_nand.c new file +363 -0

363 lines not on this page · raw message

drivers/mtd/nand/fsmc_nand.h new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#11 lore raw

PATCH 11/17 SPEAr : Configuring FSMC driver for NAND interface

Since FSMC is a standard IP and it supports different memory interfaces the FSMC is supported independent of spear platform and spear is configured to use that driver for interfacing with the NAND device

---
 arch/arm/include/asm/arch-spear/hardware.h |    8 +-
 arch/arm/include/asm/arch-spear/spr_nand.h |   57 -------------
 board/spear/spear300/spear300.c            |    5 +-
 board/spear/spear310/spear310.c            |    5 +-
 board/spear/spear320/spear320.c            |    5 +-
 board/spear/spear600/spear600.c            |    5 +-
 drivers/mtd/nand/Makefile                  |    1 -
 drivers/mtd/nand/spr_nand.c                |  124 ----------------------------
 include/configs/spear-common.h             |    2 +-
 include/configs/spear3xx.h                 |    4 +
 include/configs/spear6xx.h                 |    3 +
 11 files changed, 24 insertions(+), 195 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_nand.h
 delete mode 100644 drivers/mtd/nand/spr_nand.c
arch/arm/include/asm/arch-spear/hardware.h +4 -4
index 9f1e154..52037b6 100644
@@ -38,15 +38,15 @@
 
 #if defined(CONFIG_SPEAR600)
 #define CONFIG_SYS_I2C_BASE			(0xD0200000)
-#define CONFIG_SPEAR_FSMCBASE			(0xD1800000)
+#define CONFIG_SYS_FSMC_BASE			(0xD1800000)
 
 #elif defined(CONFIG_SPEAR300)
 #define CONFIG_SYS_I2C_BASE			(0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE			(0x94000000)
+#define CONFIG_SYS_FSMC_BASE			(0x94000000)
 
 #elif defined(CONFIG_SPEAR310)
 #define CONFIG_SYS_I2C_BASE			(0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE			(0x44000000)
+#define CONFIG_SYS_FSMC_BASE			(0x44000000)
 
 #undef CONFIG_SYS_NAND_CLE
 #undef CONFIG_SYS_NAND_ALE
@@ -63,7 +63,7 @@
 
 #elif defined(CONFIG_SPEAR320)
 #define CONFIG_SYS_I2C_BASE			(0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE			(0x4C000000)
+#define CONFIG_SYS_FSMC_BASE			(0x4C000000)
 
 #define CONFIG_SPEAR_EMIBASE			(0x40000000)
 #define CONFIG_SPEAR_RASBASE			(0xB3000000)
arch/arm/include/asm/arch-spear/spr_nand.h deleted +0 -57

57 lines not on this page · raw message

board/spear/spear300/spear300.c +3 -2
index e58792a..33f0983 100644
@@ -28,7 +28,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);
 
 int board_init(void)
 {
@@ -52,7 +53,7 @@ int board_nand_init(struct nand_chip *nand)
 	    ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
 	     MISC_SOCCFG31)) {
 
-		return spear_nand_init(nand);
+		return fsmc_nand_init(nand);
 	}
 
 	return -1;
board/spear/spear310/spear310.c +3 -2
index 1207709..3ac62d1 100644
@@ -29,7 +29,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);
 
 int board_init(void)
 {
@@ -53,7 +54,7 @@ int board_nand_init(struct nand_chip *nand)
 	    ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
 	     MISC_SOCCFG31)) {
 
-		return spear_nand_init(nand);
+		return fsmc_nand_init(nand);
 	}
 
 	return -1;
board/spear/spear320/spear320.c +3 -2
index efc9a99..b94ee25 100644
@@ -29,7 +29,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);
 
 int board_init(void)
 {
@@ -53,7 +54,7 @@ int board_nand_init(struct nand_chip *nand)
 	    ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
 	     MISC_SOCCFG31)) {
 
-		return spear_nand_init(nand);
+		return fsmc_nand_init(nand);
 	}
 
 	return -1;
board/spear/spear600/spear600.c +3 -2
index b93151e..63c2b41 100644
@@ -28,7 +28,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);
 
 int board_init(void)
 {
@@ -48,7 +49,7 @@ int board_nand_init(struct nand_chip *nand)
 	    (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
 
 	if (!(readl(&misc_regs_p->auto_cfg_reg) & MISC_NANDDIS))
-		return spear_nand_init(nand);
+		return fsmc_nand_init(nand);
 
 	return -1;
 }
drivers/mtd/nand/Makefile +0 -1
index 4c6b54f..36fc8b3 100644
@@ -48,7 +48,6 @@ COBJS-$(CONFIG_NAND_NDFC) += ndfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
-COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
drivers/mtd/nand/spr_nand.c deleted +0 -124

124 lines not on this page · raw message

include/configs/spear-common.h +1 -1
index e7905b1..1e8d9d4 100644
@@ -90,7 +90,7 @@
 #define CONFIG_SYS_LOADS_BAUD_CHANGE
 
 /* NAND FLASH Configuration */
-#define CONFIG_NAND_SPEAR			1
+#define CONFIG_NAND_FSMC			1
 #define CONFIG_SYS_MAX_NAND_DEVICE		1
 #define CONFIG_MTD_NAND_VERIFY_WRITE		1
 
include/configs/spear3xx.h +4 -0
index c53f3cc..581f28d 100644
@@ -133,6 +133,10 @@
 
 #endif
 
+/* NAND flash configuration */
+#define CONFIG_BOARD_NAND_SP			1
+#define CONFIG_BOARD_NAND_8BIT			1
+
 #if defined(CONFIG_SPEAR300)
 #define CONFIG_SYS_NAND_BASE			(0x80000000)
 
include/configs/spear6xx.h +3 -0
index 2ad5beb..24a6948 100644
@@ -38,6 +38,9 @@
 #define CONFIG_PL01x_PORTS			{ (void *)CONFIG_SYS_SERIAL0, \
 						(void *)CONFIG_SYS_SERIAL1 }
 
+/* NAND flash configuration */
+#define CONFIG_BOARD_NAND_SP			1
+#define CONFIG_BOARD_NAND_8BIT			1
 #define CONFIG_SYS_NAND_BASE			(0xD2000000)
 
 #endif  /* __CONFIG_H */
Signature · 1 line
1.6.0.2
#12 lore raw

PATCH 12/17 SPEAr : i2c driver moved completely into drivers/i2c

The i2c IP used by spear platform is a synopsys i2c controller
The earlier driver adds the driver of this controller as if it is specific to spear platform.
The driver files are now moved into drivers/i2c folder for reusability by other platforms

---
 arch/arm/include/asm/arch-spear/spr_i2c.h |  146 -------------
 drivers/i2c/Makefile                      |    2 +-
 drivers/i2c/dw_i2c.c                      |  331 +++++++++++++++++++++++++++++
 drivers/i2c/dw_i2c.h                      |  146 +++++++++++++
 drivers/i2c/spr_i2c.c                     |  331 -----------------------------
 include/configs/spear-common.h            |    2 +-
 6 files changed, 479 insertions(+), 479 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_i2c.h
 create mode 100644 drivers/i2c/dw_i2c.c
 create mode 100644 drivers/i2c/dw_i2c.h
 delete mode 100644 drivers/i2c/spr_i2c.c
arch/arm/include/asm/arch-spear/spr_i2c.h deleted +0 -146
deleted file mode 100644
index 7521ebc..0000000
@@ -1,146 +0,0 @@
-/*
- * (C) Copyright 2009
- * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef __SPR_I2C_H_
-#define __SPR_I2C_H_
-
-struct i2c_regs {
-	u32 ic_con;
-	u32 ic_tar;
-	u32 ic_sar;
-	u32 ic_hs_maddr;
-	u32 ic_cmd_data;
-	u32 ic_ss_scl_hcnt;
-	u32 ic_ss_scl_lcnt;
-	u32 ic_fs_scl_hcnt;
-	u32 ic_fs_scl_lcnt;
-	u32 ic_hs_scl_hcnt;
-	u32 ic_hs_scl_lcnt;
-	u32 ic_intr_stat;
-	u32 ic_intr_mask;
-	u32 ic_raw_intr_stat;
-	u32 ic_rx_tl;
-	u32 ic_tx_tl;
-	u32 ic_clr_intr;
-	u32 ic_clr_rx_under;
-	u32 ic_clr_rx_over;
-	u32 ic_clr_tx_over;
-	u32 ic_clr_rd_req;
-	u32 ic_clr_tx_abrt;
-	u32 ic_clr_rx_done;
-	u32 ic_clr_activity;
-	u32 ic_clr_stop_det;
-	u32 ic_clr_start_det;
-	u32 ic_clr_gen_call;
-	u32 ic_enable;
-	u32 ic_status;
-	u32 ic_txflr;
-	u32 ix_rxflr;
-	u32 reserved_1;
-	u32 ic_tx_abrt_source;
-};
-
-#define IC_CLK			166
-#define NANO_TO_MICRO		1000
-
-/* High and low times in different speed modes (in ns) */
-#define MIN_SS_SCL_HIGHTIME	4000
-#define MIN_SS_SCL_LOWTIME	5000
-#define MIN_FS_SCL_HIGHTIME	800
-#define MIN_FS_SCL_LOWTIME	1700
-#define MIN_HS_SCL_HIGHTIME	60
-#define MIN_HS_SCL_LOWTIME	160
-
-/* Worst case timeout for 1 byte is kept as 2ms */
-#define I2C_BYTE_TO		(CONFIG_SYS_HZ/500)
-#define I2C_STOPDET_TO		(CONFIG_SYS_HZ/500)
-#define I2C_BYTE_TO_BB		(I2C_BYTE_TO * 16)
-
-/* i2c control register definitions */
-#define IC_CON_SD		0x0040
-#define IC_CON_RE		0x0020
-#define IC_CON_10BITADDRMASTER	0x0010
-#define IC_CON_10BITADDR_SLAVE	0x0008
-#define IC_CON_SPD_MSK		0x0006
-#define IC_CON_SPD_SS		0x0002
-#define IC_CON_SPD_FS		0x0004
-#define IC_CON_SPD_HS		0x0006
-#define IC_CON_MM		0x0001
-
-/* i2c target address register definitions */
-#define TAR_ADDR		0x0050
-
-/* i2c slave address register definitions */
-#define IC_SLAVE_ADDR		0x0002
-
-/* i2c data buffer and command register definitions */
-#define IC_CMD			0x0100
-
-/* i2c interrupt status register definitions */
-#define IC_GEN_CALL		0x0800
-#define IC_START_DET		0x0400
-#define IC_STOP_DET		0x0200
-#define IC_ACTIVITY		0x0100
-#define IC_RX_DONE		0x0080
-#define IC_TX_ABRT		0x0040
-#define IC_RD_REQ		0x0020
-#define IC_TX_EMPTY		0x0010
-#define IC_TX_OVER		0x0008
-#define IC_RX_FULL		0x0004
-#define IC_RX_OVER 		0x0002
-#define IC_RX_UNDER		0x0001
-
-/* fifo threshold register definitions */
-#define IC_TL0			0x00
-#define IC_TL1			0x01
-#define IC_TL2			0x02
-#define IC_TL3			0x03
-#define IC_TL4			0x04
-#define IC_TL5			0x05
-#define IC_TL6			0x06
-#define IC_TL7			0x07
-#define IC_RX_TL		IC_TL0
-#define IC_TX_TL		IC_TL0
-
-/* i2c enable register definitions */
-#define IC_ENABLE_0B		0x0001
-
-/* i2c status register  definitions */
-#define IC_STATUS_SA		0x0040
-#define IC_STATUS_MA		0x0020
-#define IC_STATUS_RFF		0x0010
-#define IC_STATUS_RFNE		0x0008
-#define IC_STATUS_TFE		0x0004
-#define IC_STATUS_TFNF		0x0002
-#define IC_STATUS_ACT		0x0001
-
-/* Speed Selection */
-#define IC_SPEED_MODE_STANDARD	1
-#define IC_SPEED_MODE_FAST	2
-#define IC_SPEED_MODE_MAX	3
-
-#define I2C_MAX_SPEED		3400000
-#define I2C_FAST_SPEED		400000
-#define I2C_STANDARD_SPEED	100000
-
-#endif /* __SPR_I2C_H_ */
drivers/i2c/Makefile +1 -1
index d2c2515..3413567 100644
@@ -38,7 +38,7 @@ COBJS-$(CONFIG_PPC4XX_I2C) += ppc4xx_i2c.o
 COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
 COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
 COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
-COBJS-$(CONFIG_SPEAR_I2C) += spr_i2c.o
+COBJS-$(CONFIG_DW_I2C) += dw_i2c.o
 COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
 
 COBJS	:= $(COBJS-y)
drivers/i2c/dw_i2c.c new file +331 -0

331 lines not on this page · raw message

drivers/i2c/dw_i2c.h new file +146 -0

146 lines not on this page · raw message

drivers/i2c/spr_i2c.c deleted +0 -331

331 lines not on this page · raw message

include/configs/spear-common.h +1 -1
index 1e8d9d4..41f3241 100644
@@ -44,7 +44,7 @@
 
 /* I2C driver configuration */
 #define CONFIG_HARD_I2C
-#define CONFIG_SPEAR_I2C
+#define CONFIG_DW_I2C
 #define CONFIG_SYS_I2C_SPEED			400000
 #define CONFIG_SYS_I2C_SLAVE			0x02
 
Signature · 1 line
1.6.0.2
#13 lore raw

PATCH 13/17 SPEAr : smi driver moved completely into drivers/mtd

The smi IP used by spear platform is a ST serial memory interface controller The earlier driver adds the driver of this controller as if it is specific to spear platform.
The driver files are now moved into drivers/mtd folder for reusability by other platforms

---
 arch/arm/include/asm/arch-spear/spr_smi.h |  115 -------
 drivers/mtd/Makefile                      |    2 +-
 drivers/mtd/spr_smi.c                     |  523 -----------------------------
 drivers/mtd/st_smi.c                      |  523 +++++++++++++++++++++++++++++
 drivers/mtd/st_smi.h                      |  115 +++++++
 include/configs/spear-common.h            |    6 +-
 6 files changed, 642 insertions(+), 642 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_smi.h
 delete mode 100644 drivers/mtd/spr_smi.c
 create mode 100644 drivers/mtd/st_smi.c
 create mode 100644 drivers/mtd/st_smi.h
arch/arm/include/asm/arch-spear/spr_smi.h deleted +0 -115
deleted file mode 100644
index e2e5e8f..0000000
@@ -1,115 +0,0 @@
-/*
- * (C) Copyright 2009
- * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef SPR_SMI_H
-#define SPR_SMI_H
-
-/* 0xF800.0000 . 0xFBFF.FFFF	64MB	SMI (Serial Flash Mem) */
-/* 0xFC00.0000 . 0xFC1F.FFFF	2MB	SMI (Serial Flash Reg.) */
-
-#define FLASH_START_ADDRESS	CONFIG_SYS_FLASH_BASE
-#define FLASH_BANK_SIZE		CONFIG_SYS_FLASH_BANK_SIZE
-
-#define SMIBANK0_BASE		(FLASH_START_ADDRESS)
-#define SMIBANK1_BASE		(SMIBANK0_BASE + FLASH_BANK_SIZE)
-#define SMIBANK2_BASE		(SMIBANK1_BASE + FLASH_BANK_SIZE)
-#define SMIBANK3_BASE		(SMIBANK2_BASE + FLASH_BANK_SIZE)
-
-#define BANK0			0
-#define BANK1			1
-#define BANK2			2
-#define BANK3			3
-
-struct smi_regs {
-	u32 smi_cr1;
-	u32 smi_cr2;
-	u32 smi_sr;
-	u32 smi_tr;
-	u32 smi_rr;
-};
-
-/* CONTROL REG 1 */
-#define BANK_EN			0x0000000F	/* enables all banks */
-#define DSEL_TIME		0x00000060	/* Deselect time */
-#define PRESCAL5		0x00000500	/* AHB_CK prescaling value */
-#define PRESCALA		0x00000A00	/* AHB_CK prescaling value */
-#define PRESCAL3		0x00000300	/* AHB_CK prescaling value */
-#define PRESCAL4		0x00000400	/* AHB_CK prescaling value */
-#define SW_MODE			0x10000000	/* enables SW Mode */
-#define WB_MODE			0x20000000	/* Write Burst Mode */
-#define FAST_MODE		0x00008000	/* Fast Mode */
-#define HOLD1			0x00010000
-
-/* CONTROL REG 2 */
-#define RD_STATUS_REG		0x00000400	/* reads status reg */
-#define WE			0x00000800	/* Write Enable */
-#define BANK0_SEL		0x00000000	/* Select Banck0 */
-#define BANK1_SEL		0x00001000	/* Select Banck1 */
-#define BANK2_SEL		0x00002000	/* Select Banck2 */
-#define BANK3_SEL		0x00003000	/* Select Banck3 */
-#define BANKSEL_SHIFT		12
-#define SEND			0x00000080	/* Send data */
-#define TX_LEN_1		0x00000001	/* data length = 1 byte */
-#define TX_LEN_2		0x00000002	/* data length = 2 byte */
-#define TX_LEN_3		0x00000003	/* data length = 3 byte */
-#define TX_LEN_4		0x00000004	/* data length = 4 byte */
-#define RX_LEN_1		0x00000010	/* data length = 1 byte */
-#define RX_LEN_2		0x00000020	/* data length = 2 byte */
-#define RX_LEN_3		0x00000030	/* data length = 3 byte */
-#define RX_LEN_4		0x00000040	/* data length = 4 byte */
-#define TFIE			0x00000100	/* Tx Flag Interrupt Enable */
-#define WCIE			0x00000200	/* WCF Interrupt Enable */
-
-/* STATUS_REG */
-#define INT_WCF_CLR		0xFFFFFDFF	/* clear: WCF clear */
-#define INT_TFF_CLR		0xFFFFFEFF	/* clear: TFF clear */
-#define WIP_BIT			0x00000001	/* WIP Bit of SPI SR */
-#define WEL_BIT			0x00000002	/* WEL Bit of SPI SR */
-#define RSR			0x00000005	/* Read Status regiser */
-#define TFF			0x00000100	/* Transfer Finished FLag */
-#define WCF			0x00000200	/* Transfer Finished FLag */
-#define ERF1			0x00000400	/* Error Flag 1 */
-#define ERF2			0x00000800	/* Error Flag 2 */
-#define WM0			0x00001000	/* WM Bank 0 */
-#define WM1			0x00002000	/* WM Bank 1 */
-#define WM2			0x00004000	/* WM Bank 2 */
-#define WM3			0x00008000	/* WM Bank 3 */
-#define WM_SHIFT		12
-
-/* TR REG */
-#define READ_ID			0x0000009F	/* Read Identification */
-#define BULK_ERASE		0x000000C7	/* BULK erase */
-#define SECTOR_ERASE		0x000000D8	/* SECTOR erase */
-#define WRITE_ENABLE		0x00000006	/* Wenable command to FLASH */
-
-struct flash_dev {
-	u32 density;
-	ulong size;
-	ushort sector_count;
-};
-
-#define SFLASH_PAGE_SIZE	0x100		/* flash page size */
-#define XFER_FINISH_TOUT	(3 * CONFIG_SYS_HZ)
-#define WMODE_TOUT		(3 * CONFIG_SYS_HZ)
-
-#endif
drivers/mtd/Makefile +1 -1
index cbf6f15..d868d27 100644
@@ -34,7 +34,7 @@ COBJS-$(CONFIG_FLASH_CFI_MTD) += cfi_mtd.o
 COBJS-$(CONFIG_HAS_DATAFLASH) += dataflash.o
 COBJS-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o
 COBJS-$(CONFIG_MW_EEPROM) += mw_eeprom.o
-COBJS-$(CONFIG_SPEARSMI) += spr_smi.o
+COBJS-$(CONFIG_ST_SMI) += st_smi.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mtd/spr_smi.c deleted +0 -523

523 lines not on this page · raw message

drivers/mtd/st_smi.c new file +523 -0

523 lines not on this page · raw message

drivers/mtd/st_smi.h new file +115 -0

115 lines not on this page · raw message

include/configs/spear-common.h +3 -3
index 41f3241..e4090e5 100644
@@ -57,10 +57,10 @@
 #if defined(CONFIG_FLASH_PNOR)
 #define CONFIG_SPEAR_EMI			1
 #else
-#define CONFIG_SPEARSMI				1
+#define CONFIG_ST_SMI				1
 #endif
 
-#if defined(CONFIG_SPEARSMI)
+#if defined(CONFIG_ST_SMI)
 
 #define CONFIG_SYS_MAX_FLASH_BANKS		2
 #define CONFIG_SYS_FLASH_BASE			(0xF8000000)
@@ -125,7 +125,7 @@
  * U-Boot Environment placing definitions.
  */
 #if defined(CONFIG_ENV_IS_IN_FLASH)
-#ifdef CONFIG_SPEARSMI
+#ifdef CONFIG_ST_SMI
 /*
  * Environment is in serial NOR flash
  */
Signature · 1 line
1.6.0.2
#14 lore raw

PATCH 14/17 SPEAr : USBD driver support added

USBD is a Synopsys IP. The earlier driver implements itself as specific to spear SoCs. This patch implements this driver as a reusable driver for other platforms as well.

---
 drivers/serial/usbtty.h        |    4 +-
 drivers/usb/gadget/Makefile    |    2 +-
 drivers/usb/gadget/dw_udc.c    | 1014 ++++++++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/spr_udc.c   |  998 ---------------------------------------
 include/configs/spear-common.h |    2 +-
 include/usb/dw_udc.h           |  230 +++++++++
 include/usb/spr_udc.h          |  230 ---------
 7 files changed, 1248 insertions(+), 1232 deletions(-)
 create mode 100644 drivers/usb/gadget/dw_udc.c
 delete mode 100644 drivers/usb/gadget/spr_udc.c
 create mode 100644 include/usb/dw_udc.h
 delete mode 100644 include/usb/spr_udc.h
drivers/serial/usbtty.h +2 -2
index a23169a..507f60d 100644
@@ -33,8 +33,8 @@
 #include <usb/musb_udc.h>
 #elif defined(CONFIG_PXA27X)
 #include <usb/pxa27x_udc.h>
-#elif defined(CONFIG_SPEAR3XX) || defined(CONFIG_SPEAR600)
-#include <usb/spr_udc.h>
+#elif defined(CONFIG_DW_UDC)
+#include <usb/dw_udc.h>
 #endif
 
 #include <version_autogenerated.h>
drivers/usb/gadget/Makefile +1 -1
index 1d7362d..3524f36 100644
@@ -32,7 +32,7 @@ COBJS-$(CONFIG_OMAP1510) += omap1510_udc.o
 COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o
 COBJS-$(CONFIG_MPC885_FAMILY) += mpc8xx_udc.o
 COBJS-$(CONFIG_PXA27X) += pxa27x_udc.o
-COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
+COBJS-$(CONFIG_DW_UDC) += dw_udc.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/usb/gadget/dw_udc.c new file +1014 -0

1,014 lines not on this page · raw message

drivers/usb/gadget/spr_udc.c deleted +0 -998

998 lines not on this page · raw message

include/configs/spear-common.h +1 -1
index e4090e5..06f77e3 100644
@@ -33,7 +33,7 @@
 #define CONFIG_PHY_RESET_DELAY			(10000)		/* in usec */
 
 /* USBD driver configuration */
-#define CONFIG_SPEARUDC
+#define CONFIG_DW_UDC
 #define CONFIG_USB_DEVICE
 #define CONFIG_USB_TTY
 
include/usb/dw_udc.h new file +230 -0

230 lines not on this page · raw message

include/usb/spr_udc.h deleted +0 -230

230 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#15 lore raw

PATCH 15/17 SPEAr : Basic spear1300 architecture support added

---
 cpu/arm_cortexa8/spear13xx/Makefile        |   52 +++++
 cpu/arm_cortexa8/spear13xx/cache.S         |  112 ++++++++++
 cpu/arm_cortexa8/spear13xx/cpu_info.c      |  105 +++++++++
 cpu/arm_cortexa8/spear13xx/reset.c         |   47 ++++
 cpu/arm_cortexa8/spear13xx/timer.c         |  136 ++++++++++++
 include/asm-arm/arch-spear13xx/hardware.h  |   40 ++++
 include/asm-arm/arch-spear13xx/spr_gpt.h   |   85 ++++++++
 include/asm-arm/arch-spear13xx/spr_misc.h  |  317 ++++++++++++++++++++++++++++
 include/asm-arm/arch-spear13xx/sys_proto.h |   32 +++
 9 files changed, 926 insertions(+), 0 deletions(-)
 create mode 100644 cpu/arm_cortexa8/spear13xx/Makefile
 create mode 100644 cpu/arm_cortexa8/spear13xx/cache.S
 create mode 100644 cpu/arm_cortexa8/spear13xx/cpu_info.c
 create mode 100755 cpu/arm_cortexa8/spear13xx/reset.c
 create mode 100644 cpu/arm_cortexa8/spear13xx/timer.c
 create mode 100644 include/asm-arm/arch-spear13xx/hardware.h
 create mode 100755 include/asm-arm/arch-spear13xx/spr_gpt.h
 create mode 100755 include/asm-arm/arch-spear13xx/spr_misc.h
 create mode 100644 include/asm-arm/arch-spear13xx/sys_proto.h
cpu/arm_cortexa8/spear13xx/Makefile new file +52 -0
new file mode 100644
index 0000000..dba430a
@@ -0,0 +1,52 @@
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2008
+# Guennadi Liakhovetki, DENX Software Engineering, <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).a
+
+COBJS	= timer.o \
+	  reset.o \
+	  cpu_info.o
+
+SOBJS	= cache.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+
+all:	 $(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/arm_cortexa8/spear13xx/cache.S new file +112 -0

112 lines not on this page · raw message

cpu/arm_cortexa8/spear13xx/cpu_info.c new file +105 -0

105 lines not on this page · raw message

cpu/arm_cortexa8/spear13xx/reset.c new file +47 -0

47 lines not on this page · raw message

cpu/arm_cortexa8/spear13xx/timer.c new file +136 -0

136 lines not on this page · raw message

include/asm-arm/arch-spear13xx/hardware.h new file +40 -0
new file mode 100644
index 0000000..384260a
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, STMicroelectronics, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _ASM_ARCH_HARDWARE_H
+#define _ASM_ARCH_HARDWARE_H
+
+#define CONFIG_SYS_USBD_BASE			(0xE1100000)
+#define CONFIG_SYS_PLUG_BASE			(0xE1200000)
+#define CONFIG_SYS_FIFO_BASE			(0xE1000800)
+#define CONFIG_SYS_SMI_BASE			(0xFC000000)
+#define CONFIG_SPEAR_TIMERBASE			(0xE0380000)
+#define CONFIG_SPEAR_MISCBASE			(0xE0700000)
+#define CONFIG_SYS_I2C_BASE			(0xE0280000)
+#define CONFIG_SPEAR_ETHBASE			(0xE2000000)
+#define CONFIG_SYS_FSMC_BASE			(0xB0000000)
+
+#define CONFIG_SYS_NAND_CLE			(1 << 16)
+#define CONFIG_SYS_NAND_ALE			(1 << 17)
+
+#endif /* _ASM_ARCH_HARDWARE_H */
include/asm-arm/arch-spear13xx/spr_gpt.h new file +85 -0

85 lines not on this page · raw message

include/asm-arm/arch-spear13xx/spr_misc.h new file +317 -0

317 lines not on this page · raw message

include/asm-arm/arch-spear13xx/sys_proto.h new file +32 -0
new file mode 100644
index 0000000..e6cc3a9
@@ -0,0 +1,32 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, STMicroelectronics, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SYS_PROTO_H_
+#define _SYS_PROTO_H_
+
+u32 get_device_type(void);
+void invalidate_dcache(u32);
+void l2_cache_disable(void);
+void l2_cache_enable(void);
+
+#endif
Signature · 1 line
1.6.0.2
#16 lore raw

PATCH 16/17 SPEAr : spear1300 SoC support added

SPEAr1300 SoC support contains basic spear1300 support along with the usage of following drivers
- serial driver(UART)
- i2c driver
- smi driver
- nand driver(FSMC)
- usbd driver

---
 Makefile                                  |    6 +
 board/spear/common/Makefile               |   10 +-
 board/spear/spear1300/Makefile            |   51 ++++++++
 board/spear/spear1300/config.mk           |   28 ++++
 board/spear/spear1300/spear1300.c         |   89 +++++++++++++
 board/spear/spear1300/spr_lowlevel_init.S |   38 ++++++
 include/asm-arm/arch-spear13xx/hardware.h |    8 +-
 include/configs/spear13xx.h               |  199 +++++++++++++++++++++++++++++
 8 files changed, 423 insertions(+), 6 deletions(-)
 create mode 100644 board/spear/spear1300/Makefile
 create mode 100644 board/spear/spear1300/config.mk
 create mode 100644 board/spear/spear1300/spear1300.c
 create mode 100644 board/spear/spear1300/spr_lowlevel_init.S
 create mode 100644 include/configs/spear13xx.h
Makefile +6 -0
index 1b431a5..7af505e 100644
@@ -3045,6 +3045,12 @@ spear320_config :	unconfig
 spear600_config :	unconfig
 	@$(MKCONFIG) -n $@ -t $(@:_config=) spear6xx arm arm926ejs $(@:_config=) spear spear
 
+spear1300_config \
+spear1300_nand_config \
+spear1300_usbtty_config \
+spear1300_usbtty_nand_config :	unconfig
+	@$(MKCONFIG) -n $@ -t $(@:_config=) spear13xx arm arm_cortexa8 spear1300 spear spear13xx
+
 suen3_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm926ejs km_arm keymile kirkwood
 
board/spear/common/Makefile +8 -2
index 4f8959f..1ae4fd4 100644
@@ -29,8 +29,14 @@ endif
 
 LIB	= $(obj)lib$(VENDOR).a
 
-COBJS	:= spr_misc.o
-SOBJS	:= spr_lowlevel_init.o
+COBJS-$(CONFIG_SPEAR3XX) += spr_misc.o
+COBJS-$(CONFIG_SPEAR600) += spr_misc.o
+
+SOBJS-$(CONFIG_SPEAR3XX) += spr_lowlevel_init.o
+SOBJS-$(CONFIG_SPEAR600) += spr_lowlevel_init.o
+
+COBJS	:= $(COBJS-y)
+SOBJS	:= $(SOBJS-y)
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
board/spear/spear1300/Makefile new file +51 -0

51 lines not on this page · raw message

board/spear/spear1300/config.mk new file +28 -0
new file mode 100644
index 0000000..0bbb40f
@@ -0,0 +1,28 @@
+#
+# (C) Copyright 2009
+# Vipin Kumar, ST Microelectronics <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#########################################################################
+
+TEXT_BASE = 0x00700000
+
+ALL += $(obj)u-boot.img
board/spear/spear1300/spear1300.c new file +89 -0

89 lines not on this page · raw message

board/spear/spear1300/spr_lowlevel_init.S new file +38 -0
new file mode 100644
index 0000000..ba93922
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2006
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <config.h>
+
+/*
+ * platform specific initializations are already done in Xloader
+ * Initializations already done include
+ * DDR, PLLs, IP's clock enable and reset release etc
+ */
+.globl lowlevel_init
+lowlevel_init:
+	/* By default, U-Boot switches CPU to low-vector */
+	/* Revert this as we work in high vector even in U-Boot */
+	mrc	p15, 0, r0, c1, c0, 0
+	orr	r0, r0, #0x00002000
+	mcr	p15, 0, r0, c1, c0, 0
+	mov	pc, lr
include/asm-arm/arch-spear13xx/hardware.h +4 -4
index 384260a..7a1cedb 100644
@@ -24,10 +24,10 @@
 #ifndef _ASM_ARCH_HARDWARE_H
 #define _ASM_ARCH_HARDWARE_H
 
-#define CONFIG_SYS_USBD_BASE			(0xE1100000)
-#define CONFIG_SYS_PLUG_BASE			(0xE1200000)
-#define CONFIG_SYS_FIFO_BASE			(0xE1000800)
-#define CONFIG_SYS_SMI_BASE			(0xFC000000)
+#define CONFIG_SYS_USBD_BASE			(0xE3800000)
+#define CONFIG_SYS_PLUG_BASE			(0xE2800000)
+#define CONFIG_SYS_FIFO_BASE			(0xE3000800)
+#define CONFIG_SYS_SMI_BASE			(0xEA000000)
 #define CONFIG_SPEAR_TIMERBASE			(0xE0380000)
 #define CONFIG_SPEAR_MISCBASE			(0xE0700000)
 #define CONFIG_SYS_I2C_BASE			(0xE0280000)
include/configs/spear13xx.h new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#17 lore raw

PATCH 17/17 SPEAr : Supporting various configurations for spear3xx and spear6xx boards

spear3xx and 6xx boards can be compiled in following configurations
1. Environment placed in NAND
2. console on usb device
3. console on usb device with environment placed in NAND

---
 Makefile                       |   16 ++++++++++++++--
 board/spear/spear300/config.mk |   11 -----------
 board/spear/spear310/config.mk |   11 -----------
 board/spear/spear320/config.mk |   11 -----------
 board/spear/spear600/config.mk |   11 -----------
 include/configs/spear3xx.h     |   10 ++++++++++
 include/configs/spear6xx.h     |   10 ++++++++++
 7 files changed, 34 insertions(+), 46 deletions(-)
Makefile +14 -2
index 7af505e..04b9cc7 100644
@@ -3038,11 +3038,23 @@ smdk2410_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
 
 spear300_config \
+spear300_nand_config \
+spear300_usbtty_config \
+spear300_usbtty_nand_config \
 spear310_config \
-spear320_config :	unconfig
+spear310_nand_config \
+spear310_usbtty_config \
+spear310_usbtty_nand_config \
+spear320_config \
+spear320_nand_config \
+spear320_usbtty_config \
+spear320_usbtty_nand_config :	unconfig
 	@$(MKCONFIG) -n $@ -t $(@:_config=) spear3xx arm arm926ejs $(@:_config=) spear spear
 
-spear600_config :	unconfig
+spear600_config \
+spear600_nand_config \
+spear600_usbtty_config \
+spear600_usbtty_nand_config :	unconfig
 	@$(MKCONFIG) -n $@ -t $(@:_config=) spear6xx arm arm926ejs $(@:_config=) spear spear
 
 spear1300_config \
board/spear/spear300/config.mk +0 -11
index 35646f2..0bbb40f 100644
@@ -26,14 +26,3 @@
 TEXT_BASE = 0x00700000
 
 ALL += $(obj)u-boot.img
-
-# Environment variables in NAND
-ifeq ($(ENV),NAND)
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
-else
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
-endif
-
-ifeq ($(CONSOLE),USB)
-PLATFORM_RELFLAGS += -DCONFIG_SPEAR_USBTTY
-endif
board/spear/spear310/config.mk +0 -11
index cba8436..c8264c3 100644
@@ -27,18 +27,7 @@ TEXT_BASE = 0x00700000
 
 ALL += $(obj)u-boot.img
 
-# Environment variables in NAND
-ifeq ($(ENV),NAND)
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
-else
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
-endif
-
 # Support parallel flash
 ifeq ($(FLASH),PNOR)
 PLATFORM_RELFLAGS += -DCONFIG_FLASH_PNOR
 endif
-
-ifeq ($(CONSOLE),USB)
-PLATFORM_RELFLAGS += -DCONFIG_SPEAR_USBTTY
-endif
board/spear/spear320/config.mk +0 -11
index cba8436..c8264c3 100644
@@ -27,18 +27,7 @@ TEXT_BASE = 0x00700000
 
 ALL += $(obj)u-boot.img
 
-# Environment variables in NAND
-ifeq ($(ENV),NAND)
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
-else
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
-endif
-
 # Support parallel flash
 ifeq ($(FLASH),PNOR)
 PLATFORM_RELFLAGS += -DCONFIG_FLASH_PNOR
 endif
-
-ifeq ($(CONSOLE),USB)
-PLATFORM_RELFLAGS += -DCONFIG_SPEAR_USBTTY
-endif
board/spear/spear600/config.mk +0 -11
index 35646f2..0bbb40f 100644
@@ -26,14 +26,3 @@
 TEXT_BASE = 0x00700000
 
 ALL += $(obj)u-boot.img
-
-# Environment variables in NAND
-ifeq ($(ENV),NAND)
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
-else
-PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
-endif
-
-ifeq ($(CONSOLE),USB)
-PLATFORM_RELFLAGS += -DCONFIG_SPEAR_USBTTY
-endif
include/configs/spear3xx.h +10 -0
index 581f28d..7d4d8e0 100644
@@ -39,6 +39,16 @@
 #define CONFIG_SPEAR320				1
 #endif
 
+#if defined(CONFIG_MK_usbtty)
+#define CONFIG_SPEAR_USBTTY			1
+#endif
+
+#if defined(CONFIG_MK_nand)
+#define CONFIG_ENV_IS_IN_NAND			1
+#else
+#define CONFIG_ENV_IS_IN_FLASH			1
+#endif
+
 #include <configs/spear-common.h>
 
 /* Ethernet driver configuration */
include/configs/spear6xx.h +10 -0
index 24a6948..1930fad 100644
@@ -30,6 +30,16 @@
  */
 #define CONFIG_SPEAR600				1
 
+#if defined(CONFIG_MK_usbtty)
+#define CONFIG_SPEAR_USBTTY			1
+#endif
+
+#if defined(CONFIG_MK_nand)
+#define CONFIG_ENV_IS_IN_NAND			1
+#else
+#define CONFIG_ENV_IS_IN_FLASH			1
+#endif
+
 #include <configs/spear-common.h>
 
 /* Serial Configuration (PL011) */
Signature · 1 line
1.6.0.2
#18 lore raw

PATCH 12/17 SPEAr : i2c driver moved completely into drivers/i2c

In reply to Vipin KUMAR

Hi Vipin,

Quoted 8 lines · Vipin KUMAR

The i2c IP used by spear platform is a synopsys i2c controller The earlier driver adds the driver of this controller as if it is specific to
spear platform.
The driver files are now moved into drivers/i2c folder for reusability by other
platforms

Quoted 6 lines
---
 arch/arm/include/asm/arch-spear/spr_i2c.h |  146 -------------
 drivers/i2c/Makefile                      |    2 +-
 drivers/i2c/dw_i2c.c                      |  331

+++++++++++++++++++++++++++++

I'd similarly lean towards naming the new file designware.c, or synopsis.c. It looks like the rest of the i2c drivers use a _i2c suffix, so I guess designware_i2c.c or synopsis_i2c.c would be best for consistency's sake. At a minimum it'd be nice to mention in the dw_i2c.c file what silicon the driver supports as right now a user needs to guess what "dw_i2c.c" runs on based solely on "dw".

When you create patches with git format-patch, its nice to use the -M and -C to detect renames/copies. It makes the patch much smaller and much easier to review what actually changed.

Best,
Peter

#19 lore raw

PATCH 12/17 SPEAr : i2c driver moved completely into drivers/i2c

Quoted 18 lines · Peter Tyser

Hi Vipin,

Quoted 8 lines · Vipin KUMAR

The i2c IP used by spear platform is a synopsys i2c controller The earlier driver adds the driver of this controller as if it is specific to
spear platform.
The driver files are now moved into drivers/i2c folder for reusability by other
platforms

Quoted 6 lines
---
 arch/arm/include/asm/arch-spear/spr_i2c.h |  146 -------------
 drivers/i2c/Makefile                      |    2 +-
 drivers/i2c/dw_i2c.c                      |  331

+++++++++++++++++++++++++++++

Quoted 7 lines

I'd similarly lean towards naming the new file designware.c, or synopsis.c. It looks like the rest of the i2c drivers use a _i2c suffix, so I guess designware_i2c.c or synopsis_i2c.c would be best for consistency's sake. At a minimum it'd be nice to mention in the dw_i2c.c file what silicon the driver supports as right now a user needs to guess what "dw_i2c.c" runs on based solely on "dw".

OK, that's a good suggestion. I would change the name to designware_i2c.c and also include a little description about the manufacturer in the source header

Quoted 4 lines

When you create patches with git format-patch, its nice to use the -M and -C to detect renames/copies. It makes the patch much smaller and much easier to review what actually changed.

OK, I would generate the patch v2 with these options enabled Thanks for suggesting.
Please find the changes in next version patch-set

Quoted 4 lines

Best,
Peter

#20 lore raw

PATCH 11/17 SPEAr : Configuring FSMC driver for NAND interface

In reply to Vipin KUMAR

board/spear/spear310/spear310.c line 33

Quoted 11 lines · Vipin KUMAR
board/spear/spear310/spear310.c +2 -1
index 1207709..3ac62d1 100644
@@ -29,7 +29,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);

Put it in a header file.

-Scott

#21 lore raw

PATCH 11/17 SPEAr : Configuring FSMC driver for NAND interface

Quoted 15 lines · Scott Wood

board/spear/spear310/spear310.c line 33

Quoted 11 lines · Vipin KUMAR
board/spear/spear310/spear310.c +2 -1
index 1207709..3ac62d1 100644
@@ -29,7 +29,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);

Put it in a header file.

Should I put it in a platform specific header file. That's where I was confused

Quoted 2 lines

-Scott

#22 lore raw

PATCH 11/17 SPEAr : Configuring FSMC driver for NAND interface

Quoted 16 lines · Vipin KUMAR
Quoted 14 lines · Scott Wood

board/spear/spear310/spear310.c line 33

Quoted 11 lines · Vipin KUMAR
board/spear/spear310/spear310.c +2 -1
index 1207709..3ac62d1 100644
@@ -29,7 +29,8 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>
+
+int fsmc_nand_init(struct nand_chip *nand);

Put it in a header file.

Quoted 2 lines

Should I put it in a platform specific header file. That's where I was confused

Put it in fsmc_nand.h, and move that file to an include directory.

-Scott

#23 lore raw

PATCH 10/17 SPEAr : FSMC driver support added

In reply to Vipin KUMAR
Quoted 1 line · Vipin KUMAR

+#if defined(CONFIG_BOARD_NAND_LP)

CONFIG_SYS_FSMC_NAND_LP, CONFIG_SYS_FSMC_NAND_16BIT, etc.

drivers/mtd/nand/fsmc_nand.c line 297

Quoted 6 lines
drivers/mtd/nand/fsmc_nand.c new file +6 -0
+			/*
+			 * length is intentionally kept a higher multiple of 2
+			 * to read at least 13 bytes even in case of 16 bit NAND
+			 * devices
+			 */
+			len = ((len + 1) >> 1) << 1;

len = roundup(len, 2);

drivers/mtd/nand/fsmc_nand.c line 321

Quoted 2 lines
drivers/mtd/nand/fsmc_nand.c new file +2 -0
+	fsmc_version = (peripid2 >> FSMC_REVISION_SHFT) & \
+		       FSMC_REVISION_MSK;

Unnecessary backslash.

Quoted 13 lines
drivers/mtd/nand/fsmc_nand.h new file +13 -0
+#ifndef __FSMC_NAND_H__
+#define __FSMC_NAND_H__
+
+struct fsmc_regs {
+	u8 reserved_1[0x40];
+	u32 genmemctrl_pc;		/* 0x40 */
+	u32 genmemctrl_sts;		/* 0x44 */
+	u32 genmemctrl_comm;		/* 0x48 */
+	u32 genmemctrl_attrib;		/* 0x4c */
+	u32 genmemctrl_ioata;		/* 0x50 */
+	u32 genmemctrl_ecc1;		/* 0x54 */
+	u32 genmemctrl_ecc2;		/* 0x58 */
+	u32 genmemctrl_ecc3;		/* 0x5c */

drivers/mtd/nand/fsmc_nand.h line 46

Quoted 10 lines
drivers/mtd/nand/fsmc_nand.h new file +10 -0
+	u8 reserved_2[0xfe0 - 0x60];
+	u32 genmemctrl_peripid0;	/* 0xfe0 */
+	u32 genmemctrl_peripid1;	/* 0xfe4 */
+	u32 genmemctrl_peripid2;	/* 0xfe8 */
+	u32 genmemctrl_peripid3;	/* 0xfec */
+	u32 genmemctrl_pcellid0;	/* 0xff0 */
+	u32 genmemctrl_pcellid1;	/* 0xff4 */
+	u32 genmemctrl_pcellid2;	/* 0xff8 */
+	u32 genmemctrl_pcellid3;	/* 0xffc */
+};

Is the genmemctrl_ prefix really needed?

Quoted 1 line

+extern int spear_nand_init(struct nand_chip *nand);

fsmc_nand_init?

-Scott

#24 lore raw

PATCH 10/17 SPEAr : FSMC driver support added

Quoted 4 lines · Scott Wood
Quoted 1 line · Vipin KUMAR

+#if defined(CONFIG_BOARD_NAND_LP)

CONFIG_SYS_FSMC_NAND_LP, CONFIG_SYS_FSMC_NAND_16BIT, etc.

Incomplete comment :)
Are these deprecated

Quoted 9 lines

drivers/mtd/nand/fsmc_nand.c line 297

Quoted 6 lines
drivers/mtd/nand/fsmc_nand.c new file +6 -0
+			/*
+			 * length is intentionally kept a higher multiple of 2
+			 * to read at least 13 bytes even in case of 16 bit NAND
+			 * devices
+			 */
+			len = ((len + 1) >> 1) << 1;

len = roundup(len, 2);

OK, I would change that.
Please find the changes in patch-set v2

Quoted 5 lines

drivers/mtd/nand/fsmc_nand.c line 321

Quoted 2 lines
drivers/mtd/nand/fsmc_nand.c new file +2 -0
+	fsmc_version = (peripid2 >> FSMC_REVISION_SHFT) & \
+		       FSMC_REVISION_MSK;

Unnecessary backslash.

Would be removed

Quoted 17 lines
Quoted 17 lines
drivers/mtd/nand/fsmc_nand.h new file +17 -0
+#ifndef __FSMC_NAND_H__
+#define __FSMC_NAND_H__
+
+struct fsmc_regs {
+	u8 reserved_1[0x40];
+	u32 genmemctrl_pc;		/* 0x40 */
+	u32 genmemctrl_sts;		/* 0x44 */
+	u32 genmemctrl_comm;		/* 0x48 */
+	u32 genmemctrl_attrib;		/* 0x4c */
+	u32 genmemctrl_ioata;		/* 0x50 */
+	u32 genmemctrl_ecc1;		/* 0x54 */
+	u32 genmemctrl_ecc2;		/* 0x58 */
+	u32 genmemctrl_ecc3;		/* 0x5c */
+	u8 reserved_2[0xfe0 - 0x60];
+	u32 genmemctrl_peripid0;	/* 0xfe0 */
+	u32 genmemctrl_peripid1;	/* 0xfe4 */
+	u32 genmemctrl_peripid2;	/* 0xfe8 */
Quoted 9 lines

drivers/mtd/nand/fsmc_nand.h line 46

Quoted 6 lines
drivers/mtd/nand/fsmc_nand.h new file +6 -0
+	u32 genmemctrl_peripid3;	/* 0xfec */
+	u32 genmemctrl_pcellid0;	/* 0xff0 */
+	u32 genmemctrl_pcellid1;	/* 0xff4 */
+	u32 genmemctrl_pcellid2;	/* 0xff8 */
+	u32 genmemctrl_pcellid3;	/* 0xffc */
+};

Is the genmemctrl_ prefix really needed?

The peripheral's registers are named like these so I kept it.

Quoted 4 lines
Quoted 1 line

+extern int spear_nand_init(struct nand_chip *nand);

fsmc_nand_init?

Yes, I would change this
Thanks

Quoted 2 lines

-Scott

#25 lore raw

PATCH 10/17 SPEAr : FSMC driver support added

Quoted 7 lines · Vipin KUMAR
Quoted 3 lines · Scott Wood
Quoted 1 line · Vipin KUMAR

+#if defined(CONFIG_BOARD_NAND_LP)

CONFIG_SYS_FSMC_NAND_LP, CONFIG_SYS_FSMC_NAND_16BIT, etc.

Incomplete comment :)
Are these deprecated

CONFIG symbols that are hardware parameters rather than user-tweakable config go in the CONFIG_SYS namespace (see "Software Configuration" in README).

I think it should also be an FSMC-specific parameter, not something that looks universal.

Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
drivers/mtd/nand/fsmc_nand.h new file +16 -0
+#ifndef __FSMC_NAND_H__
+#define __FSMC_NAND_H__
+
+struct fsmc_regs {
+	u8 reserved_1[0x40];
+	u32 genmemctrl_pc;		/* 0x40 */
+	u32 genmemctrl_sts;		/* 0x44 */
+	u32 genmemctrl_comm;		/* 0x48 */
+	u32 genmemctrl_attrib;		/* 0x4c */
+	u32 genmemctrl_ioata;		/* 0x50 */
+	u32 genmemctrl_ecc1;		/* 0x54 */
+	u32 genmemctrl_ecc2;		/* 0x58 */
+	u32 genmemctrl_ecc3;		/* 0x5c */
+	u8 reserved_2[0xfe0 - 0x60];
+	u32 genmemctrl_peripid0;	/* 0xfe0 */
+	u32 genmemctrl_peripid1;	/* 0xfe4 */
Quoted 9 lines

drivers/mtd/nand/fsmc_nand.h line 46

Quoted 7 lines
drivers/mtd/nand/fsmc_nand.h new file +7 -0
+	u32 genmemctrl_peripid2;	/* 0xfe8 */
+	u32 genmemctrl_peripid3;	/* 0xfec */
+	u32 genmemctrl_pcellid0;	/* 0xff0 */
+	u32 genmemctrl_pcellid1;	/* 0xff4 */
+	u32 genmemctrl_pcellid2;	/* 0xff8 */
+	u32 genmemctrl_pcellid3;	/* 0xffc */
+};

Is the genmemctrl_ prefix really needed?

Quoted 1 line

The peripheral's registers are named like these so I kept it.

The struct name takes that role here; hardware documentation doesn't have the benefit of that.

-Scott

#26 lore raw

PATCH 7/17 SPEAr : Network driver support added

In reply to Vipin KUMAR

Hi Vipin,

Quoted 2 lines
 drivers/net/dw_eth.c |  504 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dw_eth.h |  281 ++++++++++++++++++++++++++++

I'd vote to name the driver "designware.c", or something else more descriptive than the somewhat ambiguous "dw". The _eth portion of the name isn't necessary either since its contained in the driver/net directory.

Best,
Peter

#27 lore raw

PATCH 7/17 SPEAr : Network driver support added

Quoted 10 lines · Peter Tyser

Hi Vipin,

Quoted 2 lines
 drivers/net/dw_eth.c |  504 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/dw_eth.h |  281 ++++++++++++++++++++++++++++

I'd vote to name the driver "designware.c", or something else more descriptive than the somewhat ambiguous "dw". The _eth portion of the name isn't necessary either since its contained in the driver/net directory.

OK, I would change the name to designware.c and header as designware.h Please find the changes in patch-set v2

Quoted 4 lines

Best,
Peter

#28 lore raw

PATCH 7/17 SPEAr : Network driver support added

In reply to Vipin KUMAR

Hi Vipin,

Quoted 9 lines · Vipin KUMAR

Designware network driver support added.
This is a Synopsys ethernet controller

---
  drivers/net/Makefile |    1 +
  drivers/net/dw_eth.c |  504 ++++++++++++++++++++++++++++++++++++++++++++++++++
  drivers/net/dw_eth.h |  281 ++++++++++++++++++++++++++++

I agree with Peter that a different name would be preferable. Something conveying the manufacturer or, if it's a very specific controller, the part number. Give thought to whether it will potentially be expanded up or generic-ized in the future (I know that's hard to do!)

Quoted 11 lines
  include/netdev.h     |    1 +
  4 files changed, 787 insertions(+), 0 deletions(-)

create mode 100755 drivers/net/dw_eth.c
create mode 100644 drivers/net/dw_eth.h

drivers/net/Makefile +0 -0
index 1ec0ba1..d03c353 100644

drivers/net/Makefile COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o · line 74

Quoted 7 lines
drivers/net/Makefile +1 -0
@@ -68,6 +68,7 @@ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
  COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
  COBJS-$(CONFIG_SMC91111) += smc91111.o
  COBJS-$(CONFIG_SMC911X) += smc911x.o
+COBJS-$(CONFIG_DW_ETH) += dw_eth.o
  COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
  COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
  COBJS-$(CONFIG_TSEC_ENET) += tsec.o

Alphabetical order, please

Quoted 51 lines
drivers/net/dw_eth.c new file +44 -0
new file mode 100755
index 0000000..52e7d15
@@ -0,0 +1,504 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
+ *
+ * (C) Copyright 2008
+ * Deepak Sikri, ST Micoelectronics, deepak.sikri at st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Designware ethernet IP driver for u-boot
+ */
+
+#include<common.h>
+#include<miiphy.h>
+#include<malloc.h>
+#include<linux/err.h>
+#include<asm/io.h>
+#include "dw_eth.h"
+
+static void tx_descs_init(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_dma_regs *dma_p = priv->dma_regs_p;
+	struct dmamacdescr *desc_table_p =&priv->tx_mac_descrtable[0];
+	char *txbuffs =&priv->txbuffs[0];
+	struct dmamacdescr *desc_p;

drivers/net/dw_eth.c line 54

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+
+	u32 idx;
+
+	for (idx = 0; idx<  CONFIG_TX_DESCR_NUM; idx++) {
+
+		desc_p =&desc_table_p[idx];
+		desc_p->dmamac_addr =&txbuffs[idx * CONFIG_ETH_BUFSIZE];
+		desc_p->dmamac_next =&desc_table_p[idx + 1];
+
+#if defined(CONFIG_DW_ALTDESC)

Please use a more descriptive CONFIG option. Remember these have global namespace

Quoted 23 lines
drivers/net/dw_eth.c new file +22 -0
+		desc_p->txrx_status&= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST |
+				DESC_TXSTS_TXFIRST | DESC_TXSTS_TXCRCDIS | \
+				DESC_TXSTS_TXCHECKINSCTRL | \
+				DESC_TXSTS_TXRINGEND | DESC_TXSTS_TXPADDIS);
+
+		desc_p->txrx_status |= DESC_TXSTS_TXCHAIN;
+		desc_p->dmamac_cntl = 0;
+		desc_p->txrx_status&= ~(DESC_TXSTS_MSK | DESC_TXSTS_OWNBYDMA);
+#else
+		desc_p->dmamac_cntl = DESC_TXCTRL_TXCHAIN;
+		desc_p->txrx_status = 0;
+#endif
+	}
+
+	/* Correcting the last pointer of the chain */
+	desc_p->dmamac_next =&desc_table_p[0];
+
+	writel((ulong)&desc_table_p[0],&dma_p->txdesclistaddr);
+}
+
+static void rx_descs_init(struct eth_device *dev)
+{

drivers/net/dw_eth.c line 86

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_dma_regs *dma_p = priv->dma_regs_p;
+	struct dmamacdescr *desc_table_p =&priv->rx_mac_descrtable[0];
+	char *rxbuffs =&priv->rxbuffs[0];
+	struct dmamacdescr *desc_p;
+
+	u32 idx;
+
+	for (idx = 0; idx<  CONFIG_RX_DESCR_NUM; idx++) {
+

Remove unnecessary blank lines

Quoted 51 lines
drivers/net/dw_eth.c new file +50 -0
+		desc_p =&desc_table_p[idx];
+		desc_p->dmamac_addr =&rxbuffs[idx * CONFIG_ETH_BUFSIZE];
+		desc_p->dmamac_next =&desc_table_p[idx + 1];
+
+		desc_p->dmamac_cntl =
+			(MAC_MAX_FRAME_SZ&  DESC_RXCTRL_SIZE1MASK) | \
+				      DESC_RXCTRL_RXCHAIN;
+
+		desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
+	}
+
+	/* Correcting the last pointer of the chain */
+	desc_p->dmamac_next =&desc_table_p[0];
+
+	writel((ulong)&desc_table_p[0],&dma_p->rxdesclistaddr);
+}
+
+static void descs_init(struct eth_device *dev)
+{
+	tx_descs_init(dev);
+	rx_descs_init(dev);
+}
+
+static void mac_reset(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_mac_regs *mac_p = priv->mac_regs_p;
+	struct eth_dma_regs *dma_p = priv->dma_regs_p;
+
+	u32 timeout = CONFIG_MACRESET_TIMEOUT;
+
+	writel(DMAMAC_SRST,&dma_p->busmode);
+	writel(MII_PORTSELECT,&mac_p->conf);
+
+	do {
+		if (!(readl(&dma_p->busmode)&  DMAMAC_SRST))
+			break;
+		udelay(1000);
+	} while (timeout--);
+}
+
+static int dw_eth_init(struct eth_device *dev, bd_t *bis)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_mac_regs *mac_p = priv->mac_regs_p;
+	struct eth_dma_regs *dma_p = priv->dma_regs_p;
+
+	u8 *mac_id =&dev->enetaddr[0];
+	u32 conf, macid_lo, macid_hi;
+

drivers/net/dw_eth.c line 146

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+	/* Reset ethernet hardware */
+	mac_reset(dev);
+
+	macid_lo = mac_id[0] + (mac_id[1]<<  8) + \
+		   (mac_id[2]<<  16) + (mac_id[3]<<  24);
+	macid_hi = mac_id[4] + (mac_id[5]<<  8);
+
+	writel(macid_hi,&mac_p->macaddr0hi);
+	writel(macid_lo,&mac_p->macaddr0lo);
+

Please provide a static function with signature 'static void program_mac(struct eth_device *)' for programming the MAC.

Quoted 302 lines
drivers/net/dw_eth.c new file +301 -0
+	writel(FIXEDBURST | PRIORXTX_41 | BURST_16,
+			&dma_p->busmode);
+
+	writel(FLUSHTXFIFO | readl(&dma_p->opmode),&dma_p->opmode);
+	writel(STOREFORWARD | TXSECONDFRAME,&dma_p->opmode);
+
+	conf = FRAMEBURSTENABLE | DISABLERXOWN;
+
+	if (priv->speed != SPEED_1000M)
+		conf |= MII_PORTSELECT;
+
+	if (priv->duplex == FULL_DUPLEX)
+		conf |= FULLDPLXMODE;
+
+	writel(conf,&mac_p->conf);
+
+	descs_init(dev);
+
+	/*
+	 * Start/Enable xfer at dma as well as mac level
+	 */
+	writel(readl(&dma_p->opmode) | RXSTART,&dma_p->opmode);
+	writel(readl(&dma_p->opmode) | TXSTART,&dma_p->opmode);
+
+	writel(readl(&mac_p->conf) | RXENABLE,&mac_p->conf);
+	writel(readl(&mac_p->conf) | TXENABLE,&mac_p->conf);
+
+	return 0;
+}
+
+static int dw_eth_send(struct eth_device *dev, volatile void *packet,
+		int length)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_dma_regs *dma_p = priv->dma_regs_p;
+	u32 desc_num = priv->tx_currdescnum;
+	struct dmamacdescr *desc_p =&priv->tx_mac_descrtable[desc_num];
+
+	/* Check if the descriptor is owned by CPU */
+	if (desc_p->txrx_status&  DESC_TXSTS_OWNBYDMA) {
+		printf("eth_send : CPU not owner of tx frame\n");
+		return -1;
+	}
+
+	memcpy((void *)desc_p->dmamac_addr, (void *)packet, length);
+
+#if defined(CONFIG_DW_ALTDESC)
+	desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
+	desc_p->dmamac_cntl |= (length<<  DESC_TXCTRL_SIZE1SHFT)&  \
+			       DESC_TXCTRL_SIZE1MASK;
+
+	desc_p->txrx_status&= ~(DESC_TXSTS_MSK);
+	desc_p->txrx_status |= DESC_TXSTS_OWNBYDMA;
+#else
+	desc_p->dmamac_cntl |= ((length<<  DESC_TXCTRL_SIZE1SHFT)&  \
+			       DESC_TXCTRL_SIZE1MASK) | DESC_TXCTRL_TXLAST | \
+			       DESC_TXCTRL_TXFIRST;
+
+	desc_p->txrx_status = DESC_TXSTS_OWNBYDMA;
+#endif
+
+	/* Test the wrap-around condition. */
+	if (++desc_num>= CONFIG_TX_DESCR_NUM)
+		desc_num = 0;
+
+	priv->tx_currdescnum = desc_num;
+
+	/* Start the transmission */
+	writel(POLL_DATA,&dma_p->txpolldemand);
+
+	return 0;
+}
+
+static int dw_eth_recv(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	u32 desc_num = priv->rx_currdescnum;
+	struct dmamacdescr *desc_p =&priv->rx_mac_descrtable[desc_num];
+
+	u32 status = desc_p->txrx_status;
+	int length = 0;
+
+	/* Check  if the owner is the CPU */
+	if (!(status&  DESC_RXSTS_OWNBYDMA)) {
+
+		length = (status&  DESC_RXSTS_FRMLENMSK)>>  \
+			 DESC_RXSTS_FRMLENSHFT;
+
+		NetReceive(desc_p->dmamac_addr, length);
+
+		/*
+		 * Make the current descriptor valid again and go to
+		 * the next one
+		 */
+		desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
+
+		/* Test the wrap-around condition. */
+		if (++desc_num>= CONFIG_RX_DESCR_NUM)
+			desc_num = 0;
+	}
+
+	priv->rx_currdescnum = desc_num;
+
+	return length;
+}
+
+static void dw_eth_halt(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+
+	mac_reset(dev);
+	priv->tx_currdescnum = priv->rx_currdescnum = 0;
+}
+
+static int eth_mdio_read(struct eth_device *dev, u8 addr, u8 reg, u16 *val)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_mac_regs *mac_p = priv->mac_regs_p;
+	u32 miiaddr;
+	u32 timeout = CONFIG_MDIO_TIMEOUT;
+
+	miiaddr = ((addr<<  MIIADDRSHIFT)&  MII_ADDRMSK) | \
+		  ((reg<<  MIIREGSHIFT)&  MII_REGMSK);
+
+	writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY,&mac_p->miiaddr);
+
+	do {
+		if (!(readl(&mac_p->miiaddr)&  MII_BUSY))
+			break;
+		udelay(1000);
+	} while (timeout--);
+
+	*val = readl(&mac_p->miidata);
+
+	return 0;
+}
+
+static int eth_mdio_write(struct eth_device *dev, u8 addr, u8 reg, u16 val)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	struct eth_mac_regs *mac_p = priv->mac_regs_p;
+	u32 miiaddr;
+	u32 timeout = CONFIG_MDIO_TIMEOUT;
+	u16 value;
+
+	writel(val,&mac_p->miidata);
+	miiaddr = ((addr<<  MIIADDRSHIFT)&  MII_ADDRMSK) | \
+		  ((reg<<  MIIREGSHIFT)&  MII_REGMSK) | MII_WRITE;
+
+	writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY,&mac_p->miiaddr);
+
+	do {
+		if (!(readl(&mac_p->miiaddr)&  MII_BUSY))
+			break;
+		udelay(1000);
+	} while (timeout--);
+
+	/* Needed as a fix for ST-Phy */
+	eth_mdio_read(dev, addr, reg,&value);
+
+	return 0;
+}
+
+static u8 find_phy(struct eth_device *dev)
+{
+	u8 phy_addr = 0;
+	u16 ctrl, oldctrl;
+
+	do {
+		eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+		oldctrl = ctrl&  PHY_BMCR_AUTON;
+
+		ctrl ^= PHY_BMCR_AUTON;
+		eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+		eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+		ctrl&= PHY_BMCR_AUTON;
+
+		if (ctrl == oldctrl) {
+			phy_addr++;
+		} else {
+			ctrl ^= PHY_BMCR_AUTON;
+			eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+			break;
+		}
+	} while (phy_addr<  32);
+
+	return phy_addr;
+}
+
+static void dw_reset_phy(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	u16 ctrl;
+	u32 timeout = CONFIG_PHYRESET_TIMEOUT;
+	u32 phy_addr = priv->address;
+
+	eth_mdio_write(dev, phy_addr, PHY_BMCR, PHY_BMCR_RESET);
+	do {
+		eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+		if (!(ctrl&  PHY_BMCR_RESET))
+			break;
+		udelay(1000);
+	} while (timeout--);
+
+#ifdef CONFIG_PHY_RESET_DELAY
+	udelay(CONFIG_PHY_RESET_DELAY);
+#endif
+}
+
+static void configure_phy(struct eth_device *dev)
+{
+	struct dw_eth_dev *priv = dev->priv;
+	u8 phy_addr;
+	u16 bmcr, ctrl;
+#if defined(CONFIG_DW_AUTONEG)
+	u16 bmsr;
+	u32 timeout;
+	u16 anlpar, btsr;
+#endif
+	priv->address = find_phy(dev);
+	phy_addr = priv->address;
+
+	dw_reset_phy(dev);
+
+#if defined(CONFIG_DW_AUTONEG)
+	bmcr = PHY_BMCR_AUTON | PHY_BMCR_RST_NEG | PHY_BMCR_100MB | \
+	       PHY_BMCR_DPLX | PHY_BMCR_1000_MBPS;
+#else
+	bmcr = PHY_BMCR_100MB | PHY_BMCR_DPLX;
+
+#if defined(CONFIG_DW_SPEED10M)
+	bmcr&= ~PHY_BMCR_100MB;
+#endif
+#if defined(CONFIG_DW_DUPLEXHALF)
+	bmcr&= ~PHY_BMCR_DPLX;
+#endif
+#endif
+	eth_mdio_write(dev, phy_addr, PHY_BMCR, bmcr);
+
+	/* Read the phy status register and populate priv structure */
+#if defined(CONFIG_DW_AUTONEG)
+	timeout = CONFIG_AUTONEG_TIMEOUT;
+	do {
+		eth_mdio_read(dev, phy_addr, PHY_BMSR,&bmsr);
+		if (bmsr&  PHY_BMSR_AUTN_COMP)
+			break;
+		udelay(1000);
+	} while (timeout--);
+
+	eth_mdio_read(dev, phy_addr, PHY_ANLPAR,&anlpar);
+	eth_mdio_read(dev, phy_addr, PHY_1000BTSR,&btsr);
+
+	if (btsr&  (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
+		priv->speed = SPEED_1000M;
+		if (btsr&  PHY_1000BTSR_1000FD)
+			priv->duplex = FULL_DUPLEX;
+		else
+			priv->duplex = HALF_DUPLEX;
+	} else {
+		if (anlpar&  PHY_ANLPAR_100)
+			priv->speed = SPEED_100M;
+		else
+			priv->speed = SPEED_10M;
+
+		if (anlpar&  (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD))
+			priv->duplex = FULL_DUPLEX;
+		else
+			priv->duplex = HALF_DUPLEX;
+	}
+#else
+	eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+
+	if (ctrl&  PHY_BMCR_DPLX)
+		priv->duplex = FULL_DUPLEX;
+	else
+		priv->duplex = HALF_DUPLEX;
+
+	if (ctrl&  PHY_BMCR_1000_MBPS)
+		priv->speed = SPEED_1000M;
+	else if (ctrl&  PHY_BMCR_100_MBPS)
+		priv->speed = SPEED_100M;
+	else
+		priv->speed = SPEED_10M;
+#endif
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+static int dw_mii_read(char *devname, u8 addr, u8 reg, u16 *val)
+{
+	struct eth_device *netdev;
+
+	netdev = eth_get_dev_by_name(devname);
+	if (netdev)
+		eth_mdio_read(netdev, addr, reg, val);
+
+	return 0;
+}
+
+static int dw_mii_write(char *devname, u8 addr, u8 reg, u16 val)
+{
+	struct eth_device *netdev;

drivers/net/dw_eth.c line 457

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+
+	netdev = eth_get_dev_by_name(devname);
+	if (netdev)
+		eth_mdio_write(netdev, addr, reg, val);
+
+	return 0;
+}
+#endif
+
+int dw_mii_initialize(u32 id, ulong base_addr)

Please use the same name in this function as the driver name. We usually reserve 'mii' for device control plane.

drivers/net/dw_eth.c line 459

Quoted 3 lines
drivers/net/dw_eth.c new file +2 -0
+{
+	struct eth_device *netdev;

I'd prefer if you named this variable 'dev', since 'netdev' is the name of a header file that's unrelated. Apply globally.

Quoted 13 lines
drivers/net/dw_eth.c new file +12 -0
+	struct dw_eth_dev *priv;
+
+	netdev = (struct eth_device *) malloc(sizeof(struct eth_device));
+	if (!netdev)
+		return -ENOMEM;
+
+	/*
+	 * Since the priv structure contains the descriptors which need a strict
+	 * buswidth alignment, memalign is used to allocate memory
+	 */
+	priv = (struct dw_eth_dev *) memalign(16, sizeof(struct dw_eth_dev));
+	if (!priv) {

drivers/net/dw_eth.c line 481

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+		free(netdev);
+		return -ENOMEM;
+	}
+
+	memset(netdev, 0, sizeof(struct eth_device));
+	memset(priv, 0, sizeof(struct dw_eth_dev));
+
+	sprintf(netdev->name, "mii%d", id);
+	netdev->iobase = (int)base_addr;
+	netdev->priv = priv;

If you wait a couple of days until I resubmit my change to the 'eth_device' struct, you can put in a pointer to the MAC programming function and not have to worry about that any more.

Quoted 13 lines
drivers/net/dw_eth.c new file +12 -0
+
+	eth_getenv_enetaddr_by_index(id,&netdev->enetaddr[0]);
+
+	priv->dev = netdev;
+	priv->mac_regs_p = (struct eth_mac_regs *)base_addr;
+	priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
+			DW_DMA_BASE_OFFSET);
+
+	mac_reset(netdev);
+	configure_phy(netdev);
+
+	netdev->init = dw_eth_init;

drivers/net/dw_eth.c line 503

Quoted 10 lines
drivers/net/dw_eth.c new file +10 -0
+	netdev->send = dw_eth_send;
+	netdev->recv = dw_eth_recv;
+	netdev->halt = dw_eth_halt;
+
+	eth_register(netdev);
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+	miiphy_register(netdev->name, dw_mii_read, dw_mii_write);
+#endif
+	return 0;

This should return 1 on success.

Quoted 240 lines
drivers/net/dw_eth.c new file +1 -0
+}
drivers/net/dw_eth.h new file +232 -0
new file mode 100644
index 0000000..068211a
@@ -0,0 +1,281 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _DW_ETH_H
+#define _DW_ETH_H
+
+#define CONFIG_TX_DESCR_NUM	16
+#define CONFIG_RX_DESCR_NUM	16
+#define CONFIG_ETH_BUFSIZE	2048
+#define TX_TOTAL_BUFSIZE	(CONFIG_ETH_BUFSIZE * CONFIG_TX_DESCR_NUM)
+#define RX_TOTAL_BUFSIZE	(CONFIG_ETH_BUFSIZE * CONFIG_RX_DESCR_NUM)
+
+#define CONFIG_MACRESET_TIMEOUT	(3 * CONFIG_SYS_HZ)
+#define CONFIG_MDIO_TIMEOUT	(3 * CONFIG_SYS_HZ)
+#define CONFIG_PHYRESET_TIMEOUT	(3 * CONFIG_SYS_HZ)
+#define CONFIG_AUTONEG_TIMEOUT	(5 * CONFIG_SYS_HZ)
+
+struct eth_mac_regs {
+	u32 conf;		/* 0x00 */
+	u32 framefilt;		/* 0x04 */
+	u32 hashtablehigh;	/* 0x08 */
+	u32 hashtablelow;	/* 0x0c */
+	u32 miiaddr;		/* 0x10 */
+	u32 miidata;		/* 0x14 */
+	u32 flowcontrol;	/* 0x18 */
+	u32 vlantag;		/* 0x1c */
+	u32 version;		/* 0x20 */
+	u8 reserved_1[0x38 - 0x24];
+	u32 intreg;		/* 0x38 */
+	u32 intmask;		/* 0x3c */
+	u32 macaddr0hi;		/* 0x40 */
+	u32 macaddr0lo;		/* 0x44 */
+};
+
+/* MAC configuration register definitions */
+#define FRAMEBURSTENABLE	(1<<  21)
+#define MII_PORTSELECT		(1<<  15)
+#define FES_100			(1<<  14)
+#define DISABLERXOWN		(1<<  13)
+#define FULLDPLXMODE		(1<<  11)
+#define RXENABLE		(1<<  2)
+#define TXENABLE		(1<<  3)
+
+/* MII address register definitions */
+#define MII_BUSY		(1<<  0)
+#define MII_WRITE		(1<<  1)
+#define MII_CLKRANGE_60_100M	(0)
+#define MII_CLKRANGE_100_150M	(0x4)
+#define MII_CLKRANGE_20_35M	(0x8)
+#define MII_CLKRANGE_35_60M	(0xC)
+#define MII_CLKRANGE_150_250M	(0x10)
+#define MII_CLKRANGE_250_300M	(0x14)
+
+#define MIIADDRSHIFT		(11)
+#define MIIREGSHIFT		(6)
+#define MII_REGMSK		(0x1F<<  6)
+#define MII_ADDRMSK		(0x1F<<  11)
+
+
+struct eth_dma_regs {
+	u32 busmode;		/* 0x00 */
+	u32 txpolldemand;	/* 0x04 */
+	u32 rxpolldemand;	/* 0x08 */
+	u32 rxdesclistaddr;	/* 0x0c */
+	u32 txdesclistaddr;	/* 0x10 */
+	u32 status;		/* 0x14 */
+	u32 opmode;		/* 0x18 */
+	u32 intenable;		/* 0x1c */
+	u8 reserved[0x48 - 0x20];
+	u32 currhosttxdesc;	/* 0x48 */
+	u32 currhostrxdesc;	/* 0x4c */
+	u32 currhosttxbuffaddr;	/* 0x50 */
+	u32 currhostrxbuffaddr;	/* 0x54 */
+};
+
+#define DW_DMA_BASE_OFFSET	(0x1000)
+
+/* Bus mode register definitions */
+#define FIXEDBURST		(1<<  16)
+#define PRIORXTX_41		(3<<  14)
+#define PRIORXTX_31		(2<<  14)
+#define PRIORXTX_21		(1<<  14)
+#define PRIORXTX_11		(0<<  14)
+#define BURST_1			(1<<  8)
+#define BURST_2			(2<<  8)
+#define BURST_4			(4<<  8)
+#define BURST_8			(8<<  8)
+#define BURST_16		(16<<  8)
+#define BURST_32		(32<<  8)
+#define RXHIGHPRIO		(1<<  1)
+#define DMAMAC_SRST		(1<<  0)
+
+/* Poll demand definitions */
+#define POLL_DATA		(0xFFFFFFFF)
+
+/* Operation mode definitions */
+#define STOREFORWARD		(1<<  21)
+#define FLUSHTXFIFO		(1<<  20)
+#define TXSTART			(1<<  13)
+#define TXSECONDFRAME		(1<<  2)
+#define RXSTART			(1<<  1)
+
+/* Descriptior related definitions */
+#define MAC_MAX_FRAME_SZ	(2048)
+
+struct dmamacdescr {
+	u32 txrx_status;
+	u32 dmamac_cntl;
+	void *dmamac_addr;
+	struct dmamacdescr *dmamac_next;
+};
+
+/*
+ * txrx_status definitions
+ */
+
+/* tx status bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_TXSTS_OWNBYDMA		(1<<  31)
+#define DESC_TXSTS_TXINT		(1<<  30)
+#define DESC_TXSTS_TXLAST		(1<<  29)
+#define DESC_TXSTS_TXFIRST		(1<<  28)
+#define DESC_TXSTS_TXCRCDIS		(1<<  27)
+
+#define DESC_TXSTS_TXPADDIS		(1<<  26)
+#define DESC_TXSTS_TXCHECKINSCTRL	(3<<  22)
+#define DESC_TXSTS_TXRINGEND		(1<<  21)
+#define DESC_TXSTS_TXCHAIN		(1<<  20)
+#define DESC_TXSTS_MSK			(0x1FFFF<<  0)
+
+#else
+
+#define DESC_TXSTS_OWNBYDMA		(1<<  31)
+#define DESC_TXSTS_MSK			(0x1FFFF<<  0)
+
+#endif
+
+/* rx status bits definitions */
+#define DESC_RXSTS_OWNBYDMA		(1<<  31)
+#define DESC_RXSTS_DAFILTERFAIL		(1<<  30)
+#define DESC_RXSTS_FRMLENMSK		(0x3FFF<<  16)
+#define DESC_RXSTS_FRMLENSHFT		(16)
+
+#define DESC_RXSTS_ERROR		(1<<  15)
+#define DESC_RXSTS_RXTRUNCATED		(1<<  14)
+#define DESC_RXSTS_SAFILTERFAIL		(1<<  13)
+#define DESC_RXSTS_RXIPC_GIANTFRAME	(1<<  12)
+#define DESC_RXSTS_RXDAMAGED		(1<<  11)
+#define DESC_RXSTS_RXVLANTAG		(1<<  10)
+#define DESC_RXSTS_RXFIRST		(1<<  9)
+#define DESC_RXSTS_RXLAST		(1<<  8)
+#define DESC_RXSTS_RXIPC_GIANT		(1<<  7)
+#define DESC_RXSTS_RXCOLLISION		(1<<  6)
+#define DESC_RXSTS_RXFRAMEETHER		(1<<  5)
+#define DESC_RXSTS_RXWATCHDOG		(1<<  4)
+#define DESC_RXSTS_RXMIIERROR		(1<<  3)
+#define DESC_RXSTS_RXDRIBBLING		(1<<  2)
+#define DESC_RXSTS_RXCRC		(1<<  1)
+
+/*
+ * dmamac_cntl definitions
+ */
+
+/* tx control bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_TXCTRL_SIZE1MASK		(0x1FFF<<  0)
+#define DESC_TXCTRL_SIZE1SHFT		(0)
+#define DESC_TXCTRL_SIZE2MASK		(0x1FFF<<  16)
+#define DESC_TXCTRL_SIZE2SHFT		(16)
+
+#else
+
+#define DESC_TXCTRL_TXINT		(1<<  31)
+#define DESC_TXCTRL_TXLAST		(1<<  30)
+#define DESC_TXCTRL_TXFIRST		(1<<  29)
+#define DESC_TXCTRL_TXCHECKINSCTRL	(3<<  27)
+#define DESC_TXCTRL_TXCRCDIS		(1<<  26)
+#define DESC_TXCTRL_TXRINGEND		(1<<  25)
+#define DESC_TXCTRL_TXCHAIN		(1<<  24)
+
+#define DESC_TXCTRL_SIZE1MASK		(0x7FF<<  0)
+#define DESC_TXCTRL_SIZE1SHFT		(0)
+#define DESC_TXCTRL_SIZE2MASK		(0x7FF<<  11)
+#define DESC_TXCTRL_SIZE2SHFT		(11)
+
+#endif
+
+/* rx control bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_RXCTRL_RXINTDIS		(1<<  31)
+#define DESC_RXCTRL_RXRINGEND		(1<<  15)
+#define DESC_RXCTRL_RXCHAIN		(1<<  14)
+
+#define DESC_RXCTRL_SIZE1MASK		(0x1FFF<<  0)
+#define DESC_RXCTRL_SIZE1SHFT		(0)
+#define DESC_RXCTRL_SIZE2MASK		(0x1FFF<<  16)
+#define DESC_RXCTRL_SIZE2SHFT		(16)
+
+#else
+
+#define DESC_RXCTRL_RXINTDIS		(1<<  31)
+#define DESC_RXCTRL_RXRINGEND		(1<<  25)
+#define DESC_RXCTRL_RXCHAIN		(1<<  24)
+
+#define DESC_RXCTRL_SIZE1MASK		(0x7FF<<  0)
+#define DESC_RXCTRL_SIZE1SHFT		(0)
+#define DESC_RXCTRL_SIZE2MASK		(0x7FF<<  11)
+#define DESC_RXCTRL_SIZE2SHFT		(11)
+

drivers/net/dw_eth.h line 242

Quoted 10 lines
drivers/net/dw_eth.h new file +10 -0
+#endif
+
+/*
+ * dmamac_addr definitions
+ */
+
+/* tx addr register bits definitions */
+
+/* rx addr register bits definitions */
+

Something's missing here...

Quoted 44 lines
drivers/net/dw_eth.h new file +39 -0
+
+/*
+ * dmamac_next definitions
+ */
+
+/* tx next register bits definitions */
+
+/* rx next register bits definitions */
+
+struct dw_eth_dev {
+	u32 address;
+	u32 speed;
+	u32 duplex;
+	u32 tx_currdescnum;
+	u32 rx_currdescnum;
+	u32 padding;
+
+	struct dmamacdescr tx_mac_descrtable[CONFIG_TX_DESCR_NUM];
+	struct dmamacdescr rx_mac_descrtable[CONFIG_RX_DESCR_NUM];
+
+	char txbuffs[TX_TOTAL_BUFSIZE];
+	char rxbuffs[RX_TOTAL_BUFSIZE];
+
+	struct eth_mac_regs *mac_regs_p;
+	struct eth_dma_regs *dma_regs_p;
+
+	struct eth_device *dev;
+} __attribute__ ((aligned(8)));
+
+/* Speed specific definitions */
+#define SPEED_10M		1
+#define SPEED_100M		2
+#define SPEED_1000M		3
+
+/* Duplex mode specific definitions */
+#define HALF_DUPLEX		1
+#define FULL_DUPLEX		2
+
+#endif
include/netdev.h +0 -0
index 1dd80f0..460889c 100644

include/netdev.h int scc_initialize(bd_t *bis); · line 83

Quoted 5 lines
include/netdev.h +1 -0
@@ -79,6 +79,7 @@ int scc_initialize(bd_t *bis);
  int skge_initialize(bd_t *bis);
  int smc911x_initialize(u8 dev_num, int base_addr);
  int smc91111_initialize(u8 dev_num, int base_addr);
+int dw_mii_initialize(u32 id, ulong base_addr);
 

alphabetical order, please.

Quoted 4 lines
include/netdev.h +0 -0
  int tsi108_eth_initialize(bd_t *bis);
  int uec_initialize(int index);
  int uec_standard_init(bd_t *bis);

Overall, a very good first pass.

thanks,
Ben

#29 lore raw

PATCH 7/17 SPEAr : Network driver support added

Quoted 13 lines · Ben Warren

Hi Vipin,

Quoted 10 lines · Vipin KUMAR

Designware network driver support added.
This is a Synopsys ethernet controller

---
  drivers/net/Makefile |    1 +
  drivers/net/dw_eth.c |  504
++++++++++++++++++++++++++++++++++++++++++++++++++
  drivers/net/dw_eth.h |  281 ++++++++++++++++++++++++++++
Quoted 4 lines

I agree with Peter that a different name would be preferable. Something conveying the manufacturer or, if it's a very specific controller, the part number. Give thought to whether it will potentially be expanded up or generic-ized in the future (I know that's hard to do!)

I am planning to change the name to designware.c and designware.h

Quoted 5 lines
Quoted 5 lines
  include/netdev.h     |    1 +
  4 files changed, 787 insertions(+), 0 deletions(-)

create mode 100755 drivers/net/dw_eth.c
create mode 100644 drivers/net/dw_eth.h

Quoted 14 lines

drivers/net/Makefile COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o · line 74

Quoted 13 lines
drivers/net/Makefile +1 -0
index 1ec0ba1..d03c353 100644
@@ -68,6 +68,7 @@ COBJS-$(CONFIG_DRIVER_S3C4510_ETH) += s3c4510b_eth.o
  COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
  COBJS-$(CONFIG_SMC91111) += smc91111.o
  COBJS-$(CONFIG_SMC911X) += smc911x.o
+COBJS-$(CONFIG_DW_ETH) += dw_eth.o
  COBJS-$(CONFIG_TIGON3) += tigon3.o bcm570x_autoneg.o 5701rls.o
  COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
  COBJS-$(CONFIG_TSEC_ENET) += tsec.o

Alphabetical order, please

Ah, sure

Quoted 55 lines
Quoted 55 lines
drivers/net/dw_eth.c new file +49 -0
new file mode 100755
index 0000000..52e7d15
@@ -0,0 +1,504 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
+ *
+ * (C) Copyright 2008
+ * Deepak Sikri, ST Micoelectronics, deepak.sikri at st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Designware ethernet IP driver for u-boot
+ */
+
+#include<common.h>
+#include<miiphy.h>
+#include<malloc.h>
+#include<linux/err.h>
+#include<asm/io.h>
+#include "dw_eth.h"
+
+static void tx_descs_init(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_dma_regs *dma_p = priv->dma_regs_p;
+    struct dmamacdescr *desc_table_p =&priv->tx_mac_descrtable[0];
+    char *txbuffs =&priv->txbuffs[0];
+    struct dmamacdescr *desc_p;
+
+    u32 idx;
+
+    for (idx = 0; idx<  CONFIG_TX_DESCR_NUM; idx++) {
+
Quoted 8 lines

drivers/net/dw_eth.c line 54

Quoted 6 lines
drivers/net/dw_eth.c new file +5 -0
+        desc_p =&desc_table_p[idx];
+        desc_p->dmamac_addr =&txbuffs[idx * CONFIG_ETH_BUFSIZE];
+        desc_p->dmamac_next =&desc_table_p[idx + 1];
+
+#if defined(CONFIG_DW_ALTDESC)

Please use a more descriptive CONFIG option. Remember these have global namespace

Hmmm, actually the peripheral supports two kinds of descriptors Normal and Alternate/Enhanced (as they call it) Should I put this option as CONFIG_DW_ALTDESCRIPTOR ?

Quoted 26 lines
Quoted 26 lines
drivers/net/dw_eth.c new file +26 -0
+        desc_p->txrx_status&= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST |
+                DESC_TXSTS_TXFIRST | DESC_TXSTS_TXCRCDIS | \
+                DESC_TXSTS_TXCHECKINSCTRL | \
+                DESC_TXSTS_TXRINGEND | DESC_TXSTS_TXPADDIS);
+
+        desc_p->txrx_status |= DESC_TXSTS_TXCHAIN;
+        desc_p->dmamac_cntl = 0;
+        desc_p->txrx_status&= ~(DESC_TXSTS_MSK | DESC_TXSTS_OWNBYDMA);
+#else
+        desc_p->dmamac_cntl = DESC_TXCTRL_TXCHAIN;
+        desc_p->txrx_status = 0;
+#endif
+    }
+
+    /* Correcting the last pointer of the chain */
+    desc_p->dmamac_next =&desc_table_p[0];
+
+    writel((ulong)&desc_table_p[0],&dma_p->txdesclistaddr);
+}
+
+static void rx_descs_init(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_dma_regs *dma_p = priv->dma_regs_p;
+    struct dmamacdescr *desc_table_p =&priv->rx_mac_descrtable[0];
+    char *rxbuffs =&priv->rxbuffs[0];
Quoted 8 lines

drivers/net/dw_eth.c line 49

Quoted 7 lines
drivers/net/dw_eth.c new file +6 -0
+    struct dmamacdescr *desc_p;
+
+    u32 idx;
+
+    for (idx = 0; idx<  CONFIG_RX_DESCR_NUM; idx++) {
+

Remove unnecessary blank lines

OK. would be done in patch-set v2

Quoted 55 lines
Quoted 55 lines
drivers/net/dw_eth.c new file +55 -0
+        desc_p =&desc_table_p[idx];
+        desc_p->dmamac_addr =&rxbuffs[idx * CONFIG_ETH_BUFSIZE];
+        desc_p->dmamac_next =&desc_table_p[idx + 1];
+
+        desc_p->dmamac_cntl =
+            (MAC_MAX_FRAME_SZ&  DESC_RXCTRL_SIZE1MASK) | \
+                      DESC_RXCTRL_RXCHAIN;
+
+        desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
+    }
+
+    /* Correcting the last pointer of the chain */
+    desc_p->dmamac_next =&desc_table_p[0];
+
+    writel((ulong)&desc_table_p[0],&dma_p->rxdesclistaddr);
+}
+
+static void descs_init(struct eth_device *dev)
+{
+    tx_descs_init(dev);
+    rx_descs_init(dev);
+}
+
+static void mac_reset(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_mac_regs *mac_p = priv->mac_regs_p;
+    struct eth_dma_regs *dma_p = priv->dma_regs_p;
+
+    u32 timeout = CONFIG_MACRESET_TIMEOUT;
+
+    writel(DMAMAC_SRST,&dma_p->busmode);
+    writel(MII_PORTSELECT,&mac_p->conf);
+
+    do {
+        if (!(readl(&dma_p->busmode)&  DMAMAC_SRST))
+            break;
+        udelay(1000);
+    } while (timeout--);
+}
+
+static int dw_eth_init(struct eth_device *dev, bd_t *bis)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_mac_regs *mac_p = priv->mac_regs_p;
+    struct eth_dma_regs *dma_p = priv->dma_regs_p;
+
+    u8 *mac_id =&dev->enetaddr[0];
+    u32 conf, macid_lo, macid_hi;
+
+    /* Reset ethernet hardware */
+    mac_reset(dev);
+
+    macid_lo = mac_id[0] + (mac_id[1]<<  8) + \
+           (mac_id[2]<<  16) + (mac_id[3]<<  24);
Quoted 8 lines

drivers/net/dw_eth.c line 146

Quoted 6 lines
drivers/net/dw_eth.c new file +5 -0
+    macid_hi = mac_id[4] + (mac_id[5]<<  8);
+
+    writel(macid_hi,&mac_p->macaddr0hi);
+    writel(macid_lo,&mac_p->macaddr0lo);
+

Please provide a static function with signature 'static void program_mac(struct eth_device *)' for programming the MAC.

Sure
Would be done in v2

Quoted 308 lines
Quoted 308 lines
drivers/net/dw_eth.c new file +115 -0
+    writel(FIXEDBURST | PRIORXTX_41 | BURST_16,
+            &dma_p->busmode);
+
+    writel(FLUSHTXFIFO | readl(&dma_p->opmode),&dma_p->opmode);
+    writel(STOREFORWARD | TXSECONDFRAME,&dma_p->opmode);
+
+    conf = FRAMEBURSTENABLE | DISABLERXOWN;
+
+    if (priv->speed != SPEED_1000M)
+        conf |= MII_PORTSELECT;
+
+    if (priv->duplex == FULL_DUPLEX)
+        conf |= FULLDPLXMODE;
+
+    writel(conf,&mac_p->conf);
+
+    descs_init(dev);
+
+    /*
+     * Start/Enable xfer at dma as well as mac level
+     */
+    writel(readl(&dma_p->opmode) | RXSTART,&dma_p->opmode);
+    writel(readl(&dma_p->opmode) | TXSTART,&dma_p->opmode);
+
+    writel(readl(&mac_p->conf) | RXENABLE,&mac_p->conf);
+    writel(readl(&mac_p->conf) | TXENABLE,&mac_p->conf);
+
+    return 0;
+}
+
+static int dw_eth_send(struct eth_device *dev, volatile void *packet,
+        int length)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_dma_regs *dma_p = priv->dma_regs_p;
+    u32 desc_num = priv->tx_currdescnum;
+    struct dmamacdescr *desc_p =&priv->tx_mac_descrtable[desc_num];
+
+    /* Check if the descriptor is owned by CPU */
+    if (desc_p->txrx_status&  DESC_TXSTS_OWNBYDMA) {
+        printf("eth_send : CPU not owner of tx frame\n");
+        return -1;
+    }
+
+    memcpy((void *)desc_p->dmamac_addr, (void *)packet, length);
+
+#if defined(CONFIG_DW_ALTDESC)
+    desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
+    desc_p->dmamac_cntl |= (length<<  DESC_TXCTRL_SIZE1SHFT)&  \
+                   DESC_TXCTRL_SIZE1MASK;
+
+    desc_p->txrx_status&= ~(DESC_TXSTS_MSK);
+    desc_p->txrx_status |= DESC_TXSTS_OWNBYDMA;
+#else
+    desc_p->dmamac_cntl |= ((length<<  DESC_TXCTRL_SIZE1SHFT)&  \
+                   DESC_TXCTRL_SIZE1MASK) | DESC_TXCTRL_TXLAST | \
+                   DESC_TXCTRL_TXFIRST;
+
+    desc_p->txrx_status = DESC_TXSTS_OWNBYDMA;
+#endif
+
+    /* Test the wrap-around condition. */
+    if (++desc_num>= CONFIG_TX_DESCR_NUM)
+        desc_num = 0;
+
+    priv->tx_currdescnum = desc_num;
+
+    /* Start the transmission */
+    writel(POLL_DATA,&dma_p->txpolldemand);
+
+    return 0;
+}
+
+static int dw_eth_recv(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    u32 desc_num = priv->rx_currdescnum;
+    struct dmamacdescr *desc_p =&priv->rx_mac_descrtable[desc_num];
+
+    u32 status = desc_p->txrx_status;
+    int length = 0;
+
+    /* Check  if the owner is the CPU */
+    if (!(status&  DESC_RXSTS_OWNBYDMA)) {
+
+        length = (status&  DESC_RXSTS_FRMLENMSK)>>  \
+             DESC_RXSTS_FRMLENSHFT;
+
+        NetReceive(desc_p->dmamac_addr, length);
+
+        /*
+         * Make the current descriptor valid again and go to
+         * the next one
+         */
+        desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
+
+        /* Test the wrap-around condition. */
+        if (++desc_num>= CONFIG_RX_DESCR_NUM)
+            desc_num = 0;
+    }
+
+    priv->rx_currdescnum = desc_num;
+
+    return length;
+}
+
+static void dw_eth_halt(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+
+    mac_reset(dev);
+    priv->tx_currdescnum = priv->rx_currdescnum = 0;
+}
+
+static int eth_mdio_read(struct eth_device *dev, u8 addr, u8 reg, u16

*val)

drivers/net/dw_eth.c new file +23 -0
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_mac_regs *mac_p = priv->mac_regs_p;
+    u32 miiaddr;
+    u32 timeout = CONFIG_MDIO_TIMEOUT;
+
+    miiaddr = ((addr<<  MIIADDRSHIFT)&  MII_ADDRMSK) | \
+          ((reg<<  MIIREGSHIFT)&  MII_REGMSK);
+
+    writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY,&mac_p->miiaddr);
+
+    do {
+        if (!(readl(&mac_p->miiaddr)&  MII_BUSY))
+            break;
+        udelay(1000);
+    } while (timeout--);
+
+    *val = readl(&mac_p->miidata);
+
+    return 0;
+}
+
+static int eth_mdio_write(struct eth_device *dev, u8 addr, u8 reg,

u16 val)

drivers/net/dw_eth.c new file +168 -0
+{
+    struct dw_eth_dev *priv = dev->priv;
+    struct eth_mac_regs *mac_p = priv->mac_regs_p;
+    u32 miiaddr;
+    u32 timeout = CONFIG_MDIO_TIMEOUT;
+    u16 value;
+
+    writel(val,&mac_p->miidata);
+    miiaddr = ((addr<<  MIIADDRSHIFT)&  MII_ADDRMSK) | \
+          ((reg<<  MIIREGSHIFT)&  MII_REGMSK) | MII_WRITE;
+
+    writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY,&mac_p->miiaddr);
+
+    do {
+        if (!(readl(&mac_p->miiaddr)&  MII_BUSY))
+            break;
+        udelay(1000);
+    } while (timeout--);
+
+    /* Needed as a fix for ST-Phy */
+    eth_mdio_read(dev, addr, reg,&value);
+
+    return 0;
+}
+
+static u8 find_phy(struct eth_device *dev)
+{
+    u8 phy_addr = 0;
+    u16 ctrl, oldctrl;
+
+    do {
+        eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+        oldctrl = ctrl&  PHY_BMCR_AUTON;
+
+        ctrl ^= PHY_BMCR_AUTON;
+        eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+        eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+        ctrl&= PHY_BMCR_AUTON;
+
+        if (ctrl == oldctrl) {
+            phy_addr++;
+        } else {
+            ctrl ^= PHY_BMCR_AUTON;
+            eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+            break;
+        }
+    } while (phy_addr<  32);
+
+    return phy_addr;
+}
+
+static void dw_reset_phy(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    u16 ctrl;
+    u32 timeout = CONFIG_PHYRESET_TIMEOUT;
+    u32 phy_addr = priv->address;
+
+    eth_mdio_write(dev, phy_addr, PHY_BMCR, PHY_BMCR_RESET);
+    do {
+        eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+        if (!(ctrl&  PHY_BMCR_RESET))
+            break;
+        udelay(1000);
+    } while (timeout--);
+
+#ifdef CONFIG_PHY_RESET_DELAY
+    udelay(CONFIG_PHY_RESET_DELAY);
+#endif
+}
+
+static void configure_phy(struct eth_device *dev)
+{
+    struct dw_eth_dev *priv = dev->priv;
+    u8 phy_addr;
+    u16 bmcr, ctrl;
+#if defined(CONFIG_DW_AUTONEG)
+    u16 bmsr;
+    u32 timeout;
+    u16 anlpar, btsr;
+#endif
+    priv->address = find_phy(dev);
+    phy_addr = priv->address;
+
+    dw_reset_phy(dev);
+
+#if defined(CONFIG_DW_AUTONEG)
+    bmcr = PHY_BMCR_AUTON | PHY_BMCR_RST_NEG | PHY_BMCR_100MB | \
+           PHY_BMCR_DPLX | PHY_BMCR_1000_MBPS;
+#else
+    bmcr = PHY_BMCR_100MB | PHY_BMCR_DPLX;
+
+#if defined(CONFIG_DW_SPEED10M)
+    bmcr&= ~PHY_BMCR_100MB;
+#endif
+#if defined(CONFIG_DW_DUPLEXHALF)
+    bmcr&= ~PHY_BMCR_DPLX;
+#endif
+#endif
+    eth_mdio_write(dev, phy_addr, PHY_BMCR, bmcr);
+
+    /* Read the phy status register and populate priv structure */
+#if defined(CONFIG_DW_AUTONEG)
+    timeout = CONFIG_AUTONEG_TIMEOUT;
+    do {
+        eth_mdio_read(dev, phy_addr, PHY_BMSR,&bmsr);
+        if (bmsr&  PHY_BMSR_AUTN_COMP)
+            break;
+        udelay(1000);
+    } while (timeout--);
+
+    eth_mdio_read(dev, phy_addr, PHY_ANLPAR,&anlpar);
+    eth_mdio_read(dev, phy_addr, PHY_1000BTSR,&btsr);
+
+    if (btsr&  (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) {
+        priv->speed = SPEED_1000M;
+        if (btsr&  PHY_1000BTSR_1000FD)
+            priv->duplex = FULL_DUPLEX;
+        else
+            priv->duplex = HALF_DUPLEX;
+    } else {
+        if (anlpar&  PHY_ANLPAR_100)
+            priv->speed = SPEED_100M;
+        else
+            priv->speed = SPEED_10M;
+
+        if (anlpar&  (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD))
+            priv->duplex = FULL_DUPLEX;
+        else
+            priv->duplex = HALF_DUPLEX;
+    }
+#else
+    eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+
+    if (ctrl&  PHY_BMCR_DPLX)
+        priv->duplex = FULL_DUPLEX;
+    else
+        priv->duplex = HALF_DUPLEX;
+
+    if (ctrl&  PHY_BMCR_1000_MBPS)
+        priv->speed = SPEED_1000M;
+    else if (ctrl&  PHY_BMCR_100_MBPS)
+        priv->speed = SPEED_100M;
+    else
+        priv->speed = SPEED_10M;
+#endif
+}
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+static int dw_mii_read(char *devname, u8 addr, u8 reg, u16 *val)
+{
+    struct eth_device *netdev;
+
+    netdev = eth_get_dev_by_name(devname);
+    if (netdev)
+        eth_mdio_read(netdev, addr, reg, val);
+
+    return 0;
+}
+
+static int dw_mii_write(char *devname, u8 addr, u8 reg, u16 val)
+{
+    struct eth_device *netdev;
+
+    netdev = eth_get_dev_by_name(devname);
+    if (netdev)
+        eth_mdio_write(netdev, addr, reg, val);
+
Quoted 8 lines

drivers/net/dw_eth.c line 457

Quoted 6 lines
drivers/net/dw_eth.c new file +5 -0
+    return 0;
+}
+#endif
+
+int dw_mii_initialize(u32 id, ulong base_addr)

Please use the same name in this function as the driver name. We usually reserve 'mii' for device control plane.

OK. I would change that to dw_initialize

Quoted 5 lines

drivers/net/dw_eth.c

Quoted 3 lines
drivers/net/dw_eth.c new file +2 -0
+{
+    struct eth_device *netdev;

I'd prefer if you named this variable 'dev', since 'netdev' is the name of a header file that's unrelated. Apply globally.

OK. I would change that to dev

Quoted 20 lines
Quoted 20 lines
drivers/net/dw_eth.c new file +8 -0
+    struct dw_eth_dev *priv;
+
+    netdev = (struct eth_device *) malloc(sizeof(struct eth_device));
+    if (!netdev)
+        return -ENOMEM;
+
+    /*
+     * Since the priv structure contains the descriptors which need a

strict

drivers/net/dw_eth.c new file +3 -0
+     * buswidth alignment, memalign is used to allocate memory
+     */
+    priv = (struct dw_eth_dev *) memalign(16, sizeof(struct

dw_eth_dev));

drivers/net/dw_eth.c new file +7 -0
+    if (!priv) {
+        free(netdev);
+        return -ENOMEM;
+    }
+
+    memset(netdev, 0, sizeof(struct eth_device));
+    memset(priv, 0, sizeof(struct dw_eth_dev));
Quoted 8 lines

drivers/net/dw_eth.c line 481

Quoted 5 lines
drivers/net/dw_eth.c new file +4 -0
+
+    sprintf(netdev->name, "mii%d", id);
+    netdev->iobase = (int)base_addr;
+    netdev->priv = priv;

If you wait a couple of days until I resubmit my change to the 'eth_device' struct, you can put in a pointer to the MAC programming function and not have to worry about that any more.

Sure, I would wait rebase over that patch and submit my patch v2

Quoted 16 lines
Quoted 16 lines
drivers/net/dw_eth.c new file +16 -0
+
+    eth_getenv_enetaddr_by_index(id,&netdev->enetaddr[0]);
+
+    priv->dev = netdev;
+    priv->mac_regs_p = (struct eth_mac_regs *)base_addr;
+    priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
+            DW_DMA_BASE_OFFSET);
+
+    mac_reset(netdev);
+    configure_phy(netdev);
+
+    netdev->init = dw_eth_init;
+    netdev->send = dw_eth_send;
+    netdev->recv = dw_eth_recv;
+    netdev->halt = dw_eth_halt;
+
Quoted 8 lines

drivers/net/dw_eth.c line 503

Quoted 7 lines
drivers/net/dw_eth.c new file +6 -0
+    eth_register(netdev);
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+    miiphy_register(netdev->name, dw_mii_read, dw_mii_write);
+#endif
+    return 0;

This should return 1 on success.

Ah, OK
I would change that.

Quoted 243 lines
Quoted 243 lines
drivers/net/dw_eth.c new file +1 -0
+}
drivers/net/dw_eth.h new file +236 -0
new file mode 100644
index 0000000..068211a
@@ -0,0 +1,281 @@
+/*
+ * (C) Copyright 2009
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar at st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _DW_ETH_H
+#define _DW_ETH_H
+
+#define CONFIG_TX_DESCR_NUM    16
+#define CONFIG_RX_DESCR_NUM    16
+#define CONFIG_ETH_BUFSIZE    2048
+#define TX_TOTAL_BUFSIZE    (CONFIG_ETH_BUFSIZE * CONFIG_TX_DESCR_NUM)
+#define RX_TOTAL_BUFSIZE    (CONFIG_ETH_BUFSIZE * CONFIG_RX_DESCR_NUM)
+
+#define CONFIG_MACRESET_TIMEOUT    (3 * CONFIG_SYS_HZ)
+#define CONFIG_MDIO_TIMEOUT    (3 * CONFIG_SYS_HZ)
+#define CONFIG_PHYRESET_TIMEOUT    (3 * CONFIG_SYS_HZ)
+#define CONFIG_AUTONEG_TIMEOUT    (5 * CONFIG_SYS_HZ)
+
+struct eth_mac_regs {
+    u32 conf;        /* 0x00 */
+    u32 framefilt;        /* 0x04 */
+    u32 hashtablehigh;    /* 0x08 */
+    u32 hashtablelow;    /* 0x0c */
+    u32 miiaddr;        /* 0x10 */
+    u32 miidata;        /* 0x14 */
+    u32 flowcontrol;    /* 0x18 */
+    u32 vlantag;        /* 0x1c */
+    u32 version;        /* 0x20 */
+    u8 reserved_1[0x38 - 0x24];
+    u32 intreg;        /* 0x38 */
+    u32 intmask;        /* 0x3c */
+    u32 macaddr0hi;        /* 0x40 */
+    u32 macaddr0lo;        /* 0x44 */
+};
+
+/* MAC configuration register definitions */
+#define FRAMEBURSTENABLE    (1<<  21)
+#define MII_PORTSELECT        (1<<  15)
+#define FES_100            (1<<  14)
+#define DISABLERXOWN        (1<<  13)
+#define FULLDPLXMODE        (1<<  11)
+#define RXENABLE        (1<<  2)
+#define TXENABLE        (1<<  3)
+
+/* MII address register definitions */
+#define MII_BUSY        (1<<  0)
+#define MII_WRITE        (1<<  1)
+#define MII_CLKRANGE_60_100M    (0)
+#define MII_CLKRANGE_100_150M    (0x4)
+#define MII_CLKRANGE_20_35M    (0x8)
+#define MII_CLKRANGE_35_60M    (0xC)
+#define MII_CLKRANGE_150_250M    (0x10)
+#define MII_CLKRANGE_250_300M    (0x14)
+
+#define MIIADDRSHIFT        (11)
+#define MIIREGSHIFT        (6)
+#define MII_REGMSK        (0x1F<<  6)
+#define MII_ADDRMSK        (0x1F<<  11)
+
+
+struct eth_dma_regs {
+    u32 busmode;        /* 0x00 */
+    u32 txpolldemand;    /* 0x04 */
+    u32 rxpolldemand;    /* 0x08 */
+    u32 rxdesclistaddr;    /* 0x0c */
+    u32 txdesclistaddr;    /* 0x10 */
+    u32 status;        /* 0x14 */
+    u32 opmode;        /* 0x18 */
+    u32 intenable;        /* 0x1c */
+    u8 reserved[0x48 - 0x20];
+    u32 currhosttxdesc;    /* 0x48 */
+    u32 currhostrxdesc;    /* 0x4c */
+    u32 currhosttxbuffaddr;    /* 0x50 */
+    u32 currhostrxbuffaddr;    /* 0x54 */
+};
+
+#define DW_DMA_BASE_OFFSET    (0x1000)
+
+/* Bus mode register definitions */
+#define FIXEDBURST        (1<<  16)
+#define PRIORXTX_41        (3<<  14)
+#define PRIORXTX_31        (2<<  14)
+#define PRIORXTX_21        (1<<  14)
+#define PRIORXTX_11        (0<<  14)
+#define BURST_1            (1<<  8)
+#define BURST_2            (2<<  8)
+#define BURST_4            (4<<  8)
+#define BURST_8            (8<<  8)
+#define BURST_16        (16<<  8)
+#define BURST_32        (32<<  8)
+#define RXHIGHPRIO        (1<<  1)
+#define DMAMAC_SRST        (1<<  0)
+
+/* Poll demand definitions */
+#define POLL_DATA        (0xFFFFFFFF)
+
+/* Operation mode definitions */
+#define STOREFORWARD        (1<<  21)
+#define FLUSHTXFIFO        (1<<  20)
+#define TXSTART            (1<<  13)
+#define TXSECONDFRAME        (1<<  2)
+#define RXSTART            (1<<  1)
+
+/* Descriptior related definitions */
+#define MAC_MAX_FRAME_SZ    (2048)
+
+struct dmamacdescr {
+    u32 txrx_status;
+    u32 dmamac_cntl;
+    void *dmamac_addr;
+    struct dmamacdescr *dmamac_next;
+};
+
+/*
+ * txrx_status definitions
+ */
+
+/* tx status bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_TXSTS_OWNBYDMA        (1<<  31)
+#define DESC_TXSTS_TXINT        (1<<  30)
+#define DESC_TXSTS_TXLAST        (1<<  29)
+#define DESC_TXSTS_TXFIRST        (1<<  28)
+#define DESC_TXSTS_TXCRCDIS        (1<<  27)
+
+#define DESC_TXSTS_TXPADDIS        (1<<  26)
+#define DESC_TXSTS_TXCHECKINSCTRL    (3<<  22)
+#define DESC_TXSTS_TXRINGEND        (1<<  21)
+#define DESC_TXSTS_TXCHAIN        (1<<  20)
+#define DESC_TXSTS_MSK            (0x1FFFF<<  0)
+
+#else
+
+#define DESC_TXSTS_OWNBYDMA        (1<<  31)
+#define DESC_TXSTS_MSK            (0x1FFFF<<  0)
+
+#endif
+
+/* rx status bits definitions */
+#define DESC_RXSTS_OWNBYDMA        (1<<  31)
+#define DESC_RXSTS_DAFILTERFAIL        (1<<  30)
+#define DESC_RXSTS_FRMLENMSK        (0x3FFF<<  16)
+#define DESC_RXSTS_FRMLENSHFT        (16)
+
+#define DESC_RXSTS_ERROR        (1<<  15)
+#define DESC_RXSTS_RXTRUNCATED        (1<<  14)
+#define DESC_RXSTS_SAFILTERFAIL        (1<<  13)
+#define DESC_RXSTS_RXIPC_GIANTFRAME    (1<<  12)
+#define DESC_RXSTS_RXDAMAGED        (1<<  11)
+#define DESC_RXSTS_RXVLANTAG        (1<<  10)
+#define DESC_RXSTS_RXFIRST        (1<<  9)
+#define DESC_RXSTS_RXLAST        (1<<  8)
+#define DESC_RXSTS_RXIPC_GIANT        (1<<  7)
+#define DESC_RXSTS_RXCOLLISION        (1<<  6)
+#define DESC_RXSTS_RXFRAMEETHER        (1<<  5)
+#define DESC_RXSTS_RXWATCHDOG        (1<<  4)
+#define DESC_RXSTS_RXMIIERROR        (1<<  3)
+#define DESC_RXSTS_RXDRIBBLING        (1<<  2)
+#define DESC_RXSTS_RXCRC        (1<<  1)
+
+/*
+ * dmamac_cntl definitions
+ */
+
+/* tx control bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_TXCTRL_SIZE1MASK        (0x1FFF<<  0)
+#define DESC_TXCTRL_SIZE1SHFT        (0)
+#define DESC_TXCTRL_SIZE2MASK        (0x1FFF<<  16)
+#define DESC_TXCTRL_SIZE2SHFT        (16)
+
+#else
+
+#define DESC_TXCTRL_TXINT        (1<<  31)
+#define DESC_TXCTRL_TXLAST        (1<<  30)
+#define DESC_TXCTRL_TXFIRST        (1<<  29)
+#define DESC_TXCTRL_TXCHECKINSCTRL    (3<<  27)
+#define DESC_TXCTRL_TXCRCDIS        (1<<  26)
+#define DESC_TXCTRL_TXRINGEND        (1<<  25)
+#define DESC_TXCTRL_TXCHAIN        (1<<  24)
+
+#define DESC_TXCTRL_SIZE1MASK        (0x7FF<<  0)
+#define DESC_TXCTRL_SIZE1SHFT        (0)
+#define DESC_TXCTRL_SIZE2MASK        (0x7FF<<  11)
+#define DESC_TXCTRL_SIZE2SHFT        (11)
+
+#endif
+
+/* rx control bits definitions */
+#if defined(CONFIG_DW_ALTDESC)
+
+#define DESC_RXCTRL_RXINTDIS        (1<<  31)
+#define DESC_RXCTRL_RXRINGEND        (1<<  15)
+#define DESC_RXCTRL_RXCHAIN        (1<<  14)
+
+#define DESC_RXCTRL_SIZE1MASK        (0x1FFF<<  0)
+#define DESC_RXCTRL_SIZE1SHFT        (0)
+#define DESC_RXCTRL_SIZE2MASK        (0x1FFF<<  16)
+#define DESC_RXCTRL_SIZE2SHFT        (16)
+
+#else
+
+#define DESC_RXCTRL_RXINTDIS        (1<<  31)
+#define DESC_RXCTRL_RXRINGEND        (1<<  25)
+#define DESC_RXCTRL_RXCHAIN        (1<<  24)
+
+#define DESC_RXCTRL_SIZE1MASK        (0x7FF<<  0)
+#define DESC_RXCTRL_SIZE1SHFT        (0)
+#define DESC_RXCTRL_SIZE2MASK        (0x7FF<<  11)
+#define DESC_RXCTRL_SIZE2SHFT        (11)
+
+#endif
+
+/*
+ * dmamac_addr definitions
Quoted 8 lines

drivers/net/dw_eth.h line 242

Quoted 7 lines
drivers/net/dw_eth.h new file +6 -0
+ */
+
+/* tx addr register bits definitions */
+
+/* rx addr register bits definitions */
+

Something's missing here...

Actually no, these are the addresses part of the descriptors so any bit doesn't have any special meaning.
Probably I can remove it altogather in v2

Quoted 42 lines
Quoted 42 lines
drivers/net/dw_eth.h new file +39 -0
+
+/*
+ * dmamac_next definitions
+ */
+
+/* tx next register bits definitions */
+
+/* rx next register bits definitions */
+
+struct dw_eth_dev {
+    u32 address;
+    u32 speed;
+    u32 duplex;
+    u32 tx_currdescnum;
+    u32 rx_currdescnum;
+    u32 padding;
+
+    struct dmamacdescr tx_mac_descrtable[CONFIG_TX_DESCR_NUM];
+    struct dmamacdescr rx_mac_descrtable[CONFIG_RX_DESCR_NUM];
+
+    char txbuffs[TX_TOTAL_BUFSIZE];
+    char rxbuffs[RX_TOTAL_BUFSIZE];
+
+    struct eth_mac_regs *mac_regs_p;
+    struct eth_dma_regs *dma_regs_p;
+
+    struct eth_device *dev;
+} __attribute__ ((aligned(8)));
+
+/* Speed specific definitions */
+#define SPEED_10M        1
+#define SPEED_100M        2
+#define SPEED_1000M        3
+
+/* Duplex mode specific definitions */
+#define HALF_DUPLEX        1
+#define FULL_DUPLEX        2
+
+#endif
include/netdev.h +0 -1
index 1dd80f0..460889c 100644
--- a/include/netdev.h
Quoted 8 lines

include/netdev.h int scc_initialize(bd_t *bis); · line 83

Quoted 7 lines

+++ b/include/netdev.h

include/netdev.h +1 -0
@@ -79,6 +79,7 @@ int scc_initialize(bd_t *bis);
  int skge_initialize(bd_t *bis);
  int smc911x_initialize(u8 dev_num, int base_addr);
  int smc91111_initialize(u8 dev_num, int base_addr);
+int dw_mii_initialize(u32 id, ulong base_addr);
 

alphabetical order, please.

Sure

Quoted 7 lines
Quoted 4 lines
include/netdev.h +0 -0
  int tsi108_eth_initialize(bd_t *bis);
  int uec_initialize(int index);
  int uec_standard_init(bd_t *bis);

Overall, a very good first pass.

Thanks. So, I am just waiting for a patch submission from you over which I would rebase and send my patch v2 incorporating all above changes

Quoted 3 lines

thanks,
Ben

Regards,
Vipin

#30 lore raw

PATCH 7/17 SPEAr : Network driver support added

In reply to Ben Warren

Ben,

I have a specific question on the way we handle phy address in SPEAr.

Quoted 20 lines
Quoted 20 lines
drivers/net/dw_eth.c new file +20 -0
+
+static u8 find_phy(struct eth_device *dev)
+{
+	u8 phy_addr = 0;
+	u16 ctrl, oldctrl;
+
+	do {
+		eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+		oldctrl = ctrl&  PHY_BMCR_AUTON;
+
+		ctrl ^= PHY_BMCR_AUTON;
+		eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+		eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+		ctrl&= PHY_BMCR_AUTON;
+
+		if (ctrl == oldctrl) {
+			phy_addr++;
+		} else {
+			ctrl ^= PHY_BMCR_AUTON;
+			eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
Quoted 8 lines

drivers/net/dw_eth.c line 335

Quoted 8 lines
drivers/net/dw_eth.c new file +7 -0
+			break;
+		}
+	} while (phy_addr<  32);
+
+	return phy_addr;
+}
+

As you can see we use an auto-probing mechanism implemented as find_phy() routine. This auto-probing is also used in other cases, like the drivers/net/mcfmii.c (mii_discover_phy()).

Actually I'm not sure this auto-probing mechanism is correct, as it works only
in case (very used) in which the MAC-PHY are in 1:1 relationship.

Instead, the MDIO bus nature implies that there might be N MACs and M PHYs connected
to the bus, so the auto-probing would not work.

See here some comments on the same:
http://lists.ozlabs.org/pipermail/devicetree-discuss/2010-February/001670.html

In our PCB we have the 1:1 relationship, but since the dw_eth.c driver is generic, it
might be used on differently designed pcb.

What is your general opinion in that?
Should we implement it differently?

Regards,
Arm

#31 lore raw

PATCH 7/17 SPEAr : Network driver support added

Hi Armando,

Quoted 48 lines · Armando VISCONTI

Ben,

I have a specific question on the way we handle phy address in SPEAr.

Quoted 19 lines
Quoted 19 lines
drivers/net/dw_eth.c new file +19 -0
+
+static u8 find_phy(struct eth_device *dev)
+{
+    u8 phy_addr = 0;
+    u16 ctrl, oldctrl;
+
+    do {
+        eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+        oldctrl = ctrl&  PHY_BMCR_AUTON;
+
+        ctrl ^= PHY_BMCR_AUTON;
+        eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+        eth_mdio_read(dev, phy_addr, PHY_BMCR,&ctrl);
+        ctrl&= PHY_BMCR_AUTON;
+
+        if (ctrl == oldctrl) {
+            phy_addr++;
+        } else {
+            ctrl ^= PHY_BMCR_AUTON;
Quoted 8 lines

drivers/net/dw_eth.c line 335

Quoted 8 lines
drivers/net/dw_eth.c new file +8 -0
+            eth_mdio_write(dev, phy_addr, PHY_BMCR, ctrl);
+            break;
+        }
+    } while (phy_addr<  32);
+
+    return phy_addr;
+}
+

As you can see we use an auto-probing mechanism implemented as find_phy() routine. This auto-probing is also used in other cases, like the drivers/net/mcfmii.c (mii_discover_phy()).

Actually I'm not sure this auto-probing mechanism is correct, as it works only
in case (very used) in which the MAC-PHY are in 1:1 relationship.

Instead, the MDIO bus nature implies that there might be N MACs and M PHYs connected
to the bus, so the auto-probing would not work.

See here some comments on the same:
http://lists.ozlabs.org/pipermail/devicetree-discuss/2010-February/001670.html

Quoted 7 lines

In our PCB we have the 1:1 relationship, but since the dw_eth.c driver is generic, it
might be used on differently designed pcb.

What is your general opinion in that?
Should we implement it differently?

I agree that MDIO bus probing doesn't make much sense. I don't know anything about your SOC, but the ones that I work with typically have multiple MACs (data link) but only one MDIO bus (control link). The end result is multiple PHYs on a multi-drop bus, and there's no way of knowing which one has its data link connected to which MAC.

I'd prefer to see it hard-coded, either through a CONFIG option or an environment variable.

Quoted 2 lines

Regards,
Arm

regards,
Ben

#32 lore raw

PATCH 7/17 SPEAr : Network driver support added

Hi Ben,

Quoted 8 lines

I agree that MDIO bus probing doesn't make much sense. I don't know anything about your SOC, but the ones that I work with typically have multiple MACs (data link) but only one MDIO bus (control link). The end result is multiple PHYs on a multi-drop bus, and there's no way of knowing which one has its data link connected to which MAC.

I'd prefer to see it hard-coded, either through a CONFIG option or an environment variable.

In our SoC current architecture there are multiple sdio buses, basically one for each MAC.
Neverthelees this architecture might change in the future.

Moreover, I agree that driver should be generic, so I guess that we might add a phy_addr field
in the device structure and pass it thru the initialize routine, as the macb driver is doing.

In the meantime I saw that Vipin already provided a V2 of the driver, which is still in the old
way.
Vipin, can you possibly provide your comments?

Thanks,
Arm

Signature · 8 lines
-- "Every step appears to be the unavoidable consequence of the
-- preceding one." (A. Einstein) 
-- 
Armando Visconti                  Mobile: (+39) 346 8879146
Senior SW Engineer                Fax:    (+39) 02 93519290
CPG                               Work:   (+39) 02 93519683
Computer System Division          e-mail: armando.visconti at st.com
ST Microelectronics               TINA:   051  4683
#33 lore raw

PATCH 7/17 SPEAr : Network driver support added

Quoted 19 lines · Armando VISCONTI

Hi Ben,

Quoted 8 lines

I agree that MDIO bus probing doesn't make much sense. I don't know anything about your SOC, but the ones that I work with typically have multiple MACs (data link) but only one MDIO bus (control link). The end result is multiple PHYs on a multi-drop bus, and there's no way of knowing which one has its data link connected to which MAC.

I'd prefer to see it hard-coded, either through a CONFIG option or an environment variable.

In our SoC current architecture there are multiple sdio buses, basically one for each MAC.
Neverthelees this architecture might change in the future.

Moreover, I agree that driver should be generic, so I guess that we might add a phy_addr field
in the device structure and pass it thru the initialize routine, as the macb driver is doing.

Quoted 5 lines

In the meantime I saw that Vipin already provided a V2 of the driver, which is still in the old
way.
Vipin, can you possibly provide your comments?

Actually speaking, I was waiting for a patch from Ben and this issue to get resolved by then.
Seeing no reply from Ben, I sent a patch v2 to get the comments at least on other subpatches.
I think the suggested changes are fine and can be made in patch v3

Quoted 6 lines

Thanks,
Arm

#34 lore raw

PATCH 6/17 SPEAr : Basic arch related support added for SPEAr SoCs

In reply to Vipin KUMAR

Hi Vipin,

Quoted 8 lines · Vipin KUMAR

Adding CONFIG_DISPLAY_CPUINFO and CONFIG_ARCH_CPU_INIT support for SPEAr3xx and SPEAr6xx SoCs

---
 arch/arm/cpu/arm926ejs/spear/Makefile      |    3 +-
 arch/arm/include/asm/arch-spear/spr_misc.h |    5 ++
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++++++++++++++++++++++++++++

The cpu path above needs to be adjusted to arch/arm/cpu/...

Also, cpu_info.c doesn't seem like the best filename. You put both initialization code and informational code in it, so a more generic name such as "cpu.c" would be preferred. Or possibly cpu.c and cpu_init.c. PowerPC boards would serve as a decent reference.

Best,
Peter

#35 lore raw

PATCH 6/17 SPEAr : Basic arch related support added for SPEAr SoCs

Quoted 6 lines · Peter Tyser

Hi Vipin,

Quoted 3 lines · Vipin KUMAR

Adding CONFIG_DISPLAY_CPUINFO and CONFIG_ARCH_CPU_INIT support for SPEAr3xx and SPEAr6xx SoCs

Quoted 8 lines
Quoted 5 lines
---
 arch/arm/cpu/arm926ejs/spear/Makefile      |    3 +-
 arch/arm/include/asm/arch-spear/spr_misc.h |    5 ++
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++++++++++++++++++++++++++++

The cpu path above needs to be adjusted to arch/arm/cpu/...

Yes, I would do that in patch v2

Quoted 5 lines

Also, cpu_info.c doesn't seem like the best filename. You put both initialization code and informational code in it, so a more generic name such as "cpu.c" would be preferred. Or possibly cpu.c and cpu_init.c. PowerPC boards would serve as a decent reference.

Yes, I just thought about it sometime back and then forgot to change the name. I would change the name to cpu.c

Quoted 3 lines

Best,
Peter

Thanks
Vipin

#36 lore raw

cover Network support for spear platform and spear1300 support

In reply to Vipin KUMAR

Hi Vipin,

Quoted 6 lines
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++
 cpu/arm_cortexa8/spear13xx/Makefile        |   52 ++
 cpu/arm_cortexa8/spear13xx/cache.S         |  112 +++
 cpu/arm_cortexa8/spear13xx/cpu_info.c      |  105 +++
 cpu/arm_cortexa8/spear13xx/reset.c         |   47 ++
 cpu/arm_cortexa8/spear13xx/timer.c         |  136 ++++

It looks like the cpu/ usage needs to be reviewed across the patchset.

Best,
Peter

#37 lore raw

cover Network support for spear platform and spear1300 support

Quoted 11 lines · Peter Tyser

Hi Vipin,

Quoted 6 lines
 cpu/arm926ejs/spear/cpu_info.c             |   76 ++
 cpu/arm_cortexa8/spear13xx/Makefile        |   52 ++
 cpu/arm_cortexa8/spear13xx/cache.S         |  112 +++
 cpu/arm_cortexa8/spear13xx/cpu_info.c      |  105 +++
 cpu/arm_cortexa8/spear13xx/reset.c         |   47 ++
 cpu/arm_cortexa8/spear13xx/timer.c         |  136 ++++

It looks like the cpu/ usage needs to be reviewed across the patchset.

Yes, I noticed this immediately after sending the mail
I am just waiting for other comments to incorporate this as well as other review comments in patchset v2

Quoted 4 lines

Best,
Peter