This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Ethernet - making FEC driver more generic
- From: Gary Thomas <gthomas at ecoscentric dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 03 Sep 2002 10:56:46 -0600
- Subject: Ethernet - making FEC driver more generic
Index: ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/ChangeLog,v
retrieving revision 1.76
diff -u -5 -p -r1.76 ChangeLog
--- ChangeLog 27 Aug 2002 22:20:44 -0000 1.76
+++ ChangeLog 3 Sep 2002 16:47:53 -0000
@@ -1,5 +1,9 @@
+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.
2002-08-15 Andrew Lunn <andrew.lunn@ascom.ch>
Index: ecos.db
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/ecos.db,v
retrieving revision 1.69
diff -u -5 -p -r1.69 ecos.db
--- ecos.db 27 Aug 2002 22:20:45 -0000 1.69
+++ ecos.db 3 Sep 2002 16:47:13 -0000
@@ -1166,10 +1166,18 @@ package CYGPKG_DEVS_ETH_POWERPC_FEC {
directory devs/eth/powerpc/fec
script fec_eth_drivers.cdl
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 }
hardware
directory devs/eth/intel/i82559
@@ -3585,10 +3593,11 @@ target viper {
CYGPKG_HAL_POWERPC_MPC8xx
CYGPKG_HAL_POWERPC_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
}
description "
The viper target provides the packages needed to run
Index: devs/eth/powerpc/fec/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/fec/current/ChangeLog,v
retrieving revision 1.9
diff -u -5 -p -r1.9 ChangeLog
--- devs/eth/powerpc/fec/current/ChangeLog 15 Aug 2002 13:22:40 -0000 1.9
+++ devs/eth/powerpc/fec/current/ChangeLog 3 Sep 2002 16:47:13 -0000
@@ -1,5 +1,10 @@
+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):
Clean up: remove unused variable _fec_eth_tx_count.
Index: devs/eth/powerpc/fec/current/src/if_fec.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/fec/current/src/if_fec.c,v
retrieving revision 1.9
diff -u -5 -p -r1.9 if_fec.c
--- devs/eth/powerpc/fec/current/src/if_fec.c 15 Aug 2002 13:22:40 -0000 1.9
+++ devs/eth/powerpc/fec/current/src/if_fec.c 3 Sep 2002 16:47:13 -0000
@@ -7,10 +7,11 @@
//==========================================================================
//####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.
//
@@ -54,10 +55,11 @@
// Ethernet device driver for MPC8xx FEC
#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>
#endif
@@ -143,25 +145,32 @@ static cyg_handle_t fec_fake_int_thread_
static void fec_fake_int(cyg_addrword_t);
#endif // _FEC_USE_INTS
#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)
{
_set_led(_get_led() | (1<<bit));
@@ -450,33 +459,32 @@ fec_eth_init(struct cyg_netdevtab_entry
if (!fec_eth_reset(sc, enaddr, 0)) {
return false;
}
// 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;
}
if (!phy_ok || (phy_state & PHY_BMCR_RESET)) {
os_printf("FEC: Can't get PHY unit to reset: %x\n", phy_state);
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;
} else {
CYGACC_CALL_IF_DELAY_US(1000); // 1ms
Index: devs/eth/powerpc/viper/current/ChangeLog
===================================================================
RCS file: devs/eth/powerpc/viper/current/ChangeLog
diff -N devs/eth/powerpc/viper/current/ChangeLog
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devs/eth/powerpc/viper/current/ChangeLog 3 Sep 2002 16:47:13 -0000
@@ -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####
+//===========================================================================
+
+
+
Index: devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl
===================================================================
RCS file: devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl
diff -N devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devs/eth/powerpc/viper/current/cdl/viper_eth_drivers.cdl 3 Sep 2002 16:47:13 -0000
@@ -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>"
+ }
+}
Index: devs/eth/powerpc/viper/current/include/viper_eth.inl
===================================================================
RCS file: devs/eth/powerpc/viper/current/include/viper_eth.inl
diff -N devs/eth/powerpc/viper/current/include/viper_eth.inl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devs/eth/powerpc/viper/current/include/viper_eth.inl 3 Sep 2002 16:47:13 -0000
@@ -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
+// ------------------------------------------------------------------------
--
------------------------------------------------------------
Gary Thomas |
eCosCentric, Ltd. |
+1 (970) 229-1963 | eCos & RedBoot experts
gthomas@ecoscentric.com |
http://www.ecoscentric.com/ |
------------------------------------------------------------