[PATCH try#4] Blackfin ethernet driver: on chip ethernet MAC controller driver

2007-07-16 Thread Bryan Wu
This patch implements the driver necessary use the Analog Devices
Blackfin processor's on-chip ethernet MAC controller.

[try#2]
 - add timeout control
 - kill dma_config_reg bitfields
 - some trivial cleanup

[try#3]
 - add endianess check
 - add DRV_NAME, DRV_VERSION... driver information string
 - add some comments for silicon anomaly and dma API confusion
 - some code trivial cleanup

[try#4]
 - add Blackfin latest GPIO pin mux opertion with Michael Hennerich's
   help and Dan's review
 - rewrite the DMA descriptor list operation in a more readable way
   by Joe's review

Signed-off-by: Michael Hennerich <[EMAIL PROTECTED]>
Signed-off-by: Bryan Wu <[EMAIL PROTECTED]>
Cc: Michael Buesch <[EMAIL PROTECTED]>
Cc: Mike Frysinger <[EMAIL PROTECTED]>
Cc: Jeff Garzik <[EMAIL PROTECTED]>
Cc: Christoph Hellwig <[EMAIL PROTECTED]>
Cc: Dan Williams <[EMAIL PROTECTED]>
Cc: Joe Perches <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
 MAINTAINERS|7 +
 drivers/net/Kconfig|   44 ++
 drivers/net/Makefile   |1 +
 drivers/net/bfin_mac.c | 1015 
 drivers/net/bfin_mac.h |  132 +++
 5 files changed, 1199 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/bfin_mac.c
 create mode 100644 drivers/net/bfin_mac.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 3914269..65d5805 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -754,6 +754,13 @@ L: [EMAIL PROTECTED] (subscribers-only)
 W: http://blackfin.uclinux.org
 S: Supported
 
+BLACKFIN EMAC DRIVER
+P: Bryan Wu
+M: [EMAIL PROTECTED]
+L: [EMAIL PROTECTED] (subscribers-only)
+W: http://blackfin.uclinux.org
+S: Supported
+
 BLACKFIN RTC DRIVER
 P: Mike Frysinger
 M: [EMAIL PROTECTED]
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index d17d64e..7a3edaf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -848,6 +848,50 @@ config ULTRA32
  . The module
  will be called smc-ultra32.
 
+config BFIN_MAC
+   tristate "Blackfin 536/537 on-chip mac support"
+   depends on NET_ETHERNET && (BF537 || BF536) && (!BF537_PORT_H)
+   select CRC32
+   select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+   help
+ This is the driver for blackfin on-chip mac device. Say Y if you want 
it
+ compiled into the kernel. This driver is also available as a module
+ ( = code which can be inserted in and removed from the running kernel
+ whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+   bool "Use L1 memory for rx/tx packets"
+   depends on BFIN_MAC && BF537
+   default y
+   help
+ To get maximum network performace, you should use L1 memory as rx/tx 
buffers.
+ Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+   int "Number of transmit buffer packets"
+   depends on BFIN_MAC
+   range 6 10 if BFIN_MAC_USE_L1
+   range 10 100
+   default "10"
+   help
+ Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+   int "Number of receive buffer packets"
+   depends on BFIN_MAC
+   range 20 100 if BFIN_MAC_USE_L1
+   range 20 800
+   default "20"
+   help
+ Set the number of buffer packets used in driver.
+
+config BFIN_MAC_RMII
+   bool "RMII PHY Interface (EXPERIMENTAL)"
+   depends on BFIN_MAC && EXPERIMENTAL
+   default n
+   help
+ Use Reduced PHY MII Interface
+
 config SMC9194
tristate "SMC 9194 support"
depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index c26b867..9e71eb0 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -199,6 +199,7 @@ obj-$(CONFIG_S2IO) += s2io.o
 obj-$(CONFIG_MYRI10GE) += myri10ge/
 obj-$(CONFIG_SMC91X) += smc91x.o
 obj-$(CONFIG_SMC911X) += smc911x.o
+obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_DM9000) += dm9000.o
 obj-$(CONFIG_FEC_8XX) += fec_8xx/
 obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
new file mode 100644
index 000..bb5f97d
--- /dev/null
+++ b/drivers/net/bfin_mac.c
@@ -0,0 +1,1015 @@
+/*
+ * File:   drivers/net/bfin_mac.c
+ * Based on:
+ * Maintainer:
+ * Bryan Wu <[EMAIL PROTECTED]>
+ *
+ * Original author:
+ * Luke Yang <[EMAIL PROTECTED]>
+ *
+ * Created:
+ * Description:
+ *
+ * Modified:
+ * Copyright 2004-2006 Analog Devices Inc.
+ *
+ * Bugs:   Enter bugs at http://blackfin.uclinux.org/
+ *
+ * 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, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ;  

[PATCH try#4] Blackfin ethernet driver: on chip ethernet MAC controller driver

2007-07-16 Thread Bryan Wu
This patch implements the driver necessary use the Analog Devices
Blackfin processor's on-chip ethernet MAC controller.

[try#2]
 - add timeout control
 - kill dma_config_reg bitfields
 - some trivial cleanup

[try#3]
 - add endianess check
 - add DRV_NAME, DRV_VERSION... driver information string
 - add some comments for silicon anomaly and dma API confusion
 - some code trivial cleanup

[try#4]
 - add Blackfin latest GPIO pin mux opertion with Michael Hennerich's
   help and Dan's review
 - rewrite the DMA descriptor list operation in a more readable way
   by Joe's review

Signed-off-by: Michael Hennerich [EMAIL PROTECTED]
Signed-off-by: Bryan Wu [EMAIL PROTECTED]
Cc: Michael Buesch [EMAIL PROTECTED]
Cc: Mike Frysinger [EMAIL PROTECTED]
Cc: Jeff Garzik [EMAIL PROTECTED]
Cc: Christoph Hellwig [EMAIL PROTECTED]
Cc: Dan Williams [EMAIL PROTECTED]
Cc: Joe Perches [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---
 MAINTAINERS|7 +
 drivers/net/Kconfig|   44 ++
 drivers/net/Makefile   |1 +
 drivers/net/bfin_mac.c | 1015 
 drivers/net/bfin_mac.h |  132 +++
 5 files changed, 1199 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/bfin_mac.c
 create mode 100644 drivers/net/bfin_mac.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 3914269..65d5805 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -754,6 +754,13 @@ L: [EMAIL PROTECTED] (subscribers-only)
 W: http://blackfin.uclinux.org
 S: Supported
 
+BLACKFIN EMAC DRIVER
+P: Bryan Wu
+M: [EMAIL PROTECTED]
+L: [EMAIL PROTECTED] (subscribers-only)
+W: http://blackfin.uclinux.org
+S: Supported
+
 BLACKFIN RTC DRIVER
 P: Mike Frysinger
 M: [EMAIL PROTECTED]
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index d17d64e..7a3edaf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -848,6 +848,50 @@ config ULTRA32
  file:Documentation/networking/net-modules.txt. The module
  will be called smc-ultra32.
 
+config BFIN_MAC
+   tristate Blackfin 536/537 on-chip mac support
+   depends on NET_ETHERNET  (BF537 || BF536)  (!BF537_PORT_H)
+   select CRC32
+   select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE
+   help
+ This is the driver for blackfin on-chip mac device. Say Y if you want 
it
+ compiled into the kernel. This driver is also available as a module
+ ( = code which can be inserted in and removed from the running kernel
+ whenever you want). The module will be called bfin_mac.
+
+config BFIN_MAC_USE_L1
+   bool Use L1 memory for rx/tx packets
+   depends on BFIN_MAC  BF537
+   default y
+   help
+ To get maximum network performace, you should use L1 memory as rx/tx 
buffers.
+ Say N here if you want to reserve L1 memory for other uses.
+
+config BFIN_TX_DESC_NUM
+   int Number of transmit buffer packets
+   depends on BFIN_MAC
+   range 6 10 if BFIN_MAC_USE_L1
+   range 10 100
+   default 10
+   help
+ Set the number of buffer packets used in driver.
+
+config BFIN_RX_DESC_NUM
+   int Number of receive buffer packets
+   depends on BFIN_MAC
+   range 20 100 if BFIN_MAC_USE_L1
+   range 20 800
+   default 20
+   help
+ Set the number of buffer packets used in driver.
+
+config BFIN_MAC_RMII
+   bool RMII PHY Interface (EXPERIMENTAL)
+   depends on BFIN_MAC  EXPERIMENTAL
+   default n
+   help
+ Use Reduced PHY MII Interface
+
 config SMC9194
tristate SMC 9194 support
depends on NET_VENDOR_SMC  (ISA || MAC  BROKEN)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index c26b867..9e71eb0 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -199,6 +199,7 @@ obj-$(CONFIG_S2IO) += s2io.o
 obj-$(CONFIG_MYRI10GE) += myri10ge/
 obj-$(CONFIG_SMC91X) += smc91x.o
 obj-$(CONFIG_SMC911X) += smc911x.o
+obj-$(CONFIG_BFIN_MAC) += bfin_mac.o
 obj-$(CONFIG_DM9000) += dm9000.o
 obj-$(CONFIG_FEC_8XX) += fec_8xx/
 obj-$(CONFIG_PASEMI_MAC) += pasemi_mac.o
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
new file mode 100644
index 000..bb5f97d
--- /dev/null
+++ b/drivers/net/bfin_mac.c
@@ -0,0 +1,1015 @@
+/*
+ * File:   drivers/net/bfin_mac.c
+ * Based on:
+ * Maintainer:
+ * Bryan Wu [EMAIL PROTECTED]
+ *
+ * Original author:
+ * Luke Yang [EMAIL PROTECTED]
+ *
+ * Created:
+ * Description:
+ *
+ * Modified:
+ * Copyright 2004-2006 Analog Devices Inc.
+ *
+ * Bugs:   Enter bugs at http://blackfin.uclinux.org/
+ *
+ * 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, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ;  without