Re: [U-Boot] [PATCH v5] net: add altera triple speeds ethernet mac driver

2010-04-26 Thread Ben Warren
Thomas,

On 4/19/2010 9:49 PM, Thomas Chou wrote:
 This driver supports the Altera triple speeds 10/100/1000 ethernet
 mac.

 Signed-off-by: Thomas Choutho...@wytron.com.tw
 ---
 sort the code to remove func proto.
 change initialization, with dev_num and bases.
 add tse_set_mac_address().
 sgdma code is not folded due to increased code size.

   drivers/net/Makefile |1 +
   drivers/net/altera_tse.c |  935 
 ++
   drivers/net/altera_tse.h |  494 
   include/netdev.h |2 +
   4 files changed, 1432 insertions(+), 0 deletions(-)
   create mode 100644 drivers/net/altera_tse.c
   create mode 100644 drivers/net/altera_tse.h


applied to net repo.

If you'd like this driver to automatically program MAC addresses after 
initialization (see a patch that I submitted tonight), please submit a 
follow-on to this one and I'll accept for the current release.
regards,
Ben
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] net: add altera triple speeds ethernet mac driver

2010-04-26 Thread Thomas Chou
On 04/26/2010 02:13 PM, Ben Warren wrote:
 Thomas,

 On 4/19/2010 9:49 PM, Thomas Chou wrote:
 This driver supports the Altera triple speeds 10/100/1000 ethernet
 mac.

 applied to net repo.

 If you'd like this driver to automatically program MAC addresses after 
 initialization (see a patch that I submitted tonight), please submit a 
 follow-on to this one and I'll accept for the current release.
 regards,
 Ben


Hi Ben,

Thanks a lot. I will prepare the write mac address patches for both drivers.

Cheers,
Thomas
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5] net: add altera triple speeds ethernet mac driver

2010-04-19 Thread Thomas Chou
This driver supports the Altera triple speeds 10/100/1000 ethernet
mac.

Signed-off-by: Thomas Chou tho...@wytron.com.tw
---
sort the code to remove func proto.
change initialization, with dev_num and bases.
add tse_set_mac_address().
sgdma code is not folded due to increased code size.

 drivers/net/Makefile |1 +
 drivers/net/altera_tse.c |  935 ++
 drivers/net/altera_tse.h |  494 
 include/netdev.h |2 +
 4 files changed, 1432 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/altera_tse.c
 create mode 100644 drivers/net/altera_tse.h

diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 0e68e52..b75c02f 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -27,6 +27,7 @@ LIB   := $(obj)libnet.a
 
 COBJS-$(CONFIG_DRIVER_3C589) += 3c589.o
 COBJS-$(CONFIG_PPC4xx_EMAC) += 4xx_enet.o
+COBJS-$(CONFIG_ALTERA_TSE) += altera_tse.o
 COBJS-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
 COBJS-$(CONFIG_DRIVER_AX88180) += ax88180.o
 COBJS-$(CONFIG_BCM570x) += bcm570x.o bcm570x_autoneg.o 5701rls.o
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
new file mode 100644
index 000..5927904
--- /dev/null
+++ b/drivers/net/altera_tse.c
@@ -0,0 +1,935 @@
+/*
+ * Altera 10/100/1000 triple speed ethernet mac driver
+ *
+ * Copyright (C) 2008 Altera Corporation.
+ * Copyright (C) 2010 Thomas Chou tho...@wytron.com.tw
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include config.h
+#include common.h
+#include malloc.h
+#include net.h
+#include command.h
+#include asm/cache.h
+#include asm/dma-mapping.h
+#include miiphy.h
+#include altera_tse.h
+
+/* sgdma debug - print descriptor */
+static void alt_sgdma_print_desc(volatile struct alt_sgdma_descriptor *desc)
+{
+   debug(SGDMA DEBUG :\n);
+   debug(desc-source : 0x%x \n, (unsigned int)desc-source);
+   debug(desc-destination : 0x%x \n, (unsigned int)desc-destination);
+   debug(desc-next : 0x%x \n, (unsigned int)desc-next);
+   debug(desc-source_pad : 0x%x \n, (unsigned int)desc-source_pad);
+   debug(desc-destination_pad : 0x%x \n,
+ (unsigned int)desc-destination_pad);
+   debug(desc-next_pad : 0x%x \n, (unsigned int)desc-next_pad);
+   debug(desc-bytes_to_transfer : 0x%x \n,
+ (unsigned int)desc-bytes_to_transfer);
+   debug(desc-actual_bytes_transferred : 0x%x \n,
+ (unsigned int)desc-actual_bytes_transferred);
+   debug(desc-descriptor_status : 0x%x \n,
+ (unsigned int)desc-descriptor_status);
+   debug(desc-descriptor_control : 0x%x \n,
+ (unsigned int)desc-descriptor_control);
+}
+
+/* This is a generic routine that the SGDMA mode-specific routines
+ * call to populate a descriptor.
+ * arg1:pointer to first SGDMA descriptor.
+ * arg2:pointer to next  SGDMA descriptor.
+ * arg3:Address to where data to be written.
+ * arg4:Address from where data to be read.
+ * arg5:no of byte to transaction.
+ * arg6:variable indicating to generate start of packet or not
+ * arg7:read fixed
+ * arg8:write fixed
+ * arg9:read burst
+ * arg10:write burst
+ * arg11:atlantic_channel number
+ */
+static void alt_sgdma_construct_descriptor_burst(
+   volatile struct alt_sgdma_descriptor *desc,
+   volatile struct alt_sgdma_descriptor *next,
+   unsigned int *read_addr,
+   unsigned int *write_addr,
+   unsigned short length_or_eop,
+   int generate_eop,
+   int read_fixed,
+   int write_fixed_or_sop,
+   int read_burst,
+   int write_burst,
+   unsigned char atlantic_channel)
+{
+   /*
+* Mark the next descriptor as not owned by hardware. This prevents
+* The SGDMA controller from continuing to process the chain. This is
+* done as a single IO write to bypass cache, without flushing
+* the entire descriptor, since only the 8-bit descriptor status must
+* be flushed.
+*/
+   if (!next)
+   debug(Next descriptor not defined!!\n);
+
+   next-descriptor_control = (next-descriptor_control 
+   ~ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK);
+
+   desc-source = (unsigned int *)((unsigned int)read_addr  0x1FFF);
+   desc-destination =
+   (unsigned int *)((unsigned int)write_addr  0x1FFF);
+   desc-next = (unsigned int *)((unsigned int)next  0x1FFF);
+   desc-source_pad = 0x0;
+   desc-destination_pad = 0x0;
+   desc-next_pad = 0x0;
+   desc-bytes_to_transfer = length_or_eop;
+   desc-actual_bytes_transferred = 0;
+   desc-descriptor_status = 0x0;
+
+   /* SGDMA burst not currently supported */
+   desc-read_burst