changeset 327:46ef6d9976db

Making FEC ethernet driver more generic
author gthomas
date Tue, 03 Sep 2002 16:56:13 +0000
parents afd0ab675643
children 21b2296aacb0
files packages/ChangeLog packages/devs/eth/powerpc/fec/current/ChangeLog packages/devs/eth/powerpc/fec/current/src/if_fec.c packages/devs/eth/powerpc/viper/current/ChangeLog packages/devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl packages/devs/eth/powerpc/viper/current/include/viper_eth.inl packages/ecos.db
diffstat 7 files changed, 230 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/packages/ChangeLog
+++ b/packages/ChangeLog
@@ -1,3 +1,7 @@
+2002-09-03  Gary Thomas  <gary@mlbassoc.com>
+
+	* ecos.db: Adding generic FEC driver support package (Viper).
+
 2002-08-27  Bart Veer  <bartv@ecoscentric.com>
 
 	* ecos.db: remove packages SDL and SMPEG that were never released.
--- a/packages/devs/eth/powerpc/fec/current/ChangeLog
+++ b/packages/devs/eth/powerpc/fec/current/ChangeLog
@@ -1,3 +1,8 @@
+2002-09-03  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/if_fec.c: Make driver more generic - platform specifics are
+	now contained in an include file CYGDAT_DEVS_FEC_ETH_INL.
+
 2002-08-15  Gary Thomas  <gthomas@ecoscentric.com>
 
 	* src/if_fec.c (fec_eth_send): 
--- a/packages/devs/eth/powerpc/fec/current/src/if_fec.c
+++ b/packages/devs/eth/powerpc/fec/current/src/if_fec.c
@@ -9,6 +9,7 @@
 // -------------------------------------------
 // This file is part of eCos, the Embedded Configurable Operating System.
 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
 //
 // eCos 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
@@ -56,6 +57,7 @@
 #include <pkgconf/system.h>
 #include <pkgconf/devs_eth_powerpc_fec.h>
 #include <pkgconf/io_eth_drivers.h>
+#include CYGDAT_DEVS_FEC_ETH_INL
 
 #ifdef CYGPKG_NET
 #include <pkgconf/net.h>
@@ -145,21 +147,28 @@ static void fec_fake_int(cyg_addrword_t)
 #endif // CYGINT_IO_ETH_INT_SUPPORT_REQUIRED
 static void          fec_eth_int(struct eth_drv_sc *data);
 
-#define FEC_ETH_INT CYGNUM_HAL_INTERRUPT_SIU_LVL1
+#ifndef FEC_ETH_INT
+#error  FEC_ETH_INT must be defined
+#endif
 
-#ifdef CYGPKG_HAL_POWERPC_VIPER
-extern int  hal_viper_get_led(void);
-extern void hal_viper_set_led(int);
-#define _get_led()  hal_viper_get_led()
-#define _set_led(v) hal_viper_set_led(v)
-#else
+#ifndef FEC_ETH_PHY
+#error  FEC_ETH_PHY must be defined
+#endif
+
+#ifndef FEC_ETH_RESET_PHY
+#define FEC_ETH_RESET_PHY()
+#endif
+
+// LED activity [exclusive of hardware bits]
+#ifndef _get_led
 #define _get_led()  
 #define _set_led(v) 
 #endif
-
+#ifndef LED_TxACTIVE
 #define LED_TxACTIVE  7
 #define LED_RxACTIVE  6
 #define LED_IntACTIVE 5
+#endif
 
 static void
 set_led(int bit)
@@ -452,14 +461,13 @@ fec_eth_init(struct cyg_netdevtab_entry 
     }
 
     // Reset PHY (transceiver)
-    eppc->pip_pbdat &= ~0x00004000;  // Reset PHY chip
-    CYGACC_CALL_IF_DELAY_US(10000);   // 10ms
-    eppc->pip_pbdat |= 0x00004000;   // Enable PHY chip
+    FEC_ETH_RESET_PHY();
+
     // Enable transceiver (PHY)    
     phy_ok = 0;
-    phy_write(PHY_BMCR, 0, PHY_BMCR_RESET);
+    phy_write(PHY_BMCR, FEC_ETH_PHY, PHY_BMCR_RESET);
     for (i = 0;  i < 10;  i++) {
-        phy_ok = phy_read(PHY_BMCR, 0, &phy_state);
+        phy_ok = phy_read(PHY_BMCR, FEC_ETH_PHY, &phy_state);
         if (!phy_ok) break;
         if (!(phy_state & PHY_BMCR_RESET)) break;
     }
@@ -468,13 +476,13 @@ fec_eth_init(struct cyg_netdevtab_entry 
         return false;
     }
     fec->iEvent = 0xFFFFFFFF;  // Clear all interrupts
-    phy_write(PHY_BMCR, 0, PHY_BMCR_AUTO_NEG|PHY_BMCR_RESTART);
+    phy_write(PHY_BMCR, FEC_ETH_PHY, PHY_BMCR_AUTO_NEG|PHY_BMCR_RESTART);
     while (phy_timeout-- >= 0) {
         int ev = fec->iEvent;
         unsigned short state;
         fec->iEvent = ev;
         if (ev & iEvent_MII) {
-            phy_ok = phy_read(PHY_BMSR, 0, &state);
+            phy_ok = phy_read(PHY_BMSR, FEC_ETH_PHY, &state);
             if (phy_ok && (state & PHY_BMSR_AUTO_NEG)) {
 //                os_printf("State: %x\n", state);
                 break;
new file mode 100644
--- /dev/null
+++ b/packages/devs/eth/powerpc/viper/current/ChangeLog
@@ -0,0 +1,43 @@
+2002-09-03  Gary Thomas  <gary@mlbassoc.com>
+
+	* include/viper_eth.inl: 
+	* cdl/viper_eth_drivers.cdl: New package - platform specifics for
+	PowerPC/FEC ethernet driver.
+
+//===========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//===========================================================================
+	
+	
+
new file mode 100644
--- /dev/null
+++ b/packages/devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl
@@ -0,0 +1,67 @@
+#====================================================================
+#
+#      viper_eth_drivers.cdl
+#
+#      Hardware specifics for A&M Viper ethernet
+#
+#====================================================================
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+## Copyright (C) 2002 Gary Thomas
+##
+## eCos 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.
+##
+## eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
+##
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+##
+## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+## at http://sources.redhat.com/ecos/ecos-license/
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s):      gthomas, hmt
+# Original data:  gthomas
+# Contributors:   gthomas
+# Date:           2001-02-14
+#
+#####DESCRIPTIONEND####
+#
+#====================================================================
+
+cdl_package CYGPKG_DEVS_ETH_POWERPC_VIPER {
+    display       "A&M Viper (MPC8xxT) ethernet support"
+    description   "Hardware specifics for A&M Viper ethernet"
+
+    parent        CYGPKG_IO_ETH_DRIVERS
+    active_if	  CYGPKG_IO_ETH_DRIVERS
+    active_if	  CYGPKG_HAL_POWERPC 
+    active_if	  CYGPKG_HAL_POWERPC_MPC8xx
+
+    include_dir   cyg/io
+
+    define_proc {
+        puts $::cdl_system_header "#define CYGDAT_DEVS_FEC_ETH_INL <cyg/io/viper_eth.inl>"
+    }
+}
new file mode 100644
--- /dev/null
+++ b/packages/devs/eth/powerpc/viper/current/include/viper_eth.inl
@@ -0,0 +1,79 @@
+#ifndef CYGONCE_DEVS_VIPER_ETH_INL
+#define CYGONCE_DEVS_VIPER_ETH_INL
+//==========================================================================
+//
+//      viper_eth.inl
+//
+//      Hardware specifics for A&M Viper ethernet support
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas
+// Date:         2002-09-03
+// Purpose:      
+// Description:  
+//              
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+extern int  hal_viper_get_led(void);
+extern void hal_viper_set_led(int);
+
+#define _get_led()  hal_viper_get_led()
+#define _set_led(v) hal_viper_set_led(v)
+
+#define LED_TxACTIVE  7
+#define LED_RxACTIVE  6
+#define LED_IntACTIVE 5
+
+// Interrupt generated by device
+#define FEC_ETH_INT CYGNUM_HAL_INTERRUPT_SIU_LVL1
+// Address of PHY (transceiver) device
+#define FEC_ETH_PHY 0
+
+// Reset the PHY - analagous to hardware reset
+#define FEC_ETH_RESET_PHY()                                     \
+    eppc->pip_pbdat &= ~0x00004000;  /* Reset PHY chip */       \
+    CYGACC_CALL_IF_DELAY_US(10000);  /* 10ms */                 \
+    eppc->pip_pbdat |= 0x00004000;   /* Enable PHY chip */
+
+#endif  // CYGONCE_DEVS_VIPER_ETH_INL
+// ------------------------------------------------------------------------
--- a/packages/ecos.db
+++ b/packages/ecos.db
@@ -1168,6 +1168,14 @@ package CYGPKG_DEVS_ETH_POWERPC_FEC {
         description     "Ethernet driver for PowerPC FEC (MPC8xxT) based boards."
 }
 
+package CYGPKG_DEVS_ETH_POWERPC_VIPER {
+	alias 		{ "A&M Viper ethernet driver" viper_eth_driver }
+	hardware
+	directory	devs/eth/powerpc/viper
+	script		viper_eth_drivers.cdl
+        description     "Ethernet driver specifics for A&M Viper (MPC8xxT) based boards."
+}
+
 package CYGPKG_DEVS_ETH_INTEL_I82559 {
 	alias 		{ "Intel 82559 ethernet driver"
 			   devs_eth_intel_i82559 i82559_eth_driver }
@@ -3587,6 +3595,7 @@ target viper {
                           CYGPKG_HAL_QUICC 
                           CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC
                           CYGPKG_DEVS_ETH_POWERPC_FEC
+                          CYGPKG_DEVS_ETH_POWERPC_VIPER
                           CYGPKG_DEVS_FLASH_VIPER
                           CYGPKG_DEVS_FLASH_AMD_AM29XXXXX
         }